Skip to contentSkip to conversation

sh: Runtime PM for SuperH Mobile platform bus devices

PATCH New Magnus Damm 1 participant 1 message Aug 14, 2009 SuperH

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 sh: Runtime PM for SuperH Mobile platform bus devices

From: Magnus Damm <[email protected]>

This patch is V3 of the SuperH Mobile Runtime PM platform bus implentation matching Rafael's Runtime PM v16.

The code gets invoked from the SuperH specific Runtime PM platform bus functions that override the weak symbols for:
- platform_pm_runtime_suspend()
- platform_pm_runtime_resume()
- platform_pm_runtime_idle()

This Runtime PM implementation performs two levels of power management. At the time of platform bus runtime suspend the clock to the device is stopped instantly. Later on if all devices within the power domain has their clocks stopped then the device driver ->runtime_suspend() callbacks are used to save hardware register state for each device.

Device driver ->runtime_suspend() calls are scheduled from cpuidle context using platform_pm_runtime_suspend_idle(). When all devices have been fully suspended the processor is allowed to enter deep sleep from cpuidle.

The runtime resume operation turns on clocks and also restores registers if needed. It is worth noting that the devices start in a suspended state and the device driver is responsible for calling runtime resume before accessing the actual hardware.

In this particular platform bus implementation runtime resume is not allowed from interrupt context. Runtime suspend is however allowed from interrupt context as long as the synchronous functions are avoided.

---

Changes since V2
- update to v16
- rewrite work queue code
- use mutex

Changes since V1:
- update from Runtime PM v9 to v11
- rework error handling
- implement platform_pm_runtime_idle()
- add might_sleep()
- use dev_pm_ops helpers
- use dev_dbg()
- use core_initcall()

 arch/sh/include/asm/device.h             |    9 
 arch/sh/include/asm/hwblk.h              |    4 
 arch/sh/kernel/cpu/shmobile/Makefile     |    1 
 arch/sh/kernel/cpu/shmobile/pm_runtime.c |  304 ++++++++++++++++++++++++++++++
 4 files changed, 317 insertions(+), 1 deletion(-)
arch/sh/include/asm/device.h +9 -0
@@ -14,6 +14,15 @@ int platform_resource_setup_memory(struc
 
 void plat_early_device_setup(void);
 
+#define PDEV_ARCHDATA_FLAG_INIT 0
+#define PDEV_ARCHDATA_FLAG_IDLE 1
+#define PDEV_ARCHDATA_FLAG_SUSP 2
+
 struct pdev_archdata {
 	int hwblk_id;
+#ifdef CONFIG_PM_RUNTIME
+	unsigned long flags;
+	struct list_head entry;
+	struct mutex mutex;
+#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 +304 -0

304 lines not on this page · raw message