sh: SuperH platform bus code for Runtime PM v11
PATCH 1/4 sh: SuperH platform bus code for Runtime PM v11
From: Magnus Damm <[email protected]>
This patch is V2 of the SuperH Platform Bus prototype implentation for Runtime PM v11.
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 cpuidle implementation is however not part of this patch.
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.
This code is already working quite well, but it needs a bit more attention before I remove the prototype label.
---
Changes since last 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()
TODO:
- use a mutex to serialize dev_pm_ops calls
- rewrite the schedule_work() code
arch/sh/include/asm/device.h | 8 arch/sh/include/asm/hwblk.h | 4 arch/sh/kernel/cpu/shmobile/Makefile | 1 arch/sh/kernel/cpu/shmobile/pm_runtime.c | 244 ++++++++++++++++++++++++++++++ 4 files changed, 256 insertions(+), 1 deletion(-)
arch/sh/include/asm/device.h +8 -0
@@ -14,8 +14,16 @@ int platform_resource_setup_memory(strucvoid plat_early_device_setup (void ); +#define PDEV_ARCHDATA_FLAG_INIT 0 +#define PDEV_ARCHDATA_FLAG_LIST 1 +#define PDEV_ARCHDATA_FLAG_SUSP 2 +#define PDEV_ARCHDATA_FLAG_WORK 3 +struct pdev_archdata {#ifdef CONFIG_ARCH_SHMOBILE int hwblk_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 +244 -0
244 lines not on this page · raw message