Lines Matching +full:crypto +full:- +full:engine
1 // SPDX-License-Identifier: GPL-2.0
3 * amlgoic-core.c - hardware cryptographic offloader for Amlogic GXL SoC
5 * Copyright (C) 2018-2019 Corentin Labbe <[email protected]>
7 * Core file which registers crypto algorithms supported by the hardware.
10 #include <crypto/engine.h>
11 #include <crypto/internal/skcipher.h>
13 #include <linux/dma-mapping.h>
23 #include "amlogic-gxl.h"
32 if (mc->irqs[flow] == irq) { in meson_irq_handler()
33 p = readl(mc->base + ((0x04 + flow) << 2)); in meson_irq_handler()
35 writel_relaxed(0xF, mc->base + ((0x4 + flow) << 2)); in meson_irq_handler()
36 mc->chanlist[flow].status = 1; in meson_irq_handler()
37 complete(&mc->chanlist[flow].complete); in meson_irq_handler()
40 dev_err(mc->dev, "%s %d Got irq for flow %d but ctrl is empty\n", __func__, irq, flow); in meson_irq_handler()
44 dev_err(mc->dev, "%s %d from unknown irq\n", __func__, irq); in meson_irq_handler()
55 .cra_driver_name = "cbc-aes-gxl",
84 .cra_driver_name = "ecb-aes-gxl",
110 struct meson_dev *mc __maybe_unused = seq->private; in meson_debugfs_show()
116 mc->chanlist[i].stat_req); in meson_debugfs_show()
142 crypto_engine_exit(mc->chanlist[i].engine); in meson_free_chanlist()
143 if (mc->chanlist[i].tl) in meson_free_chanlist()
144 dma_free_coherent(mc->dev, sizeof(struct meson_desc) * MAXDESC, in meson_free_chanlist()
145 mc->chanlist[i].tl, in meson_free_chanlist()
146 mc->chanlist[i].t_phy); in meson_free_chanlist()
147 i--; in meson_free_chanlist()
158 mc->chanlist = devm_kcalloc(mc->dev, MAXFLOW, in meson_allocate_chanlist()
160 if (!mc->chanlist) in meson_allocate_chanlist()
161 return -ENOMEM; in meson_allocate_chanlist()
164 init_completion(&mc->chanlist[i].complete); in meson_allocate_chanlist()
166 mc->chanlist[i].engine = crypto_engine_alloc_init(mc->dev, true); in meson_allocate_chanlist()
167 if (!mc->chanlist[i].engine) { in meson_allocate_chanlist()
168 dev_err(mc->dev, "Cannot allocate engine\n"); in meson_allocate_chanlist()
169 i--; in meson_allocate_chanlist()
170 err = -ENOMEM; in meson_allocate_chanlist()
173 err = crypto_engine_start(mc->chanlist[i].engine); in meson_allocate_chanlist()
175 dev_err(mc->dev, "Cannot start engine\n"); in meson_allocate_chanlist()
178 mc->chanlist[i].tl = dma_alloc_coherent(mc->dev, in meson_allocate_chanlist()
180 &mc->chanlist[i].t_phy, in meson_allocate_chanlist()
182 if (!mc->chanlist[i].tl) { in meson_allocate_chanlist()
183 err = -ENOMEM; in meson_allocate_chanlist()
203 dev_err(mc->dev, "Fail to register %s\n", in meson_register_algs()
235 mc = devm_kzalloc(&pdev->dev, sizeof(*mc), GFP_KERNEL); in meson_crypto_probe()
237 return -ENOMEM; in meson_crypto_probe()
239 mc->dev = &pdev->dev; in meson_crypto_probe()
242 mc->base = devm_platform_ioremap_resource(pdev, 0); in meson_crypto_probe()
243 if (IS_ERR(mc->base)) in meson_crypto_probe()
244 return PTR_ERR(mc->base); in meson_crypto_probe()
246 mc->busclk = devm_clk_get(&pdev->dev, "blkmv"); in meson_crypto_probe()
247 if (IS_ERR(mc->busclk)) { in meson_crypto_probe()
248 err = PTR_ERR(mc->busclk); in meson_crypto_probe()
249 dev_err(&pdev->dev, "Cannot get core clock err=%d\n", err); in meson_crypto_probe()
254 mc->irqs[i] = platform_get_irq(pdev, i); in meson_crypto_probe()
255 if (mc->irqs[i] < 0) in meson_crypto_probe()
256 return mc->irqs[i]; in meson_crypto_probe()
258 err = devm_request_irq(&pdev->dev, mc->irqs[i], meson_irq_handler, 0, in meson_crypto_probe()
259 "gxl-crypto", mc); in meson_crypto_probe()
261 dev_err(mc->dev, "Cannot request IRQ for flow %d\n", i); in meson_crypto_probe()
266 err = clk_prepare_enable(mc->busclk); in meson_crypto_probe()
268 dev_err(&pdev->dev, "Cannot prepare_enable busclk\n"); in meson_crypto_probe()
283 dbgfs_dir = debugfs_create_dir("gxl-crypto", NULL); in meson_crypto_probe()
287 mc->dbgfs_dir = dbgfs_dir; in meson_crypto_probe()
295 meson_free_chanlist(mc, MAXFLOW - 1); in meson_crypto_probe()
296 clk_disable_unprepare(mc->busclk); in meson_crypto_probe()
305 debugfs_remove_recursive(mc->dbgfs_dir); in meson_crypto_remove()
310 meson_free_chanlist(mc, MAXFLOW - 1); in meson_crypto_remove()
312 clk_disable_unprepare(mc->busclk); in meson_crypto_remove()
316 { .compatible = "amlogic,gxl-crypto", },
325 .name = "gxl-crypto",