linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver
@ 2014-10-27 23:09 Alexandre Belloni
  2014-10-27 23:09 ` [PATCH v2 1/8] memory: atmel-sdramc: export a shutdown function Alexandre Belloni
                   ` (8 more replies)
  0 siblings, 9 replies; 17+ messages in thread
From: Alexandre Belloni @ 2014-10-27 23:09 UTC (permalink / raw)
  To: Nicolas Ferre, Sebastian Reichel
  Cc: Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, Maxime Ripard, Boris Brezillon,
	linux-arm-kernel, linux-kernel, linux-pm, Alexandre Belloni

This series removes the mach/ headers dependency from the reset driver. It is
also laying some groundwork for the necessary power management support rework.

The first patch adds and export a function to shutdown the sdram from the sdramc
driver. That function also take the RSTC CR register and a value as parameters
to be able to reset the chip. This is a hackish way of doing it but it ensures
that all the code fits in one cache line. We already have plan to start using
the sram to have a cleaner way to execute that code safely as soon as that
series goes in:
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-September/198778.html

The second patch makes the sdramc driver usable from the board files.

The third patch actually registers the sdramc driver from the boards files.
The fourth patch does the same, only for sam9g45 and sam9rl to simplify future
merging as the board files have been removed. Simply drop that patch.

The fifth patch makes the at91-reset driver use the newly created
at91_ramc_shutdown() function and removes the mach/ headers inclusion.

Then the sixth and seven patch do some cleanup. Again, you can simply drop patch
7 when merging.

The last patch adds myself a the maintainer for those drivers.

Changes in v2:
 - corrected a typo in MAINTAINERS
 - pass the RSTC CR register address and its value to reset the SoC to ensure
   everything fits in one cache line.

Alexandre Belloni (8):
  memory: atmel-sdramc: export a shutdown function
  memory: atmel-sdramc: allow probing from pdata
  ARM: at91: sam9: probe the RAMC driver from pdata
  ARM: at91: sam9g45/sam9rl: probe the ramc driver
  power: reset: at91-reset: use at91_ramc_shutdown
  ARM: at91: sam9: remove useless resource for rstc
  ARM: at91: sam9g45/sam9rl: remove useless resources for rstc
  MAINTAINERS: add at91 power and memory entries

 MAINTAINERS                      |  19 +++++
 arch/arm/mach-at91/Kconfig       |   2 +-
 arch/arm/mach-at91/at91sam9260.c |  20 ++++--
 arch/arm/mach-at91/at91sam9261.c |  20 ++++--
 arch/arm/mach-at91/at91sam9263.c |  20 ++++--
 arch/arm/mach-at91/at91sam9g45.c |  20 ++++--
 arch/arm/mach-at91/at91sam9rl.c  |  20 ++++--
 drivers/memory/atmel-sdramc.c    | 148 ++++++++++++++++++++++++++++++++++++++-
 drivers/power/reset/at91-reset.c | 122 ++++----------------------------
 include/soc/atmel/memory.h       |   6 ++
 10 files changed, 262 insertions(+), 135 deletions(-)
 create mode 100644 include/soc/atmel/memory.h

-- 
1.9.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 1/8] memory: atmel-sdramc: export a shutdown function
  2014-10-27 23:09 [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Alexandre Belloni
@ 2014-10-27 23:09 ` Alexandre Belloni
  2014-10-27 23:09 ` [PATCH v2 2/8] memory: atmel-sdramc: allow probing from pdata Alexandre Belloni
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Alexandre Belloni @ 2014-10-27 23:09 UTC (permalink / raw)
  To: Nicolas Ferre, Sebastian Reichel
  Cc: Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, Maxime Ripard, Boris Brezillon,
	linux-arm-kernel, linux-kernel, linux-pm, Alexandre Belloni

It is necessary to shutdown the SDRAM before resetting the SoC to avoid having
issue with NAND boot.

Export a function that does exactly that.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/memory/atmel-sdramc.c | 103 ++++++++++++++++++++++++++++++++++++++++++
 include/soc/atmel/memory.h    |   6 +++
 2 files changed, 109 insertions(+)
 create mode 100644 include/soc/atmel/memory.h

diff --git a/drivers/memory/atmel-sdramc.c b/drivers/memory/atmel-sdramc.c
index fed04e8efe75..d89ed0af44d9 100644
--- a/drivers/memory/atmel-sdramc.c
+++ b/drivers/memory/atmel-sdramc.c
@@ -21,24 +21,114 @@
 #include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
 
+#include <soc/atmel/memory.h>
+
+#define AT91_SDRAMC_TR		0x04	/* SDRAM Controller Refresh Timer Register */
+#define AT91_SDRAMC_LPR		0x10	/* SDRAM Controller Low Power Register */
+#define			AT91_SDRAMC_LPCB_POWER_DOWN		2
+
+#define AT91_DDRSDRC_RTR	0x04	/* Refresh Timer Register */
+#define AT91_DDRSDRC_LPR	0x1C	/* Low Power Register */
+#define			AT91_DDRSDRC_LPCB_POWER_DOWN		2
+
+static void __iomem *at91_ramc_base[2];
+
+void (*at91_ramc_shutdown)(void __iomem *rstc_cr, u32 value);
+
 struct at91_ramc_caps {
 	bool has_ddrck;
 	bool has_mpddr_clk;
+	void (*shutdown)(void __iomem *rstc_cr, u32 value);
 };
 
+static void at91sam9260_shutdown(void __iomem *rstc_cr, u32 value)
+{
+	asm volatile(
+		/* Align to cache lines */
+		".balign 32\n\t"
+
+		/* Disable SDRAM accesses */
+		"str	%1, [%0, #" __stringify(AT91_SDRAMC_TR) "]\n\t"
+
+		/* Power down SDRAM */
+		"str	%2, [%0, #" __stringify(AT91_SDRAMC_LPR) "]\n\t"
+
+		/* Reset CPU */
+		"str	%4, [%3]\n\t"
+
+		"b	.\n\t"
+
+		:
+		: "r" (at91_ramc_base[0]),
+		  "r" (1),
+		  "r" (AT91_SDRAMC_LPCB_POWER_DOWN),
+		  "r" (rstc_cr),
+		  "r" (value));
+}
+
+static void at91sam9g45_shutdown(void __iomem *rstc_cr, u32 value)
+{
+	asm volatile(
+		/*
+		 * Test wether we have a second RAM controller to care
+		 * about.
+		 *
+		 * First, test that we can dereference the virtual address.
+		 */
+		"cmp	%1, #0\n\t"
+		"beq	1f\n\t"
+
+		/* Then, test that the RAM controller is enabled */
+		"ldr	r0, [%1]\n\t"
+		"cmp	r0, #0\n\t"
+
+		/* Align to cache lines */
+		".balign 32\n\t"
+
+		/* Disable SDRAM0 accesses */
+		"1:	str	%2, [%0, #" __stringify(AT91_DDRSDRC_RTR) "]\n\t"
+		/* Power down SDRAM0 */
+		"	str	%3, [%0, #" __stringify(AT91_DDRSDRC_LPR) "]\n\t"
+		/* Disable SDRAM1 accesses */
+		"	strne	%2, [%1, #" __stringify(AT91_DDRSDRC_RTR) "]\n\t"
+		/* Power down SDRAM1 */
+		"	strne	%3, [%1, #" __stringify(AT91_DDRSDRC_LPR) "]\n\t"
+
+		/* Reset CPU */
+		"str	%5, [%4]\n\t"
+
+		"b	.\n\t"
+
+		:
+		: "r" (at91_ramc_base[0]),
+		  "r" (at91_ramc_base[1]),
+		  "r" (1),
+		  "r" (AT91_DDRSDRC_LPCB_POWER_DOWN),
+		  "r" (rstc_cr),
+		  "r" (value)
+		: "r0");
+}
+
 static const struct at91_ramc_caps at91rm9200_caps = { };
 
+static const struct at91_ramc_caps at91sam9260_caps = {
+	.shutdown = at91sam9260_shutdown,
+};
+
 static const struct at91_ramc_caps at91sam9g45_caps = {
 	.has_ddrck = 1,
 	.has_mpddr_clk = 0,
+	.shutdown = at91sam9g45_shutdown,
 };
 
 static const struct at91_ramc_caps sama5d3_caps = {
 	.has_ddrck = 1,
 	.has_mpddr_clk = 1,
+	.shutdown = at91sam9g45_shutdown,
 };
 
 static const struct of_device_id atmel_ramc_of_match[] = {
@@ -54,7 +144,9 @@ static int atmel_ramc_probe(struct platform_device *pdev)
 {
 	const struct of_device_id *match;
 	const struct at91_ramc_caps *caps;
+	struct device_node *np;
 	struct clk *clk;
+	int idx = 0;
 
 	match = of_match_device(atmel_ramc_of_match, &pdev->dev);
 	caps = match->data;
@@ -75,6 +167,17 @@ static int atmel_ramc_probe(struct platform_device *pdev)
 		clk_prepare_enable(clk);
 	}
 
+	for_each_matching_node(np, atmel_ramc_of_match) {
+		at91_ramc_base[idx] = of_iomap(np, 0);
+		if (!at91_ramc_base[idx]) {
+			dev_err(&pdev->dev, "Could not map ram controller address\n");
+			return -ENODEV;
+		}
+		idx++;
+	}
+
+	at91_ramc_shutdown = caps->shutdown;
+
 	return 0;
 }
 
diff --git a/include/soc/atmel/memory.h b/include/soc/atmel/memory.h
new file mode 100644
index 000000000000..93f75fecf9bf
--- /dev/null
+++ b/include/soc/atmel/memory.h
@@ -0,0 +1,6 @@
+#ifndef __INCLUDE_ATMEL_MEMORY_H
+#define __INCLUDE_ATMEL_MEMORY_H
+
+extern void (*at91_ramc_shutdown)(void __iomem *rstc_cr, u32 value);
+
+#endif /* __INCLUDE_ATMEL_MEMORY_H */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 2/8] memory: atmel-sdramc: allow probing from pdata
  2014-10-27 23:09 [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Alexandre Belloni
  2014-10-27 23:09 ` [PATCH v2 1/8] memory: atmel-sdramc: export a shutdown function Alexandre Belloni
@ 2014-10-27 23:09 ` Alexandre Belloni
  2014-10-27 23:09 ` [PATCH v2 3/8] ARM: at91: sam9: probe the RAMC driver " Alexandre Belloni
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Alexandre Belloni @ 2014-10-27 23:09 UTC (permalink / raw)
  To: Nicolas Ferre, Sebastian Reichel
  Cc: Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, Maxime Ripard, Boris Brezillon,
	linux-arm-kernel, linux-kernel, linux-pm, Alexandre Belloni

Allow probing the atmel-sdramc from platform_data.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/memory/atmel-sdramc.c | 45 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/atmel-sdramc.c b/drivers/memory/atmel-sdramc.c
index d89ed0af44d9..c4a7ba0f291f 100644
--- a/drivers/memory/atmel-sdramc.c
+++ b/drivers/memory/atmel-sdramc.c
@@ -19,6 +19,7 @@
 
 #include <linux/clk.h>
 #include <linux/err.h>
+#include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of_address.h>
@@ -140,7 +141,7 @@ static const struct of_device_id atmel_ramc_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, atmel_ramc_of_match);
 
-static int atmel_ramc_probe(struct platform_device *pdev)
+static int atmel_ramc_of_probe(struct platform_device *pdev)
 {
 	const struct of_device_id *match;
 	const struct at91_ramc_caps *caps;
@@ -181,6 +182,47 @@ static int atmel_ramc_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static int atmel_ramc_platform_probe(struct platform_device *pdev)
+{
+	struct resource *res;
+	const struct platform_device_id *match;
+	int idx = 0;
+
+	for (idx = 0; idx < 2; idx++) {
+		res = platform_get_resource(pdev, IORESOURCE_MEM, idx + 1);
+		at91_ramc_base[idx] = devm_ioremap(&pdev->dev, res->start,
+						   resource_size(res));
+		if (IS_ERR(at91_ramc_base[idx])) {
+			dev_err(&pdev->dev, "Could not map ram controller address\n");
+			return PTR_ERR(at91_ramc_base[idx]);
+		}
+	}
+
+	match = platform_get_device_id(pdev);
+	at91_ramc_shutdown =
+		(void (*)(void __iomem *rstc_cr, u32 value))match->driver_data;
+
+	return 0;
+};
+
+static int atmel_ramc_probe(struct platform_device *pdev)
+{
+	int ret;
+
+	if (pdev->dev.of_node)
+		ret = atmel_ramc_of_probe(pdev);
+	else
+		ret = atmel_ramc_platform_probe(pdev);
+
+	return ret;
+}
+
+static struct platform_device_id atmel_ramc_plat_match[] = {
+	{ "at91sam9260-sdramc", (unsigned long)at91sam9260_shutdown, },
+	{ "at91sam9g45-ddramc", (unsigned long)at91sam9g45_shutdown, },
+	{ /* sentinel */ }
+};
+
 static struct platform_driver atmel_ramc_driver = {
 	.probe		= atmel_ramc_probe,
 	.driver		= {
@@ -188,6 +230,7 @@ static struct platform_driver atmel_ramc_driver = {
 		.owner	= THIS_MODULE,
 		.of_match_table = atmel_ramc_of_match,
 	},
+	.id_table = atmel_ramc_plat_match,
 };
 
 static int __init atmel_ramc_init(void)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 3/8] ARM: at91: sam9: probe the RAMC driver from pdata
  2014-10-27 23:09 [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Alexandre Belloni
  2014-10-27 23:09 ` [PATCH v2 1/8] memory: atmel-sdramc: export a shutdown function Alexandre Belloni
  2014-10-27 23:09 ` [PATCH v2 2/8] memory: atmel-sdramc: allow probing from pdata Alexandre Belloni
@ 2014-10-27 23:09 ` Alexandre Belloni
  2014-10-27 23:09 ` [PATCH v2 4/8] ARM: at91: sam9g45/sam9rl: probe the ramc driver Alexandre Belloni
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Alexandre Belloni @ 2014-10-27 23:09 UTC (permalink / raw)
  To: Nicolas Ferre, Sebastian Reichel
  Cc: Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, Maxime Ripard, Boris Brezillon,
	linux-arm-kernel, linux-kernel, linux-pm, Alexandre Belloni

Probe the atmel-sdramc driver from the board files, using platform_data.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/mach-at91/Kconfig       |  2 +-
 arch/arm/mach-at91/at91sam9260.c | 15 +++++++++++++++
 arch/arm/mach-at91/at91sam9261.c | 15 +++++++++++++++
 arch/arm/mach-at91/at91sam9263.c | 15 +++++++++++++++
 4 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 0e6d548b70d9..db38e1d4b4fa 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -48,7 +48,7 @@ config SOC_AT91SAM9
 	select CPU_ARM926T
 	select GENERIC_CLOCKEVENTS
 	select MEMORY if USE_OF
-	select ATMEL_SDRAMC if USE_OF
+	select ATMEL_SDRAMC
 
 config SOC_SAMA5
 	bool
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index aab1f969a7c3..d5a6df9ce570 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -378,6 +378,20 @@ static struct platform_device rstc_device = {
 	.num_resources  = ARRAY_SIZE(rstc_resources),
 };
 
+static struct resource ramc_resources[] = {
+	[0] = {
+		.start  = AT91SAM9260_BASE_SDRAMC,
+		.end    = AT91SAM9260_BASE_SDRAMC + SZ_512 - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device ramc_device = {
+	.name           = "at91-sam9260-ramc",
+	.resource       = ramc_resources,
+	.num_resources  = ARRAY_SIZE(ramc_resources),
+};
+
 static struct resource shdwc_resources[] = {
 	[0] = {
 		.start  = AT91SAM9260_BASE_SHDWC,
@@ -394,6 +408,7 @@ static struct platform_device shdwc_device = {
 
 static void __init at91sam9260_register_devices(void)
 {
+	platform_device_register(&ramc_device);
 	platform_device_register(&rstc_device);
 	platform_device_register(&shdwc_device);
 }
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index a8bd35963332..1b23a023cca6 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -337,6 +337,20 @@ static struct platform_device rstc_device = {
 	.num_resources  = ARRAY_SIZE(rstc_resources),
 };
 
+static struct resource ramc_resources[] = {
+	[0] = {
+		.start  = AT91SAM9261_BASE_SDRAMC,
+		.end    = AT91SAM9261_BASE_SDRAMC + SZ_512 - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device ramc_device = {
+	.name           = "at91-sam9260-ramc",
+	.resource       = ramc_resources,
+	.num_resources  = ARRAY_SIZE(ramc_resources),
+};
+
 static struct resource shdwc_resources[] = {
 	[0] = {
 		.start  = AT91SAM9261_BASE_SHDWC,
@@ -353,6 +367,7 @@ static struct platform_device shdwc_device = {
 
 static void __init at91sam9261_register_devices(void)
 {
+	platform_device_register(&ramc_device);
 	platform_device_register(&rstc_device);
 	platform_device_register(&shdwc_device);
 }
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index fbff228cc63e..55c0c212fde1 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -360,6 +360,20 @@ static struct platform_device rstc_device = {
 	.num_resources  = ARRAY_SIZE(rstc_resources),
 };
 
+static struct resource ramc_resources[] = {
+	[0] = {
+		.start  = AT91SAM9263_BASE_SDRAMC0,
+		.end    = AT91SAM9263_BASE_SDRAMC0 + SZ_512 - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device ramc_device = {
+	.name           = "at91-sam9260-ramc",
+	.resource       = ramc_resources,
+	.num_resources  = ARRAY_SIZE(ramc_resources),
+};
+
 static struct resource shdwc_resources[] = {
 	[0] = {
 		.start  = AT91SAM9263_BASE_SHDWC,
@@ -376,6 +390,7 @@ static struct platform_device shdwc_device = {
 
 static void __init at91sam9263_register_devices(void)
 {
+	platform_device_register(&ramc_device);
 	platform_device_register(&rstc_device);
 	platform_device_register(&shdwc_device);
 }
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 4/8] ARM: at91: sam9g45/sam9rl: probe the ramc driver
  2014-10-27 23:09 [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Alexandre Belloni
                   ` (2 preceding siblings ...)
  2014-10-27 23:09 ` [PATCH v2 3/8] ARM: at91: sam9: probe the RAMC driver " Alexandre Belloni
@ 2014-10-27 23:09 ` Alexandre Belloni
  2014-10-27 23:09 ` [PATCH v2 5/8] power: reset: at91-reset: use at91_ramc_shutdown Alexandre Belloni
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Alexandre Belloni @ 2014-10-27 23:09 UTC (permalink / raw)
  To: Nicolas Ferre, Sebastian Reichel
  Cc: Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, Maxime Ripard, Boris Brezillon,
	linux-arm-kernel, linux-kernel, linux-pm, Alexandre Belloni

Probe the atmel-sdramc driver from the board files, using platform_data.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/mach-at91/at91sam9g45.c | 20 ++++++++++++++++++++
 arch/arm/mach-at91/at91sam9rl.c  | 15 +++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 405427ec05f8..202d9438e1d9 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -415,6 +415,25 @@ static struct platform_device rstc_device = {
 	.num_resources  = ARRAY_SIZE(rstc_resources),
 };
 
+static struct resource ramc_resources[] = {
+	[0] = {
+		.start  = AT91SAM9G45_BASE_DDRSDRC1,
+		.end    = AT91SAM9G45_BASE_DDRSDRC1 + SZ_512 - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start  = AT91SAM9G45_BASE_DDRSDRC0,
+		.end    = AT91SAM9G45_BASE_DDRSDRC0 + SZ_512 - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device rstc_device = {
+	.name           = "at91-sam9g45-ramc",
+	.resource       = ramc_resources,
+	.num_resources  = ARRAY_SIZE(ramc_resources),
+};
+
 static struct resource shdwc_resources[] = {
 	[0] = {
 		.start  = AT91SAM9G45_BASE_SHDWC,
@@ -431,6 +450,7 @@ static struct platform_device shdwc_device = {
 
 static void __init at91sam9g45_register_devices(void)
 {
+	platform_device_register(&ramc_device);
 	platform_device_register(&rstc_device);
 	platform_device_register(&shdwc_device);
 }
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index f553e4ea034b..0e2cb3361b15 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -348,6 +348,20 @@ static struct platform_device rstc_device = {
 	.num_resources  = ARRAY_SIZE(rstc_resources),
 };
 
+static struct resource ramc_resources[] = {
+	[0] = {
+		.start  = AT91SAM9RL_BASE_SDRAMC,
+		.end    = AT91SAM9RL_BASE_SDRAMC + SZ_512 - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device ramc_device = {
+	.name           = "at91-sam9260-ramc",
+	.resource       = ramc_resources,
+	.num_resources  = ARRAY_SIZE(ramc_resources),
+};
+
 static struct resource shdwc_resources[] = {
 	[0] = {
 		.start  = AT91SAM9RL_BASE_SHDWC,
@@ -364,6 +378,7 @@ static struct platform_device shdwc_device = {
 
 static void __init at91sam9rl_register_devices(void)
 {
+	platform_device_register(&ramc_device);
 	platform_device_register(&rstc_device);
 	platform_device_register(&shdwc_device);
 }
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 5/8] power: reset: at91-reset: use at91_ramc_shutdown
  2014-10-27 23:09 [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Alexandre Belloni
                   ` (3 preceding siblings ...)
  2014-10-27 23:09 ` [PATCH v2 4/8] ARM: at91: sam9g45/sam9rl: probe the ramc driver Alexandre Belloni
@ 2014-10-27 23:09 ` Alexandre Belloni
  2014-10-28  2:18   ` Sebastian Reichel
  2014-10-27 23:09 ` [PATCH v2 6/8] ARM: at91: sam9: remove useless resource for rstc Alexandre Belloni
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Alexandre Belloni @ 2014-10-27 23:09 UTC (permalink / raw)
  To: Nicolas Ferre, Sebastian Reichel
  Cc: Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, Maxime Ripard, Boris Brezillon,
	linux-arm-kernel, linux-kernel, linux-pm, Alexandre Belloni

Now that all SoCs are registering the atmel-sdramc driver, use the
at91_ramc_shutdown() function to shutdown the sdram.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/power/reset/at91-reset.c | 122 +++++----------------------------------
 1 file changed, 14 insertions(+), 108 deletions(-)

diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c
index 3cb36693343a..1c210e53f784 100644
--- a/drivers/power/reset/at91-reset.c
+++ b/drivers/power/reset/at91-reset.c
@@ -19,8 +19,7 @@
 
 #include <asm/system_misc.h>
 
-#include <mach/at91sam9_ddrsdr.h>
-#include <mach/at91sam9_sdramc.h>
+#include <soc/atmel/memory.h>
 
 #define AT91_RSTC_CR	0x00		/* Reset Controller Control Register */
 #define AT91_RSTC_PROCRST	BIT(0)		/* Processor Reset */
@@ -47,76 +46,20 @@ enum reset_type {
 	RESET_TYPE_USER		= 4,
 };
 
-static void __iomem *at91_ramc_base[2], *at91_rstc_base;
+static void __iomem *at91_rstc_base;
 
 /*
 * unless the SDRAM is cleanly shutdown before we hit the
 * reset register it can be left driving the data bus and
 * killing the chance of a subsequent boot from NAND
 */
-static void at91sam9260_restart(enum reboot_mode mode, const char *cmd)
+static void at91_restart(enum reboot_mode mode, const char *cmd)
 {
-	asm volatile(
-		/* Align to cache lines */
-		".balign 32\n\t"
-
-		/* Disable SDRAM accesses */
-		"str	%2, [%0, #" __stringify(AT91_SDRAMC_TR) "]\n\t"
-
-		/* Power down SDRAM */
-		"str	%3, [%0, #" __stringify(AT91_SDRAMC_LPR) "]\n\t"
-
-		/* Reset CPU */
-		"str	%4, [%1, #" __stringify(AT91_RSTC_CR) "]\n\t"
-
-		"b	.\n\t"
-		:
-		: "r" (at91_ramc_base[0]),
-		  "r" (at91_rstc_base),
-		  "r" (1),
-		  "r" (AT91_SDRAMC_LPCB_POWER_DOWN),
-		  "r" (AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST));
-}
-
-static void at91sam9g45_restart(enum reboot_mode mode, const char *cmd)
-{
-	asm volatile(
-		/*
-		 * Test wether we have a second RAM controller to care
-		 * about.
-		 *
-		 * First, test that we can dereference the virtual address.
-		 */
-		"cmp	%1, #0\n\t"
-		"beq	1f\n\t"
-
-		/* Then, test that the RAM controller is enabled */
-		"ldr	r0, [%1]\n\t"
-		"cmp	r0, #0\n\t"
-
-		/* Align to cache lines */
-		".balign 32\n\t"
-
-		/* Disable SDRAM0 accesses */
-		"1:	str	%3, [%0, #" __stringify(AT91_DDRSDRC_RTR) "]\n\t"
-		/* Power down SDRAM0 */
-		"	str	%4, [%0, #" __stringify(AT91_DDRSDRC_LPR) "]\n\t"
-		/* Disable SDRAM1 accesses */
-		"	strne	%3, [%1, #" __stringify(AT91_DDRSDRC_RTR) "]\n\t"
-		/* Power down SDRAM1 */
-		"	strne	%4, [%1, #" __stringify(AT91_DDRSDRC_LPR) "]\n\t"
-		/* Reset CPU */
-		"	str	%5, [%2, #" __stringify(AT91_RSTC_CR) "]\n\t"
-
-		"	b	.\n\t"
-		:
-		: "r" (at91_ramc_base[0]),
-		  "r" (at91_ramc_base[1]),
-		  "r" (at91_rstc_base),
-		  "r" (1),
-		  "r" (AT91_DDRSDRC_LPCB_POWER_DOWN),
-		  "r" (AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST)
-		: "r0");
+	if (at91_ramc_shutdown)
+		at91_ramc_shutdown(at91_rstc_base + AT91_RSTC_CR,
+				   AT91_RSTC_KEY | AT91_RSTC_PERRST |
+				   AT91_RSTC_PROCRST);
+	BUG();
 }
 
 static void __init at91_reset_status(struct platform_device *pdev)
@@ -148,51 +91,27 @@ static void __init at91_reset_status(struct platform_device *pdev)
 	pr_info("AT91: Starting after %s\n", reason);
 }
 
-static struct of_device_id at91_ramc_of_match[] = {
-	{ .compatible = "atmel,at91sam9260-sdramc", },
-	{ .compatible = "atmel,at91sam9g45-ddramc", },
-	{ .compatible = "atmel,sama5d3-ddramc", },
-	{ /* sentinel */ }
-};
-
 static struct of_device_id at91_reset_of_match[] = {
-	{ .compatible = "atmel,at91sam9260-rstc", .data = at91sam9260_restart },
-	{ .compatible = "atmel,at91sam9g45-rstc", .data = at91sam9g45_restart },
+	{ .compatible = "atmel,at91sam9260-rstc", },
+	{ .compatible = "atmel,at91sam9g45-rstc", },
 	{ /* sentinel */ }
 };
 
 static int at91_reset_of_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *match;
-	struct device_node *np;
-	int idx = 0;
-
 	at91_rstc_base = of_iomap(pdev->dev.of_node, 0);
 	if (!at91_rstc_base) {
 		dev_err(&pdev->dev, "Could not map reset controller address\n");
 		return -ENODEV;
 	}
 
-	for_each_matching_node(np, at91_ramc_of_match) {
-		at91_ramc_base[idx] = of_iomap(np, 0);
-		if (!at91_ramc_base[idx]) {
-			dev_err(&pdev->dev, "Could not map ram controller address\n");
-			return -ENODEV;
-		}
-		idx++;
-	}
-
-	match = of_match_node(at91_reset_of_match, pdev->dev.of_node);
-	arm_pm_restart = match->data;
-
 	return 0;
 }
 
+
 static int at91_reset_platform_probe(struct platform_device *pdev)
 {
-	const struct platform_device_id *match;
 	struct resource *res;
-	int idx = 0;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	at91_rstc_base = devm_ioremap_resource(&pdev->dev, res);
@@ -201,20 +120,6 @@ static int at91_reset_platform_probe(struct platform_device *pdev)
 		return PTR_ERR(at91_rstc_base);
 	}
 
-	for (idx = 0; idx < 2; idx++) {
-		res = platform_get_resource(pdev, IORESOURCE_MEM, idx + 1 );
-		at91_ramc_base[idx] = devm_ioremap(&pdev->dev, res->start,
-						   resource_size(res));
-		if (IS_ERR(at91_ramc_base[idx])) {
-			dev_err(&pdev->dev, "Could not map ram controller address\n");
-			return PTR_ERR(at91_ramc_base[idx]);
-		}
-	}
-
-	match = platform_get_device_id(pdev);
-	arm_pm_restart = (void (*)(enum reboot_mode, const char*))
-		match->driver_data;
-
 	return 0;
 }
 
@@ -230,14 +135,15 @@ static int at91_reset_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	arm_pm_restart = at91_restart;
 	at91_reset_status(pdev);
 
 	return 0;
 }
 
 static struct platform_device_id at91_reset_plat_match[] = {
-	{ "at91-sam9260-reset", (unsigned long)at91sam9260_restart },
-	{ "at91-sam9g45-reset", (unsigned long)at91sam9g45_restart },
+	{ "at91-sam9260-reset",  },
+	{ "at91-sam9g45-reset",  },
 	{ /* sentinel */ }
 };
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 6/8] ARM: at91: sam9: remove useless resource for rstc
  2014-10-27 23:09 [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Alexandre Belloni
                   ` (4 preceding siblings ...)
  2014-10-27 23:09 ` [PATCH v2 5/8] power: reset: at91-reset: use at91_ramc_shutdown Alexandre Belloni
@ 2014-10-27 23:09 ` Alexandre Belloni
  2014-10-27 23:09 ` [PATCH v2 7/8] ARM: at91: sam9g45/sam9rl: remove useless resources " Alexandre Belloni
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Alexandre Belloni @ 2014-10-27 23:09 UTC (permalink / raw)
  To: Nicolas Ferre, Sebastian Reichel
  Cc: Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, Maxime Ripard, Boris Brezillon,
	linux-arm-kernel, linux-kernel, linux-pm, Alexandre Belloni

The RAMC resources are now unnecessary in the reset driver, remove them.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/mach-at91/at91sam9260.c | 5 -----
 arch/arm/mach-at91/at91sam9261.c | 5 -----
 arch/arm/mach-at91/at91sam9263.c | 5 -----
 3 files changed, 15 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index d5a6df9ce570..d1c97e025483 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -365,11 +365,6 @@ static struct resource rstc_resources[] = {
 		.end    = AT91SAM9260_BASE_RSTC + SZ_16 - 1,
 		.flags  = IORESOURCE_MEM,
 	},
-	[1] = {
-		.start  = AT91SAM9260_BASE_SDRAMC,
-		.end    = AT91SAM9260_BASE_SDRAMC + SZ_512 - 1,
-		.flags  = IORESOURCE_MEM,
-	},
 };
 
 static struct platform_device rstc_device = {
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 1b23a023cca6..7a354d5a3d4c 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -324,11 +324,6 @@ static struct resource rstc_resources[] = {
 		.end    = AT91SAM9261_BASE_RSTC + SZ_16 - 1,
 		.flags  = IORESOURCE_MEM,
 	},
-	[1] = {
-		.start  = AT91SAM9261_BASE_SDRAMC,
-		.end    = AT91SAM9261_BASE_SDRAMC + SZ_512 - 1,
-		.flags  = IORESOURCE_MEM,
-	},
 };
 
 static struct platform_device rstc_device = {
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 55c0c212fde1..1f7e7021ae83 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -347,11 +347,6 @@ static struct resource rstc_resources[] = {
 		.end    = AT91SAM9263_BASE_RSTC + SZ_16 - 1,
 		.flags  = IORESOURCE_MEM,
 	},
-	[1] = {
-		.start  = AT91SAM9263_BASE_SDRAMC0,
-		.end    = AT91SAM9263_BASE_SDRAMC0 + SZ_512 - 1,
-		.flags  = IORESOURCE_MEM,
-	},
 };
 
 static struct platform_device rstc_device = {
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 7/8] ARM: at91: sam9g45/sam9rl: remove useless resources for rstc
  2014-10-27 23:09 [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Alexandre Belloni
                   ` (5 preceding siblings ...)
  2014-10-27 23:09 ` [PATCH v2 6/8] ARM: at91: sam9: remove useless resource for rstc Alexandre Belloni
@ 2014-10-27 23:09 ` Alexandre Belloni
  2014-10-27 23:09 ` [PATCH v2 8/8] MAINTAINERS: add at91 power and memory entries Alexandre Belloni
  2014-10-28  7:50 ` [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Boris Brezillon
  8 siblings, 0 replies; 17+ messages in thread
From: Alexandre Belloni @ 2014-10-27 23:09 UTC (permalink / raw)
  To: Nicolas Ferre, Sebastian Reichel
  Cc: Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, Maxime Ripard, Boris Brezillon,
	linux-arm-kernel, linux-kernel, linux-pm, Alexandre Belloni

The RAMC resources are now unnecessary in the reset driver, remove them.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/mach-at91/at91sam9g45.c | 10 ----------
 arch/arm/mach-at91/at91sam9rl.c  |  5 -----
 2 files changed, 15 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 202d9438e1d9..2e1aae8152b7 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -397,16 +397,6 @@ static struct resource rstc_resources[] = {
 		.end    = AT91SAM9G45_BASE_RSTC + SZ_16 - 1,
 		.flags  = IORESOURCE_MEM,
 	},
-	[1] = {
-		.start  = AT91SAM9G45_BASE_DDRSDRC1,
-		.end    = AT91SAM9G45_BASE_DDRSDRC1 + SZ_512 - 1,
-		.flags  = IORESOURCE_MEM,
-	},
-	[2] = {
-		.start  = AT91SAM9G45_BASE_DDRSDRC0,
-		.end    = AT91SAM9G45_BASE_DDRSDRC0 + SZ_512 - 1,
-		.flags  = IORESOURCE_MEM,
-	},
 };
 
 static struct platform_device rstc_device = {
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index 0e2cb3361b15..0b00b9c7bd82 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -335,11 +335,6 @@ static struct resource rstc_resources[] = {
 		.end    = AT91SAM9RL_BASE_RSTC + SZ_16 - 1,
 		.flags  = IORESOURCE_MEM,
 	},
-	[1] = {
-		.start  = AT91SAM9RL_BASE_SDRAMC,
-		.end    = AT91SAM9RL_BASE_SDRAMC + SZ_512 - 1,
-		.flags  = IORESOURCE_MEM,
-	},
 };
 
 static struct platform_device rstc_device = {
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 8/8] MAINTAINERS: add at91 power and memory entries
  2014-10-27 23:09 [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Alexandre Belloni
                   ` (6 preceding siblings ...)
  2014-10-27 23:09 ` [PATCH v2 7/8] ARM: at91: sam9g45/sam9rl: remove useless resources " Alexandre Belloni
@ 2014-10-27 23:09 ` Alexandre Belloni
  2014-10-27 23:17   ` Joe Perches
  2014-10-28  7:50 ` [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Boris Brezillon
  8 siblings, 1 reply; 17+ messages in thread
From: Alexandre Belloni @ 2014-10-27 23:09 UTC (permalink / raw)
  To: Nicolas Ferre, Sebastian Reichel
  Cc: Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, Maxime Ripard, Boris Brezillon,
	linux-arm-kernel, linux-kernel, linux-pm, Alexandre Belloni

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 MAINTAINERS | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index a20df9bf8ab0..3403a7089f80 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -871,6 +871,25 @@ M:	Boris Brezillon <boris.brezillon@free-electrons.com>
 S:	Maintained
 F:	drivers/clk/at91
 
+ARM/ATMEL AT91 Poweroff driver
+M:	Alexandre Belloni <alexandre.belloni@free-electrons.com>
+L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
+S:	Maintained
+F:	drivers/power/reset/at91-poweroff.c
+
+ARM/ATMEL AT91 Reset driver
+M:	Alexandre Belloni <alexandre.belloni@free-electrons.com>
+L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
+S:	Maintained
+F:	drivers/power/reset/at91-reset.c
+
+ARM/ATMEL AT91 SDRAM Controller driver
+M:	Alexandre Belloni <alexandre.belloni@free-electrons.com>
+L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
+S:	Maintained
+F:	drivers/memory/atmel-sdramc.c
+F:	include/soc/atmel/memory.h
+
 ARM/CALXEDA HIGHBANK ARCHITECTURE
 M:	Rob Herring <robh@kernel.org>
 L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 8/8] MAINTAINERS: add at91 power and memory entries
  2014-10-27 23:09 ` [PATCH v2 8/8] MAINTAINERS: add at91 power and memory entries Alexandre Belloni
@ 2014-10-27 23:17   ` Joe Perches
  2014-11-21 20:17     ` Pavel Machek
  0 siblings, 1 reply; 17+ messages in thread
From: Joe Perches @ 2014-10-27 23:17 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Sebastian Reichel,
	Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, Maxime Ripard, Boris Brezillon,
	linux-arm-kernel, linux-kernel, linux-pm

On Tue, 2014-10-28 at 00:09 +0100, Alexandre Belloni wrote:
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
[]
> diff --git a/MAINTAINERS b/MAINTAINERS
[]
> @@ -871,6 +871,25 @@ M:	Boris Brezillon <boris.brezillon@free-electrons.com>
>  S:	Maintained
>  F:	drivers/clk/at91
>  
> +ARM/ATMEL AT91 Poweroff driver
> +M:	Alexandre Belloni <alexandre.belloni@free-electrons.com>
> +L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
> +S:	Maintained
> +F:	drivers/power/reset/at91-poweroff.c
> +
> +ARM/ATMEL AT91 Reset driver
> +M:	Alexandre Belloni <alexandre.belloni@free-electrons.com>
> +L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
> +S:	Maintained
> +F:	drivers/power/reset/at91-reset.c

It's traditional to use upper case section descriptions.

Do these 2 really need to be separate entries?

> +
> +ARM/ATMEL AT91 SDRAM Controller driver
> +M:	Alexandre Belloni <alexandre.belloni@free-electrons.com>
> +L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
> +S:	Maintained
> +F:	drivers/memory/atmel-sdramc.c
> +F:	include/soc/atmel/memory.h
> +
>  ARM/CALXEDA HIGHBANK ARCHITECTURE
>  M:	Rob Herring <robh@kernel.org>
>  L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 5/8] power: reset: at91-reset: use at91_ramc_shutdown
  2014-10-27 23:09 ` [PATCH v2 5/8] power: reset: at91-reset: use at91_ramc_shutdown Alexandre Belloni
@ 2014-10-28  2:18   ` Sebastian Reichel
  0 siblings, 0 replies; 17+ messages in thread
From: Sebastian Reichel @ 2014-10-28  2:18 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Jean-Christophe Plagniol-Villard,
	Dmitry Eremin-Solenikov, David Woodhouse, Maxime Ripard,
	Boris Brezillon, linux-arm-kernel, linux-kernel, linux-pm

[-- Attachment #1: Type: text/plain, Size: 344 bytes --]

Hi,

On Tue, Oct 28, 2014 at 12:09:34AM +0100, Alexandre Belloni wrote:
> Now that all SoCs are registering the atmel-sdramc driver, use the
> at91_ramc_shutdown() function to shutdown the sdram.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Acked-By: Sebastian Reichel <sre@kernel.org>

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver
  2014-10-27 23:09 [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Alexandre Belloni
                   ` (7 preceding siblings ...)
  2014-10-27 23:09 ` [PATCH v2 8/8] MAINTAINERS: add at91 power and memory entries Alexandre Belloni
@ 2014-10-28  7:50 ` Boris Brezillon
  2014-10-28  8:52   ` Alexandre Belloni
  8 siblings, 1 reply; 17+ messages in thread
From: Boris Brezillon @ 2014-10-28  7:50 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Sebastian Reichel,
	Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, Maxime Ripard, linux-arm-kernel, linux-kernel,
	linux-pm

Hi,

On Tue, 28 Oct 2014 00:09:29 +0100
Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote:

> This series removes the mach/ headers dependency from the reset driver. It is
> also laying some groundwork for the necessary power management support rework.
> 
> The first patch adds and export a function to shutdown the sdram from the sdramc
> driver. That function also take the RSTC CR register and a value as parameters
> to be able to reset the chip. This is a hackish way of doing it but it ensures
> that all the code fits in one cache line. We already have plan to start using
> the sram to have a cleaner way to execute that code safely as soon as that
> series goes in:
> http://lists.infradead.org/pipermail/linux-arm-kernel/2013-September/198778.html
> 
> The second patch makes the sdramc driver usable from the board files.
> 
> The third patch actually registers the sdramc driver from the boards files.
> The fourth patch does the same, only for sam9g45 and sam9rl to simplify future
> merging as the board files have been removed. Simply drop that patch.
> 
> The fifth patch makes the at91-reset driver use the newly created
> at91_ramc_shutdown() function and removes the mach/ headers inclusion.

I'm not a big fan of this approach.

I definitely think each step of the reset process should be handled in
the appropriate block (and the patch series you pointed out would
definitely help in achieving this goal), but you're just moving all the
stuff done in the reset driver into the SDRAM one, which means you're
solving one design issue by introducing a new one.

Moreover, the errata at the origin of this hack is attached to the RSTC
(Rest Controller) block in the datasheets.

I'd rather keep the reset driver as is and move SDRAM related macros
into a specific header (include/linux/memory/atmel-sdram.h or
include/soc/atmel/memory.h as you proposed) so that the reset driver
can reference them without including mach headers.


Best Regards,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver
  2014-10-28  7:50 ` [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Boris Brezillon
@ 2014-10-28  8:52   ` Alexandre Belloni
  2014-10-28  8:59     ` Maxime Ripard
  0 siblings, 1 reply; 17+ messages in thread
From: Alexandre Belloni @ 2014-10-28  8:52 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Nicolas Ferre, Sebastian Reichel,
	Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, Maxime Ripard, linux-arm-kernel, linux-kernel,
	linux-pm

Hi,

On 28/10/2014 at 08:50:53 +0100, Boris Brezillon wrote :
> Hi,
> 
> On Tue, 28 Oct 2014 00:09:29 +0100
> Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote:
> 
> > This series removes the mach/ headers dependency from the reset driver. It is
> > also laying some groundwork for the necessary power management support rework.
> > 
> > The first patch adds and export a function to shutdown the sdram from the sdramc
> > driver. That function also take the RSTC CR register and a value as parameters
> > to be able to reset the chip. This is a hackish way of doing it but it ensures
> > that all the code fits in one cache line. We already have plan to start using
> > the sram to have a cleaner way to execute that code safely as soon as that
> > series goes in:
> > http://lists.infradead.org/pipermail/linux-arm-kernel/2013-September/198778.html
> > 
> > The second patch makes the sdramc driver usable from the board files.
> > 
> > The third patch actually registers the sdramc driver from the boards files.
> > The fourth patch does the same, only for sam9g45 and sam9rl to simplify future
> > merging as the board files have been removed. Simply drop that patch.
> > 
> > The fifth patch makes the at91-reset driver use the newly created
> > at91_ramc_shutdown() function and removes the mach/ headers inclusion.
> 
> I'm not a big fan of this approach.
> 
> I definitely think each step of the reset process should be handled in
> the appropriate block (and the patch series you pointed out would
> definitely help in achieving this goal), but you're just moving all the
> stuff done in the reset driver into the SDRAM one, which means you're
> solving one design issue by introducing a new one.
> 
> Moreover, the errata at the origin of this hack is attached to the RSTC
> (Rest Controller) block in the datasheets.
> 

I agree it is still not clean but it is a step in the good direction.
The sdram shutdown will have to be down in the sdram driver at some
point, even if the errata is attached to the reset controller. At least,
the series introduces a function to do the sdram shutdown.

> I'd rather keep the reset driver as is and move SDRAM related macros
> into a specific header (include/linux/memory/atmel-sdram.h or
> include/soc/atmel/memory.h as you proposed) so that the reset driver
> can reference them without including mach headers.
> 

My personal opinion is that it is better to hide the registers/bits from
the reset driver right now as we have two different IPs and the sdram
driver already knows how to make the difference between them.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver
  2014-10-28  8:52   ` Alexandre Belloni
@ 2014-10-28  8:59     ` Maxime Ripard
  2014-10-28  9:04       ` Alexandre Belloni
  0 siblings, 1 reply; 17+ messages in thread
From: Maxime Ripard @ 2014-10-28  8:59 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Boris Brezillon, Nicolas Ferre, Sebastian Reichel,
	Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, linux-arm-kernel, linux-kernel, linux-pm

[-- Attachment #1: Type: text/plain, Size: 3202 bytes --]

Hi,

On Tue, Oct 28, 2014 at 09:52:03AM +0100, Alexandre Belloni wrote:
> Hi,
> 
> On 28/10/2014 at 08:50:53 +0100, Boris Brezillon wrote :
> > Hi,
> > 
> > On Tue, 28 Oct 2014 00:09:29 +0100
> > Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote:
> > 
> > > This series removes the mach/ headers dependency from the reset driver. It is
> > > also laying some groundwork for the necessary power management support rework.
> > > 
> > > The first patch adds and export a function to shutdown the sdram from the sdramc
> > > driver. That function also take the RSTC CR register and a value as parameters
> > > to be able to reset the chip. This is a hackish way of doing it but it ensures
> > > that all the code fits in one cache line. We already have plan to start using
> > > the sram to have a cleaner way to execute that code safely as soon as that
> > > series goes in:
> > > http://lists.infradead.org/pipermail/linux-arm-kernel/2013-September/198778.html
> > > 
> > > The second patch makes the sdramc driver usable from the board files.
> > > 
> > > The third patch actually registers the sdramc driver from the boards files.
> > > The fourth patch does the same, only for sam9g45 and sam9rl to simplify future
> > > merging as the board files have been removed. Simply drop that patch.
> > > 
> > > The fifth patch makes the at91-reset driver use the newly created
> > > at91_ramc_shutdown() function and removes the mach/ headers inclusion.
> > 
> > I'm not a big fan of this approach.
> > 
> > I definitely think each step of the reset process should be handled in
> > the appropriate block (and the patch series you pointed out would
> > definitely help in achieving this goal), but you're just moving all the
> > stuff done in the reset driver into the SDRAM one, which means you're
> > solving one design issue by introducing a new one.
> > 
> > Moreover, the errata at the origin of this hack is attached to the RSTC
> > (Rest Controller) block in the datasheets.
> > 
> 
> I agree it is still not clean but it is a step in the good direction.
> The sdram shutdown will have to be down in the sdram driver at some
> point, even if the errata is attached to the reset controller. At least,
> the series introduces a function to do the sdram shutdown.

Not really. AFAICS, this adds a function to reset the CPU. Actually,
it doesn't add anything at all, it just copies what was done in the
reset driver.

> > I'd rather keep the reset driver as is and move SDRAM related macros
> > into a specific header (include/linux/memory/atmel-sdram.h or
> > include/soc/atmel/memory.h as you proposed) so that the reset driver
> > can reference them without including mach headers.
> > 
> 
> My personal opinion is that it is better to hide the registers/bits from
> the reset driver right now as we have two different IPs and the sdram
> driver already knows how to make the difference between them.

The reset driver doesn't do anything anymore with these patches. Why
not just remove it altogether?

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver
  2014-10-28  8:59     ` Maxime Ripard
@ 2014-10-28  9:04       ` Alexandre Belloni
  2014-10-28  9:11         ` Maxime Ripard
  0 siblings, 1 reply; 17+ messages in thread
From: Alexandre Belloni @ 2014-10-28  9:04 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Boris Brezillon, Nicolas Ferre, Sebastian Reichel,
	Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, linux-arm-kernel, linux-kernel, linux-pm

On 28/10/2014 at 09:59:08 +0100, Maxime Ripard wrote :
> Hi,
> 
> On Tue, Oct 28, 2014 at 09:52:03AM +0100, Alexandre Belloni wrote:
> > Hi,
> > 
> > On 28/10/2014 at 08:50:53 +0100, Boris Brezillon wrote :
> > > Hi,
> > > 
> > > On Tue, 28 Oct 2014 00:09:29 +0100
> > > Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote:
> > > 
> > > > This series removes the mach/ headers dependency from the reset driver. It is
> > > > also laying some groundwork for the necessary power management support rework.
> > > > 
> > > > The first patch adds and export a function to shutdown the sdram from the sdramc
> > > > driver. That function also take the RSTC CR register and a value as parameters
> > > > to be able to reset the chip. This is a hackish way of doing it but it ensures
> > > > that all the code fits in one cache line. We already have plan to start using
> > > > the sram to have a cleaner way to execute that code safely as soon as that
> > > > series goes in:
> > > > http://lists.infradead.org/pipermail/linux-arm-kernel/2013-September/198778.html
> > > > 
> > > > The second patch makes the sdramc driver usable from the board files.
> > > > 
> > > > The third patch actually registers the sdramc driver from the boards files.
> > > > The fourth patch does the same, only for sam9g45 and sam9rl to simplify future
> > > > merging as the board files have been removed. Simply drop that patch.
> > > > 
> > > > The fifth patch makes the at91-reset driver use the newly created
> > > > at91_ramc_shutdown() function and removes the mach/ headers inclusion.
> > > 
> > > I'm not a big fan of this approach.
> > > 
> > > I definitely think each step of the reset process should be handled in
> > > the appropriate block (and the patch series you pointed out would
> > > definitely help in achieving this goal), but you're just moving all the
> > > stuff done in the reset driver into the SDRAM one, which means you're
> > > solving one design issue by introducing a new one.
> > > 
> > > Moreover, the errata at the origin of this hack is attached to the RSTC
> > > (Rest Controller) block in the datasheets.
> > > 
> > 
> > I agree it is still not clean but it is a step in the good direction.
> > The sdram shutdown will have to be down in the sdram driver at some
> > point, even if the errata is attached to the reset controller. At least,
> > the series introduces a function to do the sdram shutdown.
> 
> Not really. AFAICS, this adds a function to reset the CPU. Actually,
> it doesn't add anything at all, it just copies what was done in the
> reset driver.
> 
> > > I'd rather keep the reset driver as is and move SDRAM related macros
> > > into a specific header (include/linux/memory/atmel-sdram.h or
> > > include/soc/atmel/memory.h as you proposed) so that the reset driver
> > > can reference them without including mach headers.
> > > 
> > 
> > My personal opinion is that it is better to hide the registers/bits from
> > the reset driver right now as we have two different IPs and the sdram
> > driver already knows how to make the difference between them.
> 
> The reset driver doesn't do anything anymore with these patches. Why
> not just remove it altogether?
> 

It does, the reset driver knows about the reset registers. The plan is
to move the actual reset back to that driver when the kernel will be
able to easily execute code from sram.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver
  2014-10-28  9:04       ` Alexandre Belloni
@ 2014-10-28  9:11         ` Maxime Ripard
  0 siblings, 0 replies; 17+ messages in thread
From: Maxime Ripard @ 2014-10-28  9:11 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Boris Brezillon, Nicolas Ferre, Sebastian Reichel,
	Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, linux-arm-kernel, linux-kernel, linux-pm

[-- Attachment #1: Type: text/plain, Size: 1207 bytes --]

On Tue, Oct 28, 2014 at 10:04:55AM +0100, Alexandre Belloni wrote:
> > > > I'd rather keep the reset driver as is and move SDRAM related macros
> > > > into a specific header (include/linux/memory/atmel-sdram.h or
> > > > include/soc/atmel/memory.h as you proposed) so that the reset driver
> > > > can reference them without including mach headers.
> > > > 
> > > 
> > > My personal opinion is that it is better to hide the registers/bits from
> > > the reset driver right now as we have two different IPs and the sdram
> > > driver already knows how to make the difference between them.
> > 
> > The reset driver doesn't do anything anymore with these patches. Why
> > not just remove it altogether?
> > 
> 
> It does, the reset driver knows about the reset registers.

So the only thing it does it to define a few register and that's it?
It looks like it's a case for a header, not a driver.

> The plan is to move the actual reset back to that driver when the
> kernel will be able to easily execute code from sram.

Why not go directly for the plan then?

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 8/8] MAINTAINERS: add at91 power and memory entries
  2014-10-27 23:17   ` Joe Perches
@ 2014-11-21 20:17     ` Pavel Machek
  0 siblings, 0 replies; 17+ messages in thread
From: Pavel Machek @ 2014-11-21 20:17 UTC (permalink / raw)
  To: Joe Perches
  Cc: Alexandre Belloni, Nicolas Ferre, Sebastian Reichel,
	Jean-Christophe Plagniol-Villard, Dmitry Eremin-Solenikov,
	David Woodhouse, Maxime Ripard, Boris Brezillon,
	linux-arm-kernel, linux-kernel, linux-pm

On Mon 2014-10-27 16:17:17, Joe Perches wrote:
> On Tue, 2014-10-28 at 00:09 +0100, Alexandre Belloni wrote:
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> []
> > diff --git a/MAINTAINERS b/MAINTAINERS
> []
> > @@ -871,6 +871,25 @@ M:	Boris Brezillon <boris.brezillon@free-electrons.com>
> >  S:	Maintained
> >  F:	drivers/clk/at91
> >  
> > +ARM/ATMEL AT91 Poweroff driver
> > +M:	Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > +L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
> > +S:	Maintained
> > +F:	drivers/power/reset/at91-poweroff.c
> > +
> > +ARM/ATMEL AT91 Reset driver
> > +M:	Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > +L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
> > +S:	Maintained
> > +F:	drivers/power/reset/at91-reset.c
> 
> It's traditional to use upper case section descriptions.

Actually, it might be nice to switch to normal case
descriptions. Easier to search for...


								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2014-11-21 20:17 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-27 23:09 [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Alexandre Belloni
2014-10-27 23:09 ` [PATCH v2 1/8] memory: atmel-sdramc: export a shutdown function Alexandre Belloni
2014-10-27 23:09 ` [PATCH v2 2/8] memory: atmel-sdramc: allow probing from pdata Alexandre Belloni
2014-10-27 23:09 ` [PATCH v2 3/8] ARM: at91: sam9: probe the RAMC driver " Alexandre Belloni
2014-10-27 23:09 ` [PATCH v2 4/8] ARM: at91: sam9g45/sam9rl: probe the ramc driver Alexandre Belloni
2014-10-27 23:09 ` [PATCH v2 5/8] power: reset: at91-reset: use at91_ramc_shutdown Alexandre Belloni
2014-10-28  2:18   ` Sebastian Reichel
2014-10-27 23:09 ` [PATCH v2 6/8] ARM: at91: sam9: remove useless resource for rstc Alexandre Belloni
2014-10-27 23:09 ` [PATCH v2 7/8] ARM: at91: sam9g45/sam9rl: remove useless resources " Alexandre Belloni
2014-10-27 23:09 ` [PATCH v2 8/8] MAINTAINERS: add at91 power and memory entries Alexandre Belloni
2014-10-27 23:17   ` Joe Perches
2014-11-21 20:17     ` Pavel Machek
2014-10-28  7:50 ` [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Boris Brezillon
2014-10-28  8:52   ` Alexandre Belloni
2014-10-28  8:59     ` Maxime Ripard
2014-10-28  9:04       ` Alexandre Belloni
2014-10-28  9:11         ` Maxime Ripard

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).