idle-path reorg for interrupt-enabled runtime PM
cover idle-path reorg for interrupt-enabled runtime PM
From: Kevin Hilman <[email protected]>
This series is a cleanup/reorg/streamline of the core idle path.
The goal is to remove all device-specific idle management out of the core idle path into device-specific code.
This series starts with some of the device-specific hacks currently in the idle path, and also moves GPIO handling out of the core idle loop.
Eventually, all device-specific idle management should be done using the runtime PM hooks of the driver for that device. Until then, temporary hacks belong in the new omap3_device_[idle|resume] functions.
Note that for debug purposes, UART is still managed inside the interrupt-disabled idle path. This is for debug purposes only so that any panic/BUG code that gets triggered before the device resume code is run will not crash the system. As soon as the new omap-serial driver is converted to runtime PM, the UART management can be removed from the idle path as well.
Patch 1 will be queued in my pm-next branch for .37 and patch 2 should be incorporated into baseline for the GPIO hwmod conversion.
Kevin Hilman (2):
OMAP3: PM: move device-specific special cases from PM core into
CPUidle
OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
arch/arm/mach-omap2/cpuidle34xx.c | 54 ++++++++++++++++++++++++++++-- arch/arm/mach-omap2/pm.h | 2 + arch/arm/mach-omap2/pm24xx.c | 2 +- arch/arm/mach-omap2/pm34xx.c | 48 ++++++++------------------ arch/arm/plat-omap/gpio.c | 57 ++++++++++++++++++++++++-------- arch/arm/plat-omap/include/plat/gpio.h | 4 +-- 6 files changed, 113 insertions(+), 54 deletions(-)
Signature · 1 line
1.7.2.1
PATCH 1/2 OMAP3: PM: move device-specific special cases from PM core into CPUidle
From: Kevin Hilman <[email protected]>
In an effort to simplify the core idle path, move any device-specific special case handling from the core PM idle path into the CPUidle pre-idle checking path.
This keeps the core, interrupts-disabled idle path streamlined and independent of any device-specific handling, and also allows CPUidle to do the checking only for certain C-states as needed. This patch has the device checks in place for all states with the CHECK_BM flag, namely all states >= C2.
This patch was inspired by a similar patch written by Tero Kristo as part of a larger series to add INACTIVE state support.
--- arch/arm/mach-omap2/cpuidle34xx.c | 50 ++++++++++++++++++++++++++++++++++-- arch/arm/mach-omap2/pm34xx.c | 14 +--------- 2 files changed, 48 insertions(+), 16 deletions(-)
arch/arm/mach-omap2/cpuidle34xx.c +47 -3
@@ -60,7 +60,8 @@ struct omap3_processor_cx {struct omap3_processor_cx omap3_power_states[OMAP3_MAX_STATES ];struct omap3_processor_cx current_cx_state; -struct powerdomain *mpu_pd, *core_pd; +struct powerdomain *mpu_pd, *core_pd, *per_pd; +struct powerdomain *cam_pd;/* * The latencies/thresholds for various C states have
@@ -233,14 +234,54 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev, struct cpuidle_state *state) {struct cpuidle_state *new_state =next_valid_state (dev, state); +u32 core_next_state, per_next_state =0 , per_saved_state =0 ; +u32 cam_state; +struct omap3_processor_cx *cx; +int ret;if ((state->flags &CPUIDLE_FLAG_CHECK_BM ) &&omap3_idle_bm_check ()) {BUG_ON (!dev->safe_state); new_state = dev->safe_state; + goto select_state; + } + + cx =cpuidle_get_statedata (state); + core_next_state = cx->core_state; + +/* +* Prevent idle completely if CAM is active. +* CAM does not have wakeup capability in OMAP3. +*/ + cam_state =pwrdm_read_pwrst (cam_pd); +if (cam_state ==PWRDM_POWER_ON ) { + new_state = dev->safe_state; + goto select_state; } +/* +* Prevent PER off if CORE is not in retention or off as this +* would disable PER wakeups completely. +*/ + per_next_state = per_saved_state =pwrdm_read_next_pwrst (per_pd); +if ((per_next_state ==PWRDM_POWER_OFF ) && + (core_next_state >PWRDM_POWER_RET )) { + per_next_state =PWRDM_POWER_RET ; +pwrdm_set_next_pwrst (per_pd, per_next_state); + } + +/* Are we changing PER target state? */ +if (per_next_state != per_saved_state) +pwrdm_set_next_pwrst (per_pd, per_next_state); + +select_state: dev->last_state = new_state; -return omap3_enter_idle (dev, new_state); + ret =omap3_enter_idle (dev, new_state); + +/* Restore original PER state if it was modified */ +if (per_next_state != per_saved_state) +pwrdm_set_next_pwrst (per_pd, per_saved_state); + +return ret; } DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
@@ -328,7 +369,8 @@ void omap_init_power_states(void) cpuidle_params_table[OMAP3_STATE_C2 ].threshold; omap3_power_states[OMAP3_STATE_C2 ].mpu_state =PWRDM_POWER_ON ; omap3_power_states[OMAP3_STATE_C2 ].core_state =PWRDM_POWER_ON ; - omap3_power_states[OMAP3_STATE_C2 ].flags =CPUIDLE_FLAG_TIME_VALID ; + omap3_power_states[OMAP3_STATE_C2 ].flags =CPUIDLE_FLAG_TIME_VALID | +CPUIDLE_FLAG_CHECK_BM ;/* C3 . MPU CSWR + Core inactive */ omap3_power_states[OMAP3_STATE_C3].valid =
@@ -426,6 +468,8 @@ int __init omap3_idle_init(void) mpu_pd =pwrdm_lookup ("mpu_pwrdm" ); core_pd =pwrdm_lookup ("core_pwrdm" ); + per_pd =pwrdm_lookup ("per_pwrdm" ); + cam_pd =pwrdm_lookup ("cam_pwrdm" );omap_init_power_states ();cpuidle_register_driver (&omap3_idle_driver);
arch/arm/mach-omap2/pm34xx.c +1 -13
@@ -346,7 +346,6 @@ void omap_sram_idle(void)int core_next_state =PWRDM_POWER_ON ;int core_prev_state, per_prev_state;u32 sdrc_pwr =0 ; -int per_state_modified =0 ;if (!_omap_sram_idle)return ;
@@ -391,19 +390,10 @@ void omap_sram_idle(void)if (per_next_state <PWRDM_POWER_ON ) {omap_uart_prepare_idle (2 );omap2_gpio_prepare_for_idle (per_next_state); -if (per_next_state ==PWRDM_POWER_OFF ) { -if (core_next_state ==PWRDM_POWER_ON ) { - per_next_state =PWRDM_POWER_RET ; -pwrdm_set_next_pwrst (per_pwrdm, per_next_state); - per_state_modified =1 ; - }else +if (per_next_state ==PWRDM_POWER_OFF )omap3_per_save_context (); - } } -if (pwrdm_read_pwrst (cam_pwrdm) ==PWRDM_POWER_ON ) -omap2_clkdm_deny_idle (mpu_pwrdm->pwrdm_clkdms[0 ]); -/* CORE */ if (core_next_state <PWRDM_POWER_ON ) {omap_uart_prepare_idle (0 );
@@ -470,8 +460,6 @@ void omap_sram_idle(void)if (per_prev_state ==PWRDM_POWER_OFF )omap3_per_restore_context ();omap_uart_resume_idle (2 ); -if (per_state_modified) -pwrdm_set_next_pwrst (per_pwrdm,PWRDM_POWER_OFF ); }/* Disable IO-PAD and IO-CHAIN wakeup */
Signature · 1 line
1.7.2.1
PATCH 2/2 OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
In reply to Kevin HilmanFrom: Kevin Hilman <[email protected]>
Currently, we wait until late in the idle path where interrupts are disabled to do runtime-PM-like management for certain special-case devices like GPIO.
As a prerequiste to moving GPIO to the new runtime PM framework, move this runtime-PM-like code out of the late idle path into new device idle and resume functions that can be called before interrupts are disabled by CPUidle and/or suspend.
In addition, move all the GPIO-specific logic into the GPIO core instead of keeping GPIO-specific knowledge of power-states, context saving etc. in the PM core.
Also, call the new device-idle and -resume methods from CPUidle and static suspend path.
--- arch/arm/mach-omap2/cpuidle34xx.c | 4 ++ arch/arm/mach-omap2/pm.h | 2 + arch/arm/mach-omap2/pm24xx.c | 2 +- arch/arm/mach-omap2/pm34xx.c | 38 +++++++++------------ arch/arm/plat-omap/gpio.c | 57 ++++++++++++++++++++++++-------- arch/arm/plat-omap/include/plat/gpio.h | 4 +-- 6 files changed, 67 insertions(+), 40 deletions(-)
arch/arm/mach-omap2/cpuidle34xx.c +4 -0
@@ -274,9 +274,13 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,pwrdm_set_next_pwrst (per_pd, per_next_state); select_state: +omap3_device_idle (); + dev->last_state = new_state; ret =omap3_enter_idle (dev, new_state); +omap3_device_resume (); +/* Restore original PER state if it was modified */ if (per_next_state != per_saved_state)pwrdm_set_next_pwrst (per_pd, per_saved_state);
arch/arm/mach-omap2/pm.h +2 -0
@@ -22,6 +22,8 @@ extern void omap_sram_idle(void);extern int omap3_can_sleep (void );extern int set_pwrdm_state (struct powerdomain *pwrdm,u32 state);extern int omap3_idle_init (void ); +extern void omap3_device_idle (void ); +extern void omap3_device_resume (void );struct cpuidle_params {u8 valid;
arch/arm/mach-omap2/pm24xx.c +1 -1
@@ -106,7 +106,7 @@ static void omap2_enter_full_retention(void) l =omap_ctrl_readl (OMAP2_CONTROL_DEVCONF0 ) |OMAP24XX_USBSTANDBYCTRL ;omap_ctrl_writel (l,OMAP2_CONTROL_DEVCONF0 ); -omap2_gpio_prepare_for_idle (PWRDM_POWER_RET ); +omap2_gpio_prepare_for_idle ();if (omap2_pm_debug) {omap2_pm_dump (0 ,0 ,0 );
arch/arm/mach-omap2/pm34xx.c +16 -22
@@ -74,16 +74,6 @@ static struct powerdomain *mpu_pwrdm, *neon_pwrdm;static struct powerdomain *core_pwrdm, *per_pwrdm;static struct powerdomain *cam_pwrdm; -static inline void omap3_per_save_context (void ) -{ -omap_gpio_save_context (); -} - -static inline void omap3_per_restore_context (void ) -{ -omap_gpio_restore_context (); -} -static void omap3_enable_io_chain (void ) {int timeout =0 ;
@@ -332,6 +322,16 @@ static void restore_table_entry(void)restore_control_register (control_reg_value); } +void omap3_device_idle (void ) +{ +omap2_gpio_prepare_for_idle (); +} + +void omap3_device_resume (void ) +{ +omap2_gpio_resume_after_idle (); +} +void omap_sram_idle (void ) {/* Variable to tell what needs to be saved and restored
@@ -344,7 +344,7 @@ void omap_sram_idle(void)int mpu_next_state =PWRDM_POWER_ON ;int per_next_state =PWRDM_POWER_ON ;int core_next_state =PWRDM_POWER_ON ; -int core_prev_state, per_prev_state; +int core_prev_state;u32 sdrc_pwr =0 ;if (!_omap_sram_idle)
@@ -387,12 +387,9 @@ void omap_sram_idle(void) }/* PER */ -if (per_next_state <PWRDM_POWER_ON ) { +if (per_next_state <PWRDM_POWER_ON )omap_uart_prepare_idle (2 ); -omap2_gpio_prepare_for_idle (per_next_state); -if (per_next_state ==PWRDM_POWER_OFF ) -omap3_per_save_context (); - } +/* CORE */ if (core_next_state <PWRDM_POWER_ON ) {
@@ -454,13 +451,8 @@ void omap_sram_idle(void)omap3_intc_resume_idle ();/* PER */ -if (per_next_state <PWRDM_POWER_ON ) { - per_prev_state =pwrdm_read_prev_pwrst (per_pwrdm); -omap2_gpio_resume_after_idle (); -if (per_prev_state ==PWRDM_POWER_OFF ) -omap3_per_restore_context (); +if (per_next_state <PWRDM_POWER_ON )omap_uart_resume_idle (2 ); - }/* Disable IO-PAD and IO-CHAIN wakeup */ if (omap3_has_io_wakeup() &&
@@ -570,6 +562,7 @@ static void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)static int omap3_pm_prepare (void ) {disable_hlt (); +omap3_device_idle ();return 0 ; }
@@ -637,6 +630,7 @@ static int omap3_pm_enter(suspend_state_t unused)static void omap3_pm_finish (void ) { +omap3_device_resume ();enable_hlt (); }
arch/arm/plat-omap/gpio.c +43 -14
123 lines not on this page · raw message
arch/arm/plat-omap/include/plat/gpio.h +1 -3
@@ -72,12 +72,10 @@ IH_GPIO_BASE + (nr))extern int omap_gpio_init (void );/* Call from board init only */ -extern void omap2_gpio_prepare_for_idle (int power_state); +extern void omap2_gpio_prepare_for_idle (void );extern void omap2_gpio_resume_after_idle (void );extern void omap_set_gpio_debounce (int gpio,int enable);extern void omap_set_gpio_debounce_time (int gpio,int enable); -extern void omap_gpio_save_context (void ); -extern void omap_gpio_restore_context (void );/*-------------------------------------------------------------------------*/ /* Wrappers for "new style" GPIO calls, using the new infrastructure
Signature · 1 line
1.7.2.1
RE: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
Quoted 29 lines
-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Tuesday, September 14, 2010 4:33 AM
To: [email protected]
Cc: Varadarajan, Charulatha; Basak, Partha; Tero Kristo
Subject: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle pathFrom: Kevin Hilman <[email protected]>
Currently, we wait until late in the idle path where interrupts are disabled to do runtime-PM-like management for certain special-case devices like GPIO.
As a prerequiste to moving GPIO to the new runtime PM framework, move this runtime-PM-like code out of the late idle path into new device idle and resume functions that can be called before interrupts are disabled by CPUidle and/or suspend.
In addition, move all the GPIO-specific logic into the GPIO core instead of keeping GPIO-specific knowledge of power-states, context saving etc. in the PM core.
Also, call the new device-idle and -resume methods from CPUidle and static suspend path.
Signed-off-by Kevin Hilman <[email protected]>
Quoted 9 lines
--- arch/arm/mach-omap2/cpuidle34xx.c | 4 ++ arch/arm/mach-omap2/pm.h | 2 + arch/arm/mach-omap2/pm24xx.c | 2 +- arch/arm/mach-omap2/pm34xx.c | 38 +++++++++------------ arch/arm/plat-omap/gpio.c | 57 ++++++++++++++++++++++++-------- arch/arm/plat-omap/include/plat/gpio.h | 4 +-- 6 files changed, 67 insertions(+), 40 deletions(-)
<<snip>>
Quoted 25 lines
arch/arm/plat-omap/gpio.c +5
-0@@ -29,6 +29,8 @@#include <asm/mach/irq.h> #include <plat/powerdomain.h> +static struct powerdomain *per_pwrdm; +/* * OMAP1510 GPIO registers */ @@ -207,6 +209,9 @@ struct gpio_bank {u32 dbck_enable_mask; }; +static void omap3_gpio_restore_context (void ); +static void omap3_gpio_save_context (void ); +#define METHOD_MPUIO 0#define METHOD_GPIO_1510 1#define METHOD_GPIO_1610 2
arch/arm/plat-omap/gpio.c static int __init _omap_gpio_init(void) · line 1787
Quoted 5 lines
arch/arm/plat-omap/gpio.c +2
-0@@ -1778,6 +1783,8 @@ static int __init _omap_gpio_init(void) }#endif +if (cpu_class_is_omap2 ()) + per_pwrdm =pwrdm_lookup ("per_pwrdm" );
"per_pwrdm" is not available for OMAP24xx.
Quoted 7 lines
arch/arm/plat-omap/gpio.c +0
-0#ifdef CONFIG_ARCH_OMAP15XX if (cpu_is_omap15xx ()) {@@ -2074,14 +2081,22 @@ static struct sys_device omap_gpio_device = {static int workaround_enabled;
arch/arm/plat-omap/gpio.c static struct sys_device omap_gpio_device = { · line 2090
Quoted 10 lines
arch/arm/plat-omap/gpio.c +6
-3-void omap2_gpio_prepare_for_idle (int power_state) +void omap2_gpio_prepare_for_idle (void ) { -int i, c =0 ; -int min =0 ; +int i, c =0 , min =0 ; +int per_next_state; + +if (!per_pwrdm) +return ;
"per_pwrdm" is not available for OMAP24xx. Hence this breaks the omap2_gpio_prepare_for_idle() path for OMAP2.
In OMAP2420, all gpio banks are in wakeup domain and in OMAP2430 GPIO banks 1-4 are in wakeup domain & GPIO5 is in core domain.
-V Charulatha
arch/arm/plat-omap/gpio.c static struct sys_device omap_gpio_device = { · line 2097
Quoted 7 lines
arch/arm/plat-omap/gpio.c +4
-0+ + per_next_state =pwrdm_read_next_pwrst (per_pwrdm); +if (per_next_state >=PWRDM_POWER_INACTIVE ) +return ;if (cpu_is_omap34xx ()) min =1 ;
<<snip>>
Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
"Varadarajan, Charulatha" <[email protected]> writes:
[...]
Quoted 14 lines
arch/arm/plat-omap/gpio.c static struct sys_device omap_gpio_device = { · line 2090
Quoted 10 lines
arch/arm/plat-omap/gpio.c +6
-3-void omap2_gpio_prepare_for_idle (int power_state) +void omap2_gpio_prepare_for_idle (void ) { -int i, c =0 ; -int min =0 ; +int i, c =0 , min =0 ; +int per_next_state; + +if (!per_pwrdm) +return ;"
per_pwrdm" is not available for OMAP24xx. Hence this breaks theomap2_gpio_prepare_for_idle()path for OMAP2.
Quoted 3 lines
In OMAP2420, all gpio banks are in wakeup domain and in OMAP2430 GPIO banks 1-4 are in wakeup domain & GPIO5 is in core domain.
Sure, this patch is just a proof of concept that we can move the GPIO idle management out of the interrupts disabled path.
When you adapt this approach to your conversion series, since you have already broken these functions up to be per-bank, you can have a per-bank powerdomain that can be configured per-SoC.
Kevin
RE: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
In reply to Kevin HilmanQuoted 46 lines
-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Tuesday, September 14, 2010 4:33 AM
To: [email protected]
Cc: Varadarajan, Charulatha; Basak, Partha; Tero Kristo
Subject: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle pathFrom: Kevin Hilman <[email protected]>
Currently, we wait until late in the idle path where interrupts are disabled to do runtime-PM-like management for certain special-case devices like GPIO.
As a prerequiste to moving GPIO to the new runtime PM framework, move this runtime-PM-like code out of the late idle path into new device idle and resume functions that can be called before interrupts are disabled by CPUidle and/or suspend.
In addition, move all the GPIO-specific logic into the GPIO core instead of keeping GPIO-specific knowledge of power-states, context saving etc. in the PM core.
Also, call the new device-idle and -resume methods from CPUidle and static suspend path.
Signed-off-by Kevin Hilman <[email protected]>--- arch/arm/mach-omap2/cpuidle34xx.c | 4 ++ arch/arm/mach-omap2/pm.h | 2 + arch/arm/mach-omap2/pm24xx.c | 2 +- arch/arm/mach-omap2/pm34xx.c | 38 +++++++++------------ arch/arm/plat-omap/gpio.c | 57 ++++++++++++++++++++++++-------- arch/arm/plat-omap/include/plat/gpio.h | 4 +-- 6 files changed, 67 insertions(+), 40 deletions(-)arch/arm/mach-omap2/cpuidle34xx.c +0
-0@@ -274,9 +274,13 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
arch/arm/mach-omap2/cpuidle34xx.c static int omap3_enter_idle_bm(struct · line 284
Quoted 10 lines
arch/arm/mach-omap2/cpuidle34xx.c +4
-0pwrdm_set_next_pwrst (per_pd, per_next_state); select_state: +omap3_device_idle (); + dev->last_state = new_state; ret =omap3_enter_idle (dev, new_state); +omap3_device_resume (); +
In the generic cpu_idle() in process.c, interrupts are already disabled before control comes to cpuidle_idle_call() via pm_idle()
local_irq_disable();
if (hlt_counter) {
local_irq_enable();
cpu_relax();
} else {
stop_critical_timings();
pm_idle();
start_critical_timings();
/*
* This will eventually be removed - pm_idle
* functions should always return with IRQs
* enabled.
*/
WARN_ON(irqs_disabled());
local_irq_enable();
}omap3_enter_idle_bm() will be called from inside cpuidle_idle_call() via target_state->enter(dev, target_state).
So, interrupts are already disabled here.
Am I missing something?
Quoted 288 lines
arch/arm/mach-omap2/cpuidle34xx.c +0
-0/* Restore original PER state if it was modified */ if (per_next_state != per_saved_state)arch/arm/mach-omap2/cpuidle34xx.c +0
-0pwrdm_set_next_pwrst (per_pd, per_saved_state);arch/arm/mach-omap2/pm.h +2
-0@@ -22,6 +22,8 @@ extern void omap_sram_idle(void);extern int omap3_can_sleep (void );extern int set_pwrdm_state (struct powerdomain *pwrdm,u32 state);extern int omap3_idle_init (void ); +extern void omap3_device_idle (void ); +extern void omap3_device_resume (void );struct cpuidle_params {u8 valid;arch/arm/mach-omap2/pm24xx.c +1
-1@@ -106,7 +106,7 @@ static void omap2_enter_full_retention(void) l =omap_ctrl_readl (OMAP2_CONTROL_DEVCONF0 ) |OMAP24XX_USBSTANDBYCTRL ;omap_ctrl_writel (l,OMAP2_CONTROL_DEVCONF0 ); -omap2_gpio_prepare_for_idle (PWRDM_POWER_RET ); +omap2_gpio_prepare_for_idle ();if (omap2_pm_debug) {arch/arm/mach-omap2/pm24xx.c +0
-0omap2_pm_dump (0 ,0 ,0 );arch/arm/mach-omap2/pm34xx.c +16
-22@@ -74,16 +74,6 @@ static struct powerdomain *mpu_pwrdm, *neon_pwrdm;static struct powerdomain *core_pwrdm, *per_pwrdm;static struct powerdomain *cam_pwrdm; -static inline void omap3_per_save_context (void ) -{ -omap_gpio_save_context (); -} - -static inline void omap3_per_restore_context (void ) -{ -omap_gpio_restore_context (); -} -static void omap3_enable_io_chain (void ) {int timeout =0 ;@@ -332,6 +322,16 @@ static void restore_table_entry(void)restore_control_register (control_reg_value); } +void omap3_device_idle (void ) +{ +omap2_gpio_prepare_for_idle (); +} + +void omap3_device_resume (void ) +{ +omap2_gpio_resume_after_idle (); +} +void omap_sram_idle (void ) {/* Variable to tell what needs to be saved and restored @@ -344,7 +344,7 @@ void omap_sram_idle(void)int mpu_next_state =PWRDM_POWER_ON ;int per_next_state =PWRDM_POWER_ON ;int core_next_state =PWRDM_POWER_ON ; -int core_prev_state, per_prev_state; +int core_prev_state;u32 sdrc_pwr =0 ;if (!_omap_sram_idle)@@ -387,12 +387,9 @@ void omap_sram_idle(void) }/* PER */ -if (per_next_state <PWRDM_POWER_ON ) { +if (per_next_state <PWRDM_POWER_ON )omap_uart_prepare_idle (2 ); -omap2_gpio_prepare_for_idle (per_next_state); -if (per_next_state ==PWRDM_POWER_OFF ) -omap3_per_save_context (); - } +/* CORE */ if (core_next_state <PWRDM_POWER_ON ) {@@ -454,13 +451,8 @@ void omap_sram_idle(void)omap3_intc_resume_idle ();/* PER */ -if (per_next_state <PWRDM_POWER_ON ) { - per_prev_state =pwrdm_read_prev_pwrst (per_pwrdm); -omap2_gpio_resume_after_idle (); -if (per_prev_state ==PWRDM_POWER_OFF ) -omap3_per_restore_context (); +if (per_next_state <PWRDM_POWER_ON )omap_uart_resume_idle (2 ); - }/* Disable IO-PAD and IO-CHAIN wakeup */ if (omap3_has_io_wakeup() &&@@ -570,6 +562,7 @@ static void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)static int omap3_pm_prepare (void ) {disable_hlt (); +omap3_device_idle ();return 0 ; }@@ -637,6 +630,7 @@ static int omap3_pm_enter(suspend_state_t unused)static void omap3_pm_finish (void ) { +omap3_device_resume ();enable_hlt (); }arch/arm/plat-omap/gpio.c +19
-4@@ -29,6 +29,8 @@#include <asm/mach/irq.h> #include <plat/powerdomain.h> +static struct powerdomain *per_pwrdm; +/* * OMAP1510 GPIO registers */ @@ -207,6 +209,9 @@ struct gpio_bank {u32 dbck_enable_mask; }; +static void omap3_gpio_restore_context (void ); +static void omap3_gpio_save_context (void ); +#define METHOD_MPUIO 0#define METHOD_GPIO_1510 1#define METHOD_GPIO_1610 2@@ -1778,6 +1783,8 @@ static int __init _omap_gpio_init(void) }#endif +if (cpu_class_is_omap2 ()) + per_pwrdm =pwrdm_lookup ("per_pwrdm" );#ifdef CONFIG_ARCH_OMAP15XX if (cpu_is_omap15xx ()) {@@ -2074,14 +2081,22 @@ static struct sys_device omap_gpio_device = {static int workaround_enabled; -void omap2_gpio_prepare_for_idle (int power_state) +void omap2_gpio_prepare_for_idle (void ) { -int i, c =0 ; -int min =0 ; +int i, c =0 , min =0 ; +int per_next_state; + +if (!per_pwrdm) +return ; + + per_next_state =pwrdm_read_next_pwrst (per_pwrdm); +if (per_next_state >=PWRDM_POWER_INACTIVE ) +return ;if (cpu_is_omap34xx ()) min =1 ; + workaround_enabled =0 ;for (i = min; i < gpio_bank_count; i++) {struct gpio_bank *bank = &gpio_bank[i];u32 l1, l2;@@ -2089,7 +2104,7 @@ void omap2_gpio_prepare_for_idle(int power_state)if (bank->dbck_enable_mask)clk_disable (bank->dbck); -if (power_state >PWRDM_POWER_OFF ) +if (per_next_state >PWRDM_POWER_OFF )continue ;arch/arm/plat-omap/gpio.c +22
-7/* If going to OFF, remove triggering for all @@ -2135,20 +2150,35 @@ void omap2_gpio_prepare_for_idle(int power_state) c++; } -if (!c) { - workaround_enabled =0 ; -return ; - } - workaround_enabled =1 ; +if (c) + workaround_enabled =1 ; + +if (cpu_is_omap34xx () && (per_next_state ==PWRDM_POWER_OFF )) +omap3_gpio_save_context (); }void omap2_gpio_resume_after_idle (void ) { -int i; -int min =0 ; +int i, min =0 ; +int per_next_state; + +if (!per_pwrdm) +return ; + + per_next_state =pwrdm_read_next_pwrst (per_pwrdm); +if (per_next_state >=PWRDM_POWER_INACTIVE ) +return ; + +if (cpu_is_omap34xx () && (per_next_state ==PWRDM_POWER_OFF )) { +int per_prev_state =pwrdm_read_prev_pwrst (per_pwrdm); + +if (per_prev_state ==PWRDM_POWER_OFF ) +omap3_gpio_restore_context (); + }if (cpu_is_omap34xx ()) min =1 ; +for (i = min; i < gpio_bank_count; i++) {struct gpio_bank *bank = &gpio_bank[i];arch/arm/plat-omap/gpio.c +2
-3u32 l, gen, gen0, gen1;@@ -2235,14 +2265,13 @@ void omap2_gpio_resume_after_idle(void) } } } - }#endif #ifdef CONFIG_ARCH_OMAP3 /* save the registers of bank 2-6 */ -void omap_gpio_save_context (void ) +static void omap3_gpio_save_context (void ) {int i;@@ -2275,7 +2304,7 @@ void omap_gpio_save_context(void) }/* restore the required registers of bank 2-6 */ -void omap_gpio_restore_context (void ) +static void omap3_gpio_restore_context (void ) {int i;arch/arm/plat-omap/include/plat/gpio.h +1
-4@@ -72,12 +72,10 @@ IH_GPIO_BASE + (nr))extern int omap_gpio_init (void );/* Call from board init only */ -extern void omap2_gpio_prepare_for_idle (int power_state); +extern void omap2_gpio_prepare_for_idle (void );extern void omap2_gpio_resume_after_idle (void );extern void omap_set_gpio_debounce (int gpio,int enable);extern void omap_set_gpio_debounce_time (int gpio,int enable); -extern void omap_gpio_save_context (void ); -extern void omap_gpio_restore_context (void );/*------------------------------------------------------------ -------------*/ /* Wrappers for "new style" GPIO calls, using the new infrastructure Signature · 1 line
1.7.2.1
Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
Quoted 65 lines · Partha
Quoted 36 lines
From: Kevin Hilman <[email protected]>
Currently, we wait until late in the idle path where interrupts are disabled to do runtime-PM-like management for certain special-case devices like GPIO.
As a prerequiste to moving GPIO to the new runtime PM framework, move this runtime-PM-like code out of the late idle path into new device idle and resume functions that can be called before interrupts are disabled by CPUidle and/or suspend.
In addition, move all the GPIO-specific logic into the GPIO core instead of keeping GPIO-specific knowledge of power-states, context saving etc. in the PM core.
Also, call the new device-idle and -resume methods from CPUidle and static suspend path.
Signed-off-by Kevin Hilman <[email protected]>--- arch/arm/mach-omap2/cpuidle34xx.c | 4 ++ arch/arm/mach-omap2/pm.h | 2 + arch/arm/mach-omap2/pm24xx.c | 2 +- arch/arm/mach-omap2/pm34xx.c | 38 +++++++++------------ arch/arm/plat-omap/gpio.c | 57 ++++++++++++++++++++++++-------- arch/arm/plat-omap/include/plat/gpio.h | 4 +-- 6 files changed, 67 insertions(+), 40 deletions(-)arch/arm/mach-omap2/cpuidle34xx.c +0
-0@@ -274,9 +274,13 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,arch/arm/mach-omap2/cpuidle34xx.c static int omap3_enter_idle_bm(struct · line 284
Quoted 10 lines
arch/arm/mach-omap2/cpuidle34xx.c +4
-0pwrdm_set_next_pwrst (per_pd, per_next_state); select_state: +omap3_device_idle (); + dev->last_state = new_state; ret =omap3_enter_idle (dev, new_state); +omap3_device_resume (); +In the generic
cpu_idle()inprocess.c, interrupts are already disabled before control comes tocpuidle_idle_call()viapm_idle()local_irq_disable(); if (hlt_counter) { local_irq_enable(); cpu_relax(); } else { stop_critical_timings(); pm_idle(); start_critical_timings(); /* * This will eventually be removed - pm_idle * functions should always return with IRQs * enabled. */ WARN_ON(irqs_disabled()); local_irq_enable(); }
Quoted 5 lines
omap3_enter_idle_bm()will be called from insidecpuidle_idle_call()viatarget_state->enter(dev, target_state).
So, interrupts are already disabled here.Am I missing something?
You're right.
I knew this was the case for !CPUIDLE setup, but had thought (without testing) that the CPUidle core had re-enabled interrupts during the governor selection process etc.
While I investigate ways to manage this in CPUidle, the following should be fine for now to include with $SUBJECT patch.
Kevin
arch/arm/mach-omap2/cpuidle34xx.c +8 -0
@@ -245,6 +245,14 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev, goto select_state; } +/* +* Enable IRQs during the device activity checking and idle management. +* IRQs are later (re)disabled when entering the actual idle function. +* Device idle management that is using runtime PM needs to have +* interrupts enabled when calling into the runtime PM core. +*/ +local_irq_enable (); + cx =cpuidle_get_statedata (state); core_next_state = cx->core_state;
k
RE: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
Quoted 117 lines
-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Tuesday, September 14, 2010 10:28 PM
To: Basak, Partha
Cc: [email protected]; Varadarajan, Charulatha; Tero Kristo
Subject: Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle pathQuoted 7 lines · Partha
Quoted 7 lines
From: Kevin Hilman <[email protected]>
Currently, we wait until late in the idle path where interrupts are disabled to do runtime-PM-like management for certain special-case devices like GPIO.
As a prerequiste to moving GPIO to the new runtime PM
framework, move
Quoted 11 lines
Quoted 11 lines
this runtime-PM-like code out of the late idle path into new device idle and resume functions that can be called before interrupts are disabled by CPUidle and/or suspend.
In addition, move all the GPIO-specific logic into the GPIO core instead of keeping GPIO-specific knowledge of power-states, context saving etc. in the PM core.
Also, call the new device-idle and -resume methods from CPUidle and static suspend path.
Quoted 6 lines
Quoted 6 lines
Signed-off-by Kevin Hilman <[email protected]>--- arch/arm/mach-omap2/cpuidle34xx.c | 4 ++ arch/arm/mach-omap2/pm.h | 2 + arch/arm/mach-omap2/pm24xx.c | 2 +- arch/arm/mach-omap2/pm34xx.c | 38+++++++++------------
Quoted 20 lines
Quoted 20 lines
arch/arm/plat-omap/gpio.c | 57 ++++++++++++++++++++++++-------- arch/arm/plat-omap/include/plat/gpio.h | 4 +-- 6 files changed, 67 insertions(+), 40 deletions(-)arch/arm/mach-omap2/cpuidle34xx.c +2
-0@@ -274,9 +274,13 @@ static int omap3_enter_idle_bm(structcpuidle_device *dev,pwrdm_set_next_pwrst (per_pd ,per_next_state ); select_state: +omap3_device_idle (); + dev->last_state = new_state; ret =omap3_enter_idle (dev, new_state);Quoted 3 lines
arch/arm/mach-omap2/cpuidle34xx.c static int omap3_enter_idle_bm(struct · line 284
Quoted 2 lines
arch/arm/mach-omap2/cpuidle34xx.c +2
-0+omap3_device_resume (); +In the generic
cpu_idle()inprocess.c, interrupts arealready disabled
Quoted 11 lines
before control comes to
cpuidle_idle_call()viapm_idle()local_irq_disable(); if (hlt_counter) { local_irq_enable(); cpu_relax(); } else { stop_critical_timings(); pm_idle(); start_critical_timings(); /* * This will eventually beremoved -
pm_idleQuoted 1 line
* functions should always
return with IRQs
Quoted 7 lines
* enabled. */ WARN_ON(irqs_disabled()); local_irq_enable(); }
omap3_enter_idle_bm()will be called from inside
cpuidle_idle_call()Quoted 4 lines
via
target_state->enter(dev, target_state).
So, interrupts are already disabled here.Am I missing something?
You're right.
I knew this was the case for !CPUIDLE setup, but had thought (without testing) that the CPUidle core had re-enabled interrupts during the governor selection process etc.
While I investigate ways to manage this in CPUidle, the following should
be fine for now to include with $SUBJECT patch.Kevin
arch/arm/mach-omap2/cpuidle34xx.c +2
-0@@ -245,6 +245,14 @@ static int omap3_enter_idle_bm(structcpuidle_device *dev, goto select_state; } +/* +* Enable IRQs during the device activity checking and idle management.
arch/arm/mach-omap2/cpuidle34xx.c +1
-0+* IRQs are later (re)disabled when entering the actual idle function.
arch/arm/mach-omap2/cpuidle34xx.c static int omap3_enter_idle_bm(struct cpuidle_device *dev, · line 257
Quoted 7 lines
arch/arm/mach-omap2/cpuidle34xx.c +5
-0+* Device idle management that is using runtime PM needs to have +* interrupts enabled when calling into the runtime PM core. +*/ +local_irq_enable (); + cx =cpuidle_get_statedata (state); core_next_state = cx->core_state;
OK. We will base on top of this patch.
Quoted 2 lines
k
RE: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
In reply to Kevin HilmanQuoted 116 lines
-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Tuesday, September 14, 2010 10:28 PM
To: Basak, Partha
Cc: [email protected]; Varadarajan, Charulatha; Tero Kristo
Subject: Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle pathQuoted 7 lines · Partha
Quoted 7 lines
From: Kevin Hilman <[email protected]>
Currently, we wait until late in the idle path where interrupts are disabled to do runtime-PM-like management for certain special-case devices like GPIO.
As a prerequiste to moving GPIO to the new runtime PM
framework, move
Quoted 11 lines
Quoted 11 lines
this runtime-PM-like code out of the late idle path into new device idle and resume functions that can be called before interrupts are disabled by CPUidle and/or suspend.
In addition, move all the GPIO-specific logic into the GPIO core instead of keeping GPIO-specific knowledge of power-states, context saving etc. in the PM core.
Also, call the new device-idle and -resume methods from CPUidle and static suspend path.
Quoted 6 lines
Quoted 6 lines
Signed-off-by Kevin Hilman <[email protected]>--- arch/arm/mach-omap2/cpuidle34xx.c | 4 ++ arch/arm/mach-omap2/pm.h | 2 + arch/arm/mach-omap2/pm24xx.c | 2 +- arch/arm/mach-omap2/pm34xx.c | 38+++++++++------------
Quoted 20 lines
Quoted 20 lines
arch/arm/plat-omap/gpio.c | 57 ++++++++++++++++++++++++-------- arch/arm/plat-omap/include/plat/gpio.h | 4 +-- 6 files changed, 67 insertions(+), 40 deletions(-)arch/arm/mach-omap2/cpuidle34xx.c +2
-0@@ -274,9 +274,13 @@ static int omap3_enter_idle_bm(structcpuidle_device *dev,pwrdm_set_next_pwrst (per_pd ,per_next_state ); select_state: +omap3_device_idle (); + dev->last_state = new_state; ret =omap3_enter_idle (dev, new_state);Quoted 3 lines
arch/arm/mach-omap2/cpuidle34xx.c static int omap3_enter_idle_bm(struct · line 284
Quoted 2 lines
arch/arm/mach-omap2/cpuidle34xx.c +2
-0+omap3_device_resume (); +In the generic
cpu_idle()inprocess.c, interrupts arealready disabled
Quoted 11 lines
before control comes to
cpuidle_idle_call()viapm_idle()local_irq_disable(); if (hlt_counter) { local_irq_enable(); cpu_relax(); } else { stop_critical_timings(); pm_idle(); start_critical_timings(); /* * This will eventually beremoved -
pm_idleQuoted 1 line
* functions should always
return with IRQs
Quoted 7 lines
* enabled. */ WARN_ON(irqs_disabled()); local_irq_enable(); }
omap3_enter_idle_bm()will be called from inside
cpuidle_idle_call()Quoted 4 lines
via
target_state->enter(dev, target_state).
So, interrupts are already disabled here.Am I missing something?
You're right.
I knew this was the case for !CPUIDLE setup, but had thought (without testing) that the CPUidle core had re-enabled interrupts during the governor selection process etc.
While I investigate ways to manage this in CPUidle, the following should
be fine for now to include with $SUBJECT patch.Kevin
arch/arm/mach-omap2/cpuidle34xx.c +2
-0@@ -245,6 +245,14 @@ static int omap3_enter_idle_bm(structcpuidle_device *dev, goto select_state; } +/* +* Enable IRQs during the device activity checking and idle management.
arch/arm/mach-omap2/cpuidle34xx.c +1
-0+* IRQs are later (re)disabled when entering the actual idle function.
arch/arm/mach-omap2/cpuidle34xx.c static int omap3_enter_idle_bm(struct cpuidle_device *dev, · line 254
Quoted 4 lines
arch/arm/mach-omap2/cpuidle34xx.c +4
-0+* Device idle management that is using runtime PM needs to have +* interrupts enabled when calling into the runtime PM core. +*/ +local_irq_enable ();
After put_sync() retuns, there will be a time window where interrupts are enabled but clocks are disabled before the interrupts are disabled again. Accessing any register to service a device interrupt coming during this window will lead to a crash for cases where iclk and fclks are same and we have the iclk defined as the main_clk as well.
Same argument holds while returning from Idle. We are facing this issue for OMAP3 GPIO while trying to define the main_clk = interface clock based on your other commment.
Quoted 6 lines
arch/arm/mach-omap2/cpuidle34xx.c +1
-0+ cx =cpuidle_get_statedata (state); core_next_state = cx->core_state;k
Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
Quoted 127 lines · Partha
Quoted 116 lines
-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Tuesday, September 14, 2010 10:28 PM
To: Basak, Partha
Cc: [email protected]; Varadarajan, Charulatha; Tero Kristo
Subject: Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle pathQuoted 7 lines · Partha
Quoted 7 lines
From: Kevin Hilman <[email protected]>
Currently, we wait until late in the idle path where interrupts are disabled to do runtime-PM-like management for certain special-case devices like GPIO.
As a prerequiste to moving GPIO to the new runtime PM
framework, move
Quoted 11 lines
Quoted 11 lines
this runtime-PM-like code out of the late idle path into new device idle and resume functions that can be called before interrupts are disabled by CPUidle and/or suspend.
In addition, move all the GPIO-specific logic into the GPIO core instead of keeping GPIO-specific knowledge of power-states, context saving etc. in the PM core.
Also, call the new device-idle and -resume methods from CPUidle and static suspend path.
Quoted 6 lines
Quoted 6 lines
Signed-off-by Kevin Hilman <[email protected]>--- arch/arm/mach-omap2/cpuidle34xx.c | 4 ++ arch/arm/mach-omap2/pm.h | 2 + arch/arm/mach-omap2/pm24xx.c | 2 +- arch/arm/mach-omap2/pm34xx.c | 38+++++++++------------
Quoted 20 lines
Quoted 20 lines
arch/arm/plat-omap/gpio.c | 57 ++++++++++++++++++++++++-------- arch/arm/plat-omap/include/plat/gpio.h | 4 +-- 6 files changed, 67 insertions(+), 40 deletions(-)arch/arm/mach-omap2/cpuidle34xx.c +2
-0@@ -274,9 +274,13 @@ static int omap3_enter_idle_bm(structcpuidle_device *dev,pwrdm_set_next_pwrst (per_pd ,per_next_state ); select_state: +omap3_device_idle (); + dev->last_state = new_state; ret =omap3_enter_idle (dev, new_state);Quoted 3 lines
arch/arm/mach-omap2/cpuidle34xx.c static int omap3_enter_idle_bm(struct · line 284
Quoted 2 lines
arch/arm/mach-omap2/cpuidle34xx.c +2
-0+omap3_device_resume (); +In the generic
cpu_idle()inprocess.c, interrupts arealready disabled
Quoted 11 lines
before control comes to
cpuidle_idle_call()viapm_idle()local_irq_disable(); if (hlt_counter) { local_irq_enable(); cpu_relax(); } else { stop_critical_timings(); pm_idle(); start_critical_timings(); /* * This will eventually beremoved -
pm_idleQuoted 1 line
* functions should always
return with IRQs
Quoted 7 lines
* enabled. */ WARN_ON(irqs_disabled()); local_irq_enable(); }
omap3_enter_idle_bm()will be called from inside
cpuidle_idle_call()Quoted 4 lines
via
target_state->enter(dev, target_state).
So, interrupts are already disabled here.Am I missing something?
You're right.
I knew this was the case for !CPUIDLE setup, but had thought (without testing) that the CPUidle core had re-enabled interrupts during the governor selection process etc.
While I investigate ways to manage this in CPUidle, the following should
be fine for now to include with $SUBJECT patch.Kevin
arch/arm/mach-omap2/cpuidle34xx.c +2
-0@@ -245,6 +245,14 @@ static int omap3_enter_idle_bm(structcpuidle_device *dev, goto select_state; } +/* +* Enable IRQs during the device activity checking and idle management.
arch/arm/mach-omap2/cpuidle34xx.c +1
-0+* IRQs are later (re)disabled when entering the actual idle function.
arch/arm/mach-omap2/cpuidle34xx.c static int omap3_enter_idle_bm(struct cpuidle_device *dev, · line 254
Quoted 4 lines
arch/arm/mach-omap2/cpuidle34xx.c +4
-0+* Device idle management that is using runtime PM needs to have +* interrupts enabled when calling into the runtime PM core. +*/ +local_irq_enable ();After
put_sync()retuns, there will be a time window where interrupts are enabled but clocks are disabled before the interrupts are disabled again. Accessing any register to service a device interrupt coming during this window will lead to a crash for cases where iclk and fclks are same and we have the iclk defined as themain_clkas well.
Quoted 2 lines
Same argument holds while returning from Idle. We are facing this issue for OMAP3 GPIO while trying to define the
main_clk= interface clock based on your other commment.
This is the same problem as has existed in static/suspend resume.
IOW, if it's possible for a device interrupt to arrive between device suspend and actual suspend, then the device interrupt should be disabled in the suspend hook (or runtime_suspend hook in your case.)
The catch is how to handle these interrupts if they are wakeup sources.
If these interrupt are wakeup sources, then they should not be disabled in the [runtime_]suspend path, but rather the ISR for that device should just do a get_sync() and continue.
Kevin
RE: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
Quoted 156 lines
-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Thursday, September 23, 2010 9:08 PM
To: Basak, Partha
Cc: [email protected]; Varadarajan, Charulatha; Tero Kristo
Subject: Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle pathQuoted 7 lines · Partha
Quoted 7 lines
-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Tuesday, September 14, 2010 10:28 PM
To: Basak, Partha
Cc: [email protected]; Varadarajan, Charulatha;Tero Kristo
Quoted 8 lines
Quoted 8 lines
Subject: Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
Quoted 3 lines · Partha
Quoted 3 lines
From: Kevin Hilman <[email protected]>
Currently, we wait until late in the idle path where
interrupts are
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
disabled to do runtime-PM-like management for certain
special-case
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
devices like GPIO.
As a prerequiste to moving GPIO to the new runtime PM
framework, move
Quoted 1 line
Quoted 1 line
this runtime-PM-like code out of the late idle path
into new device
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
idle and resume functions that can be called before
interrupts are
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
disabled by CPUidle and/or suspend.
In addition, move all the GPIO-specific logic into the GPIO core instead of keeping GPIO-specific knowledge of
power-states, context
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
saving etc. in the PM core.
Also, call the new device-idle and -resume methods from
CPUidle and
Quoted 55 lines
Quoted 55 lines
Quoted 8 lines
Quoted 8 lines
static suspend path.
Signed-off-by Kevin Hilman <[email protected]>--- arch/arm/mach-omap2/cpuidle34xx.c | 4 ++ arch/arm/mach-omap2/pm.h | 2 + arch/arm/mach-omap2/pm24xx.c | 2 +- arch/arm/mach-omap2/pm34xx.c | 38+++++++++------------
Quoted 20 lines
Quoted 20 lines
arch/arm/plat-omap/gpio.c | 57 ++++++++++++++++++++++++-------- arch/arm/plat-omap/include/plat/gpio.h | 4 +-- 6 files changed, 67 insertions(+), 40 deletions(-)arch/arm/mach-omap2/cpuidle34xx.c +2
-0@@ -274,9 +274,13 @@ static int omap3_enter_idle_bm(structcpuidle_device *dev,pwrdm_set_next_pwrst (per_pd ,per_next_state ); select_state: +omap3_device_idle (); + dev->last_state = new_state; ret =omap3_enter_idle (dev, new_state);Quoted 3 lines
arch/arm/mach-omap2/cpuidle34xx.c static int omap3_enter_idle_bm(struct · line 284
Quoted 2 lines
arch/arm/mach-omap2/cpuidle34xx.c +2
-0+omap3_device_resume (); +In the generic
cpu_idle()inprocess.c, interrupts arealready disabled
Quoted 11 lines
before control comes to
cpuidle_idle_call()viapm_idle()local_irq_disable(); if (hlt_counter) { local_irq_enable(); cpu_relax(); } else { stop_critical_timings(); pm_idle(); start_critical_timings(); /* * This will eventually beremoved -
pm_idleQuoted 1 line
* functions should always
return with IRQs
Quoted 7 lines
* enabled. */ WARN_ON(irqs_disabled()); local_irq_enable(); }
omap3_enter_idle_bm()will be called from inside
cpuidle_idle_call()Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
via
target_state->enter(dev, target_state).
So, interrupts are already disabled here.Am I missing something?
You're right.
I knew this was the case for !CPUIDLE setup, but had
thought (without
Quoted 19 lines
Quoted 19 lines
testing) that the CPUidle core had re-enabled interrupts during the governor selection process etc.
While I investigate ways to manage this in CPUidle, the following should
be fine for now to include with $SUBJECT patch.Kevin
arch/arm/mach-omap2/cpuidle34xx.c +0
-0@@ -245,6 +245,14 @@ static int omap3_enter_idle_bm(structcpuidle_device *dev, goto select_state; }Quoted 11 lines
arch/arm/mach-omap2/cpuidle34xx.c static int omap3_enter_idle_bm(struct cpuidle_device *dev, · line 254
Quoted 9 lines
arch/arm/mach-omap2/cpuidle34xx.c +2
-0+/* +* Enable IRQs during the device activity checking and idle management.
arch/arm/mach-omap2/cpuidle34xx.c +1
-0+* IRQs are later (re)disabled when entering the actual idle function.
arch/arm/mach-omap2/cpuidle34xx.c +4
-0+* Device idle management that is using runtime PM needs to have +* interrupts enabled when calling into the runtime PM core. +*/ +local_irq_enable ();After
put_sync()retuns, there will be a time window whereinterrupts
Quoted 1 line
are enabled but clocks are disabled before the interrupts
are disabled again.
Quoted 1 line
Accessing any register to service a device interrupt coming
during this window
Quoted 1 line
will lead to a crash for cases where iclk and fclks are
same and we have the
Quoted 3 lines
iclk defined as the
main_clkas well.Same argument holds while returning from Idle. We are
facing this issue for OMAP3
Quoted 1 line
GPIO while trying to define the
main_clk= interface clockbased on your other commment.
Quoted 8 lines
This is the same problem as has existed in static/suspend resume.
IOW, if it's possible for a device interrupt to arrive between device suspend and actual suspend, then the device interrupt should be disabled in the suspend hook (or
runtime_suspendhook in your case.)The catch is how to handle these interrupts if they are wakeup sources.
Precisely.
For example, the ethernet interrupts over GPIO are causing problem.
Quoted 6 lines
If these interrupt are wakeup sources, then they should not be disabled
in the [runtime_]suspend path, but rather the ISR for that device should
just do aget_sync()and continue.
We cannot do a get_sync() from ISR context, right?
For GPIOs in particular, this problem can be resolved if we do not tie up the interface clock as the main_clk. So long the interface/slave clock is not also a main_clk & OCPIF_SWSUP_IDLE flag is not set for a hwmod there is no issue, as slave clocks are NOT turned on/off in _enable_clocks() /_disable_clocks() inside hwmod fw.
Alternatively, we could have thought of removing get_sync/put_sync altogether from the Idle path for GPIO. But though this would work fine for OMAP3/OMAP4 & OMAP2420/2430 Wakeup domain GPIOs, but for OMAP2430 CORE domain GPIOs, since it has a separate fclk & iclk, we would still need to cut the fclk in the Idle-path to enable CORE transition, thereby needing a get_sync/put_sync .
If this is OK, we can consider this approach.
Quoted 3 lines
Kevin
Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
Quoted 169 lines · Partha
Quoted 156 lines
-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Thursday, September 23, 2010 9:08 PM
To: Basak, Partha
Cc: [email protected]; Varadarajan, Charulatha; Tero Kristo
Subject: Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle pathQuoted 7 lines · Partha
Quoted 7 lines
-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Tuesday, September 14, 2010 10:28 PM
To: Basak, Partha
Cc: [email protected]; Varadarajan, Charulatha;Tero Kristo
Quoted 8 lines
Quoted 8 lines
Subject: Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
Quoted 3 lines · Partha
Quoted 3 lines
From: Kevin Hilman <[email protected]>
Currently, we wait until late in the idle path where
interrupts are
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
disabled to do runtime-PM-like management for certain
special-case
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
devices like GPIO.
As a prerequiste to moving GPIO to the new runtime PM
framework, move
Quoted 1 line
Quoted 1 line
this runtime-PM-like code out of the late idle path
into new device
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
idle and resume functions that can be called before
interrupts are
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
disabled by CPUidle and/or suspend.
In addition, move all the GPIO-specific logic into the GPIO core instead of keeping GPIO-specific knowledge of
power-states, context
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
saving etc. in the PM core.
Also, call the new device-idle and -resume methods from
CPUidle and
Quoted 55 lines
Quoted 55 lines
Quoted 8 lines
Quoted 8 lines
static suspend path.
Signed-off-by Kevin Hilman <[email protected]>--- arch/arm/mach-omap2/cpuidle34xx.c | 4 ++ arch/arm/mach-omap2/pm.h | 2 + arch/arm/mach-omap2/pm24xx.c | 2 +- arch/arm/mach-omap2/pm34xx.c | 38+++++++++------------
Quoted 20 lines
Quoted 20 lines
arch/arm/plat-omap/gpio.c | 57 ++++++++++++++++++++++++-------- arch/arm/plat-omap/include/plat/gpio.h | 4 +-- 6 files changed, 67 insertions(+), 40 deletions(-)arch/arm/mach-omap2/cpuidle34xx.c +2
-0@@ -274,9 +274,13 @@ static int omap3_enter_idle_bm(structcpuidle_device *dev,pwrdm_set_next_pwrst (per_pd ,per_next_state ); select_state: +omap3_device_idle (); + dev->last_state = new_state; ret =omap3_enter_idle (dev, new_state);Quoted 3 lines
arch/arm/mach-omap2/cpuidle34xx.c static int omap3_enter_idle_bm(struct · line 284
Quoted 2 lines
arch/arm/mach-omap2/cpuidle34xx.c +2
-0+omap3_device_resume (); +In the generic
cpu_idle()inprocess.c, interrupts arealready disabled
Quoted 11 lines
before control comes to
cpuidle_idle_call()viapm_idle()local_irq_disable(); if (hlt_counter) { local_irq_enable(); cpu_relax(); } else { stop_critical_timings(); pm_idle(); start_critical_timings(); /* * This will eventually beremoved -
pm_idleQuoted 1 line
* functions should always
return with IRQs
Quoted 7 lines
* enabled. */ WARN_ON(irqs_disabled()); local_irq_enable(); }
omap3_enter_idle_bm()will be called from inside
cpuidle_idle_call()Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
via
target_state->enter(dev, target_state).
So, interrupts are already disabled here.Am I missing something?
You're right.
I knew this was the case for !CPUIDLE setup, but had
thought (without
Quoted 19 lines
Quoted 19 lines
testing) that the CPUidle core had re-enabled interrupts during the governor selection process etc.
While I investigate ways to manage this in CPUidle, the following should
be fine for now to include with $SUBJECT patch.Kevin
arch/arm/mach-omap2/cpuidle34xx.c +0
-0@@ -245,6 +245,14 @@ static int omap3_enter_idle_bm(structcpuidle_device *dev, goto select_state; }Quoted 11 lines
arch/arm/mach-omap2/cpuidle34xx.c static int omap3_enter_idle_bm(struct cpuidle_device *dev, · line 254
Quoted 9 lines
arch/arm/mach-omap2/cpuidle34xx.c +2
-0+/* +* Enable IRQs during the device activity checking and idle management.
arch/arm/mach-omap2/cpuidle34xx.c +1
-0+* IRQs are later (re)disabled when entering the actual idle function.
arch/arm/mach-omap2/cpuidle34xx.c +4
-0+* Device idle management that is using runtime PM needs to have +* interrupts enabled when calling into the runtime PM core. +*/ +local_irq_enable ();After
put_sync()retuns, there will be a time window whereinterrupts
Quoted 1 line
are enabled but clocks are disabled before the interrupts
are disabled again.
Quoted 1 line
Accessing any register to service a device interrupt coming
during this window
Quoted 1 line
will lead to a crash for cases where iclk and fclks are
same and we have the
Quoted 3 lines
iclk defined as the
main_clkas well.Same argument holds while returning from Idle. We are
facing this issue for OMAP3
Quoted 1 line
GPIO while trying to define the
main_clk= interface clockbased on your other commment.
Quoted 8 lines
This is the same problem as has existed in static/suspend resume.
IOW, if it's possible for a device interrupt to arrive between device suspend and actual suspend, then the device interrupt should be disabled in the suspend hook (or
runtime_suspendhook in your case.)The catch is how to handle these interrupts if they are wakeup sources.
Precisely.
For example, the ethernet interrupts over GPIO are causing problem.Quoted 1 line
Quoted 7 lines
Quoted 5 lines
If these interrupt are wakeup sources, then they should not be disabled
in the [runtime_]suspend path, but rather the ISR for that device should
just do aget_sync()and continue.We cannot do a
get_sync()from ISR context, right?
Right, but we *should* be able to. ;)
I'm still trying to craft a good description of this problem so I can argue better for it on linux-pm.
Until then...
A bit of a hack, but you could do a _get_noresume() (which is safe from interrupt context) and directly call the drivers ->runtime_resume() method, which would be the equivalent of a _get_sync(). Followed of course by a _put() (async version, also interrupt safe) at the end of the ISR to keep the usecount correct.
Quoted 5 lines
For GPIOs in particular, this problem can be resolved if we do not tie up the interface clock as the
main_clk. So long the interface/slave clock is not also amain_clk&OCPIF_SWSUP_IDLEflag is not set for a hwmod there is no issue, as slave clocks are NOT turned on/off in_enable_clocks()/_disable_clocks() inside hwmod fw.
The problem though is that without a main clock, autodeps are not tracked which means that PER might transition independently of the initiator (in this case, MPU) which we do not want either.
I discussed this a little more with Paul, and the root of the problem is that the clock framework really should not disable iclks if iclk autoidle is enabled. This is a change that is needed in the clock framework that might have other side effects so is to late to attempt for this merge window.
So for now, I suggest we try the above hack (well commented in the code, of course.)
Quoted 7 lines
Alternatively, we could have thought of removing get_sync/put_sync altogether from the Idle path for GPIO. But though this would work fine for OMAP3/OMAP4 & OMAP2420/2430 Wakeup domain GPIOs, but for OMAP2430 CORE domain GPIOs, since it has a separate fclk & iclk, we would still need to cut the fclk in the Idle-path to enable CORE transition, thereby needing a get_sync/put_sync .
If this is OK, we can consider this approach.
This would certainly be the ideal solution.
It would be great to get rid of the need for calling GPIO core in the idle path, but I'm not yet convinced we can do that.
For example, there is some other errata handling in my pm-gpio branch (that I've been waiting to rework until after this hwmod conversion.) I would want to be sure that those things can still be correctly handled.
Also How would you propose to handle 2430 CORE GPIOs?
Kevin
Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
Kevin Hilman <[email protected]> writes:
[...]
Quoted 8 lines
Quoted 2 lines
We cannot do a
get_sync()from ISR context, right?Right, but we *should* be able to. ;)
I'm still trying to craft a good description of this problem so I can argue better for it on linux-pm.
Quoted 7 lines
Until then...
A bit of a hack, but you could do a
_get_noresume()(which is safe from interrupt context) and directly call the drivers ->runtime_resume() method, which would be the equivalent of a_get_sync(). Followed of course by a_put()(async version, also interrupt safe) at the end of the ISR to keep the usecount correct.
You probably figured this out already, but I just realized that this won't currently work either as omap_hwmod is using mutexes, and is safe in ISR context either. :(
What about for now just directly enabling (and re-disabling) the hwmod clocks in the ISR using omap_hwmod_[enable|disable]_clocks()
Since this is a core driver in arch/arm/*omap*, you can directly call the omap_hwmod API.
Kevin
RE: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
Quoted 38 lines
-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Friday, September 24, 2010 5:23 AM
To: Basak, Partha
Cc: [email protected]; Varadarajan, Charulatha; Tero Kristo; Cousson, Benoit
Subject: Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle pathKevin Hilman <[email protected]> writes:
[...]
Quoted 6 lines
Quoted 2 lines
We cannot do a
get_sync()from ISR context, right?Right, but we *should* be able to. ;)
I'm still trying to craft a good description of this
problem so I can
Quoted 5 lines
argue better for it on linux-pm.
Until then...
A bit of a hack, but you could do a
_get_noresume()(whichis safe from
Quoted 3 lines
interrupt context) and directly call the drivers ->runtime_resume() method, which would be the equivalent of a
_get_sync(). Followed of course by a_put()(async version, also interrupt safe) atthe end of
Quoted 1 line
the ISR to keep the usecount correct.
You probably figured this out already, but I just realized that this won't currently work either as
omap_hwmodis using mutexes, and is safe in ISR context either. :(
Quoted 6 lines
What about for now just directly enabling (and re-disabling) the hwmod clocks in the ISR using omap_hwmod_[enable|disable]_clocks()
Since this is a core driver in
arch/arm/*omap*, you can directly call theomap_hwmodAPI.
omap_hwmod_[enable/disable]_clocks() use mutex inside & therefore cannot be used in the ISR context
We cannot readily use the _enable_clocks/_disble_clocks directly as they are static APIs.
But we can use the non-mutex versions, of omap_hwmod_enable/idle. (_omap_hwmod_enable/_omap_hwmod_disable)
Do you agree?
Quoted 3 lines
Kevin
Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
Quoted 48 lines · Partha
Quoted 38 lines
-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Friday, September 24, 2010 5:23 AM
To: Basak, Partha
Cc: [email protected]; Varadarajan, Charulatha; Tero Kristo; Cousson, Benoit
Subject: Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle pathKevin Hilman <[email protected]> writes:
[...]
Quoted 6 lines
Quoted 2 lines
We cannot do a
get_sync()from ISR context, right?Right, but we *should* be able to. ;)
I'm still trying to craft a good description of this
problem so I can
Quoted 5 lines
argue better for it on linux-pm.
Until then...
A bit of a hack, but you could do a
_get_noresume()(whichis safe from
Quoted 3 lines
interrupt context) and directly call the drivers ->runtime_resume() method, which would be the equivalent of a
_get_sync(). Followed of course by a_put()(async version, also interrupt safe) atthe end of
Quoted 1 line
the ISR to keep the usecount correct.
You probably figured this out already, but I just realized that this won't currently work either as
omap_hwmodis using mutexes, and is safe in ISR context either. :(Quoted 6 lines
What about for now just directly enabling (and re-disabling) the hwmod clocks in the ISR using omap_hwmod_[enable|disable]_clocks()
Since this is a core driver in
arch/arm/*omap*, you can directly call theomap_hwmodAPI.omap_hwmod_[enable/disable]_clocks() use mutex inside & therefore cannot be used in the ISR context
Quoted 7 lines
We cannot readily use the _enable_clocks/_disble_clocks directly as they are static APIs.
But we can use the non-mutex versions, of omap_hwmod_enable/idle. (_omap_hwmod_enable/_omap_hwmod_disable)
Do you agree?
Yes, I meant to use the non-mutex versions.
Sorry,
Kevin
RE: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
In reply to Kevin HilmanHi,
Quoted 109 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Kevin Hilman
Sent: Tuesday, September 14, 2010 4:33 AM
To: [email protected]
Cc: Varadarajan, Charulatha; Basak, Partha; Tero Kristo
Subject: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle pathFrom: Kevin Hilman <[email protected]>
Currently, we wait until late in the idle path where interrupts are disabled to do runtime-PM-like management for certain special-case devices like GPIO.
As a prerequiste to moving GPIO to the new runtime PM framework, move this runtime-PM-like code out of the late idle path into new device idle and resume functions that can be called before interrupts are disabled by CPUidle and/or suspend.
In addition, move all the GPIO-specific logic into the GPIO core instead of keeping GPIO-specific knowledge of power-states, context saving etc. in the PM core.
Also, call the new device-idle and -resume methods from CPUidle and static suspend path.
Signed-off-by Kevin Hilman <[email protected]>---
arch/arm/mach-omap2/cpuidle34xx.c | 4 ++ arch/arm/mach-omap2/pm.h | 2 + arch/arm/mach-omap2/pm24xx.c | 2 +- arch/arm/mach-omap2/pm34xx.c | 38 +++++++++------------ arch/arm/plat-omap/gpio.c | 57 ++++++++++++++++++++++++-------- arch/arm/plat-omap/include/plat/gpio.h | 4 +-- 6 files changed, 67 insertions(+), 40 deletions(-)arch/arm/mach-omap2/cpuidle34xx.c +0
-0@@ -274,9 +274,13 @@ static int omap3_enter_idle_bm(structcpuidle_device *dev,pwrdm_set_next_pwrst (per_pd ,per_next_state );
select_state:arch/arm/mach-omap2/cpuidle34xx.c +2
-0+omap3_device_idle (); +dev->last_state = new_state; ret = omap3_enter_idle(dev, new_state);arch/arm/mach-omap2/cpuidle34xx.c +2
-0+omap3_device_resume (); +/* Restore original PER state if it was modified */ if (per_next_state != per_saved_state) pwrdm_set_next_pwrst(per_pd, per_saved_state);arch/arm/mach-omap2/pm.h +2
-0@@ -22,6 +22,8 @@ extern void omap_sram_idle(void);extern int omap3_can_sleep (void );extern int set_pwrdm_state (struct powerdomain *pwrdm,u32 state);extern int omap3_idle_init (void ); +extern void omap3_device_idle (void ); +extern void omap3_device_resume (void );struct cpuidle_params {u8 valid;arch/arm/mach-omap2/pm24xx.c +1
-1@@ -106,7 +106,7 @@ static void omap2_enter_full_retention(void) l =omap_ctrl_readl (OMAP2_CONTROL_DEVCONF0 ) |OMAP24XX_USBSTANDBYCTRL ;omap_ctrl_writel (l,OMAP2_CONTROL_DEVCONF0 ); -omap2_gpio_prepare_for_idle (PWRDM_POWER_RET ); +omap2_gpio_prepare_for_idle ();if (omap2_pm_debug) {omap2_pm_dump(0, 0, 0);arch/arm/mach-omap2/pm34xx.c +0
-10@@ -74,16 +74,6 @@ static struct powerdomain *mpu_pwrdm, *neon_pwrdm;static struct powerdomain *core_pwrdm, *per_pwrdm;static struct powerdomain *cam_pwrdm; -static inline void omap3_per_save_context (void ) -{ -omap_gpio_save_context (); -} - -static inline void omap3_per_restore_context (void ) -{ -omap_gpio_restore_context (); -} -static void omap3_enable_io_chain (void ) {int timeout =0 ;
arch/arm/mach-omap2/pm34xx.c static void restore_table_entry(void) · line 329
Quoted 8 lines
arch/arm/mach-omap2/pm34xx.c +5
-0@@ -332,6 +322,16 @@ static void restore_table_entry(void)restore_control_register (control_reg_value); } +void omap3_device_idle (void ) +{ +omap2_gpio_prepare_for_idle (); +} +
Is not it is a good idea to pass the new_state as the parameter for the driver calls? It will reduce each individual drivers reading the PRCM register to findout the next state. This might save some time in the idle loop.
arch/arm/mach-omap2/pm34xx.c static void restore_table_entry(void) · line 334
Quoted 5 lines
arch/arm/mach-omap2/pm34xx.c +5
-0+void omap3_device_resume (void ) +{ +omap2_gpio_resume_after_idle (); +} +
Here we will need to pass the next_state as well as previous_state as parameters. If we agree to pass the parameters.
~Hema
Quoted 225 lines
arch/arm/mach-omap2/pm34xx.c +6
-12void omap_sram_idle (void ) {/* Variable to tell what needs to be saved and restored @@ -344,7 +344,7 @@ void omap_sram_idle(void)int mpu_next_state =PWRDM_POWER_ON ;int per_next_state =PWRDM_POWER_ON ;int core_next_state =PWRDM_POWER_ON ; -int core_prev_state, per_prev_state; +int core_prev_state;u32 sdrc_pwr =0 ;if (!_omap_sram_idle)@@ -387,12 +387,9 @@ void omap_sram_idle(void) }/* PER */ -if (per_next_state <PWRDM_POWER_ON ) { +if (per_next_state <PWRDM_POWER_ON )omap_uart_prepare_idle (2 ); -omap2_gpio_prepare_for_idle (per_next_state); -if (per_next_state ==PWRDM_POWER_OFF ) -omap3_per_save_context (); - } +/* CORE */ if (core_next_state <PWRDM_POWER_ON ) {@@ -454,13 +451,8 @@ void omap_sram_idle(void)omap3_intc_resume_idle ();/* PER */ -if (per_next_state <PWRDM_POWER_ON ) { - per_prev_state =pwrdm_read_prev_pwrst (per_pwrdm); -omap2_gpio_resume_after_idle (); -if (per_prev_state ==PWRDM_POWER_OFF ) -omap3_per_restore_context (); +if (per_next_state <PWRDM_POWER_ON )omap_uart_resume_idle (2 ); - }/* Disable IO-PAD and IO-CHAIN wakeup */ if (omap3_has_io_wakeup() &&@@ -570,6 +562,7 @@ static void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)static int omap3_pm_prepare (void ) {disable_hlt (); +omap3_device_idle ();return 0 ; }@@ -637,6 +630,7 @@ static int omap3_pm_enter(suspend_state_t unused)static void omap3_pm_finish (void ) { +omap3_device_resume ();enable_hlt (); }arch/arm/plat-omap/gpio.c +41
-11@@ -29,6 +29,8 @@#include <asm/mach/irq.h> #include <plat/powerdomain.h> +static struct powerdomain *per_pwrdm; +/* * OMAP1510 GPIO registers */ @@ -207,6 +209,9 @@ struct gpio_bank {u32 dbck_enable_mask; }; +static void omap3_gpio_restore_context (void ); +static void omap3_gpio_save_context (void ); +#define METHOD_MPUIO 0#define METHOD_GPIO_1510 1#define METHOD_GPIO_1610 2@@ -1778,6 +1783,8 @@ static int __init _omap_gpio_init(void) }#endif +if (cpu_class_is_omap2 ()) + per_pwrdm =pwrdm_lookup ("per_pwrdm" );#ifdef CONFIG_ARCH_OMAP15XX if (cpu_is_omap15xx ()) {@@ -2074,14 +2081,22 @@ static struct sys_device omap_gpio_device = {static int workaround_enabled; -void omap2_gpio_prepare_for_idle (int power_state) +void omap2_gpio_prepare_for_idle (void ) { -int i, c =0 ; -int min =0 ; +int i, c =0 , min =0 ; +int per_next_state; + +if (!per_pwrdm) +return ; + + per_next_state =pwrdm_read_next_pwrst (per_pwrdm); +if (per_next_state >=PWRDM_POWER_INACTIVE ) +return ;if (cpu_is_omap34xx ()) min =1 ; + workaround_enabled =0 ;for (i = min; i < gpio_bank_count; i++) {struct gpio_bank *bank = &gpio_bank[i];u32 l1, l2;@@ -2089,7 +2104,7 @@ void omap2_gpio_prepare_for_idle(int power_state)if (bank->dbck_enable_mask)clk_disable (bank->dbck); -if (power_state >PWRDM_POWER_OFF ) +if (per_next_state >PWRDM_POWER_OFF )continue ;/* If going to OFF, remove triggering for all @@ -2135,20 +2150,35 @@ void omap2_gpio_prepare_for_idle(int power_state) c++; } -if (!c) { - workaround_enabled =0 ; -return ; - } - workaround_enabled =1 ; +if (c) + workaround_enabled =1 ; + +if (cpu_is_omap34xx () && (per_next_state ==PWRDM_POWER_OFF )) +omap3_gpio_save_context (); }void omap2_gpio_resume_after_idle (void ) { -int i; -int min =0 ; +int i, min =0 ; +int per_next_state; + +if (!per_pwrdm) +return ; + + per_next_state =pwrdm_read_next_pwrst (per_pwrdm); +if (per_next_state >=PWRDM_POWER_INACTIVE ) +return ; + +if (cpu_is_omap34xx () && (per_next_state ==PWRDM_POWER_OFF )) { +int per_prev_state =pwrdm_read_prev_pwrst (per_pwrdm); + +if (per_prev_state ==PWRDM_POWER_OFF ) +omap3_gpio_restore_context (); + }if (cpu_is_omap34xx ()) min =1 ; +for (i = min; i < gpio_bank_count; i++) {struct gpio_bank *bank = &gpio_bank[i];u32 l, gen, gen0, gen1;arch/arm/plat-omap/gpio.c +2
-3@@ -2235,14 +2265,13 @@ void omap2_gpio_resume_after_idle(void) } } } - }#endif #ifdef CONFIG_ARCH_OMAP3 /* save the registers of bank 2-6 */ -void omap_gpio_save_context (void ) +static void omap3_gpio_save_context (void ) {int i;@@ -2275,7 +2304,7 @@ void omap_gpio_save_context(void) }/* restore the required registers of bank 2-6 */ -void omap_gpio_restore_context (void ) +static void omap3_gpio_restore_context (void ) {int i;arch/arm/plat-omap/include/plat/gpio.h +0
-0@@ -72,12 +72,10 @@ IH_GPIO_BASE + (nr))extern int
omap_gpio_init(void); /* Call from board init only */arch/arm/plat-omap/include/plat/gpio.h +1
-1-extern void omap2_gpio_prepare_for_idle (int power_state); +extern void omap2_gpio_prepare_for_idle (void );extern void
omap2_gpio_resume_after_idle(void); extern voidomap_set_gpio_debounce(int gpio, int enable); extern voidomap_set_gpio_debounce_time(int gpio, int enable);arch/arm/plat-omap/include/plat/gpio.h +0
-2-extern void omap_gpio_save_context (void ); -extern void omap_gpio_restore_context (void );/*------------------------------------------------------------- ------------*/
/* Wrappers for "new style" GPIO calls, using the new infrastructure
Signature · 7 lines
1.7.2.1 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
Quoted 112 lines · Hema
Quoted 112 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Kevin Hilman
Sent: Tuesday, September 14, 2010 4:33 AM
To: [email protected]
Cc: Varadarajan, Charulatha; Basak, Partha; Tero Kristo
Subject: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle pathFrom: Kevin Hilman <[email protected]>
Currently, we wait until late in the idle path where interrupts are disabled to do runtime-PM-like management for certain special-case devices like GPIO.
As a prerequiste to moving GPIO to the new runtime PM framework, move this runtime-PM-like code out of the late idle path into new device idle and resume functions that can be called before interrupts are disabled by CPUidle and/or suspend.
In addition, move all the GPIO-specific logic into the GPIO core instead of keeping GPIO-specific knowledge of power-states, context saving etc. in the PM core.
Also, call the new device-idle and -resume methods from CPUidle and static suspend path.
Signed-off-by Kevin Hilman <[email protected]>---
arch/arm/mach-omap2/cpuidle34xx.c | 4 ++ arch/arm/mach-omap2/pm.h | 2 + arch/arm/mach-omap2/pm24xx.c | 2 +- arch/arm/mach-omap2/pm34xx.c | 38 +++++++++------------ arch/arm/plat-omap/gpio.c | 57 ++++++++++++++++++++++++-------- arch/arm/plat-omap/include/plat/gpio.h | 4 +-- 6 files changed, 67 insertions(+), 40 deletions(-)arch/arm/mach-omap2/cpuidle34xx.c +0
-0@@ -274,9 +274,13 @@ static int omap3_enter_idle_bm(structcpuidle_device *dev,pwrdm_set_next_pwrst (per_pd ,per_next_state );
select_state:arch/arm/mach-omap2/cpuidle34xx.c +2
-0+omap3_device_idle (); +dev->last_state = new_state; ret = omap3_enter_idle(dev, new_state);arch/arm/mach-omap2/cpuidle34xx.c +2
-0+omap3_device_resume (); +/* Restore original PER state if it was modified */ if (per_next_state != per_saved_state) pwrdm_set_next_pwrst(per_pd, per_saved_state);arch/arm/mach-omap2/pm.h +2
-0@@ -22,6 +22,8 @@ extern void omap_sram_idle(void);extern int omap3_can_sleep (void );extern int set_pwrdm_state (struct powerdomain *pwrdm,u32 state);extern int omap3_idle_init (void ); +extern void omap3_device_idle (void ); +extern void omap3_device_resume (void );struct cpuidle_params {u8 valid;arch/arm/mach-omap2/pm24xx.c +1
-1@@ -106,7 +106,7 @@ static void omap2_enter_full_retention(void) l =omap_ctrl_readl (OMAP2_CONTROL_DEVCONF0 ) |OMAP24XX_USBSTANDBYCTRL ;omap_ctrl_writel (l,OMAP2_CONTROL_DEVCONF0 ); -omap2_gpio_prepare_for_idle (PWRDM_POWER_RET ); +omap2_gpio_prepare_for_idle ();if (omap2_pm_debug) {omap2_pm_dump(0, 0, 0);arch/arm/mach-omap2/pm34xx.c +0
-10@@ -74,16 +74,6 @@ static struct powerdomain *mpu_pwrdm, *neon_pwrdm;static struct powerdomain *core_pwrdm, *per_pwrdm;static struct powerdomain *cam_pwrdm; -static inline void omap3_per_save_context (void ) -{ -omap_gpio_save_context (); -} - -static inline void omap3_per_restore_context (void ) -{ -omap_gpio_restore_context (); -} -static void omap3_enable_io_chain (void ) {int timeout =0 ;@@ -332,6 +322,16 @@ static void restore_table_entry(void)restore_control_register (control_reg_value); }
Quoted 9 lines
arch/arm/mach-omap2/pm34xx.c static void restore_table_entry(void) · line 329
Quoted 5 lines
arch/arm/mach-omap2/pm34xx.c +5
-0+void omap3_device_idle (void ) +{ +omap2_gpio_prepare_for_idle (); +} +Is not it is a good idea to pass the
new_stateas the parameter for the driver calls? It will reduce each individual drivers reading the PRCM register to findout the next state. This might save some time in the idle loop.
I chose not to pass the parameters on purpose. All of the intelligence for device idle (including which powerdomain state to check) should live in the driver code.
If reading the PRCM registers is becoming a problem, it will be a simple patch to patch the powerdomain core to cache the current value of it's next state so at least reads of next_state will be fast.
Kevin
Quoted 236 lines
arch/arm/mach-omap2/pm34xx.c static void restore_table_entry(void) · line 334
Quoted 5 lines
arch/arm/mach-omap2/pm34xx.c +5
-0+void omap3_device_resume (void ) +{ +omap2_gpio_resume_after_idle (); +} +Here we will need to pass the
next_stateas well asprevious_stateas parameters. If we agree to pass the parameters.~Hema
Quoted 225 lines
arch/arm/mach-omap2/pm34xx.c +6
-12void omap_sram_idle (void ) {/* Variable to tell what needs to be saved and restored @@ -344,7 +344,7 @@ void omap_sram_idle(void)int mpu_next_state =PWRDM_POWER_ON ;int per_next_state =PWRDM_POWER_ON ;int core_next_state =PWRDM_POWER_ON ; -int core_prev_state, per_prev_state; +int core_prev_state;u32 sdrc_pwr =0 ;if (!_omap_sram_idle)@@ -387,12 +387,9 @@ void omap_sram_idle(void) }/* PER */ -if (per_next_state <PWRDM_POWER_ON ) { +if (per_next_state <PWRDM_POWER_ON )omap_uart_prepare_idle (2 ); -omap2_gpio_prepare_for_idle (per_next_state); -if (per_next_state ==PWRDM_POWER_OFF ) -omap3_per_save_context (); - } +/* CORE */ if (core_next_state <PWRDM_POWER_ON ) {@@ -454,13 +451,8 @@ void omap_sram_idle(void)omap3_intc_resume_idle ();/* PER */ -if (per_next_state <PWRDM_POWER_ON ) { - per_prev_state =pwrdm_read_prev_pwrst (per_pwrdm); -omap2_gpio_resume_after_idle (); -if (per_prev_state ==PWRDM_POWER_OFF ) -omap3_per_restore_context (); +if (per_next_state <PWRDM_POWER_ON )omap_uart_resume_idle (2 ); - }/* Disable IO-PAD and IO-CHAIN wakeup */ if (omap3_has_io_wakeup() &&@@ -570,6 +562,7 @@ static void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)static int omap3_pm_prepare (void ) {disable_hlt (); +omap3_device_idle ();return 0 ; }@@ -637,6 +630,7 @@ static int omap3_pm_enter(suspend_state_t unused)static void omap3_pm_finish (void ) { +omap3_device_resume ();enable_hlt (); }arch/arm/plat-omap/gpio.c +41
-11@@ -29,6 +29,8 @@#include <asm/mach/irq.h> #include <plat/powerdomain.h> +static struct powerdomain *per_pwrdm; +/* * OMAP1510 GPIO registers */ @@ -207,6 +209,9 @@ struct gpio_bank {u32 dbck_enable_mask; }; +static void omap3_gpio_restore_context (void ); +static void omap3_gpio_save_context (void ); +#define METHOD_MPUIO 0#define METHOD_GPIO_1510 1#define METHOD_GPIO_1610 2@@ -1778,6 +1783,8 @@ static int __init _omap_gpio_init(void) }#endif +if (cpu_class_is_omap2 ()) + per_pwrdm =pwrdm_lookup ("per_pwrdm" );#ifdef CONFIG_ARCH_OMAP15XX if (cpu_is_omap15xx ()) {@@ -2074,14 +2081,22 @@ static struct sys_device omap_gpio_device = {static int workaround_enabled; -void omap2_gpio_prepare_for_idle (int power_state) +void omap2_gpio_prepare_for_idle (void ) { -int i, c =0 ; -int min =0 ; +int i, c =0 , min =0 ; +int per_next_state; + +if (!per_pwrdm) +return ; + + per_next_state =pwrdm_read_next_pwrst (per_pwrdm); +if (per_next_state >=PWRDM_POWER_INACTIVE ) +return ;if (cpu_is_omap34xx ()) min =1 ; + workaround_enabled =0 ;for (i = min; i < gpio_bank_count; i++) {struct gpio_bank *bank = &gpio_bank[i];u32 l1, l2;@@ -2089,7 +2104,7 @@ void omap2_gpio_prepare_for_idle(int power_state)if (bank->dbck_enable_mask)clk_disable (bank->dbck); -if (power_state >PWRDM_POWER_OFF ) +if (per_next_state >PWRDM_POWER_OFF )continue ;/* If going to OFF, remove triggering for all @@ -2135,20 +2150,35 @@ void omap2_gpio_prepare_for_idle(int power_state) c++; } -if (!c) { - workaround_enabled =0 ; -return ; - } - workaround_enabled =1 ; +if (c) + workaround_enabled =1 ; + +if (cpu_is_omap34xx () && (per_next_state ==PWRDM_POWER_OFF )) +omap3_gpio_save_context (); }void omap2_gpio_resume_after_idle (void ) { -int i; -int min =0 ; +int i, min =0 ; +int per_next_state; + +if (!per_pwrdm) +return ; + + per_next_state =pwrdm_read_next_pwrst (per_pwrdm); +if (per_next_state >=PWRDM_POWER_INACTIVE ) +return ; + +if (cpu_is_omap34xx () && (per_next_state ==PWRDM_POWER_OFF )) { +int per_prev_state =pwrdm_read_prev_pwrst (per_pwrdm); + +if (per_prev_state ==PWRDM_POWER_OFF ) +omap3_gpio_restore_context (); + }if (cpu_is_omap34xx ()) min =1 ; +for (i = min; i < gpio_bank_count; i++) {struct gpio_bank *bank = &gpio_bank[i];u32 l, gen, gen0, gen1;arch/arm/plat-omap/gpio.c +2
-3@@ -2235,14 +2265,13 @@ void omap2_gpio_resume_after_idle(void) } } } - }#endif #ifdef CONFIG_ARCH_OMAP3 /* save the registers of bank 2-6 */ -void omap_gpio_save_context (void ) +static void omap3_gpio_save_context (void ) {int i;@@ -2275,7 +2304,7 @@ void omap_gpio_save_context(void) }/* restore the required registers of bank 2-6 */ -void omap_gpio_restore_context (void ) +static void omap3_gpio_restore_context (void ) {int i;arch/arm/plat-omap/include/plat/gpio.h +0
-0@@ -72,12 +72,10 @@ IH_GPIO_BASE + (nr))extern int
omap_gpio_init(void); /* Call from board init only */arch/arm/plat-omap/include/plat/gpio.h +1
-1-extern void omap2_gpio_prepare_for_idle (int power_state); +extern void omap2_gpio_prepare_for_idle (void );extern void
omap2_gpio_resume_after_idle(void); extern voidomap_set_gpio_debounce(int gpio, int enable); extern voidomap_set_gpio_debounce_time(int gpio, int enable);arch/arm/plat-omap/include/plat/gpio.h +0
-2-extern void omap_gpio_save_context (void ); -extern void omap_gpio_restore_context (void );/*------------------------------------------------------------- ------------*/
/* Wrappers for "new style" GPIO calls, using the new infrastructure
Signature · 7 lines
1.7.2.1 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle path
Quoted 133 lines
-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Wednesday, September 22, 2010 7:55 PM
To: Kalliguddi, Hema
Cc: [email protected]; Varadarajan, Charulatha; Basak, Partha; Tero Kristo
Subject: Re: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle pathQuoted 112 lines · Hema
Quoted 112 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Kevin Hilman
Sent: Tuesday, September 14, 2010 4:33 AM
To: [email protected]
Cc: Varadarajan, Charulatha; Basak, Partha; Tero Kristo
Subject: [PATCH 2/2] OMAP2+: GPIO: move late PM out of interrupts-disabled idle pathFrom: Kevin Hilman <[email protected]>
Currently, we wait until late in the idle path where interrupts are disabled to do runtime-PM-like management for certain special-case devices like GPIO.
As a prerequiste to moving GPIO to the new runtime PM framework, move this runtime-PM-like code out of the late idle path into new device idle and resume functions that can be called before interrupts are disabled by CPUidle and/or suspend.
In addition, move all the GPIO-specific logic into the GPIO core instead of keeping GPIO-specific knowledge of power-states, context saving etc. in the PM core.
Also, call the new device-idle and -resume methods from CPUidle and static suspend path.
Signed-off-by Kevin Hilman <[email protected]>---
arch/arm/mach-omap2/cpuidle34xx.c | 4 ++ arch/arm/mach-omap2/pm.h | 2 + arch/arm/mach-omap2/pm24xx.c | 2 +- arch/arm/mach-omap2/pm34xx.c | 38 +++++++++------------ arch/arm/plat-omap/gpio.c | 57 ++++++++++++++++++++++++-------- arch/arm/plat-omap/include/plat/gpio.h | 4 +-- 6 files changed, 67 insertions(+), 40 deletions(-)arch/arm/mach-omap2/cpuidle34xx.c +0
-0@@ -274,9 +274,13 @@ static int omap3_enter_idle_bm(structcpuidle_device *dev,pwrdm_set_next_pwrst (per_pd ,per_next_state );
select_state:arch/arm/mach-omap2/cpuidle34xx.c +2
-0+omap3_device_idle (); +dev->last_state = new_state; ret = omap3_enter_idle(dev, new_state);arch/arm/mach-omap2/cpuidle34xx.c +2
-0+omap3_device_resume (); +/* Restore original PER state if it was modified */ if (per_next_state != per_saved_state) pwrdm_set_next_pwrst(per_pd, per_saved_state);arch/arm/mach-omap2/pm.h +2
-0@@ -22,6 +22,8 @@ extern void omap_sram_idle(void);extern int omap3_can_sleep (void );extern int set_pwrdm_state (struct powerdomain *pwrdm,u32 state);extern int omap3_idle_init (void ); +extern void omap3_device_idle (void ); +extern void omap3_device_resume (void );struct cpuidle_params {u8 valid;arch/arm/mach-omap2/pm24xx.c +1
-1@@ -106,7 +106,7 @@ static void omap2_enter_full_retention(void) l =omap_ctrl_readl (OMAP2_CONTROL_DEVCONF0 ) |OMAP24XX_USBSTANDBYCTRL ;omap_ctrl_writel (l,OMAP2_CONTROL_DEVCONF0 ); -omap2_gpio_prepare_for_idle (PWRDM_POWER_RET ); +omap2_gpio_prepare_for_idle ();if (omap2_pm_debug) {omap2_pm_dump(0, 0, 0);arch/arm/mach-omap2/pm34xx.c +0
-10@@ -74,16 +74,6 @@ static struct powerdomain *mpu_pwrdm, *neon_pwrdm;static struct powerdomain *core_pwrdm, *per_pwrdm;static struct powerdomain *cam_pwrdm; -static inline void omap3_per_save_context (void ) -{ -omap_gpio_save_context (); -} - -static inline void omap3_per_restore_context (void ) -{ -omap_gpio_restore_context (); -} -static void omap3_enable_io_chain (void ) {int timeout =0 ;@@ -332,6 +322,16 @@ static void restore_table_entry(void)restore_control_register (control_reg_value); }Quoted 7 lines
arch/arm/mach-omap2/pm34xx.c static void restore_table_entry(void) · line 329
Quoted 5 lines
arch/arm/mach-omap2/pm34xx.c +5
-0+void omap3_device_idle (void ) +{ +omap2_gpio_prepare_for_idle (); +} +Is not it is a good idea to pass the
new_stateas theparameter for the driver calls?
Quoted 9 lines
Quoted 1 line
It will reduce each individual drivers reading the PRCM
register to findout the next state.
Quoted 1 line
This might save some time in the idle loop.
I chose not to pass the parameters on purpose. All of the intelligence for device idle (including which powerdomain state to check) should live
in the driver code.
OK agree.
Quoted 5 lines
If reading the PRCM registers is becoming a problem, it will be a simple
patch to patch the powerdomain core to cache the current value of it's next state so at least reads ofnext_statewill be fast.
This is good idea, with this we can avoid n number of PRCM register reads. Today it may not be a problem as there are few hooks in the idle path But if there are more number of driver calls, then it might be useful patch. ~Hema
Quoted 241 lines
Kevin
Quoted 7 lines
arch/arm/mach-omap2/pm34xx.c static void restore_table_entry(void) · line 334
Quoted 5 lines
arch/arm/mach-omap2/pm34xx.c +5
-0+void omap3_device_resume (void ) +{ +omap2_gpio_resume_after_idle (); +} +Here we will need to pass the
next_stateas well as
previous_stateas parameters. If we agree toQuoted 114 lines
pass the parameters.
~Hema
Quoted 110 lines
arch/arm/mach-omap2/pm34xx.c +6
-12void omap_sram_idle (void ) {/* Variable to tell what needs to be saved and restored @@ -344,7 +344,7 @@ void omap_sram_idle(void)int mpu_next_state =PWRDM_POWER_ON ;int per_next_state =PWRDM_POWER_ON ;int core_next_state =PWRDM_POWER_ON ; -int core_prev_state, per_prev_state; +int core_prev_state;u32 sdrc_pwr =0 ;if (!_omap_sram_idle)@@ -387,12 +387,9 @@ void omap_sram_idle(void) }/* PER */ -if (per_next_state <PWRDM_POWER_ON ) { +if (per_next_state <PWRDM_POWER_ON )omap_uart_prepare_idle (2 ); -omap2_gpio_prepare_for_idle (per_next_state); -if (per_next_state ==PWRDM_POWER_OFF ) -omap3_per_save_context (); - } +/* CORE */ if (core_next_state <PWRDM_POWER_ON ) {@@ -454,13 +451,8 @@ void omap_sram_idle(void)omap3_intc_resume_idle ();/* PER */ -if (per_next_state <PWRDM_POWER_ON ) { - per_prev_state =pwrdm_read_prev_pwrst (per_pwrdm); -omap2_gpio_resume_after_idle (); -if (per_prev_state ==PWRDM_POWER_OFF ) -omap3_per_restore_context (); +if (per_next_state <PWRDM_POWER_ON )omap_uart_resume_idle (2 ); - }/* Disable IO-PAD and IO-CHAIN wakeup */ if (omap3_has_io_wakeup() &&@@ -570,6 +562,7 @@ static void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)static int omap3_pm_prepare (void ) {disable_hlt (); +omap3_device_idle ();return 0 ; }@@ -637,6 +630,7 @@ static int omap3_pm_enter(suspend_state_t unused)static void omap3_pm_finish (void ) { +omap3_device_resume ();enable_hlt (); }arch/arm/plat-omap/gpio.c +17
-3@@ -29,6 +29,8 @@#include <asm/mach/irq.h> #include <plat/powerdomain.h> +static struct powerdomain *per_pwrdm; +/* * OMAP1510 GPIO registers */ @@ -207,6 +209,9 @@ struct gpio_bank {u32 dbck_enable_mask; }; +static void omap3_gpio_restore_context (void ); +static void omap3_gpio_save_context (void ); +#define METHOD_MPUIO 0#define METHOD_GPIO_1510 1#define METHOD_GPIO_1610 2@@ -1778,6 +1783,8 @@ static int __init _omap_gpio_init(void) }#endif +if (cpu_class_is_omap2 ()) + per_pwrdm =pwrdm_lookup ("per_pwrdm" );#ifdef CONFIG_ARCH_OMAP15XX if (cpu_is_omap15xx ()) {@@ -2074,14 +2081,22 @@ static struct sys_device omap_gpio_device = {static int workaround_enabled; -void omap2_gpio_prepare_for_idle (int power_state) +void omap2_gpio_prepare_for_idle (void ) { -int i, c =0 ; -int min =0 ; +int i, c =0 , min =0 ; +int per_next_state; + +if (!per_pwrdm) +return ; + + per_next_state =pwrdm_read_next_pwrst (per_pwrdm); +if (per_next_state >=PWRDM_POWER_INACTIVE ) +return ;Quoted 8 lines
arch/arm/plat-omap/gpio.c void omap2_gpio_prepare_for_idle(int
Quoted 8 lines
arch/arm/plat-omap/gpio.c +1
-0if (cpu_is_omap34xx ()) min =1 ; + workaround_enabled =0 ;for (i = min; i < gpio_bank_count; i++) {struct gpio_bank *bank = &gpio_bank[i];u32 l1, l2;@@ -2089,7 +2104,7 @@ void omap2_gpio_prepare_for_idle(int
power_state)Quoted 107 lines
Quoted 107 lines
arch/arm/plat-omap/gpio.c +23
-8if (bank->dbck_enable_mask)clk_disable (bank->dbck); -if (power_state >PWRDM_POWER_OFF ) +if (per_next_state >PWRDM_POWER_OFF )continue ;/* If going to OFF, remove triggering for all @@ -2135,20 +2150,35 @@ void omap2_gpio_prepare_for_idle(int power_state) c++; } -if (!c) { - workaround_enabled =0 ; -return ; - } - workaround_enabled =1 ; +if (c) + workaround_enabled =1 ; + +if (cpu_is_omap34xx () && (per_next_state ==PWRDM_POWER_OFF )) +omap3_gpio_save_context (); }void omap2_gpio_resume_after_idle (void ) { -int i; -int min =0 ; +int i, min =0 ; +int per_next_state; + +if (!per_pwrdm) +return ; + + per_next_state =pwrdm_read_next_pwrst (per_pwrdm); +if (per_next_state >=PWRDM_POWER_INACTIVE ) +return ; + +if (cpu_is_omap34xx () && (per_next_state ==PWRDM_POWER_OFF )) { +int per_prev_state =pwrdm_read_prev_pwrst (per_pwrdm); + +if (per_prev_state ==PWRDM_POWER_OFF ) +omap3_gpio_restore_context (); + }if (cpu_is_omap34xx ()) min =1 ; +for (i = min; i < gpio_bank_count; i++) {struct gpio_bank *bank = &gpio_bank[i];u32 l, gen, gen0, gen1;arch/arm/plat-omap/gpio.c +2
-3@@ -2235,14 +2265,13 @@ void omap2_gpio_resume_after_idle(void) } } } - }#endif #ifdef CONFIG_ARCH_OMAP3 /* save the registers of bank 2-6 */ -void omap_gpio_save_context (void ) +static void omap3_gpio_save_context (void ) {int i;@@ -2275,7 +2304,7 @@ void omap_gpio_save_context(void) }/* restore the required registers of bank 2-6 */ -void omap_gpio_restore_context (void ) +static void omap3_gpio_restore_context (void ) {int i;arch/arm/plat-omap/include/plat/gpio.h +0
-0@@ -72,12 +72,10 @@ IH_GPIO_BASE + (nr))extern int
omap_gpio_init(void); /* Call from board init only */arch/arm/plat-omap/include/plat/gpio.h +1
-1-extern void omap2_gpio_prepare_for_idle (int power_state); +extern void omap2_gpio_prepare_for_idle (void );extern void
omap2_gpio_resume_after_idle(void); extern voidomap_set_gpio_debounce(int gpio, int enable); extern voidomap_set_gpio_debounce_time(int gpio, int enable);arch/arm/plat-omap/include/plat/gpio.h +0
-2-extern void omap_gpio_save_context (void ); -extern void omap_gpio_restore_context (void );/*------------------------------------------------------------- ------------*/
/* Wrappers for "new style" GPIO calls, using the new infrastructure
Signature · 7 lines
1.7.2.1 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html