Lines Matching refs:cryp
39 struct starfive_cryp_dev *cryp = NULL, *tmp; in starfive_cryp_find_dev() local
42 if (!ctx->cryp) { in starfive_cryp_find_dev()
44 cryp = tmp; in starfive_cryp_find_dev()
47 ctx->cryp = cryp; in starfive_cryp_find_dev()
49 cryp = ctx->cryp; in starfive_cryp_find_dev()
54 return cryp; in starfive_cryp_find_dev()
64 static int starfive_dma_init(struct starfive_cryp_dev *cryp) in starfive_dma_init() argument
71 cryp->tx = dma_request_chan(cryp->dev, "tx"); in starfive_dma_init()
72 if (IS_ERR(cryp->tx)) in starfive_dma_init()
73 return dev_err_probe(cryp->dev, PTR_ERR(cryp->tx), in starfive_dma_init()
76 cryp->rx = dma_request_chan(cryp->dev, "rx"); in starfive_dma_init()
77 if (IS_ERR(cryp->rx)) { in starfive_dma_init()
78 dma_release_channel(cryp->tx); in starfive_dma_init()
79 return dev_err_probe(cryp->dev, PTR_ERR(cryp->rx), in starfive_dma_init()
86 static void starfive_dma_cleanup(struct starfive_cryp_dev *cryp) in starfive_dma_cleanup() argument
88 dma_release_channel(cryp->tx); in starfive_dma_cleanup()
89 dma_release_channel(cryp->rx); in starfive_dma_cleanup()
96 struct starfive_cryp_dev *cryp = (struct starfive_cryp_dev *)priv; in starfive_cryp_irq() local
98 mask = readl(cryp->base + STARFIVE_IE_MASK_OFFSET); in starfive_cryp_irq()
99 status = readl(cryp->base + STARFIVE_IE_FLAG_OFFSET); in starfive_cryp_irq()
102 writel(mask, cryp->base + STARFIVE_IE_MASK_OFFSET); in starfive_cryp_irq()
103 tasklet_schedule(&cryp->aes_done); in starfive_cryp_irq()
108 writel(mask, cryp->base + STARFIVE_IE_MASK_OFFSET); in starfive_cryp_irq()
109 tasklet_schedule(&cryp->hash_done); in starfive_cryp_irq()
114 writel(mask, cryp->base + STARFIVE_IE_MASK_OFFSET); in starfive_cryp_irq()
115 complete(&cryp->pka_done); in starfive_cryp_irq()
123 struct starfive_cryp_dev *cryp; in starfive_cryp_probe() local
128 cryp = devm_kzalloc(&pdev->dev, sizeof(*cryp), GFP_KERNEL); in starfive_cryp_probe()
129 if (!cryp) in starfive_cryp_probe()
132 platform_set_drvdata(pdev, cryp); in starfive_cryp_probe()
133 cryp->dev = &pdev->dev; in starfive_cryp_probe()
135 cryp->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in starfive_cryp_probe()
136 if (IS_ERR(cryp->base)) in starfive_cryp_probe()
137 return dev_err_probe(&pdev->dev, PTR_ERR(cryp->base), in starfive_cryp_probe()
140 tasklet_init(&cryp->aes_done, starfive_aes_done_task, (unsigned long)cryp); in starfive_cryp_probe()
141 tasklet_init(&cryp->hash_done, starfive_hash_done_task, (unsigned long)cryp); in starfive_cryp_probe()
143 cryp->phys_base = res->start; in starfive_cryp_probe()
144 cryp->dma_maxburst = 32; in starfive_cryp_probe()
145 cryp->side_chan = side_chan; in starfive_cryp_probe()
147 cryp->hclk = devm_clk_get(&pdev->dev, "hclk"); in starfive_cryp_probe()
148 if (IS_ERR(cryp->hclk)) in starfive_cryp_probe()
149 return dev_err_probe(&pdev->dev, PTR_ERR(cryp->hclk), in starfive_cryp_probe()
152 cryp->ahb = devm_clk_get(&pdev->dev, "ahb"); in starfive_cryp_probe()
153 if (IS_ERR(cryp->ahb)) in starfive_cryp_probe()
154 return dev_err_probe(&pdev->dev, PTR_ERR(cryp->ahb), in starfive_cryp_probe()
157 cryp->rst = devm_reset_control_get_shared(cryp->dev, NULL); in starfive_cryp_probe()
158 if (IS_ERR(cryp->rst)) in starfive_cryp_probe()
159 return dev_err_probe(&pdev->dev, PTR_ERR(cryp->rst), in starfive_cryp_probe()
162 init_completion(&cryp->pka_done); in starfive_cryp_probe()
169 (void *)cryp); in starfive_cryp_probe()
174 clk_prepare_enable(cryp->hclk); in starfive_cryp_probe()
175 clk_prepare_enable(cryp->ahb); in starfive_cryp_probe()
176 reset_control_deassert(cryp->rst); in starfive_cryp_probe()
179 list_add(&cryp->list, &dev_list.dev_list); in starfive_cryp_probe()
182 ret = starfive_dma_init(cryp); in starfive_cryp_probe()
191 cryp->engine = crypto_engine_alloc_init(&pdev->dev, 1); in starfive_cryp_probe()
192 if (!cryp->engine) { in starfive_cryp_probe()
197 ret = crypto_engine_start(cryp->engine); in starfive_cryp_probe()
220 crypto_engine_stop(cryp->engine); in starfive_cryp_probe()
222 crypto_engine_exit(cryp->engine); in starfive_cryp_probe()
224 starfive_dma_cleanup(cryp); in starfive_cryp_probe()
227 list_del(&cryp->list); in starfive_cryp_probe()
230 clk_disable_unprepare(cryp->hclk); in starfive_cryp_probe()
231 clk_disable_unprepare(cryp->ahb); in starfive_cryp_probe()
232 reset_control_assert(cryp->rst); in starfive_cryp_probe()
234 tasklet_kill(&cryp->aes_done); in starfive_cryp_probe()
235 tasklet_kill(&cryp->hash_done); in starfive_cryp_probe()
242 struct starfive_cryp_dev *cryp = platform_get_drvdata(pdev); in starfive_cryp_remove() local
248 tasklet_kill(&cryp->aes_done); in starfive_cryp_remove()
249 tasklet_kill(&cryp->hash_done); in starfive_cryp_remove()
251 crypto_engine_stop(cryp->engine); in starfive_cryp_remove()
252 crypto_engine_exit(cryp->engine); in starfive_cryp_remove()
254 starfive_dma_cleanup(cryp); in starfive_cryp_remove()
257 list_del(&cryp->list); in starfive_cryp_remove()
260 clk_disable_unprepare(cryp->hclk); in starfive_cryp_remove()
261 clk_disable_unprepare(cryp->ahb); in starfive_cryp_remove()
262 reset_control_assert(cryp->rst); in starfive_cryp_remove()