Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1488440 > unrolled thread
| Started by | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| First post | 2016-09-22 00:20 +0200 |
| Last post | 2016-09-22 07:10 +0200 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v2 0/6] Atmel sama5d2 security module support Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-09-22 00:20 +0200
[PATCH v2 3/6] ARM: dts: at91: sama5d2: Add secumod node Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-09-22 00:20 +0200
[PATCH v2 5/6] misc: sram: add Atmel securam support Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-09-22 00:20 +0200
Re: [PATCH v2 5/6] misc: sram: add Atmel securam support Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 07:10 +0200
| From | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| Date | 2016-09-22 00:20 +0200 |
| Subject | [PATCH v2 0/6] Atmel sama5d2 security module support |
| Message-ID | <sjXSh-6ij-3@gated-at.bofh.it> |
Hi, There has already been multiple tentatives trying to add support for the Sama5d2 security module and in particular, access to its SRAM. After multiple discussions, I believe adding support in the sram driver/framework is probably the best because it allows exporting the SRAM to the kernel, to userspace and also to run code from it. As the support for the sama5d2 securam is fairly small, I've included it directly in the mmio-sram driver. Changes in v2: - Fixed an issued in the sama5d2 dtsi - Use regmap_read_poll_timeout and of_device_get_match_data as suggested by Philipp - Shrink the timeout to 500ms - Added Rob's acks Cc: Arnd Bergmann <arnd@arndb.de> Cc: Philipp Zabel <p.zabel@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Alexandre Belloni (6): Documentation: dt: atmel-at91: Document secumod bindings ARM: at91: add secumod register definitions ARM: dts: at91: sama5d2: Add secumod node misc: sram: document new compatible misc: sram: add Atmel securam support ARM: dts: at91: sama5d2: Add securam node .../devicetree/bindings/arm/atmel-at91.txt | 17 +++++++++ Documentation/devicetree/bindings/sram/sram.txt | 2 +- arch/arm/boot/dts/sama5d2.dtsi | 19 ++++++++++ drivers/misc/sram.c | 42 ++++++++++++++++++---- include/soc/at91/atmel-secumod.h | 20 +++++++++++ 5 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 include/soc/at91/atmel-secumod.h -- 2.9.3
[toc] | [next] | [standalone]
| From | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| Date | 2016-09-22 00:20 +0200 |
| Subject | [PATCH v2 3/6] ARM: dts: at91: sama5d2: Add secumod node |
| Message-ID | <sjY1Y-6nf-23@gated-at.bofh.it> |
| In reply to | #1488440 |
The sama5d2 has a security module, add its node.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
arch/arm/boot/dts/sama5d2.dtsi | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi
index 353d0e5ec83b..0b62bff86f49 100644
--- a/arch/arm/boot/dts/sama5d2.dtsi
+++ b/arch/arm/boot/dts/sama5d2.dtsi
@@ -1231,6 +1231,11 @@
clocks = <&pioA_clk>;
};
+ secumod@fc040000 {
+ compatible = "atmel,sama5d2-secumod", "syscon";
+ reg = <0xfc040000 0x100>;
+ };
+
tdes@fc044000 {
compatible = "atmel,at91sam9g46-tdes";
reg = <0xfc044000 0x100>;
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| Date | 2016-09-22 00:20 +0200 |
| Subject | [PATCH v2 5/6] misc: sram: add Atmel securam support |
| Message-ID | <sjY1Y-6nf-15@gated-at.bofh.it> |
| In reply to | #1488440 |
The Atmel secure SRAM is connected to a security module and may be erased
automatically under certain conditions. For that reason, it is necessary to
wait for the security module to flag that SRAM accesses are allowed before
accessing it.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/sram.c | 42 +++++++++++++++++++++++++++++++++++-------
1 file changed, 35 insertions(+), 7 deletions(-)
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index f84b53d6ce50..b0d4dd9b0586 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -19,12 +19,17 @@
*/
#include <linux/clk.h>
+#include <linux/delay.h>
#include <linux/genalloc.h>
#include <linux/io.h>
#include <linux/list_sort.h>
#include <linux/of_address.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
+#include <linux/regmap.h>
#include <linux/slab.h>
+#include <linux/mfd/syscon.h>
+#include <soc/at91/atmel-secumod.h>
#define SRAM_GRANULARITY 32
@@ -334,12 +339,35 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res)
return ret;
}
+static int atmel_securam_wait(void)
+{
+ struct regmap *regmap;
+ u32 val;
+
+ regmap = syscon_regmap_lookup_by_compatible("atmel,sama5d2-secumod");
+ if (IS_ERR(regmap))
+ return -ENODEV;
+
+ return regmap_read_poll_timeout(regmap, AT91_SECUMOD_RAMRDY, val,
+ val & AT91_SECUMOD_RAMRDY_READY,
+ 10000, 500000);
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id sram_dt_ids[] = {
+ { .compatible = "mmio-sram" },
+ { .compatible = "atmel,sama5d2-securam", .data = atmel_securam_wait },
+ {}
+};
+#endif
+
static int sram_probe(struct platform_device *pdev)
{
struct sram_dev *sram;
struct resource *res;
size_t size;
int ret;
+ int (*init_func)(void);
sram = devm_kzalloc(&pdev->dev, sizeof(*sram), GFP_KERNEL);
if (!sram)
@@ -384,6 +412,13 @@ static int sram_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, sram);
+ init_func = of_device_get_match_data(&pdev->dev);
+ if (init_func) {
+ ret = init_func();
+ if (ret)
+ return ret;
+ }
+
dev_dbg(sram->dev, "SRAM pool: %zu KiB @ 0x%p\n",
gen_pool_size(sram->pool) / 1024, sram->virt_base);
@@ -405,13 +440,6 @@ static int sram_remove(struct platform_device *pdev)
return 0;
}
-#ifdef CONFIG_OF
-static const struct of_device_id sram_dt_ids[] = {
- { .compatible = "mmio-sram" },
- {}
-};
-#endif
-
static struct platform_driver sram_driver = {
.driver = {
.name = "sram",
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2016-09-22 07:10 +0200 |
| Subject | Re: [PATCH v2 5/6] misc: sram: add Atmel securam support |
| Message-ID | <sk4qJ-274-5@gated-at.bofh.it> |
| In reply to | #1488442 |
On Thu, Sep 22, 2016 at 12:09:38AM +0200, Alexandre Belloni wrote: > The Atmel secure SRAM is connected to a security module and may be erased > automatically under certain conditions. For that reason, it is necessary to > wait for the security module to flag that SRAM accesses are allowed before > accessing it. > > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> > --- > Cc: Arnd Bergmann <arnd@arndb.de> > Cc: Philipp Zabel <p.zabel@pengutronix.de> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > drivers/misc/sram.c | 42 +++++++++++++++++++++++++++++++++++------- > 1 file changed, 35 insertions(+), 7 deletions(-) Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web