All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2][RFC] at91 : move pm.h header to include/mach
@ 2012-01-04 16:55 Daniel Lezcano
  2012-01-04 16:55 ` [PATCH 2/2][RFC] at91 : move cpuidle driver to drivers/cpuidle directory Daniel Lezcano
  2012-01-04 17:31 ` [PATCH 1/2][RFC] at91 : move pm.h header to include/mach Rob Herring
  0 siblings, 2 replies; 6+ messages in thread
From: Daniel Lezcano @ 2012-01-04 16:55 UTC (permalink / raw)
  To: linux-arm-kernel

Move the location of the pm.h header file to the include directory,
so it can be included from another place from the current one.

That will allow the next patch which moves the cpuidle code to the
drivers/cpuidle directory.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-at91/cpuidle.c         |    2 +-
 arch/arm/mach-at91/include/mach/pm.h |  107 ++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/pm.c              |    2 +-
 arch/arm/mach-at91/pm.h              |  107 ----------------------------------
 4 files changed, 109 insertions(+), 109 deletions(-)
 create mode 100644 arch/arm/mach-at91/include/mach/pm.h
 delete mode 100644 arch/arm/mach-at91/pm.h

diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c
index a851e6c..f658154 100644
--- a/arch/arm/mach-at91/cpuidle.c
+++ b/arch/arm/mach-at91/cpuidle.c
@@ -21,7 +21,7 @@
 #include <linux/io.h>
 #include <linux/export.h>
 
-#include "pm.h"
+#include <mach/pm.h>
 
 #define AT91_MAX_STATES	2
 
diff --git a/arch/arm/mach-at91/include/mach/pm.h b/arch/arm/mach-at91/include/mach/pm.h
new file mode 100644
index 0000000..ce9a206
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/pm.h
@@ -0,0 +1,107 @@
+#ifdef CONFIG_ARCH_AT91RM9200
+#include <mach/at91rm9200_mc.h>
+
+/*
+ * The AT91RM9200 goes into self-refresh mode with this command, and will
+ * terminate self-refresh automatically on the next SDRAM access.
+ *
+ * Self-refresh mode is exited as soon as a memory access is made, but we don't
+ * know for sure when that happens. However, we need to restore the low-power
+ * mode if it was enabled before going idle. Restoring low-power mode while
+ * still in self-refresh is "not recommended", but seems to work.
+ */
+
+static inline u32 sdram_selfrefresh_enable(void)
+{
+	u32 saved_lpr = at91_sys_read(AT91_SDRAMC_LPR);
+
+	at91_sys_write(AT91_SDRAMC_LPR, 0);
+	at91_sys_write(AT91_SDRAMC_SRR, 1);
+	return saved_lpr;
+}
+
+#define sdram_selfrefresh_disable(saved_lpr)	at91_sys_write(AT91_SDRAMC_LPR, saved_lpr)
+#define wait_for_interrupt_enable()		asm volatile ("mcr p15, 0, %0, c7, c0, 4" \
+								: : "r" (0))
+
+#elif defined(CONFIG_ARCH_AT91CAP9)
+#include <mach/at91cap9_ddrsdr.h>
+
+
+static inline u32 sdram_selfrefresh_enable(void)
+{
+	u32 saved_lpr, lpr;
+
+	saved_lpr = at91_ramc_read(0, AT91_DDRSDRC_LPR);
+
+	lpr = saved_lpr & ~AT91_DDRSDRC_LPCB;
+	at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr | AT91_DDRSDRC_LPCB_SELF_REFRESH);
+	return saved_lpr;
+}
+
+#define sdram_selfrefresh_disable(saved_lpr)	at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr)
+#define wait_for_interrupt_enable()		cpu_do_idle()
+
+#elif defined(CONFIG_ARCH_AT91SAM9G45)
+#include <mach/at91sam9_ddrsdr.h>
+
+/* We manage both DDRAM/SDRAM controllers, we need more than one value to
+ * remember.
+ */
+static u32 saved_lpr1;
+
+static inline u32 sdram_selfrefresh_enable(void)
+{
+	/* Those tow values allow us to delay self-refresh activation
+	 * to the maximum. */
+	u32 lpr0, lpr1;
+	u32 saved_lpr0;
+
+	saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR);
+	lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB;
+	lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
+
+	saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR);
+	lpr0 = saved_lpr0 & ~AT91_DDRSDRC_LPCB;
+	lpr0 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
+
+	/* self-refresh mode now */
+	at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
+	at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1);
+
+	return saved_lpr0;
+}
+
+#define sdram_selfrefresh_disable(saved_lpr0)	\
+	do { \
+		at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); \
+		at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); \
+	} while (0)
+#define wait_for_interrupt_enable()		cpu_do_idle()
+
+#else
+#include <mach/at91sam9_sdramc.h>
+
+#ifdef CONFIG_ARCH_AT91SAM9263
+/*
+ * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use;
+ * handle those cases both here and in the Suspend-To-RAM support.
+ */
+#warning Assuming EB1 SDRAM controller is *NOT* used
+#endif
+
+static inline u32 sdram_selfrefresh_enable(void)
+{
+	u32 saved_lpr, lpr;
+
+	saved_lpr = at91_ramc_read(0, AT91_SDRAMC_LPR);
+
+	lpr = saved_lpr & ~AT91_SDRAMC_LPCB;
+	at91_ramc_write(0, AT91_SDRAMC_LPR, lpr | AT91_SDRAMC_LPCB_SELF_REFRESH);
+	return saved_lpr;
+}
+
+#define sdram_selfrefresh_disable(saved_lpr)	at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr)
+#define wait_for_interrupt_enable()		cpu_do_idle()
+
+#endif
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 62ad955..7efac37 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -27,9 +27,9 @@
 
 #include <mach/at91_pmc.h>
 #include <mach/cpu.h>
+#include <mach/pm.h>
 
 #include "generic.h"
-#include "pm.h"
 
 /*
  * Show the reason for the previous system reset.
diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h
deleted file mode 100644
index ce9a206..0000000
--- a/arch/arm/mach-at91/pm.h
+++ /dev/null
@@ -1,107 +0,0 @@
-#ifdef CONFIG_ARCH_AT91RM9200
-#include <mach/at91rm9200_mc.h>
-
-/*
- * The AT91RM9200 goes into self-refresh mode with this command, and will
- * terminate self-refresh automatically on the next SDRAM access.
- *
- * Self-refresh mode is exited as soon as a memory access is made, but we don't
- * know for sure when that happens. However, we need to restore the low-power
- * mode if it was enabled before going idle. Restoring low-power mode while
- * still in self-refresh is "not recommended", but seems to work.
- */
-
-static inline u32 sdram_selfrefresh_enable(void)
-{
-	u32 saved_lpr = at91_sys_read(AT91_SDRAMC_LPR);
-
-	at91_sys_write(AT91_SDRAMC_LPR, 0);
-	at91_sys_write(AT91_SDRAMC_SRR, 1);
-	return saved_lpr;
-}
-
-#define sdram_selfrefresh_disable(saved_lpr)	at91_sys_write(AT91_SDRAMC_LPR, saved_lpr)
-#define wait_for_interrupt_enable()		asm volatile ("mcr p15, 0, %0, c7, c0, 4" \
-								: : "r" (0))
-
-#elif defined(CONFIG_ARCH_AT91CAP9)
-#include <mach/at91cap9_ddrsdr.h>
-
-
-static inline u32 sdram_selfrefresh_enable(void)
-{
-	u32 saved_lpr, lpr;
-
-	saved_lpr = at91_ramc_read(0, AT91_DDRSDRC_LPR);
-
-	lpr = saved_lpr & ~AT91_DDRSDRC_LPCB;
-	at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr | AT91_DDRSDRC_LPCB_SELF_REFRESH);
-	return saved_lpr;
-}
-
-#define sdram_selfrefresh_disable(saved_lpr)	at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr)
-#define wait_for_interrupt_enable()		cpu_do_idle()
-
-#elif defined(CONFIG_ARCH_AT91SAM9G45)
-#include <mach/at91sam9_ddrsdr.h>
-
-/* We manage both DDRAM/SDRAM controllers, we need more than one value to
- * remember.
- */
-static u32 saved_lpr1;
-
-static inline u32 sdram_selfrefresh_enable(void)
-{
-	/* Those tow values allow us to delay self-refresh activation
-	 * to the maximum. */
-	u32 lpr0, lpr1;
-	u32 saved_lpr0;
-
-	saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR);
-	lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB;
-	lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
-
-	saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR);
-	lpr0 = saved_lpr0 & ~AT91_DDRSDRC_LPCB;
-	lpr0 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
-
-	/* self-refresh mode now */
-	at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
-	at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1);
-
-	return saved_lpr0;
-}
-
-#define sdram_selfrefresh_disable(saved_lpr0)	\
-	do { \
-		at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); \
-		at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); \
-	} while (0)
-#define wait_for_interrupt_enable()		cpu_do_idle()
-
-#else
-#include <mach/at91sam9_sdramc.h>
-
-#ifdef CONFIG_ARCH_AT91SAM9263
-/*
- * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use;
- * handle those cases both here and in the Suspend-To-RAM support.
- */
-#warning Assuming EB1 SDRAM controller is *NOT* used
-#endif
-
-static inline u32 sdram_selfrefresh_enable(void)
-{
-	u32 saved_lpr, lpr;
-
-	saved_lpr = at91_ramc_read(0, AT91_SDRAMC_LPR);
-
-	lpr = saved_lpr & ~AT91_SDRAMC_LPCB;
-	at91_ramc_write(0, AT91_SDRAMC_LPR, lpr | AT91_SDRAMC_LPCB_SELF_REFRESH);
-	return saved_lpr;
-}
-
-#define sdram_selfrefresh_disable(saved_lpr)	at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr)
-#define wait_for_interrupt_enable()		cpu_do_idle()
-
-#endif
-- 
1.7.4.1

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

* [PATCH 2/2][RFC] at91 : move cpuidle driver to drivers/cpuidle directory
  2012-01-04 16:55 [PATCH 1/2][RFC] at91 : move pm.h header to include/mach Daniel Lezcano
@ 2012-01-04 16:55 ` Daniel Lezcano
  2012-01-04 17:31 ` [PATCH 1/2][RFC] at91 : move pm.h header to include/mach Rob Herring
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2012-01-04 16:55 UTC (permalink / raw)
  To: linux-arm-kernel

This patch follows the discussion [1] about moving the cpuidle code which
is located in the architecture specific to the drivers directory.

[1] http://www.spinics.net/lists/arm-kernel/msg154109.html

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-at91/Kconfig   |    5 ++
 arch/arm/mach-at91/Makefile  |    1 -
 arch/arm/mach-at91/cpuidle.c |  100 ------------------------------------------
 drivers/cpuidle/Makefile     |    1 +
 drivers/cpuidle/at91_idle.c  |  100 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 106 insertions(+), 101 deletions(-)
 delete mode 100644 arch/arm/mach-at91/cpuidle.c
 create mode 100644 drivers/cpuidle/at91_idle.c

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 4f991f2..ddeaf0e 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -18,6 +18,11 @@ config HAVE_AT91_USART4
 config HAVE_AT91_USART5
 	bool
 
+config AT91_IDLE
+	bool
+	default y
+	depends on CPU_IDLE
+
 menu "Atmel AT91 System-on-Chip"
 
 choice
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 242174f..ce0cd4c 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -91,7 +91,6 @@ obj-y				+= leds.o
 # Power Management
 obj-$(CONFIG_PM)		+= pm.o
 obj-$(CONFIG_AT91_SLOW_CLOCK)	+= pm_slowclock.o
-obj-$(CONFIG_CPU_IDLE)	+= cpuidle.o
 
 ifeq ($(CONFIG_PM_DEBUG),y)
 CFLAGS_pm.o += -DDEBUG
diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c
deleted file mode 100644
index f658154..0000000
--- a/arch/arm/mach-at91/cpuidle.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * based on arch/arm/mach-kirkwood/cpuidle.c
- *
- * CPU idle support for AT91 SoC
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2.  This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- *
- * The cpu idle uses wait-for-interrupt and RAM self refresh in order
- * to implement two idle states -
- * #1 wait-for-interrupt
- * #2 wait-for-interrupt and RAM self refresh
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/cpuidle.h>
-#include <asm/proc-fns.h>
-#include <linux/io.h>
-#include <linux/export.h>
-
-#include <mach/pm.h>
-
-#define AT91_MAX_STATES	2
-
-static DEFINE_PER_CPU(struct cpuidle_device, at91_cpuidle_device);
-
-static struct cpuidle_driver at91_idle_driver = {
-	.name =         "at91_idle",
-	.owner =        THIS_MODULE,
-};
-
-/* Actual code that puts the SoC in different idle states */
-static int at91_enter_idle(struct cpuidle_device *dev,
-			struct cpuidle_driver *drv,
-			       int index)
-{
-	struct timeval before, after;
-	int idle_time;
-	u32 saved_lpr;
-
-	local_irq_disable();
-	do_gettimeofday(&before);
-	if (index == 0)
-		/* Wait for interrupt state */
-		cpu_do_idle();
-	else if (index == 1) {
-		asm("b 1f; .align 5; 1:");
-		asm("mcr p15, 0, r0, c7, c10, 4");	/* drain write buffer */
-		saved_lpr = sdram_selfrefresh_enable();
-		cpu_do_idle();
-		sdram_selfrefresh_disable(saved_lpr);
-	}
-	do_gettimeofday(&after);
-	local_irq_enable();
-	idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC +
-			(after.tv_usec - before.tv_usec);
-
-	dev->last_residency = idle_time;
-	return index;
-}
-
-/* Initialize CPU idle by registering the idle states */
-static int at91_init_cpuidle(void)
-{
-	struct cpuidle_device *device;
-	struct cpuidle_driver *driver = &at91_idle_driver;
-
-	device = &per_cpu(at91_cpuidle_device, smp_processor_id());
-	device->state_count = AT91_MAX_STATES;
-	driver->state_count = AT91_MAX_STATES;
-
-	/* Wait for interrupt state */
-	driver->states[0].enter = at91_enter_idle;
-	driver->states[0].exit_latency = 1;
-	driver->states[0].target_residency = 10000;
-	driver->states[0].flags = CPUIDLE_FLAG_TIME_VALID;
-	strcpy(driver->states[0].name, "WFI");
-	strcpy(driver->states[0].desc, "Wait for interrupt");
-
-	/* Wait for interrupt and RAM self refresh state */
-	driver->states[1].enter = at91_enter_idle;
-	driver->states[1].exit_latency = 10;
-	driver->states[1].target_residency = 10000;
-	driver->states[1].flags = CPUIDLE_FLAG_TIME_VALID;
-	strcpy(driver->states[1].name, "RAM_SR");
-	strcpy(driver->states[1].desc, "WFI and RAM Self Refresh");
-
-	cpuidle_register_driver(&at91_idle_driver);
-
-	if (cpuidle_register_device(device)) {
-		printk(KERN_ERR "at91_init_cpuidle: Failed registering\n");
-		return -EIO;
-	}
-	return 0;
-}
-
-device_initcall(at91_init_cpuidle);
diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile
index 5634f88..31c9b5f 100644
--- a/drivers/cpuidle/Makefile
+++ b/drivers/cpuidle/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-y += cpuidle.o driver.o governor.o sysfs.o governors/
+obj-$(CONFIG_AT91_IDLE) += at91_idle.o
diff --git a/drivers/cpuidle/at91_idle.c b/drivers/cpuidle/at91_idle.c
new file mode 100644
index 0000000..f658154
--- /dev/null
+++ b/drivers/cpuidle/at91_idle.c
@@ -0,0 +1,100 @@
+/*
+ * based on arch/arm/mach-kirkwood/cpuidle.c
+ *
+ * CPU idle support for AT91 SoC
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ *
+ * The cpu idle uses wait-for-interrupt and RAM self refresh in order
+ * to implement two idle states -
+ * #1 wait-for-interrupt
+ * #2 wait-for-interrupt and RAM self refresh
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/cpuidle.h>
+#include <asm/proc-fns.h>
+#include <linux/io.h>
+#include <linux/export.h>
+
+#include <mach/pm.h>
+
+#define AT91_MAX_STATES	2
+
+static DEFINE_PER_CPU(struct cpuidle_device, at91_cpuidle_device);
+
+static struct cpuidle_driver at91_idle_driver = {
+	.name =         "at91_idle",
+	.owner =        THIS_MODULE,
+};
+
+/* Actual code that puts the SoC in different idle states */
+static int at91_enter_idle(struct cpuidle_device *dev,
+			struct cpuidle_driver *drv,
+			       int index)
+{
+	struct timeval before, after;
+	int idle_time;
+	u32 saved_lpr;
+
+	local_irq_disable();
+	do_gettimeofday(&before);
+	if (index == 0)
+		/* Wait for interrupt state */
+		cpu_do_idle();
+	else if (index == 1) {
+		asm("b 1f; .align 5; 1:");
+		asm("mcr p15, 0, r0, c7, c10, 4");	/* drain write buffer */
+		saved_lpr = sdram_selfrefresh_enable();
+		cpu_do_idle();
+		sdram_selfrefresh_disable(saved_lpr);
+	}
+	do_gettimeofday(&after);
+	local_irq_enable();
+	idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC +
+			(after.tv_usec - before.tv_usec);
+
+	dev->last_residency = idle_time;
+	return index;
+}
+
+/* Initialize CPU idle by registering the idle states */
+static int at91_init_cpuidle(void)
+{
+	struct cpuidle_device *device;
+	struct cpuidle_driver *driver = &at91_idle_driver;
+
+	device = &per_cpu(at91_cpuidle_device, smp_processor_id());
+	device->state_count = AT91_MAX_STATES;
+	driver->state_count = AT91_MAX_STATES;
+
+	/* Wait for interrupt state */
+	driver->states[0].enter = at91_enter_idle;
+	driver->states[0].exit_latency = 1;
+	driver->states[0].target_residency = 10000;
+	driver->states[0].flags = CPUIDLE_FLAG_TIME_VALID;
+	strcpy(driver->states[0].name, "WFI");
+	strcpy(driver->states[0].desc, "Wait for interrupt");
+
+	/* Wait for interrupt and RAM self refresh state */
+	driver->states[1].enter = at91_enter_idle;
+	driver->states[1].exit_latency = 10;
+	driver->states[1].target_residency = 10000;
+	driver->states[1].flags = CPUIDLE_FLAG_TIME_VALID;
+	strcpy(driver->states[1].name, "RAM_SR");
+	strcpy(driver->states[1].desc, "WFI and RAM Self Refresh");
+
+	cpuidle_register_driver(&at91_idle_driver);
+
+	if (cpuidle_register_device(device)) {
+		printk(KERN_ERR "at91_init_cpuidle: Failed registering\n");
+		return -EIO;
+	}
+	return 0;
+}
+
+device_initcall(at91_init_cpuidle);
-- 
1.7.4.1

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

* [PATCH 1/2][RFC] at91 : move pm.h header to include/mach
  2012-01-04 16:55 [PATCH 1/2][RFC] at91 : move pm.h header to include/mach Daniel Lezcano
  2012-01-04 16:55 ` [PATCH 2/2][RFC] at91 : move cpuidle driver to drivers/cpuidle directory Daniel Lezcano
@ 2012-01-04 17:31 ` Rob Herring
  2012-01-04 22:10   ` Russell King - ARM Linux
  1 sibling, 1 reply; 6+ messages in thread
From: Rob Herring @ 2012-01-04 17:31 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/04/2012 10:55 AM, Daniel Lezcano wrote:
> Move the location of the pm.h header file to the include directory,
> so it can be included from another place from the current one.
> 
> That will allow the next patch which moves the cpuidle code to the
> drivers/cpuidle directory.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  arch/arm/mach-at91/cpuidle.c         |    2 +-
>  arch/arm/mach-at91/include/mach/pm.h |  107 ++++++++++++++++++++++++++++++++++
>  arch/arm/mach-at91/pm.c              |    2 +-
>  arch/arm/mach-at91/pm.h              |  107 ----------------------------------

You should use -M git option when doing moves to avoid the large diff.

This header should probably be named something more specific like
at91_pm.h or at91_sdram.h. This will be needed to avoid name collisions
with mach headers on a single kernel binary.

Rob

>  4 files changed, 109 insertions(+), 109 deletions(-)
>  create mode 100644 arch/arm/mach-at91/include/mach/pm.h
>  delete mode 100644 arch/arm/mach-at91/pm.h
> 
> diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c
> index a851e6c..f658154 100644
> --- a/arch/arm/mach-at91/cpuidle.c
> +++ b/arch/arm/mach-at91/cpuidle.c
> @@ -21,7 +21,7 @@
>  #include <linux/io.h>
>  #include <linux/export.h>
>  
> -#include "pm.h"
> +#include <mach/pm.h>
>  
>  #define AT91_MAX_STATES	2
>  
> diff --git a/arch/arm/mach-at91/include/mach/pm.h b/arch/arm/mach-at91/include/mach/pm.h
> new file mode 100644
> index 0000000..ce9a206
> --- /dev/null
> +++ b/arch/arm/mach-at91/include/mach/pm.h
> @@ -0,0 +1,107 @@
> +#ifdef CONFIG_ARCH_AT91RM9200
> +#include <mach/at91rm9200_mc.h>
> +
> +/*
> + * The AT91RM9200 goes into self-refresh mode with this command, and will
> + * terminate self-refresh automatically on the next SDRAM access.
> + *
> + * Self-refresh mode is exited as soon as a memory access is made, but we don't
> + * know for sure when that happens. However, we need to restore the low-power
> + * mode if it was enabled before going idle. Restoring low-power mode while
> + * still in self-refresh is "not recommended", but seems to work.
> + */
> +
> +static inline u32 sdram_selfrefresh_enable(void)
> +{
> +	u32 saved_lpr = at91_sys_read(AT91_SDRAMC_LPR);
> +
> +	at91_sys_write(AT91_SDRAMC_LPR, 0);
> +	at91_sys_write(AT91_SDRAMC_SRR, 1);
> +	return saved_lpr;
> +}
> +
> +#define sdram_selfrefresh_disable(saved_lpr)	at91_sys_write(AT91_SDRAMC_LPR, saved_lpr)
> +#define wait_for_interrupt_enable()		asm volatile ("mcr p15, 0, %0, c7, c0, 4" \
> +								: : "r" (0))
> +
> +#elif defined(CONFIG_ARCH_AT91CAP9)
> +#include <mach/at91cap9_ddrsdr.h>
> +
> +
> +static inline u32 sdram_selfrefresh_enable(void)
> +{
> +	u32 saved_lpr, lpr;
> +
> +	saved_lpr = at91_ramc_read(0, AT91_DDRSDRC_LPR);
> +
> +	lpr = saved_lpr & ~AT91_DDRSDRC_LPCB;
> +	at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr | AT91_DDRSDRC_LPCB_SELF_REFRESH);
> +	return saved_lpr;
> +}
> +
> +#define sdram_selfrefresh_disable(saved_lpr)	at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr)
> +#define wait_for_interrupt_enable()		cpu_do_idle()
> +
> +#elif defined(CONFIG_ARCH_AT91SAM9G45)
> +#include <mach/at91sam9_ddrsdr.h>
> +
> +/* We manage both DDRAM/SDRAM controllers, we need more than one value to
> + * remember.
> + */
> +static u32 saved_lpr1;
> +
> +static inline u32 sdram_selfrefresh_enable(void)
> +{
> +	/* Those tow values allow us to delay self-refresh activation
> +	 * to the maximum. */
> +	u32 lpr0, lpr1;
> +	u32 saved_lpr0;
> +
> +	saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR);
> +	lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB;
> +	lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
> +
> +	saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR);
> +	lpr0 = saved_lpr0 & ~AT91_DDRSDRC_LPCB;
> +	lpr0 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
> +
> +	/* self-refresh mode now */
> +	at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
> +	at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1);
> +
> +	return saved_lpr0;
> +}
> +
> +#define sdram_selfrefresh_disable(saved_lpr0)	\
> +	do { \
> +		at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); \
> +		at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); \
> +	} while (0)
> +#define wait_for_interrupt_enable()		cpu_do_idle()
> +
> +#else
> +#include <mach/at91sam9_sdramc.h>
> +
> +#ifdef CONFIG_ARCH_AT91SAM9263
> +/*
> + * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use;
> + * handle those cases both here and in the Suspend-To-RAM support.
> + */
> +#warning Assuming EB1 SDRAM controller is *NOT* used
> +#endif
> +
> +static inline u32 sdram_selfrefresh_enable(void)
> +{
> +	u32 saved_lpr, lpr;
> +
> +	saved_lpr = at91_ramc_read(0, AT91_SDRAMC_LPR);
> +
> +	lpr = saved_lpr & ~AT91_SDRAMC_LPCB;
> +	at91_ramc_write(0, AT91_SDRAMC_LPR, lpr | AT91_SDRAMC_LPCB_SELF_REFRESH);
> +	return saved_lpr;
> +}
> +
> +#define sdram_selfrefresh_disable(saved_lpr)	at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr)
> +#define wait_for_interrupt_enable()		cpu_do_idle()
> +
> +#endif
> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> index 62ad955..7efac37 100644
> --- a/arch/arm/mach-at91/pm.c
> +++ b/arch/arm/mach-at91/pm.c
> @@ -27,9 +27,9 @@
>  
>  #include <mach/at91_pmc.h>
>  #include <mach/cpu.h>
> +#include <mach/pm.h>
>  
>  #include "generic.h"
> -#include "pm.h"
>  
>  /*
>   * Show the reason for the previous system reset.
> diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h
> deleted file mode 100644
> index ce9a206..0000000
> --- a/arch/arm/mach-at91/pm.h
> +++ /dev/null
> @@ -1,107 +0,0 @@
> -#ifdef CONFIG_ARCH_AT91RM9200
> -#include <mach/at91rm9200_mc.h>
> -
> -/*
> - * The AT91RM9200 goes into self-refresh mode with this command, and will
> - * terminate self-refresh automatically on the next SDRAM access.
> - *
> - * Self-refresh mode is exited as soon as a memory access is made, but we don't
> - * know for sure when that happens. However, we need to restore the low-power
> - * mode if it was enabled before going idle. Restoring low-power mode while
> - * still in self-refresh is "not recommended", but seems to work.
> - */
> -
> -static inline u32 sdram_selfrefresh_enable(void)
> -{
> -	u32 saved_lpr = at91_sys_read(AT91_SDRAMC_LPR);
> -
> -	at91_sys_write(AT91_SDRAMC_LPR, 0);
> -	at91_sys_write(AT91_SDRAMC_SRR, 1);
> -	return saved_lpr;
> -}
> -
> -#define sdram_selfrefresh_disable(saved_lpr)	at91_sys_write(AT91_SDRAMC_LPR, saved_lpr)
> -#define wait_for_interrupt_enable()		asm volatile ("mcr p15, 0, %0, c7, c0, 4" \
> -								: : "r" (0))
> -
> -#elif defined(CONFIG_ARCH_AT91CAP9)
> -#include <mach/at91cap9_ddrsdr.h>
> -
> -
> -static inline u32 sdram_selfrefresh_enable(void)
> -{
> -	u32 saved_lpr, lpr;
> -
> -	saved_lpr = at91_ramc_read(0, AT91_DDRSDRC_LPR);
> -
> -	lpr = saved_lpr & ~AT91_DDRSDRC_LPCB;
> -	at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr | AT91_DDRSDRC_LPCB_SELF_REFRESH);
> -	return saved_lpr;
> -}
> -
> -#define sdram_selfrefresh_disable(saved_lpr)	at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr)
> -#define wait_for_interrupt_enable()		cpu_do_idle()
> -
> -#elif defined(CONFIG_ARCH_AT91SAM9G45)
> -#include <mach/at91sam9_ddrsdr.h>
> -
> -/* We manage both DDRAM/SDRAM controllers, we need more than one value to
> - * remember.
> - */
> -static u32 saved_lpr1;
> -
> -static inline u32 sdram_selfrefresh_enable(void)
> -{
> -	/* Those tow values allow us to delay self-refresh activation
> -	 * to the maximum. */
> -	u32 lpr0, lpr1;
> -	u32 saved_lpr0;
> -
> -	saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR);
> -	lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB;
> -	lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
> -
> -	saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR);
> -	lpr0 = saved_lpr0 & ~AT91_DDRSDRC_LPCB;
> -	lpr0 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
> -
> -	/* self-refresh mode now */
> -	at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
> -	at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1);
> -
> -	return saved_lpr0;
> -}
> -
> -#define sdram_selfrefresh_disable(saved_lpr0)	\
> -	do { \
> -		at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); \
> -		at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); \
> -	} while (0)
> -#define wait_for_interrupt_enable()		cpu_do_idle()
> -
> -#else
> -#include <mach/at91sam9_sdramc.h>
> -
> -#ifdef CONFIG_ARCH_AT91SAM9263
> -/*
> - * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use;
> - * handle those cases both here and in the Suspend-To-RAM support.
> - */
> -#warning Assuming EB1 SDRAM controller is *NOT* used
> -#endif
> -
> -static inline u32 sdram_selfrefresh_enable(void)
> -{
> -	u32 saved_lpr, lpr;
> -
> -	saved_lpr = at91_ramc_read(0, AT91_SDRAMC_LPR);
> -
> -	lpr = saved_lpr & ~AT91_SDRAMC_LPCB;
> -	at91_ramc_write(0, AT91_SDRAMC_LPR, lpr | AT91_SDRAMC_LPCB_SELF_REFRESH);
> -	return saved_lpr;
> -}
> -
> -#define sdram_selfrefresh_disable(saved_lpr)	at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr)
> -#define wait_for_interrupt_enable()		cpu_do_idle()
> -
> -#endif

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

* [PATCH 1/2][RFC] at91 : move pm.h header to include/mach
  2012-01-04 17:31 ` [PATCH 1/2][RFC] at91 : move pm.h header to include/mach Rob Herring
@ 2012-01-04 22:10   ` Russell King - ARM Linux
  2012-01-05  9:46     ` Daniel Lezcano
  0 siblings, 1 reply; 6+ messages in thread
From: Russell King - ARM Linux @ 2012-01-04 22:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jan 04, 2012 at 11:31:05AM -0600, Rob Herring wrote:
> This header should probably be named something more specific like
> at91_pm.h or at91_sdram.h. This will be needed to avoid name collisions
> with mach headers on a single kernel binary.

I think actually the idea that mach/*.h headers can be included by stuff
outside of arch/arm is something that we should deprecate, because it's
not going to be sane to make them all unique in this way.

Not only that but it prevents the .c files being built on other
architectures, and provides another reason why the .c file is tied to
a pariticular SoC - even if the same IP is used in a different SoC, it
can be used as a reason why not to reuse the .c file.

Let's not give people excuses not to share code!

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

* [PATCH 1/2][RFC] at91 : move pm.h header to include/mach
  2012-01-04 22:10   ` Russell King - ARM Linux
@ 2012-01-05  9:46     ` Daniel Lezcano
  2012-01-06 19:06       ` Russell King - ARM Linux
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Lezcano @ 2012-01-05  9:46 UTC (permalink / raw)
  To: linux-arm-kernel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/04/2012 11:10 PM, Russell King - ARM Linux wrote:
> On Wed, Jan 04, 2012 at 11:31:05AM -0600, Rob Herring wrote:
>> This header should probably be named something more specific like
>> at91_pm.h or at91_sdram.h. This will be needed to avoid name collisions
>> with mach headers on a single kernel binary.
> 
> I think actually the idea that mach/*.h headers can be included by stuff
> outside of arch/arm is something that we should deprecate, because it's
> not going to be sane to make them all unique in this way.
> 
> Not only that but it prevents the .c files being built on other
> architectures, and provides another reason why the .c file is tied to
> a pariticular SoC - even if the same IP is used in a different SoC, it
> can be used as a reason why not to reuse the .c file.
> 
> Let's not give people excuses not to share code!

As the pm.h file should be included from drivers/cpuidle/at91_idle.c,
does it make sense to move
	arch/arm/mach-at91/pm.h to arch/arm/include/asm/at91_pm.h ?

Thanks
  -- Daniel

- -- 
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPBXGIAAoJEAKBbMCpUGYAUFoH/izNX5+7lZV33aZGERypoBHW
+3WRyAEhiMJPDAEYTDKxXyN4jz9177qEUfJXPpzA9+UZpoVKH6JHONbbzPMIFXf6
cj0lG6VrZh6ntDxFvZ531sCghqy6u75YYfTrJflrijsKAtBbv6OVOrTVnoOqZLn8
HG1noRNz4cey5JgzO627grQBt4UCWYGs/+gNr1H0K5AqjCjyUdSuPFQwSEUotPki
7tV54U+ba4jm2xbhRjARSjeMJh5EVCiVOnYjkJbOYWE0xEODOQKglKk8ptG/9GUT
AVzBb4kGZu5DFD0Q8JZvArLjowB27jRmTnHwsCiOB3HwuZMmhXy5ntV7GYiTRwI=
=LHB3
-----END PGP SIGNATURE-----

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

* [PATCH 1/2][RFC] at91 : move pm.h header to include/mach
  2012-01-05  9:46     ` Daniel Lezcano
@ 2012-01-06 19:06       ` Russell King - ARM Linux
  0 siblings, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux @ 2012-01-06 19:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jan 05, 2012 at 10:46:48AM +0100, Daniel Lezcano wrote:
> On 01/04/2012 11:10 PM, Russell King - ARM Linux wrote:
> > On Wed, Jan 04, 2012 at 11:31:05AM -0600, Rob Herring wrote:
> >> This header should probably be named something more specific like
> >> at91_pm.h or at91_sdram.h. This will be needed to avoid name collisions
> >> with mach headers on a single kernel binary.
> > 
> > I think actually the idea that mach/*.h headers can be included by stuff
> > outside of arch/arm is something that we should deprecate, because it's
> > not going to be sane to make them all unique in this way.
> > 
> > Not only that but it prevents the .c files being built on other
> > architectures, and provides another reason why the .c file is tied to
> > a pariticular SoC - even if the same IP is used in a different SoC, it
> > can be used as a reason why not to reuse the .c file.
> > 
> > Let's not give people excuses not to share code!
> 
> As the pm.h file should be included from drivers/cpuidle/at91_idle.c,
> does it make sense to move
> 	arch/arm/mach-at91/pm.h to arch/arm/include/asm/at91_pm.h ?

Not really.  If code is being moved out of arch/arm, their dependent
headers should also be moved out of arch/arm as well.  It makes no
sense to move the code out of arch/arm into drivers if it still
requires headers only found in arch/arm to build.

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

end of thread, other threads:[~2012-01-06 19:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-04 16:55 [PATCH 1/2][RFC] at91 : move pm.h header to include/mach Daniel Lezcano
2012-01-04 16:55 ` [PATCH 2/2][RFC] at91 : move cpuidle driver to drivers/cpuidle directory Daniel Lezcano
2012-01-04 17:31 ` [PATCH 1/2][RFC] at91 : move pm.h header to include/mach Rob Herring
2012-01-04 22:10   ` Russell King - ARM Linux
2012-01-05  9:46     ` Daniel Lezcano
2012-01-06 19:06       ` Russell King - ARM Linux

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.