提交 5ed903b3 编写于 作者: S Steffen Trumtrar 提交者: Herbert Xu

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: NSteffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
上级 20ec9d81
Freescale SAHARA Cryptographic Accelerator included in some i.MX chips. Freescale SAHARA Cryptographic Accelerator included in some i.MX chips.
Currently only i.MX27 is supported. Currently only i.MX27 and i.MX53 are supported.
Required properties: Required properties:
- compatible : Should be "fsl,<soc>-sahara" - compatible : Should be "fsl,<soc>-sahara"
......
...@@ -24,10 +24,12 @@ ...@@ -24,10 +24,12 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#define SAHARA_NAME "sahara" #define SAHARA_NAME "sahara"
#define SAHARA_VERSION_3 3 #define SAHARA_VERSION_3 3
#define SAHARA_VERSION_4 4
#define SAHARA_TIMEOUT_MS 1000 #define SAHARA_TIMEOUT_MS 1000
#define SAHARA_MAX_HW_DESC 2 #define SAHARA_MAX_HW_DESC 2
#define SAHARA_MAX_HW_LINK 20 #define SAHARA_MAX_HW_LINK 20
...@@ -130,6 +132,7 @@ struct sahara_aes_reqctx { ...@@ -130,6 +132,7 @@ struct sahara_aes_reqctx {
struct sahara_dev { struct sahara_dev {
struct device *device; struct device *device;
unsigned int version;
void __iomem *regs_base; void __iomem *regs_base;
struct clk *clk_ipg; struct clk *clk_ipg;
struct clk *clk_ahb; struct clk *clk_ahb;
...@@ -860,6 +863,7 @@ static struct platform_device_id sahara_platform_ids[] = { ...@@ -860,6 +863,7 @@ static struct platform_device_id sahara_platform_ids[] = {
MODULE_DEVICE_TABLE(platform, sahara_platform_ids); MODULE_DEVICE_TABLE(platform, sahara_platform_ids);
static struct of_device_id sahara_dt_ids[] = { static struct of_device_id sahara_dt_ids[] = {
{ .compatible = "fsl,imx53-sahara" },
{ .compatible = "fsl,imx27-sahara" }, { .compatible = "fsl,imx27-sahara" },
{ /* sentinel */ } { /* sentinel */ }
}; };
...@@ -973,13 +977,23 @@ static int sahara_probe(struct platform_device *pdev) ...@@ -973,13 +977,23 @@ static int sahara_probe(struct platform_device *pdev)
clk_prepare_enable(dev->clk_ahb); clk_prepare_enable(dev->clk_ahb);
version = sahara_read(dev, SAHARA_REG_VERSION); version = sahara_read(dev, SAHARA_REG_VERSION);
if (version != SAHARA_VERSION_3) { if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx27-sahara")) {
if (version != SAHARA_VERSION_3)
err = -ENODEV;
} else if (of_device_is_compatible(pdev->dev.of_node,
"fsl,imx53-sahara")) {
if (((version >> 8) & 0xff) != SAHARA_VERSION_4)
err = -ENODEV;
version = (version >> 8) & 0xff;
}
if (err == -ENODEV) {
dev_err(&pdev->dev, "SAHARA version %d not supported\n", dev_err(&pdev->dev, "SAHARA version %d not supported\n",
version); version);
err = -ENODEV;
goto err_algs; goto err_algs;
} }
dev->version = version;
sahara_write(dev, SAHARA_CMD_RESET | SAHARA_CMD_MODE_BATCH, sahara_write(dev, SAHARA_CMD_RESET | SAHARA_CMD_MODE_BATCH,
SAHARA_REG_CMD); SAHARA_REG_CMD);
sahara_write(dev, SAHARA_CONTROL_SET_THROTTLE(0) | sahara_write(dev, SAHARA_CONTROL_SET_THROTTLE(0) |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册