mediatek: Add support for Xiaomi Redmi Router AX6S
[openwrt/staging/wigyori.git] / target / linux / layerscape / patches-5.4 / 804-crypto-0031-crypto-caam-add-caam_dma-device-on-caam_probe.patch
1 From 0547020c73ab7a457f3e1601ef822b61f0b963b9 Mon Sep 17 00:00:00 2001
2 From: Radu Alexe <radu.alexe@nxp.com>
3 Date: Wed, 8 Nov 2017 17:22:12 +0200
4 Subject: [PATCH] crypto: caam - add caam_dma device on caam_probe
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Dynamically create a platform device for the caam_dma driver
10 at caam_probe() time.
11
12 Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
13 Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
14
15 Use devres for caam_dma platform device unregistering.
16
17 Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
18 ---
19 drivers/crypto/caam/ctrl.c | 24 ++++++++++++++++++++++++
20 1 file changed, 24 insertions(+)
21
22 --- a/drivers/crypto/caam/ctrl.c
23 +++ b/drivers/crypto/caam/ctrl.c
24 @@ -566,12 +566,22 @@ static void caam_remove_debugfs(void *ro
25 }
26 #endif
27
28 +static void caam_dma_dev_unregister(void *data)
29 +{
30 + platform_device_unregister(data);
31 +}
32 +
33 /* Probe routine for CAAM top (controller) level */
34 static int caam_probe(struct platform_device *pdev)
35 {
36 int ret, ring, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN;
37 u64 caam_id;
38 const struct soc_device_attribute *imx_soc_match;
39 + static struct platform_device_info caam_dma_pdev_info = {
40 + .name = "caam-dma",
41 + .id = PLATFORM_DEVID_NONE
42 + };
43 + static struct platform_device *caam_dma_dev;
44 struct device *dev;
45 struct device_node *nprop, *np;
46 struct resource res_regs;
47 @@ -849,6 +859,20 @@ set_dma_mask:
48 return -ENOMEM;
49 }
50
51 + caam_dma_pdev_info.parent = dev;
52 + caam_dma_pdev_info.dma_mask = dma_get_mask(dev);
53 + caam_dma_dev = platform_device_register_full(&caam_dma_pdev_info);
54 + if (IS_ERR(caam_dma_dev)) {
55 + dev_err(dev, "Unable to create and register caam-dma dev\n");
56 + return PTR_ERR(caam_dma_dev);
57 + } else {
58 + set_dma_ops(&caam_dma_dev->dev, get_dma_ops(dev));
59 + ret = devm_add_action_or_reset(dev, caam_dma_dev_unregister,
60 + caam_dma_dev);
61 + if (ret)
62 + return ret;
63 + }
64 +
65 if (!reg_access)
66 goto report_live;
67