Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: sahara - add support for i.MX53

The Sahara on the i.MX53 is of version 4. Add support for probing the
device.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Steffen Trumtrar and committed by
Herbert Xu
5ed903b3 20ec9d81

+18 -4
+1 -1
Documentation/devicetree/bindings/crypto/fsl-imx-sahara.txt
··· 1 1 Freescale SAHARA Cryptographic Accelerator included in some i.MX chips. 2 - Currently only i.MX27 is supported. 2 + Currently only i.MX27 and i.MX53 are supported. 3 3 4 4 Required properties: 5 5 - compatible : Should be "fsl,<soc>-sahara"
+17 -3
drivers/crypto/sahara.c
··· 24 24 #include <linux/kernel.h> 25 25 #include <linux/module.h> 26 26 #include <linux/of.h> 27 + #include <linux/of_device.h> 27 28 #include <linux/platform_device.h> 28 29 29 30 #define SAHARA_NAME "sahara" 30 31 #define SAHARA_VERSION_3 3 32 + #define SAHARA_VERSION_4 4 31 33 #define SAHARA_TIMEOUT_MS 1000 32 34 #define SAHARA_MAX_HW_DESC 2 33 35 #define SAHARA_MAX_HW_LINK 20 ··· 132 130 133 131 struct sahara_dev { 134 132 struct device *device; 133 + unsigned int version; 135 134 void __iomem *regs_base; 136 135 struct clk *clk_ipg; 137 136 struct clk *clk_ahb; ··· 863 860 MODULE_DEVICE_TABLE(platform, sahara_platform_ids); 864 861 865 862 static struct of_device_id sahara_dt_ids[] = { 863 + { .compatible = "fsl,imx53-sahara" }, 866 864 { .compatible = "fsl,imx27-sahara" }, 867 865 { /* sentinel */ } 868 866 }; ··· 977 973 clk_prepare_enable(dev->clk_ahb); 978 974 979 975 version = sahara_read(dev, SAHARA_REG_VERSION); 980 - if (version != SAHARA_VERSION_3) { 976 + if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx27-sahara")) { 977 + if (version != SAHARA_VERSION_3) 978 + err = -ENODEV; 979 + } else if (of_device_is_compatible(pdev->dev.of_node, 980 + "fsl,imx53-sahara")) { 981 + if (((version >> 8) & 0xff) != SAHARA_VERSION_4) 982 + err = -ENODEV; 983 + version = (version >> 8) & 0xff; 984 + } 985 + if (err == -ENODEV) { 981 986 dev_err(&pdev->dev, "SAHARA version %d not supported\n", 982 - version); 983 - err = -ENODEV; 987 + version); 984 988 goto err_algs; 985 989 } 990 + 991 + dev->version = version; 986 992 987 993 sahara_write(dev, SAHARA_CMD_RESET | SAHARA_CMD_MODE_BATCH, 988 994 SAHARA_REG_CMD);