^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Crypto acceleration support for Rockchip RK3288
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2015, Fuzhou Rockchip Electronics Co., Ltd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Author: Zain Wang <zain.wang@rock-chips.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Some ideas are from marvell-cesa.c and s5p-sss.c driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "rk3288_crypto.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/dma-mapping.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/clk.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/crypto.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/reset.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static int rk_crypto_enable_clk(struct rk_crypto_info *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) err = clk_prepare_enable(dev->sclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) dev_err(dev->dev, "[%s:%d], Couldn't enable clock sclk\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) __func__, __LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) goto err_return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) err = clk_prepare_enable(dev->aclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) dev_err(dev->dev, "[%s:%d], Couldn't enable clock aclk\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) __func__, __LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) goto err_aclk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) err = clk_prepare_enable(dev->hclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) dev_err(dev->dev, "[%s:%d], Couldn't enable clock hclk\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) __func__, __LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) goto err_hclk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) err = clk_prepare_enable(dev->dmaclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) dev_err(dev->dev, "[%s:%d], Couldn't enable clock dmaclk\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) __func__, __LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) goto err_dmaclk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) err_dmaclk:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) clk_disable_unprepare(dev->hclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) err_hclk:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) clk_disable_unprepare(dev->aclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) err_aclk:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) clk_disable_unprepare(dev->sclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) err_return:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static void rk_crypto_disable_clk(struct rk_crypto_info *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) clk_disable_unprepare(dev->dmaclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) clk_disable_unprepare(dev->hclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) clk_disable_unprepare(dev->aclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) clk_disable_unprepare(dev->sclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) static int check_alignment(struct scatterlist *sg_src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct scatterlist *sg_dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) int align_mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int in, out, align;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) in = IS_ALIGNED((uint32_t)sg_src->offset, 4) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) IS_ALIGNED((uint32_t)sg_src->length, align_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) if (!sg_dst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) return in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) out = IS_ALIGNED((uint32_t)sg_dst->offset, 4) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) IS_ALIGNED((uint32_t)sg_dst->length, align_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) align = in && out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) return (align && (sg_src->length == sg_dst->length));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static int rk_load_data(struct rk_crypto_info *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct scatterlist *sg_src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct scatterlist *sg_dst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) unsigned int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) dev->aligned = dev->aligned ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) check_alignment(sg_src, sg_dst, dev->align_size) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) dev->aligned;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) if (dev->aligned) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) count = min(dev->left_bytes, sg_src->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) dev->left_bytes -= count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) if (!dma_map_sg(dev->dev, sg_src, 1, DMA_TO_DEVICE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) dev_err(dev->dev, "[%s:%d] dma_map_sg(src) error\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) __func__, __LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) dev->addr_in = sg_dma_address(sg_src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) if (sg_dst) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (!dma_map_sg(dev->dev, sg_dst, 1, DMA_FROM_DEVICE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) dev_err(dev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) "[%s:%d] dma_map_sg(dst) error\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) __func__, __LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) dma_unmap_sg(dev->dev, sg_src, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) dev->addr_out = sg_dma_address(sg_dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) count = (dev->left_bytes > PAGE_SIZE) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) PAGE_SIZE : dev->left_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (!sg_pcopy_to_buffer(dev->first, dev->src_nents,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) dev->addr_vir, count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) dev->total - dev->left_bytes)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) dev_err(dev->dev, "[%s:%d] pcopy err\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) __func__, __LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) dev->left_bytes -= count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) sg_init_one(&dev->sg_tmp, dev->addr_vir, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) if (!dma_map_sg(dev->dev, &dev->sg_tmp, 1, DMA_TO_DEVICE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) dev_err(dev->dev, "[%s:%d] dma_map_sg(sg_tmp) error\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) __func__, __LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) dev->addr_in = sg_dma_address(&dev->sg_tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) if (sg_dst) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) if (!dma_map_sg(dev->dev, &dev->sg_tmp, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) DMA_FROM_DEVICE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) dev_err(dev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) "[%s:%d] dma_map_sg(sg_tmp) error\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) __func__, __LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) dma_unmap_sg(dev->dev, &dev->sg_tmp, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) dev->addr_out = sg_dma_address(&dev->sg_tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) dev->count = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static void rk_unload_data(struct rk_crypto_info *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) struct scatterlist *sg_in, *sg_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) sg_in = dev->aligned ? dev->sg_src : &dev->sg_tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) dma_unmap_sg(dev->dev, sg_in, 1, DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (dev->sg_dst) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) sg_out = dev->aligned ? dev->sg_dst : &dev->sg_tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) dma_unmap_sg(dev->dev, sg_out, 1, DMA_FROM_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static irqreturn_t rk_crypto_irq_handle(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) struct rk_crypto_info *dev = platform_get_drvdata(dev_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) u32 interrupt_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) spin_lock(&dev->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) interrupt_status = CRYPTO_READ(dev, RK_CRYPTO_INTSTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) CRYPTO_WRITE(dev, RK_CRYPTO_INTSTS, interrupt_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) if (interrupt_status & 0x0a) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) dev_warn(dev->dev, "DMA Error\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) dev->err = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) tasklet_schedule(&dev->done_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) spin_unlock(&dev->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) static int rk_crypto_enqueue(struct rk_crypto_info *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) struct crypto_async_request *async_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) spin_lock_irqsave(&dev->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) ret = crypto_enqueue_request(&dev->queue, async_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) if (dev->busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) spin_unlock_irqrestore(&dev->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) dev->busy = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) spin_unlock_irqrestore(&dev->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) tasklet_schedule(&dev->queue_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) static void rk_crypto_queue_task_cb(unsigned long data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) struct rk_crypto_info *dev = (struct rk_crypto_info *)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) struct crypto_async_request *async_req, *backlog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) dev->err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) spin_lock_irqsave(&dev->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) backlog = crypto_get_backlog(&dev->queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) async_req = crypto_dequeue_request(&dev->queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) if (!async_req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) dev->busy = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) spin_unlock_irqrestore(&dev->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) spin_unlock_irqrestore(&dev->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) if (backlog) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) backlog->complete(backlog, -EINPROGRESS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) backlog = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) dev->async_req = async_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) err = dev->start(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) dev->complete(dev->async_req, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) static void rk_crypto_done_task_cb(unsigned long data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) struct rk_crypto_info *dev = (struct rk_crypto_info *)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) if (dev->err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) dev->complete(dev->async_req, dev->err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) dev->err = dev->update(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if (dev->err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) dev->complete(dev->async_req, dev->err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) static struct rk_crypto_tmp *rk_cipher_algs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) &rk_ecb_aes_alg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) &rk_cbc_aes_alg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) &rk_ecb_des_alg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) &rk_cbc_des_alg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) &rk_ecb_des3_ede_alg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) &rk_cbc_des3_ede_alg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) &rk_ahash_sha1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) &rk_ahash_sha256,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) &rk_ahash_md5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) static int rk_crypto_register(struct rk_crypto_info *crypto_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) unsigned int i, k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) for (i = 0; i < ARRAY_SIZE(rk_cipher_algs); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) rk_cipher_algs[i]->dev = crypto_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) if (rk_cipher_algs[i]->type == ALG_TYPE_CIPHER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) err = crypto_register_skcipher(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) &rk_cipher_algs[i]->alg.skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) err = crypto_register_ahash(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) &rk_cipher_algs[i]->alg.hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) goto err_cipher_algs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) err_cipher_algs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) for (k = 0; k < i; k++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) if (rk_cipher_algs[i]->type == ALG_TYPE_CIPHER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) crypto_unregister_skcipher(&rk_cipher_algs[k]->alg.skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) crypto_unregister_ahash(&rk_cipher_algs[i]->alg.hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) static void rk_crypto_unregister(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) for (i = 0; i < ARRAY_SIZE(rk_cipher_algs); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) if (rk_cipher_algs[i]->type == ALG_TYPE_CIPHER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) crypto_unregister_skcipher(&rk_cipher_algs[i]->alg.skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) crypto_unregister_ahash(&rk_cipher_algs[i]->alg.hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) static void rk_crypto_action(void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) struct rk_crypto_info *crypto_info = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) reset_control_assert(crypto_info->rst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) static const struct of_device_id crypto_of_id_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) { .compatible = "rockchip,rk3288-crypto" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) MODULE_DEVICE_TABLE(of, crypto_of_id_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) static int rk_crypto_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) struct device *dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) struct rk_crypto_info *crypto_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) crypto_info = devm_kzalloc(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) sizeof(*crypto_info), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) if (!crypto_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) goto err_crypto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) crypto_info->rst = devm_reset_control_get(dev, "crypto-rst");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) if (IS_ERR(crypto_info->rst)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) err = PTR_ERR(crypto_info->rst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) goto err_crypto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) reset_control_assert(crypto_info->rst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) usleep_range(10, 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) reset_control_deassert(crypto_info->rst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) err = devm_add_action_or_reset(dev, rk_crypto_action, crypto_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) goto err_crypto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) spin_lock_init(&crypto_info->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) crypto_info->reg = devm_platform_ioremap_resource(pdev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) if (IS_ERR(crypto_info->reg)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) err = PTR_ERR(crypto_info->reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) goto err_crypto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) crypto_info->aclk = devm_clk_get(&pdev->dev, "aclk");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) if (IS_ERR(crypto_info->aclk)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) err = PTR_ERR(crypto_info->aclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) goto err_crypto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) crypto_info->hclk = devm_clk_get(&pdev->dev, "hclk");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) if (IS_ERR(crypto_info->hclk)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) err = PTR_ERR(crypto_info->hclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) goto err_crypto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) crypto_info->sclk = devm_clk_get(&pdev->dev, "sclk");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) if (IS_ERR(crypto_info->sclk)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) err = PTR_ERR(crypto_info->sclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) goto err_crypto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) crypto_info->dmaclk = devm_clk_get(&pdev->dev, "apb_pclk");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) if (IS_ERR(crypto_info->dmaclk)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) err = PTR_ERR(crypto_info->dmaclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) goto err_crypto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) crypto_info->irq = platform_get_irq(pdev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) if (crypto_info->irq < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) dev_warn(crypto_info->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) "control Interrupt is not available.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) err = crypto_info->irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) goto err_crypto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) err = devm_request_irq(&pdev->dev, crypto_info->irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) rk_crypto_irq_handle, IRQF_SHARED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) "rk-crypto", pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) dev_err(crypto_info->dev, "irq request failed.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) goto err_crypto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) crypto_info->dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) platform_set_drvdata(pdev, crypto_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) tasklet_init(&crypto_info->queue_task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) rk_crypto_queue_task_cb, (unsigned long)crypto_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) tasklet_init(&crypto_info->done_task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) rk_crypto_done_task_cb, (unsigned long)crypto_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) crypto_init_queue(&crypto_info->queue, 50);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) crypto_info->enable_clk = rk_crypto_enable_clk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) crypto_info->disable_clk = rk_crypto_disable_clk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) crypto_info->load_data = rk_load_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) crypto_info->unload_data = rk_unload_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) crypto_info->enqueue = rk_crypto_enqueue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) crypto_info->busy = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) err = rk_crypto_register(crypto_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) dev_err(dev, "err in register alg");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) goto err_register_alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) dev_info(dev, "Crypto Accelerator successfully registered\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) err_register_alg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) tasklet_kill(&crypto_info->queue_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) tasklet_kill(&crypto_info->done_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) err_crypto:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) static int rk_crypto_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) struct rk_crypto_info *crypto_tmp = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) rk_crypto_unregister();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) tasklet_kill(&crypto_tmp->done_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) tasklet_kill(&crypto_tmp->queue_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) static struct platform_driver crypto_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) .probe = rk_crypto_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) .remove = rk_crypto_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) .name = "rk3288-crypto",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) .of_match_table = crypto_of_id_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) module_platform_driver(crypto_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) MODULE_AUTHOR("Zain Wang <zain.wang@rock-chips.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) MODULE_DESCRIPTION("Support for Rockchip's cryptographic engine");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) MODULE_LICENSE("GPL");