Lines Matching +full:rk3288 +full:- +full:crypto
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Crypto acceleration support for Rockchip RK3288
7 * Author: Zain Wang <zain.wang@rock-chips.com>
9 * Some ideas are from marvell-cesa.c and s5p-sss.c driver.
13 #include <linux/dma-mapping.h>
18 #include <linux/crypto.h>
25 err = clk_prepare_enable(dev->sclk); in rk_crypto_enable_clk()
27 dev_err(dev->dev, "[%s:%d], Couldn't enable clock sclk\n", in rk_crypto_enable_clk()
31 err = clk_prepare_enable(dev->aclk); in rk_crypto_enable_clk()
33 dev_err(dev->dev, "[%s:%d], Couldn't enable clock aclk\n", in rk_crypto_enable_clk()
37 err = clk_prepare_enable(dev->hclk); in rk_crypto_enable_clk()
39 dev_err(dev->dev, "[%s:%d], Couldn't enable clock hclk\n", in rk_crypto_enable_clk()
43 err = clk_prepare_enable(dev->dmaclk); in rk_crypto_enable_clk()
45 dev_err(dev->dev, "[%s:%d], Couldn't enable clock dmaclk\n", in rk_crypto_enable_clk()
51 clk_disable_unprepare(dev->hclk); in rk_crypto_enable_clk()
53 clk_disable_unprepare(dev->aclk); in rk_crypto_enable_clk()
55 clk_disable_unprepare(dev->sclk); in rk_crypto_enable_clk()
62 clk_disable_unprepare(dev->dmaclk); in rk_crypto_disable_clk()
63 clk_disable_unprepare(dev->hclk); in rk_crypto_disable_clk()
64 clk_disable_unprepare(dev->aclk); in rk_crypto_disable_clk()
65 clk_disable_unprepare(dev->sclk); in rk_crypto_disable_clk()
76 dev->status = 1; in rk_crypto_irq_handle()
78 dev_warn(dev->dev, "DMA Error\n"); in rk_crypto_irq_handle()
79 dev->status = 0; in rk_crypto_irq_handle()
81 complete(&dev->complete); in rk_crypto_irq_handle()
104 rk_cipher_algs[i]->dev = crypto_info; in rk_crypto_register()
105 if (rk_cipher_algs[i]->type == ALG_TYPE_CIPHER) in rk_crypto_register()
107 &rk_cipher_algs[i]->alg.skcipher); in rk_crypto_register()
110 &rk_cipher_algs[i]->alg.hash); in rk_crypto_register()
118 if (rk_cipher_algs[i]->type == ALG_TYPE_CIPHER) in rk_crypto_register()
119 crypto_unregister_skcipher(&rk_cipher_algs[k]->alg.skcipher); in rk_crypto_register()
121 crypto_unregister_ahash(&rk_cipher_algs[i]->alg.hash); in rk_crypto_register()
131 if (rk_cipher_algs[i]->type == ALG_TYPE_CIPHER) in rk_crypto_unregister()
132 crypto_unregister_skcipher(&rk_cipher_algs[i]->alg.skcipher); in rk_crypto_unregister()
134 crypto_unregister_ahash(&rk_cipher_algs[i]->alg.hash); in rk_crypto_unregister()
142 reset_control_assert(crypto_info->rst); in rk_crypto_action()
146 { .compatible = "rockchip,rk3288-crypto" },
153 struct device *dev = &pdev->dev; in rk_crypto_probe()
157 crypto_info = devm_kzalloc(&pdev->dev, in rk_crypto_probe()
160 err = -ENOMEM; in rk_crypto_probe()
164 crypto_info->rst = devm_reset_control_get(dev, "crypto-rst"); in rk_crypto_probe()
165 if (IS_ERR(crypto_info->rst)) { in rk_crypto_probe()
166 err = PTR_ERR(crypto_info->rst); in rk_crypto_probe()
170 reset_control_assert(crypto_info->rst); in rk_crypto_probe()
172 reset_control_deassert(crypto_info->rst); in rk_crypto_probe()
178 crypto_info->reg = devm_platform_ioremap_resource(pdev, 0); in rk_crypto_probe()
179 if (IS_ERR(crypto_info->reg)) { in rk_crypto_probe()
180 err = PTR_ERR(crypto_info->reg); in rk_crypto_probe()
184 crypto_info->aclk = devm_clk_get(&pdev->dev, "aclk"); in rk_crypto_probe()
185 if (IS_ERR(crypto_info->aclk)) { in rk_crypto_probe()
186 err = PTR_ERR(crypto_info->aclk); in rk_crypto_probe()
190 crypto_info->hclk = devm_clk_get(&pdev->dev, "hclk"); in rk_crypto_probe()
191 if (IS_ERR(crypto_info->hclk)) { in rk_crypto_probe()
192 err = PTR_ERR(crypto_info->hclk); in rk_crypto_probe()
196 crypto_info->sclk = devm_clk_get(&pdev->dev, "sclk"); in rk_crypto_probe()
197 if (IS_ERR(crypto_info->sclk)) { in rk_crypto_probe()
198 err = PTR_ERR(crypto_info->sclk); in rk_crypto_probe()
202 crypto_info->dmaclk = devm_clk_get(&pdev->dev, "apb_pclk"); in rk_crypto_probe()
203 if (IS_ERR(crypto_info->dmaclk)) { in rk_crypto_probe()
204 err = PTR_ERR(crypto_info->dmaclk); in rk_crypto_probe()
208 crypto_info->irq = platform_get_irq(pdev, 0); in rk_crypto_probe()
209 if (crypto_info->irq < 0) { in rk_crypto_probe()
210 dev_warn(crypto_info->dev, in rk_crypto_probe()
212 err = crypto_info->irq; in rk_crypto_probe()
216 err = devm_request_irq(&pdev->dev, crypto_info->irq, in rk_crypto_probe()
218 "rk-crypto", pdev); in rk_crypto_probe()
221 dev_err(crypto_info->dev, "irq request failed.\n"); in rk_crypto_probe()
225 crypto_info->dev = &pdev->dev; in rk_crypto_probe()
228 crypto_info->engine = crypto_engine_alloc_init(&pdev->dev, true); in rk_crypto_probe()
229 crypto_engine_start(crypto_info->engine); in rk_crypto_probe()
230 init_completion(&crypto_info->complete); in rk_crypto_probe()
240 dev_info(dev, "Crypto Accelerator successfully registered\n"); in rk_crypto_probe()
244 crypto_engine_exit(crypto_info->engine); in rk_crypto_probe()
246 dev_err(dev, "Crypto Accelerator not successfully registered\n"); in rk_crypto_probe()
256 crypto_engine_exit(crypto_tmp->engine); in rk_crypto_remove()
264 .name = "rk3288-crypto",
271 MODULE_AUTHOR("Zain Wang <zain.wang@rock-chips.com>");