* [PATCH] drivers: nvmem: atmel-secumod: New driver for Atmel Secumod nvram [not found] <alpine.LNX.2.00.1605121505320.21379@nippy.intranet> @ 2016-05-16 20:17 ` David Mosberger-Tang [not found] ` <1463429830-20539-1-git-send-email-davidm-haPfTeumbwasTnJN9+BGXg@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: David Mosberger-Tang @ 2016-05-16 20:17 UTC (permalink / raw) To: srinivas.kandagatla, maxime.ripard Cc: mark.rutland, devicetree, pawel.moll, ijc+devicetree, David Mosberger-Tang, nicolas.ferre, linux-kernel, galak, linux-arm-kernel Signed-off-by: David Mosberger <davidm@egauge.net> --- .../devicetree/bindings/nvmem/atmel-secumod.txt | 46 ++++++++ drivers/nvmem/atmel-secumod.c | 125 +++++++++++++++++++++ 2 files changed, 171 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/atmel-secumod.txt create mode 100644 drivers/nvmem/atmel-secumod.c diff --git a/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt b/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt new file mode 100644 index 0000000..85db709 --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt @@ -0,0 +1,46 @@ += Atmel Secumod device tree bindings = + +This binding is intended to represent Atmel's Secumod which is found +in SAMA5D2 and perhaps others. + +Required properties: +- compatible: should be "atmel,sama5d2-secumod" +- reg: Should contain registers location and length of the RAM, followed + by register location and length of the Secumod controller. + += Data cells = +Are child nodes of secumod, bindings of which as described in +bindings/nvmem/nvmem.txt + +Example: + + secumod@fc040000 { + compatible = "atmel,sama5d2-secumod"; + reg = <0xf8044000 0x1420 + 0xfc040000 0x4000>; + status = "okay"; + + #address-cells = <1>; + #size-cells = <1>; + + secram_auto_erasable@0000 { + reg = <0x0000 0x1000>; + }; + secram@1000 { + reg = <0x1000 0x400>; + }; + ram@1400 { + reg = <0x1400 0x20>; + }; + }; + += Data consumers = +Are device nodes which consume nvmem data cells. + +For example: + + ram { + ... + nvmem-cells = <&ram>; + nvmem-cell-names = "RAM"; + }; diff --git a/drivers/nvmem/atmel-secumod.c b/drivers/nvmem/atmel-secumod.c new file mode 100644 index 0000000..fda83c9 --- /dev/null +++ b/drivers/nvmem/atmel-secumod.c @@ -0,0 +1,125 @@ +/* + * Driver for SAMA5D2 secure module (SECUMOD). + * + * Copyright (C) 2016 eGauge Systems LLC + * + * David Mosberger <davidm@egauge.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ +#include <linux/delay.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/nvmem-provider.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> + +static struct regmap_config secumod_regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4 +}; + +static struct nvmem_config econfig = { + .name = "secumod", + .owner = THIS_MODULE, +}; + +/* + * Security-module register definitions: + */ +#define SECUMOD_RAMRDY 0x0014 + +/* + * Since the secure module may need to automatically erase some of the + * RAM, it may take a while for it to be ready. As far as I know, + * it's not documented how long this might take in the worst-case. + */ +static void +secumod_wait_ready (void *regs) +{ + unsigned long start, stop; + + start = jiffies; + while (!(readl(regs + SECUMOD_RAMRDY) & 1)) + msleep_interruptible(1); + stop = jiffies; + if (stop != start) + pr_info("nvmem-atmel-secumod: it took %u msec for SECUMOD " + "to become ready...\n", jiffies_to_msecs(stop - start)); + else + pr_info("nvmem-atmel-secumod: ready\n"); +} + +static int secumod_remove(struct platform_device *pdev) +{ + struct nvmem_device *nvmem = platform_get_drvdata(pdev); + + return nvmem_unregister(nvmem); +} + +static int secumod_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct resource *res; + struct nvmem_device *nvmem; + struct regmap *regmap; + void __iomem *base; + + /* + * Map controller address temporarily so we can ensure that + * the hardware is ready: + */ + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + base = devm_ioremap_resource(dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + + secumod_wait_ready(base); + devm_iounmap(dev, base); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(dev, res); + + if (IS_ERR(base)) + return PTR_ERR(base); + + secumod_regmap_config.max_register = resource_size(res) - 1; + + regmap = devm_regmap_init_mmio(dev, base, &secumod_regmap_config); + if (IS_ERR(regmap)) { + dev_err(dev, "%s: regmap init failed\n", __func__); + return PTR_ERR(regmap); + } + econfig.dev = dev; + nvmem = nvmem_register(&econfig); + if (IS_ERR(nvmem)) + return PTR_ERR(nvmem); + + platform_set_drvdata(pdev, nvmem); + + return 0; +} + +static const struct of_device_id secumod_of_match[] = { + { .compatible = "atmel,sama5d2-secumod",}, + {/* sentinel */}, +}; +MODULE_DEVICE_TABLE(of, secumod_of_match); + +static struct platform_driver secumod_driver = { + .probe = secumod_probe, + .remove = secumod_remove, + .driver = { + .name = "atmel,sama5d2-secumod", + .of_match_table = secumod_of_match, + }, +}; +module_platform_driver(secumod_driver); +MODULE_AUTHOR("David Mosberger <davidm@egauge.net>"); +MODULE_DESCRIPTION("Atmel Secumod driver"); +MODULE_LICENSE("GPL v2"); -- 1.9.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <1463429830-20539-1-git-send-email-davidm-haPfTeumbwasTnJN9+BGXg@public.gmane.org>]
* Re: [PATCH] drivers: nvmem: atmel-secumod: New driver for Atmel Secumod nvram [not found] ` <1463429830-20539-1-git-send-email-davidm-haPfTeumbwasTnJN9+BGXg@public.gmane.org> @ 2016-05-18 16:42 ` Rob Herring 2016-05-18 20:46 ` David Mosberger 2016-05-18 21:06 ` David Mosberger-Tang 0 siblings, 2 replies; 6+ messages in thread From: Rob Herring @ 2016-05-18 16:42 UTC (permalink / raw) To: David Mosberger-Tang Cc: srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A, maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, mark.rutland-5wv7dgnIgG8, devicetree-u79uwXL29TY76Z2rM5mHXA, pawel.moll-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg, nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w, linux-kernel-u79uwXL29TY76Z2rM5mHXA, galak-sgV2jX0FEOL9JmXXK+q4OQ, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On Mon, May 16, 2016 at 02:17:10PM -0600, David Mosberger-Tang wrote: > Signed-off-by: David Mosberger <davidm-haPfTeumbwasTnJN9+BGXg@public.gmane.org> > --- > .../devicetree/bindings/nvmem/atmel-secumod.txt | 46 ++++++++ > drivers/nvmem/atmel-secumod.c | 125 +++++++++++++++++++++ > 2 files changed, 171 insertions(+) > create mode 100644 Documentation/devicetree/bindings/nvmem/atmel-secumod.txt > create mode 100644 drivers/nvmem/atmel-secumod.c > > diff --git a/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt b/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt > new file mode 100644 > index 0000000..85db709 > --- /dev/null > +++ b/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt > @@ -0,0 +1,46 @@ > += Atmel Secumod device tree bindings = > + > +This binding is intended to represent Atmel's Secumod which is found > +in SAMA5D2 and perhaps others. > + > +Required properties: > +- compatible: should be "atmel,sama5d2-secumod" > +- reg: Should contain registers location and length of the RAM, followed registers or RAM location? "Should contain RAM location and length, ..." > + by register location and length of the Secumod controller. > + > += Data cells = > +Are child nodes of secumod, bindings of which as described in > +bindings/nvmem/nvmem.txt > + > +Example: > + > + secumod@fc040000 { > + compatible = "atmel,sama5d2-secumod"; > + reg = <0xf8044000 0x1420 > + 0xfc040000 0x4000>; You are missing ranges property. > + status = "okay"; > + > + #address-cells = <1>; > + #size-cells = <1>; > + > + secram_auto_erasable@0000 { Use '-' rather than '_' and drop leading 0s. > + reg = <0x0000 0x1000>; > + }; > + secram@1000 { > + reg = <0x1000 0x400>; > + }; > + ram@1400 { > + reg = <0x1400 0x20>; > + }; > + }; > + > += Data consumers = > +Are device nodes which consume nvmem data cells. > + > +For example: > + > + ram { > + ... > + nvmem-cells = <&ram>; > + nvmem-cell-names = "RAM"; > + }; -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drivers: nvmem: atmel-secumod: New driver for Atmel Secumod nvram 2016-05-18 16:42 ` Rob Herring @ 2016-05-18 20:46 ` David Mosberger 2016-05-18 21:06 ` David Mosberger-Tang 1 sibling, 0 replies; 6+ messages in thread From: David Mosberger @ 2016-05-18 20:46 UTC (permalink / raw) To: Rob Herring Cc: srinivas.kandagatla, maxime.ripard, mark.rutland, devicetree, pawel.moll, ijc+devicetree, Nicolas Ferre, linux-kernel, galak, linux-arm-kernel Thanks for the feedback. Rob! I'll make the changes and resend the patch (which has now also been updated to work with linux-next). ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] drivers: nvmem: atmel-secumod: New driver for Atmel Secumod nvram 2016-05-18 16:42 ` Rob Herring 2016-05-18 20:46 ` David Mosberger @ 2016-05-18 21:06 ` David Mosberger-Tang 2016-05-20 19:21 ` Rob Herring 2016-05-23 8:50 ` Srinivas Kandagatla 1 sibling, 2 replies; 6+ messages in thread From: David Mosberger-Tang @ 2016-05-18 21:06 UTC (permalink / raw) To: srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A, maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8 Cc: pawel.moll-5wv7dgnIgG8, mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg, galak-sgV2jX0FEOL9JmXXK+q4OQ, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, David Mosberger-Tang Signed-off-by: David Mosberger <davidm-haPfTeumbwasTnJN9+BGXg@public.gmane.org> --- .../devicetree/bindings/nvmem/atmel-secumod.txt | 47 +++++++ drivers/nvmem/Kconfig | 7 + drivers/nvmem/Makefile | 2 + drivers/nvmem/atmel-secumod.c | 143 +++++++++++++++++++++ 4 files changed, 199 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/atmel-secumod.txt create mode 100644 drivers/nvmem/atmel-secumod.c diff --git a/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt b/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt new file mode 100644 index 0000000..d65cad5 --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt @@ -0,0 +1,47 @@ += Atmel Secumod device tree bindings = + +This binding is intended to represent Atmel's Secumod which is found +in SAMA5D2 and perhaps others. + +Required properties: +- compatible: should be "atmel,sama5d2-secumod" +- reg: Should contain RAM location and length, followed + by register location and length of the Secumod controller. + += Data cells = +Are child nodes of secumod, bindings of which as described in +bindings/nvmem/nvmem.txt + +Example: + + secumod@fc040000 { + compatible = "atmel,sama5d2-secumod"; + reg = <0xf8044000 0x1420>, <0xfc040000 0x4000>; + reg-names = "SECURAM", "SECUMOD"; + status = "okay"; + + #address-cells = <1>; + #size-cells = <1>; + ranges; + + secram-auto-erasable@0 { + reg = <0x0000 0x1000>; + }; + secram@1000 { + reg = <0x1000 0x400>; + }; + ram@1400 { + reg = <0x1400 0x20>; + }; + }; + += Data consumers = +Are device nodes which consume nvmem data cells. + +For example: + + ram { + ... + nvmem-cells = <&ram>; + nvmem-cell-names = "RAM"; + }; diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 3041d48..88b21e3 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -101,4 +101,11 @@ config NVMEM_VF610_OCOTP This driver can also be build as a module. If so, the module will be called nvmem-vf610-ocotp. +config NVMEM_ATMEL_SECUMOD + tristate "Atmel Secure Module driver" + depends on ARCH_AT91 + help + Select this to get support for the secure module (SECUMOD) built + into the SAMA5D2 chips. + endif diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index 45ab1ae..9cbd950 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -22,3 +22,5 @@ obj-$(CONFIG_NVMEM_SUNXI_SID) += nvmem_sunxi_sid.o nvmem_sunxi_sid-y := sunxi_sid.o obj-$(CONFIG_NVMEM_VF610_OCOTP) += nvmem-vf610-ocotp.o nvmem-vf610-ocotp-y := vf610-ocotp.o +obj-$(CONFIG_NVMEM_ATMEL_SECUMOD) += nvmem-atmel-secumod.o +nvmem-atmel-secumod-y := atmel-secumod.o diff --git a/drivers/nvmem/atmel-secumod.c b/drivers/nvmem/atmel-secumod.c new file mode 100644 index 0000000..fc5a96b --- /dev/null +++ b/drivers/nvmem/atmel-secumod.c @@ -0,0 +1,143 @@ +/* + * Driver for SAMA5D2 secure module (SECUMOD). + * + * Copyright (C) 2016 eGauge Systems LLC + * + * David Mosberger <davidm-haPfTeumbwasTnJN9+BGXg@public.gmane.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ +#include <linux/delay.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/nvmem-provider.h> +#include <linux/of.h> +#include <linux/platform_device.h> + +static int +secumod_reg_read(void *context, unsigned int reg, void *_val, size_t bytes) +{ + void __iomem *base = context; + u32 *val = _val; + int i = 0, words = bytes / 4; + + while (words--) + *val++ = readl(base + reg + (i++ * 4)); + + return 0; +} + +static int +secumod_reg_write(void *context, unsigned int reg, void *_val, size_t bytes) +{ + void __iomem *base = context; + u32 *val = _val; + int i = 0, words = bytes / 4; + + while (words--) + writel(*val++, base + reg + (i++ * 4)); + + return 0; +} + +static struct nvmem_config econfig = { + .name = "secumod", + .owner = THIS_MODULE, + .stride = 4, + .word_size = 1, + .reg_read = secumod_reg_read, + .reg_write = secumod_reg_write, +}; + +/* + * Security-module register definitions: + */ +#define SECUMOD_RAMRDY 0x0014 + +/* + * Since the secure module may need to automatically erase some of the + * RAM, it may take a while for it to be ready. As far as I know, + * it's not documented how long this might take in the worst-case. + */ +static void +secumod_wait_ready (void *regs) +{ + unsigned long start, stop; + + start = jiffies; + while (!(readl(regs + SECUMOD_RAMRDY) & 1)) + msleep_interruptible(1); + stop = jiffies; + if (stop != start) + pr_info("nvmem-atmel-secumod: it took %u msec for SECUMOD " + "to become ready...\n", jiffies_to_msecs(stop - start)); + else + pr_info("nvmem-atmel-secumod: ready\n"); +} + +static int secumod_remove(struct platform_device *pdev) +{ + struct nvmem_device *nvmem = platform_get_drvdata(pdev); + + return nvmem_unregister(nvmem); +} + +static int secumod_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct resource *res; + struct nvmem_device *nvmem; + void __iomem *base; + + /* + * Map controller address temporarily so we can ensure that + * the hardware is ready: + */ + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + base = devm_ioremap_resource(dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + + secumod_wait_ready(base); + devm_iounmap(dev, base); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(dev, res); + + if (IS_ERR(base)) + return PTR_ERR(base); + + econfig.size = resource_size(res); + econfig.dev = dev; + econfig.priv = base; + + nvmem = nvmem_register(&econfig); + if (IS_ERR(nvmem)) + return PTR_ERR(nvmem); + + platform_set_drvdata(pdev, nvmem); + + return 0; +} + +static const struct of_device_id secumod_of_match[] = { + { .compatible = "atmel,sama5d2-secumod",}, + {/* sentinel */}, +}; +MODULE_DEVICE_TABLE(of, secumod_of_match); + +static struct platform_driver secumod_driver = { + .probe = secumod_probe, + .remove = secumod_remove, + .driver = { + .name = "atmel,sama5d2-secumod", + .of_match_table = secumod_of_match, + }, +}; +module_platform_driver(secumod_driver); +MODULE_AUTHOR("David Mosberger <davidm-haPfTeumbwasTnJN9+BGXg@public.gmane.org>"); +MODULE_DESCRIPTION("Atmel Secumod driver"); +MODULE_LICENSE("GPL v2"); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] drivers: nvmem: atmel-secumod: New driver for Atmel Secumod nvram 2016-05-18 21:06 ` David Mosberger-Tang @ 2016-05-20 19:21 ` Rob Herring 2016-05-23 8:50 ` Srinivas Kandagatla 1 sibling, 0 replies; 6+ messages in thread From: Rob Herring @ 2016-05-20 19:21 UTC (permalink / raw) To: David Mosberger-Tang Cc: srinivas.kandagatla, maxime.ripard, pawel.moll, mark.rutland, ijc+devicetree, galak, devicetree, linux-kernel, nicolas.ferre, linux-arm-kernel On Wed, May 18, 2016 at 03:06:04PM -0600, David Mosberger-Tang wrote: > Signed-off-by: David Mosberger <davidm@egauge.net> > --- > .../devicetree/bindings/nvmem/atmel-secumod.txt | 47 +++++++ > drivers/nvmem/Kconfig | 7 + > drivers/nvmem/Makefile | 2 + > drivers/nvmem/atmel-secumod.c | 143 +++++++++++++++++++++ > 4 files changed, 199 insertions(+) > create mode 100644 Documentation/devicetree/bindings/nvmem/atmel-secumod.txt > create mode 100644 drivers/nvmem/atmel-secumod.c > > diff --git a/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt b/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt > new file mode 100644 > index 0000000..d65cad5 > --- /dev/null > +++ b/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt > @@ -0,0 +1,47 @@ > += Atmel Secumod device tree bindings = > + > +This binding is intended to represent Atmel's Secumod which is found > +in SAMA5D2 and perhaps others. > + > +Required properties: > +- compatible: should be "atmel,sama5d2-secumod" > +- reg: Should contain RAM location and length, followed > + by register location and length of the Secumod controller. > + > += Data cells = > +Are child nodes of secumod, bindings of which as described in > +bindings/nvmem/nvmem.txt > + > +Example: > + > + secumod@fc040000 { This unit-address should match the first reg address. > + compatible = "atmel,sama5d2-secumod"; > + reg = <0xf8044000 0x1420>, <0xfc040000 0x4000>; > + reg-names = "SECURAM", "SECUMOD"; > + status = "okay"; > + > + #address-cells = <1>; > + #size-cells = <1>; > + ranges; Sorry, to be clear, you need values here too. > + > + secram-auto-erasable@0 { > + reg = <0x0000 0x1000>; The 0 here is address 0xf8044000, right? So ranges is what is used to translate from child address of 0 to the parent address. > + }; > + secram@1000 { > + reg = <0x1000 0x400>; > + }; > + ram@1400 { > + reg = <0x1400 0x20>; > + }; > + }; > + > += Data consumers = > +Are device nodes which consume nvmem data cells. > + > +For example: > + > + ram { > + ... > + nvmem-cells = <&ram>; > + nvmem-cell-names = "RAM"; > + }; ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drivers: nvmem: atmel-secumod: New driver for Atmel Secumod nvram 2016-05-18 21:06 ` David Mosberger-Tang 2016-05-20 19:21 ` Rob Herring @ 2016-05-23 8:50 ` Srinivas Kandagatla 1 sibling, 0 replies; 6+ messages in thread From: Srinivas Kandagatla @ 2016-05-23 8:50 UTC (permalink / raw) To: David Mosberger-Tang, maxime.ripard Cc: mark.rutland, devicetree, pawel.moll, ijc+devicetree, nicolas.ferre, linux-kernel, galak, linux-arm-kernel Thanks for the patch, Few minors comments below. On 18/05/16 22:06, David Mosberger-Tang wrote: > Signed-off-by: David Mosberger <davidm@egauge.net> > --- > .../devicetree/bindings/nvmem/atmel-secumod.txt | 47 +++++++ > drivers/nvmem/Kconfig | 7 + > drivers/nvmem/Makefile | 2 + > drivers/nvmem/atmel-secumod.c | 143 +++++++++++++++++++++ > 4 files changed, 199 insertions(+) > create mode 100644 Documentation/devicetree/bindings/nvmem/atmel-secumod.txt > create mode 100644 drivers/nvmem/atmel-secumod.c > > diff --git a/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt b/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt > new file mode 100644 > index 0000000..d65cad5 > --- /dev/null > +++ b/Documentation/devicetree/bindings/nvmem/atmel-secumod.txt > @@ -0,0 +1,47 @@ > += Atmel Secumod device tree bindings = > + Can you split the dt-bindings into separate patch. > +This binding is intended to represent Atmel's Secumod which is found > +in SAMA5D2 and perhaps others. > + > +Required properties: > +- compatible: should be "atmel,sama5d2-secumod" > +- reg: Should contain RAM location and length, followed > + by register location and length of the Secumod controller. > + > += Data cells = > +Are child nodes of secumod, bindings of which as described in > +bindings/nvmem/nvmem.txt > + > +Example: > + > + secumod@fc040000 { > + compatible = "atmel,sama5d2-secumod"; > + reg = <0xf8044000 0x1420>, <0xfc040000 0x4000>; > + reg-names = "SECURAM", "SECUMOD"; > + status = "okay"; > + > + #address-cells = <1>; > + #size-cells = <1>; > + ranges; > + > + secram-auto-erasable@0 { > + reg = <0x0000 0x1000>; > + }; > + secram@1000 { > + reg = <0x1000 0x400>; > + }; > + ram@1400 { > + reg = <0x1400 0x20>; > + }; > + }; > + > += Data consumers = > +Are device nodes which consume nvmem data cells. > + > +For example: > + > + ram { > + ... > + nvmem-cells = <&ram>; > + nvmem-cell-names = "RAM"; > + }; > diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig > index 3041d48..88b21e3 100644 > --- a/drivers/nvmem/Kconfig > +++ b/drivers/nvmem/Kconfig > @@ -101,4 +101,11 @@ config NVMEM_VF610_OCOTP > This driver can also be build as a module. If so, the module will > be called nvmem-vf610-ocotp. > > +config NVMEM_ATMEL_SECUMOD > + tristate "Atmel Secure Module driver" > + depends on ARCH_AT91 COMPILE_TEST ? Also please add depends on HAS_IOMEM > + help > + Select this to get support for the secure module (SECUMOD) built > + into the SAMA5D2 chips. > + > endif ... > index 0000000..fc5a96b > --- /dev/null > +++ b/drivers/nvmem/atmel-secumod.c ... > + > +/* > + * Security-module register definitions: > + */ > +#define SECUMOD_RAMRDY 0x0014 > + > +/* > + * Since the secure module may need to automatically erase some of the > + * RAM, it may take a while for it to be ready. As far as I know, > + * it's not documented how long this might take in the worst-case. > + */ > +static void > +secumod_wait_ready (void *regs) > +{ > + unsigned long start, stop; > + > + start = jiffies; > + while (!(readl(regs + SECUMOD_RAMRDY) & 1)) > + msleep_interruptible(1); Worst case would be the system loop here forever, Can we add worst case timeout for this, and get out of this loop. > + stop = jiffies; > + if (stop != start) > + pr_info("nvmem-atmel-secumod: it took %u msec for SECUMOD " > + "to become ready...\n", jiffies_to_msecs(stop - start)); > + else > + pr_info("nvmem-atmel-secumod: ready\n"); I dont see any use of this prints, We should probably remove these and add just a one dev_dbg. > +} > + ... thanks, srini ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-05-23 8:50 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <alpine.LNX.2.00.1605121505320.21379@nippy.intranet> 2016-05-16 20:17 ` [PATCH] drivers: nvmem: atmel-secumod: New driver for Atmel Secumod nvram David Mosberger-Tang [not found] ` <1463429830-20539-1-git-send-email-davidm-haPfTeumbwasTnJN9+BGXg@public.gmane.org> 2016-05-18 16:42 ` Rob Herring 2016-05-18 20:46 ` David Mosberger 2016-05-18 21:06 ` David Mosberger-Tang 2016-05-20 19:21 ` Rob Herring 2016-05-23 8:50 ` Srinivas Kandagatla
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).