Lines Matching +full:gxl +full:- +full:crypto
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 <clabbe@baylibre.com>
7 * Core file which registers crypto algorithms supported by the hardware.
10 #include <linux/crypto.h>
18 #include <crypto/internal/skcipher.h>
19 #include <linux/dma-mapping.h>
21 #include "amlogic-gxl.h"
30 if (mc->irqs[flow] == irq) { in meson_irq_handler()
31 p = readl(mc->base + ((0x04 + flow) << 2)); in meson_irq_handler()
33 writel_relaxed(0xF, mc->base + ((0x4 + flow) << 2)); in meson_irq_handler()
34 mc->chanlist[flow].status = 1; in meson_irq_handler()
35 complete(&mc->chanlist[flow].complete); in meson_irq_handler()
38 dev_err(mc->dev, "%s %d Got irq for flow %d but ctrl is empty\n", __func__, irq, flow); in meson_irq_handler()
42 dev_err(mc->dev, "%s %d from unknown irq\n", __func__, irq); in meson_irq_handler()
53 .cra_driver_name = "cbc-aes-gxl",
79 .cra_driver_name = "ecb-aes-gxl",
103 struct meson_dev *mc = seq->private; in meson_debugfs_show()
107 seq_printf(seq, "Channel %d: nreq %lu\n", i, mc->chanlist[i].stat_req); in meson_debugfs_show()
127 crypto_engine_exit(mc->chanlist[i].engine); in meson_free_chanlist()
128 if (mc->chanlist[i].tl) in meson_free_chanlist()
129 dma_free_coherent(mc->dev, sizeof(struct meson_desc) * MAXDESC, in meson_free_chanlist()
130 mc->chanlist[i].tl, in meson_free_chanlist()
131 mc->chanlist[i].t_phy); in meson_free_chanlist()
132 i--; in meson_free_chanlist()
143 mc->chanlist = devm_kcalloc(mc->dev, MAXFLOW, in meson_allocate_chanlist()
145 if (!mc->chanlist) in meson_allocate_chanlist()
146 return -ENOMEM; in meson_allocate_chanlist()
149 init_completion(&mc->chanlist[i].complete); in meson_allocate_chanlist()
151 mc->chanlist[i].engine = crypto_engine_alloc_init(mc->dev, true); in meson_allocate_chanlist()
152 if (!mc->chanlist[i].engine) { in meson_allocate_chanlist()
153 dev_err(mc->dev, "Cannot allocate engine\n"); in meson_allocate_chanlist()
154 i--; in meson_allocate_chanlist()
155 err = -ENOMEM; in meson_allocate_chanlist()
158 err = crypto_engine_start(mc->chanlist[i].engine); in meson_allocate_chanlist()
160 dev_err(mc->dev, "Cannot start engine\n"); in meson_allocate_chanlist()
163 mc->chanlist[i].tl = dma_alloc_coherent(mc->dev, in meson_allocate_chanlist()
165 &mc->chanlist[i].t_phy, in meson_allocate_chanlist()
167 if (!mc->chanlist[i].tl) { in meson_allocate_chanlist()
168 err = -ENOMEM; in meson_allocate_chanlist()
188 dev_err(mc->dev, "Fail to register %s\n", in meson_register_algs()
220 mc = devm_kzalloc(&pdev->dev, sizeof(*mc), GFP_KERNEL); in meson_crypto_probe()
222 return -ENOMEM; in meson_crypto_probe()
224 mc->dev = &pdev->dev; in meson_crypto_probe()
227 mc->base = devm_platform_ioremap_resource(pdev, 0); in meson_crypto_probe()
228 if (IS_ERR(mc->base)) { in meson_crypto_probe()
229 err = PTR_ERR(mc->base); in meson_crypto_probe()
230 dev_err(&pdev->dev, "Cannot request MMIO err=%d\n", err); in meson_crypto_probe()
233 mc->busclk = devm_clk_get(&pdev->dev, "blkmv"); in meson_crypto_probe()
234 if (IS_ERR(mc->busclk)) { in meson_crypto_probe()
235 err = PTR_ERR(mc->busclk); in meson_crypto_probe()
236 dev_err(&pdev->dev, "Cannot get core clock err=%d\n", err); in meson_crypto_probe()
240 mc->irqs = devm_kcalloc(mc->dev, MAXFLOW, sizeof(int), GFP_KERNEL); in meson_crypto_probe()
242 mc->irqs[i] = platform_get_irq(pdev, i); in meson_crypto_probe()
243 if (mc->irqs[i] < 0) in meson_crypto_probe()
244 return mc->irqs[i]; in meson_crypto_probe()
246 err = devm_request_irq(&pdev->dev, mc->irqs[i], meson_irq_handler, 0, in meson_crypto_probe()
247 "gxl-crypto", mc); in meson_crypto_probe()
249 dev_err(mc->dev, "Cannot request IRQ for flow %d\n", i); in meson_crypto_probe()
254 err = clk_prepare_enable(mc->busclk); in meson_crypto_probe()
256 dev_err(&pdev->dev, "Cannot prepare_enable busclk\n"); in meson_crypto_probe()
269 mc->dbgfs_dir = debugfs_create_dir("gxl-crypto", NULL); in meson_crypto_probe()
270 debugfs_create_file("stats", 0444, mc->dbgfs_dir, mc, &meson_debugfs_fops); in meson_crypto_probe()
277 meson_free_chanlist(mc, MAXFLOW - 1); in meson_crypto_probe()
278 clk_disable_unprepare(mc->busclk); in meson_crypto_probe()
287 debugfs_remove_recursive(mc->dbgfs_dir); in meson_crypto_remove()
292 meson_free_chanlist(mc, MAXFLOW - 1); in meson_crypto_remove()
294 clk_disable_unprepare(mc->busclk); in meson_crypto_remove()
299 { .compatible = "amlogic,gxl-crypto", },
308 .name = "gxl-crypto",
315 MODULE_DESCRIPTION("Amlogic GXL cryptographic offloader");