OMAP 2/3 GPIO fixes for idling debounce clocks
v2 cover OMAP 2/3 GPIO fixes for idling debounce clocks
[updated since v1: also works for retention/off when idle by
masking off GPIO clocks in the 'fclks_active' check.]
This series against the current PM branch is to add support for auto-disabling GPIO debounce clocks when the system is idle. Without this, any platform using the GPIO debounce feature will not go into retention since the GPIO debounce clocks are still active.
This is needed particularily on OMAP3EVM which sets up the debounce clocks for the touchscreen GPIO.
Kevin Hilman (2):
OMAP2/3: GPIO: generalize prepare for idle
OMAP3: GPIO: disable GPIO debounce clocks on idle
arch/arm/mach-omap2/pm24xx.c | 4 ++-- arch/arm/mach-omap2/pm34xx.c | 14 ++++++++------ arch/arm/plat-omap/gpio.c | 27 +++++++++++++++++++++------ arch/arm/plat-omap/include/mach/gpio.h | 4 ++-- 4 files changed, 33 insertions(+), 16 deletions(-)
PATCH v2 1/2 OMAP2/3: GPIO: generalize prepare for idle
Currently, the GPIO 'prepare' hook is only called when going to off-mode, while the function is called 'prepare_for_retention.' This patch renames the function to 'prepare_for_idle' and calls it for any powersate != PWRDM_POWER_ON passing in the powerstate.
The hook itself is then responsible for doing various preparation based on the powerstate.
--- arch/arm/mach-omap2/pm24xx.c | 4 ++-- arch/arm/mach-omap2/pm34xx.c | 10 ++++------ arch/arm/plat-omap/gpio.c | 19 +++++++++++++------ arch/arm/plat-omap/include/mach/gpio.h | 4 ++-- 4 files changed, 21 insertions(+), 16 deletions(-)
arch/arm/mach-omap2/pm24xx.c +2 -2
@@ -114,7 +114,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_retention (); +omap2_gpio_prepare_for_idle (PWRDM_POWER_RET );if (omap2_pm_debug) {omap2_pm_dump (0 ,0 ,0 );
@@ -147,7 +147,7 @@ no_sleep: tmp =timespec_to_ns (&ts_idle) *NSEC_PER_USEC ;omap2_pm_dump (0 ,1 , tmp); } -omap2_gpio_resume_after_retention (); +omap2_gpio_resume_after_idle ();clk_enable (osc_ck);
arch/arm/mach-omap2/pm34xx.c +4 -6
@@ -330,15 +330,14 @@ void omap_sram_idle(void) core_next_state =pwrdm_read_next_pwrst (core_pwrdm);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 { -omap2_gpio_prepare_for_retention (); + }else omap3_per_save_context (); - } } }
@@ -412,10 +411,9 @@ void omap_sram_idle(void)/* PER */ if (per_next_state <PWRDM_POWER_ON ) { per_prev_state =pwrdm_read_prev_pwrst (per_pwrdm); -if (per_prev_state ==PWRDM_POWER_OFF ) { +omap2_gpio_resume_after_idle (); +if (per_prev_state ==PWRDM_POWER_OFF )omap3_per_restore_context (); -omap2_gpio_resume_after_retention (); - }omap_uart_resume_idle (2 );if (per_state_modified)pwrdm_set_next_pwrst (per_pwrdm,PWRDM_POWER_OFF );
arch/arm/plat-omap/gpio.c +13 -6
@@ -24,6 +24,7 @@#include <mach/irqs.h> #include <mach/gpio.h> #include <asm/mach/irq.h> +#include <mach/powerdomain.h> /* * OMAP1510 GPIO registers
@@ -1626,19 +1627,24 @@ static struct sys_device omap_gpio_device = {static int workaround_enabled; -void omap2_gpio_prepare_for_retention (void ) +void omap2_gpio_prepare_for_idle (int power_state) {int i, c =0 ;int min =0 ;if (cpu_is_omap34xx ()) min =1 ; -/* Remove triggering for all non-wakeup GPIOs. Otherwise spurious -* IRQs will be generated. See OMAP2420 Errata item 1.101. */ +for (i = min; i < gpio_bank_count; i++) {struct gpio_bank *bank = &gpio_bank[i];u32 l1, l2; +if (power_state >PWRDM_POWER_OFF ) +continue ; + +/* If going to OFF, remove triggering for all +* non-wakeup GPIOs. Otherwise spurious IRQs will be +* generated. See OMAP2420 Errata item 1.101. */ if (!(bank->enabled_non_wakeup_gpios))continue ;#if defined(CONFIG_ARCH_OMAP24XX ) || defined(CONFIG_ARCH_OMAP34XX )
@@ -1665,19 +1671,20 @@ void omap2_gpio_prepare_for_retention(void) workaround_enabled =1 ; } -void omap2_gpio_resume_after_retention (void ) +void omap2_gpio_resume_after_idle (void ) {int i;int min =0 ; -if (!workaround_enabled) -return ;if (cpu_is_omap34xx ()) min =1 ;for (i = min; i < gpio_bank_count; i++) {struct gpio_bank *bank = &gpio_bank[i];u32 l; +if (!workaround_enabled) +continue ; +if (!(bank->enabled_non_wakeup_gpios))continue ;#if defined(CONFIG_ARCH_OMAP24XX ) || defined(CONFIG_ARCH_OMAP34XX )
arch/arm/plat-omap/include/mach/gpio.h +2 -2
@@ -71,8 +71,8 @@ IH_GPIO_BASE + (nr))extern int omap_gpio_init (void );/* Call from board init only */ -extern void omap2_gpio_prepare_for_retention (void ); -extern void omap2_gpio_resume_after_retention (void ); +extern void omap2_gpio_prepare_for_idle (int power_state); +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 omap3_gpio_save_context (void );
Signature · 1 line
1.6.1
PATCH v2 2/2 OMAP3: GPIO: disable GPIO debounce clocks on idle
Ensure GPIO debounce clocks are disabled when idle. Otherwise, clocks will prevent PER powerdomain from entering retention.
--- arch/arm/mach-omap2/pm34xx.c | 4 ++++ arch/arm/plat-omap/gpio.c | 8 ++++++++ 2 files changed, 12 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/pm34xx.c +4 -0
@@ -466,6 +466,10 @@ static int omap3_fclks_active(void) fck_core1 &= ~(OMAP3430_EN_UART1 |OMAP3430_EN_UART2 ); fck_per &= ~OMAP3430_EN_UART3 ; +/* Ignore GPIO clocks. Handled by GPIO prepare-idle hooks */ + fck_per &= ~(OMAP3430_EN_GPIO2 |OMAP3430_EN_GPIO3 | +OMAP3430_EN_GPIO4 |OMAP3430_EN_GPIO5 |OMAP3430_EN_GPIO6 ); +if (fck_core1 | fck_core3 | fck_sgx | fck_dss | fck_cam | fck_per | fck_usbhost)return 1 ;
arch/arm/plat-omap/gpio.c +8 -0
@@ -154,6 +154,7 @@ struct gpio_bank {spinlock_t lock;struct gpio_chip chip;struct clk *dbck; +u32 dbck_enable_mask; };#define METHOD_MPUIO 0
@@ -489,6 +490,7 @@ void omap_set_gpio_debounce(int gpio, int enable) goto done;if (cpu_is_omap34xx ()) { + bank->dbck_enable_mask = val;if (enable)clk_enable (bank->dbck);else
@@ -1639,6 +1641,9 @@ void omap2_gpio_prepare_for_idle(int power_state)struct gpio_bank *bank = &gpio_bank[i];u32 l1, l2; +if (cpu_is_omap34xx () && bank->dbck_enable_mask) +clk_disable (bank->dbck); +if (power_state >PWRDM_POWER_OFF )continue ;
@@ -1682,6 +1687,9 @@ void omap2_gpio_resume_after_idle(void)struct gpio_bank *bank = &gpio_bank[i];u32 l; +if (cpu_is_omap34xx () && bank->dbck_enable_mask) +clk_enable (bank->dbck); +if (!workaround_enabled)continue ;
Signature · 1 line
1.6.1
Quoted 15 lines · Kevin Hilman
[updated since v1: also works for retention/off when idle by
masking off GPIO clocks in the 'fclks_active' check.]This series against the current PM branch is to add support for auto-disabling GPIO debounce clocks when the system is idle. Without this, any platform using the GPIO debounce feature will not go into retention since the GPIO debounce clocks are still active.
This is needed particularily on OMAP3EVM which sets up the debounce clocks for the touchscreen GPIO.
Kevin Hilman (2):
OMAP2/3: GPIO: generalize prepare for idle
OMAP3: GPIO: disable GPIO debounce clocks on idle
Quoted 5 lines
arch/arm/mach-omap2/pm24xx.c | 4 ++-- arch/arm/mach-omap2/pm34xx.c | 14 ++++++++------ arch/arm/plat-omap/gpio.c | 27 +++++++++++++++++++++------ arch/arm/plat-omap/include/mach/gpio.h | 4 ++-- 4 files changed, 33 insertions(+), 16 deletions(-)
Pushing this series to PM branch.
Kevin