Skip to contentSkip to conversation

sh: Runtime PM for SuperH Mobile

PATCH New Magnus Damm 1 participant 1 message Jul 9, 2009 SuperH

lore
Share & tools
lore
#0 lore raw

PATCH 3/6 sh: Runtime PM for SuperH Mobile

From: Magnus Damm <[email protected]>

This patch contains the processor independent part of the SuperH Mobile Runtime PM prototype.

The patch adds fields for Runtime PM to the architecture specific part of struct platform_device. The most important field is hw_blk_id which contains an id for the hardware block within the SoC.

This hwblk id is used by the SuperH specific Runtime PM callbacks for the platform bus. Multiple devices are allowed to use the same hwblk id.

The SuperH specific Runtime PM platform bus callbacks platform_pm_runtime_suspend() and platform_pm_runtime_resume() control clocks and adds/removes the platform device to a list of platform devices that has had their bus suspend callback executed.

The driver Runtime PM suspend callbacks get invoked when cpuidle discovers that all devices in the power domain has had their bus suspend callback executed. When all devices have been suspended using their driver Runtime PM suspend callbacks, cpuidle is allowed to enter the deepest mode which involves turning off power to the domain.

Please note that the code is very experimental. Alan kindly suggested a cleaner way to do this using the idle callback, but for that to work I need to rearrange all platform devices.

---

 arch/sh/include/asm/device.h             |   16 ++
 arch/sh/include/asm/hwblk.h              |    4 
 arch/sh/kernel/cpu/shmobile/Makefile     |    1 
 arch/sh/kernel/cpu/shmobile/pm_runtime.c |  206 ++++++++++++++++++++++++++++++
 4 files changed, 225 insertions(+), 2 deletions(-)
arch/sh/include/asm/device.h +15 -1
@@ -3,7 +3,9 @@
  *
  * This file is released under the GPLv2
  */
-#include <asm-generic/device.h>
+
+struct dev_archdata {
+};
 
 struct platform_device;
 /* allocate contiguous memory chunk and fill in struct resource */
@@ -12,3 +14,15 @@ int platform_resource_setup_memory(struc
 
 void plat_early_device_setup(void);
 
+#define PDEV_ARCHDATA_FLAG_INIT 0
+#define PDEV_ARCHDATA_FLAG_LIST 1
+#define PDEV_ARCHDATA_FLAG_SUSP 2
+
+struct pdev_archdata {
+#ifdef CONFIG_ARCH_SHMOBILE
+	int hw_blk_id;
+	unsigned long flags;
+	struct list_head entry;
+	struct work_struct work;
+#endif
+};
arch/sh/include/asm/hwblk.h +3 -1
@@ -5,7 +5,9 @@
 #include <asm/io.h>
 
 #define HWBLK_CNT_USAGE 0
-#define HWBLK_CNT_NR 1
+#define HWBLK_CNT_IDLE 1
+#define HWBLK_CNT_DEVICES 2
+#define HWBLK_CNT_NR 3
 
 #define HWBLK_AREA_FLAG_PARENT (1 << 0) /* valid parent */
 
arch/sh/kernel/cpu/shmobile/Makefile +1 -0
@@ -5,3 +5,4 @@
 # Power Management & Sleep mode
 obj-$(CONFIG_PM)	+= pm.o sleep.o
 obj-$(CONFIG_CPU_IDLE)	+= cpuidle.o
+obj-$(CONFIG_PM_RUNTIME)	+= pm_runtime.o
arch/sh/kernel/cpu/shmobile/pm_runtime.c new file +206 -0

206 lines not on this page · raw message