Skip to contentSkip to conversation

at91 : move pm.h header to include/mach

RFC PATCH New Daniel Lezcano 3 participants 6 messages Jan 4, 2012 – Jan 6, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/2 at91 : move pm.h header to include/mach

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.

---
 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
arch/arm/mach-at91/cpuidle.c +1 -1
index a851e6c..f658154 100644
@@ -21,7 +21,7 @@
 #include <linux/io.h>
 #include <linux/export.h>
 
-#include "pm.h"
+#include <mach/pm.h>
 
 #define AT91_MAX_STATES	2
 
arch/arm/mach-at91/include/mach/pm.h new file +107 -0

107 lines not on this page · raw message

arch/arm/mach-at91/pm.c +1 -1
index 62ad955..7efac37 100644
@@ -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.
arch/arm/mach-at91/pm.h deleted +0 -107

107 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#1 lore raw

RFC PATCH 2/2 at91 : move cpuidle driver to drivers/cpuidle directory

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

---
 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
arch/arm/mach-at91/Kconfig +5 -0
index 4f991f2..ddeaf0e 100644
@@ -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
arch/arm/mach-at91/Makefile +0 -1
index 242174f..ce0cd4c 100644
@@ -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
arch/arm/mach-at91/cpuidle.c deleted +0 -100

100 lines not on this page · raw message

drivers/cpuidle/Makefile +1 -0
index 5634f88..31c9b5f 100644
@@ -3,3 +3,4 @@
 #
 
 obj-y += cpuidle.o driver.o governor.o sysfs.o governors/
+obj-$(CONFIG_AT91_IDLE) += at91_idle.o
drivers/cpuidle/at91_idle.c new file +100 -0

100 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#2 lore raw

RFC PATCH 1/2 at91 : move pm.h header to include/mach

In reply to Daniel Lezcano
Quoted 6 lines · Daniel Lezcano

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.

Quoted 6 lines
---
 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

Quoted 258 lines
 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
arch/arm/mach-at91/cpuidle.c +1 -1
index a851e6c..f658154 100644
@@ -21,7 +21,7 @@
 #include <linux/io.h>
 #include <linux/export.h>
 
-#include "pm.h"
+#include <mach/pm.h>
 
 #define AT91_MAX_STATES	2
 
arch/arm/mach-at91/include/mach/pm.h new file +107 -0
new file mode 100644
index 0000000..ce9a206
@@ -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
arch/arm/mach-at91/pm.c +1 -1
index 62ad955..7efac37 100644
@@ -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.
arch/arm/mach-at91/pm.h deleted +0 -107
deleted file mode 100644
index ce9a206..0000000
@@ -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
#3 lore raw

RFC PATCH 1/2 at91 : move pm.h header to include/mach

Quoted 3 lines · Rob Herring

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!

#4 lore raw

RFC PATCH 1/2 at91 : move pm.h header to include/mach

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

Quoted 9 lines · Russell King - ARM Linux
Quoted 3 lines · Rob Herring

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.

Quoted 6 lines

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

#5 lore raw

RFC PATCH 1/2 at91 : move pm.h header to include/mach

Quoted 15 lines · Daniel Lezcano
Quoted 14 lines · Russell King - ARM Linux
Quoted 3 lines · Rob Herring

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.

Quoted 5 lines
Quoted 1 line

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.