34XX: PM: Workarounds to get omap3 to retention 4th.
cover 34XX: PM: Workarounds to get omap3 to retention 4th.
Hi,
This patch set contains all workarounds that are needed to get omap3 to retention. Also patch from Tero Kristo to get PM to work if using serial console is included in this set. Basically all patches in this set should be reverted one by one as correct fixes are implemented and applied.
This patch set superseeds earlier version sent 2008-06-25 9:11:49.
To get Omap into retention, this patch set still depends on:
1. ARCH: OMAP: MUSB: Do not block sleep (Felipe Balbi)
Test:
1. Apply dependency patch and workaround set on top of them
2. Enable disabling/enabling of gpio2-6 and uart clocks on idle:
$ echo 1 > /sys/power/clocks_off_while_idle
3. Try out static suspend:
$ echo mem > /sys/power/state Wake up from suspend by entering character to serial console. This should print out: "Successfully put all powerdomains to target state"
4. Try out dynamic sleep:
$ echo 1 > /sys/power/sleep_while_idle On Omap3430 SDP board VCORE_EN led can be used as an indicator. If it starts to blink after a while then Omap enters retention on idle. To make this work also display needs to be blanked.
Signature · 6 lines
Jouni Högander -- 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
PATCH 1/6 34XX: PM: Workaround to reset all wkdeps
This workaround is needed until powerdomain code resets wkdeps.
--- arch/arm/mach-omap2/pm34xx.c | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/pm34xx.c +18 -2
@@ -332,6 +332,20 @@ static struct platform_suspend_ops omap_pm_ops = {static void __init prcm_setup_regs (void ) { +/* XXX Reset all wkdeps. This should be done when initializing +* powerdomains */ +prm_write_mod_reg (0 ,OMAP3430_IVA2_MOD ,PM_WKDEP ); +prm_write_mod_reg (0 ,MPU_MOD ,PM_WKDEP ); +prm_write_mod_reg (0 ,OMAP3430_DSS_MOD ,PM_WKDEP ); +prm_write_mod_reg (0 ,OMAP3430_NEON_MOD ,PM_WKDEP ); +prm_write_mod_reg (0 ,OMAP3430_CAM_MOD ,PM_WKDEP ); +prm_write_mod_reg (0 ,OMAP3430_PER_MOD ,PM_WKDEP ); +if (is_sil_rev_greater_than (OMAP3430_REV_ES1_0 )) { +prm_write_mod_reg (0 ,OMAP3430ES2_SGX_MOD ,PM_WKDEP ); +prm_write_mod_reg (0 ,OMAP3430ES2_USBHOST_MOD ,PM_WKDEP ); + }else +prm_write_mod_reg (0 ,GFX_MOD ,PM_WKDEP ); +/* setup wakup source */ prm_write_mod_reg (OMAP3430_EN_IO |OMAP3430_EN_GPIO1 |OMAP3430_EN_GPT1 ,WKUP_MOD ,PM_WKEN );
@@ -371,6 +385,10 @@ int __init omap3_pm_init(void)printk (KERN_ERR "Power Management for TI OMAP3.\n" ); +/* XXX prcm_setup_regs needs to be before enabling hw +* supervised mode for powerdomains */ +prcm_setup_regs (); + ret =request_irq (INT_34XX_PRCM_MPU_IRQ , (irq_handler_t )prcm_interrupt_handler,IRQF_DISABLED ,"prcm" ,NULL );
@@ -397,8 +415,6 @@ int __init omap3_pm_init(void)suspend_set_ops (&omap_pm_ops); -prcm_setup_regs (); - pm_idle = omap3_pm_idle; err1:
Signature · 1 line
1.5.5
Tony Lindgren
maintainerRe: [PATCH 1/6] 34XX: PM: Workaround to reset all wkdeps
Quoted 1 line · Jouni Hogander
This workaround is needed until powerdomain code resets wkdeps.
Pushing today.
Tony
Quoted 57 lines
Signed-off-by Jouni Hogander <[email protected]>--- arch/arm/mach-omap2/pm34xx.c | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-)arch/arm/mach-omap2/pm34xx.c +18
-2@@ -332,6 +332,20 @@ static struct platform_suspend_ops omap_pm_ops = {static void __init prcm_setup_regs (void ) { +/* XXX Reset all wkdeps. This should be done when initializing +* powerdomains */ +prm_write_mod_reg (0 ,OMAP3430_IVA2_MOD ,PM_WKDEP ); +prm_write_mod_reg (0 ,MPU_MOD ,PM_WKDEP ); +prm_write_mod_reg (0 ,OMAP3430_DSS_MOD ,PM_WKDEP ); +prm_write_mod_reg (0 ,OMAP3430_NEON_MOD ,PM_WKDEP ); +prm_write_mod_reg (0 ,OMAP3430_CAM_MOD ,PM_WKDEP ); +prm_write_mod_reg (0 ,OMAP3430_PER_MOD ,PM_WKDEP ); +if (is_sil_rev_greater_than (OMAP3430_REV_ES1_0 )) { +prm_write_mod_reg (0 ,OMAP3430ES2_SGX_MOD ,PM_WKDEP ); +prm_write_mod_reg (0 ,OMAP3430ES2_USBHOST_MOD ,PM_WKDEP ); + }else +prm_write_mod_reg (0 ,GFX_MOD ,PM_WKDEP ); +/* setup wakup source */ prm_write_mod_reg (OMAP3430_EN_IO |OMAP3430_EN_GPIO1 |OMAP3430_EN_GPT1 ,WKUP_MOD ,PM_WKEN );@@ -371,6 +385,10 @@ int __init omap3_pm_init(void)printk (KERN_ERR "Power Management for TI OMAP3.\n" ); +/* XXX prcm_setup_regs needs to be before enabling hw +* supervised mode for powerdomains */ +prcm_setup_regs (); + ret =request_irq (INT_34XX_PRCM_MPU_IRQ , (irq_handler_t )prcm_interrupt_handler,IRQF_DISABLED ,"prcm" ,NULL );@@ -397,8 +415,6 @@ int __init omap3_pm_init(void)suspend_set_ops (&omap_pm_ops); -prcm_setup_regs (); - pm_idle = omap3_pm_idle; err1:Signature · 6 lines
1.5.5 -- 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
PATCH 2/6 34XX: PM: Workaround to check wether any fck is active before entering sleep
In reply to Högander JouniThis workaround shouldn't be needed when all drivers are configuring their sysconfig registers properly and using their clocks properly.
--- arch/arm/mach-omap2/pm34xx.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/pm34xx.c +31 -0
@@ -174,10 +174,41 @@ static void omap_sram_idle(void)omap2_gpio_resume_after_retention (); } +static int omap3_fclks_active (void ) +{ +u32 fck_core1 =0 , fck_core3 =0 , fck_sgx =0 , fck_dss =0 , + fck_cam =0 , fck_per =0 , fck_usbhost =0 ; + + fck_core1 =cm_read_mod_reg (CORE_MOD , +CM_FCLKEN1 ); +if (is_sil_rev_greater_than (OMAP3430_REV_ES1_0 )) { + fck_core3 =cm_read_mod_reg (CORE_MOD , +OMAP3430ES2_CM_FCLKEN3 ); + fck_sgx =cm_read_mod_reg (OMAP3430ES2_SGX_MOD , +CM_FCLKEN ); + fck_usbhost =cm_read_mod_reg (OMAP3430ES2_USBHOST_MOD , +CM_FCLKEN ); + }else + fck_sgx =cm_read_mod_reg (GFX_MOD , +OMAP3430ES2_CM_FCLKEN3 ); + fck_dss =cm_read_mod_reg (OMAP3430_DSS_MOD , +CM_FCLKEN ); + fck_cam =cm_read_mod_reg (OMAP3430_CAM_MOD , +CM_FCLKEN ); + fck_per =cm_read_mod_reg (OMAP3430_PER_MOD , +CM_FCLKEN ); +if (fck_core1 | fck_core3 | fck_sgx | fck_dss | + fck_cam | fck_per | fck_usbhost) +return 1 ; +return 0 ; +} +static int omap3_can_sleep (void ) {if (!enable_dyn_sleep)return 0 ; +if (omap3_fclks_active ()) +return 0 ;if (atomic_read (&sleep_block) >0 )return 0 ;return 1 ;
Signature · 1 line
1.5.5
Tony Lindgren
maintainerRe: [PATCH 2/6] 34XX: PM: Workaround to check wether any fck is active before entering sleep
Quoted 2 lines · Jouni Hogander
This workaround shouldn't be needed when all drivers are configuring their sysconfig registers properly and using their clocks properly.
Can you please update this one more time to add the comments above also to the code so we'll remember why it's there when reading the code?
Thanks,
Tony
Quoted 58 lines
Signed-off-by Jouni Hogander <[email protected]>--- arch/arm/mach-omap2/pm34xx.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-)arch/arm/mach-omap2/pm34xx.c +31
-0@@ -174,10 +174,41 @@ static void omap_sram_idle(void)omap2_gpio_resume_after_retention (); } +static int omap3_fclks_active (void ) +{ +u32 fck_core1 =0 , fck_core3 =0 , fck_sgx =0 , fck_dss =0 , + fck_cam =0 , fck_per =0 , fck_usbhost =0 ; + + fck_core1 =cm_read_mod_reg (CORE_MOD , +CM_FCLKEN1 ); +if (is_sil_rev_greater_than (OMAP3430_REV_ES1_0 )) { + fck_core3 =cm_read_mod_reg (CORE_MOD , +OMAP3430ES2_CM_FCLKEN3 ); + fck_sgx =cm_read_mod_reg (OMAP3430ES2_SGX_MOD , +CM_FCLKEN ); + fck_usbhost =cm_read_mod_reg (OMAP3430ES2_USBHOST_MOD , +CM_FCLKEN ); + }else + fck_sgx =cm_read_mod_reg (GFX_MOD , +OMAP3430ES2_CM_FCLKEN3 ); + fck_dss =cm_read_mod_reg (OMAP3430_DSS_MOD , +CM_FCLKEN ); + fck_cam =cm_read_mod_reg (OMAP3430_CAM_MOD , +CM_FCLKEN ); + fck_per =cm_read_mod_reg (OMAP3430_PER_MOD , +CM_FCLKEN ); +if (fck_core1 | fck_core3 | fck_sgx | fck_dss | + fck_cam | fck_per | fck_usbhost) +return 1 ; +return 0 ; +} +static int omap3_can_sleep (void ) {if (!enable_dyn_sleep)return 0 ; +if (omap3_fclks_active ()) +return 0 ;if (atomic_read (&sleep_block) >0 )return 0 ;return 1 ;Signature · 6 lines
1.5.5 -- 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
PATCH 3/6 OMAP: PM: Add new sysfs option for disabling clocks when entering idle
In reply to Högander JouniThere are drivers that are not disabling their clocks (gpio & uart). These clocks need to be disabled if retention/off state is wanted when idling. Before disabling them in idle loop this option needs to be checked.
--- arch/arm/mach-omap2/pm.c | 37 +++++++++++++++++++++++++++++++------ arch/arm/mach-omap2/pm.h | 1 + 2 files changed, 32 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/pm.c +31 -6
@@ -31,30 +31,51 @@#include "pm.h" unsigned short enable_dyn_sleep; +unsigned short clocks_off_while_idle;atomic_t sleep_block =ATOMIC_INIT (0 ); +static ssize_t idle_show (struct kobject *,struct kobj_attribute *,char *); +static ssize_t idle_store (struct kobject *k,struct kobj_attribute *, +const char *buf,size_t n); + +static struct kobj_attribute sleep_while_idle_attr = +__ATTR (sleep_while_idle,0644 , idle_show, idle_store); + +static struct kobj_attribute clocks_off_while_idle_attr = +__ATTR (clocks_off_while_idle,0644 , idle_show, idle_store); +static ssize_t idle_show (struct kobject *kobj,struct kobj_attribute *attr,char *buf) { -return sprintf (buf,"%hu\n" , enable_dyn_sleep); +if (attr == &sleep_while_idle_attr) +return sprintf (buf,"%hu\n" , enable_dyn_sleep); +else if (attr == &clocks_off_while_idle_attr) +return sprintf (buf,"%hu\n" , clocks_off_while_idle); +else +return -EINVAL ; }static ssize_t idle_store (struct kobject *kobj,struct kobj_attribute *attr,const char *buf,size_t n) {unsigned short value; +if (sscanf (buf,"%hu" , &value) !=1 || (value !=0 && value !=1 )) { -printk (KERN_ERR "idle_sleep_store: Invalid value\n" ); +printk (KERN_ERR "idle_store: Invalid value\n" );return -EINVAL ; } - enable_dyn_sleep = value; + +if (attr == &sleep_while_idle_attr) + enable_dyn_sleep = value; +else if (attr == &clocks_off_while_idle_attr) + clocks_off_while_idle = value; +else +return -EINVAL ; +return n; } -static struct kobj_attribute sleep_while_idle_attr = -__ATTR (sleep_while_idle,0644 , idle_show, idle_store); -void omap2_block_sleep (void ) {atomic_inc (&sleep_block);
@@ -86,6 +107,10 @@ int __init omap_pm_init(void) error =sysfs_create_file (power_kobj, &sleep_while_idle_attr.attr);if (error)printk (KERN_ERR "sysfs_create_file failed: %d\n" , error); + error =sysfs_create_file (power_kobj, + &clocks_off_while_idle_attr.attr); +if (error) +printk (KERN_ERR "sysfs_create_file failed: %d\n" , error);return error; }
arch/arm/mach-omap2/pm.h +1 -0
@@ -17,6 +17,7 @@ extern int omap2_pm_init(void);extern int omap3_pm_init (void );extern unsigned short enable_dyn_sleep; +extern unsigned short clocks_off_while_idle;extern atomic_t sleep_block;#ifdef CONFIG_PM_DEBUG
Signature · 1 line
1.5.5
Tony Lindgren
maintainerRe: [PATCH 3/6] OMAP: PM: Add new sysfs option for disabling clocks when entering idle
Quoted 4 lines · Jouni Hogander
There are drivers that are not disabling their clocks (gpio & uart). These clocks need to be disabled if retention/off state is wanted when idling. Before disabling them in idle loop this option needs to be checked.
Pushing today.
Tony
Quoted 98 lines
Signed-off-by Jouni Hogander <[email protected]>--- arch/arm/mach-omap2/pm.c | 37 +++++++++++++++++++++++++++++++------ arch/arm/mach-omap2/pm.h | 1 + 2 files changed, 32 insertions(+), 6 deletions(-)arch/arm/mach-omap2/pm.c +31
-6@@ -31,30 +31,51 @@#include "pm.h" unsigned short enable_dyn_sleep; +unsigned short clocks_off_while_idle;atomic_t sleep_block =ATOMIC_INIT (0 ); +static ssize_t idle_show (struct kobject *,struct kobj_attribute *,char *); +static ssize_t idle_store (struct kobject *k,struct kobj_attribute *, +const char *buf,size_t n); + +static struct kobj_attribute sleep_while_idle_attr = +__ATTR (sleep_while_idle,0644 , idle_show, idle_store); + +static struct kobj_attribute clocks_off_while_idle_attr = +__ATTR (clocks_off_while_idle,0644 , idle_show, idle_store); +static ssize_t idle_show (struct kobject *kobj,struct kobj_attribute *attr,char *buf) { -return sprintf (buf,"%hu\n" , enable_dyn_sleep); +if (attr == &sleep_while_idle_attr) +return sprintf (buf,"%hu\n" , enable_dyn_sleep); +else if (attr == &clocks_off_while_idle_attr) +return sprintf (buf,"%hu\n" , clocks_off_while_idle); +else +return -EINVAL ; }static ssize_t idle_store (struct kobject *kobj,struct kobj_attribute *attr,const char *buf,size_t n) {unsigned short value; +if (sscanf (buf,"%hu" , &value) !=1 || (value !=0 && value !=1 )) { -printk (KERN_ERR "idle_sleep_store: Invalid value\n" ); +printk (KERN_ERR "idle_store: Invalid value\n" );return -EINVAL ; } - enable_dyn_sleep = value; + +if (attr == &sleep_while_idle_attr) + enable_dyn_sleep = value; +else if (attr == &clocks_off_while_idle_attr) + clocks_off_while_idle = value; +else +return -EINVAL ; +return n; } -static struct kobj_attribute sleep_while_idle_attr = -__ATTR (sleep_while_idle,0644 , idle_show, idle_store); -void omap2_block_sleep (void ) {atomic_inc (&sleep_block);@@ -86,6 +107,10 @@ int __init omap_pm_init(void) error =sysfs_create_file (power_kobj, &sleep_while_idle_attr.attr);if (error)printk (KERN_ERR "sysfs_create_file failed: %d\n" , error); + error =sysfs_create_file (power_kobj, + &clocks_off_while_idle_attr.attr); +if (error) +printk (KERN_ERR "sysfs_create_file failed: %d\n" , error);return error; }arch/arm/mach-omap2/pm.h +1
-0@@ -17,6 +17,7 @@ extern int omap2_pm_init(void);extern int omap3_pm_init (void );extern unsigned short enable_dyn_sleep; +extern unsigned short clocks_off_while_idle;extern atomic_t sleep_block;#ifdef CONFIG_PM_DEBUG Signature · 6 lines
1.5.5 -- 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
PATCH 4/6 34XX: PM: Workaround for taking care of gpio clocks
In reply to Högander JouniIn omap3 gpios 2-6 are in per domain. Functional clocks for these should be disabled. This patch is needed until gpio driver disables gpio clocks.
GPIO modules in PER domain are not able to act as a wake up source if PER domain is in retention. PER domain sleep transition before MPU is prevented by leaving icks active. PER domain still enters retention together with MPU. When this happens IOPAD wake up mechanism is used for gpios.
--- arch/arm/mach-omap2/pm34xx.c | 58 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 55 insertions(+), 3 deletions(-)
arch/arm/mach-omap2/pm34xx.c +55 -3
@@ -47,12 +47,42 @@ struct power_state {static LIST_HEAD (pwrst_list); -void (*_omap_sram_idle)(u32 *addr,int save_state); +void (*_omap_sram_idle)(u32 *addr,int save_state,int disable_clocks);static void (*saved_idle)(void );static struct powerdomain *mpu_pwrdm; +/* XXX This is for gpio fclk hack. Will be removed as gpio driver +* handles fcks correctly */ +#define NUM_OF_PERGPIOS 5 +static struct clk *gpio_fcks[NUM_OF_PERGPIOS ]; + +/* XXX This is for gpio fclk hack. Will be removed as gpio driver +* handles fcks correctly */ +static void per_gpio_clk_enable (void ) +{ +int i; +for (i =1 ; i <NUM_OF_PERGPIOS +1 ; i++) +clk_enable (gpio_fcks[i-1 ]); +} + +/* XXX This is for gpio fclk hack. Will be removed as gpio driver +* handles fcks correctly */ +static void per_gpio_clk_disable (void ) +{ +int i; +for (i =1 ; i <NUM_OF_PERGPIOS +1 ; i++) +clk_disable (gpio_fcks[i-1 ]); +} + +/* XXX This is for gpio fclk hack. Will be removed as gpio driver +* handles fcks correctly */ +static void gpio_fclk_mask (u32 *fclk) +{ + *fclk &= ~(0x1f <<13 ); +} +/* PRCM Interrupt Handler for wakeups */ static irqreturn_t prcm_interrupt_handler (int irq,void *dev_id) {
@@ -169,7 +199,17 @@ static void omap_sram_idle(void)omap2_gpio_prepare_for_retention (); -_omap_sram_idle (NULL , save_state); +/* XXX This is for gpio fclk hack. Will be removed as gpio driver +* handles fcks correctly */ +if (clocks_off_while_idle) +per_gpio_clk_disable (); + +_omap_sram_idle (NULL , save_state, clocks_off_while_idle); + +/* XXX This is for gpio fclk hack. Will be removed as gpio driver +* handles fcks correctly */ +if (clocks_off_while_idle) +per_gpio_clk_enable ();omap2_gpio_resume_after_retention (); }
@@ -197,6 +237,10 @@ static int omap3_fclks_active(void) CM_FCLKEN); fck_per =cm_read_mod_reg (OMAP3430_PER_MOD ,CM_FCLKEN ); + +if (clocks_off_while_idle) +gpio_fclk_mask (&fck_per); +if (fck_core1 | fck_core3 | fck_sgx | fck_dss | fck_cam | fck_per | fck_usbhost)return 1 ;
@@ -412,7 +456,8 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm)int __init omap3_pm_init (void ) {struct power_state *pwrst; -int ret; +char clk_name[11 ]; +int ret, i;printk (KERN_ERR "Power Management for TI OMAP3.\n" );
@@ -448,6 +493,13 @@ int __init omap3_pm_init(void) pm_idle = omap3_pm_idle; +/* XXX This is for gpio fclk hack. Will be removed as gpio driver +* handles fcks correctly */ +for (i =1 ; i <NUM_OF_PERGPIOS +1 ; i++) { +sprintf (clk_name,"gpio%d_fck" , i +1 ); + gpio_fcks[i-1 ] =clk_get (NULL , clk_name); + } + err1:return ret; err2:
Signature · 1 line
1.5.5
PATCH 5/6 Added sleep support to UART
In reply to Högander JouniFrom: Tero Kristo <[email protected]>
UART usage (e.g. serial console) now denies sleep for 5 seconds. This makes it possible to use serial console when dynamic idle is enabled. Write 1 to /sys/power/clocks_off_while_sleep to enable uart clock disable on idle. Without this omap won't enter retention.
Also moved code from pm-debug.c to serial.c, and made pm24xx.c use this new implementation.
--- arch/arm/mach-omap2/pm-debug.c | 132 -------------------------------- arch/arm/mach-omap2/pm.h | 8 -- arch/arm/mach-omap2/pm24xx.c | 57 ++++++++------ arch/arm/mach-omap2/pm34xx.c | 26 +++++-- arch/arm/mach-omap2/serial.c | 148 ++++++++++++++++++++++++++++++++++++ include/asm-arm/arch-omap/common.h | 3 + 6 files changed, 204 insertions(+), 170 deletions(-)
arch/arm/mach-omap2/pm-debug.c +0 -132
@@ -37,138 +37,6 @@#ifdef CONFIG_PM_DEBUG int omap2_pm_debug =0 ; -static int serial_console_clock_disabled; -static int serial_console_uart; -static unsigned int serial_console_next_disable; - -static struct clk *console_iclk, *console_fclk; - -static void serial_console_kick (void ) -{ - serial_console_next_disable =omap2_read_32k_sync_counter (); -/* Keep the clocks on for 4 secs */ - serial_console_next_disable +=4 *32768 ; -} - -static void serial_wait_tx (void ) -{ -static const unsigned long uart_bases[3 ] = { -0x4806a000 ,0x4806c000 ,0x4806e000 - }; -unsigned long lsr_reg; -int looped =0 ; - -/* Wait for TX FIFO and THR to get empty */ - lsr_reg =IO_ADDRESS (uart_bases[serial_console_uart -1 ] + (5 <<2 )); -while ((__raw_readb (lsr_reg) &0x60 ) !=0x60 ) - looped =1 ; -if (looped) -serial_console_kick (); -} - -u32 omap2_read_32k_sync_counter (void ) -{ -return omap_readl (OMAP2_32KSYNCT_BASE +0x0010 ); -} - -void serial_console_fclk_mask (u32 *f1,u32 *f2) -{ -switch (serial_console_uart) { -case 1 : - *f1 &= ~(1 <<21 ); -break ; -case 2 : - *f1 &= ~(1 <<22 ); -break ; -case 3 : - *f2 &= ~(1 <<2 ); -break ; - } -} - -void serial_console_sleep (int enable) -{ -if (console_iclk ==NULL || console_fclk ==NULL ) -return ; - -if (enable) { -BUG_ON (serial_console_clock_disabled); -if (clk_get_usecount (console_fclk) ==0 ) -return ; -if ((int ) serial_console_next_disable - (int )omap2_read_32k_sync_counter () >=0 ) -return ; -serial_wait_tx (); -clk_disable (console_iclk); -clk_disable (console_fclk); - serial_console_clock_disabled =1 ; - }else { -int serial_wakeup =0 ; -u32 l; - -switch (serial_console_uart) { -case 1 : - l =prm_read_mod_reg (CORE_MOD ,PM_WKST1 ); -if (l &OMAP24XX_ST_UART1 ) - serial_wakeup =1 ; -break ; -case 2 : - l =prm_read_mod_reg (CORE_MOD ,PM_WKST1 ); -if (l &OMAP24XX_ST_UART2 ) - serial_wakeup =1 ; -break ; -case 3 : - l =prm_read_mod_reg (CORE_MOD ,OMAP24XX_PM_WKST2 ); -if (l &OMAP24XX_ST_UART3 ) - serial_wakeup =1 ; -break ; - } -if (serial_wakeup) -serial_console_kick (); -if (!serial_console_clock_disabled) -return ; -clk_enable (console_iclk); -clk_enable (console_fclk); - serial_console_clock_disabled =0 ; - } -} - -void pm_init_serial_console (void ) -{ -const struct omap_serial_console_config *conf; -char name[16 ]; - - conf =omap_get_config (OMAP_TAG_SERIAL_CONSOLE , - struct omap_serial_console_config); -if (conf ==NULL ) -return ; -if (conf->console_uart >3 || conf->console_uart <1 ) -return ; - serial_console_uart = conf->console_uart; -sprintf (name,"uart%d_fck" , conf->console_uart); - console_fclk =clk_get (NULL , name); -if (IS_ERR (console_fclk)) - console_fclk =NULL ; - name[6 ] ='i' ; - console_iclk =clk_get (NULL , name); -if (IS_ERR (console_fclk)) - console_iclk =NULL ; -if (console_fclk ==NULL || console_iclk ==NULL ) { - serial_console_uart =0 ; -return ; - } -switch (serial_console_uart) { -case 1 : -prm_set_mod_reg_bits (OMAP24XX_ST_UART1 ,CORE_MOD ,PM_WKEN1 ); -break ; -case 2 : -prm_set_mod_reg_bits (OMAP24XX_ST_UART2 ,CORE_MOD ,PM_WKEN1 ); -break ; -case 3 : -prm_set_mod_reg_bits (OMAP24XX_ST_UART3 ,CORE_MOD ,OMAP24XX_PM_WKEN2 ); -break ; - } -} -#define DUMP_PRM_MOD_REG (mod, reg) \ regs[reg_count].name = #mod "." #reg; \ regs[reg_count++].val = prm_read_mod_reg(mod, reg)
arch/arm/mach-omap2/pm.h +0 -8
@@ -21,18 +21,10 @@ extern unsigned short clocks_off_while_idle;extern atomic_t sleep_block;#ifdef CONFIG_PM_DEBUG -extern u32 omap2_read_32k_sync_counter (void );extern void omap2_pm_dump (int mode,int resume,unsigned int us); -extern void serial_console_fclk_mask (u32 *f1,u32 *f2); -extern void pm_init_serial_console (void ); -extern void serial_console_sleep (int enable);extern int omap2_pm_debug;#else -#define omap2_read_32k_sync_counter () 0; -#define serial_console_sleep (enable) do; while(0) -#define pm_init_serial_console () do; while(0)#define omap2_pm_dump (mode,resume,us) do; while(0) -#define serial_console_fclk_mask (f1,f2) do; while(0)#define omap2_pm_debug 0#endif /* CONFIG_PM_DEBUG */ #endif
arch/arm/mach-omap2/pm24xx.c +34 -23
122 lines not on this page · raw message
arch/arm/mach-omap2/pm34xx.c +19 -7
@@ -29,6 +29,7 @@#include <asm/arch/pm.h> #include <asm/arch/clockdomain.h> #include <asm/arch/powerdomain.h> +#include <asm/arch/common.h> #include "cm.h" #include "cm-regbits-34xx.h"
@@ -89,6 +90,9 @@ static irqreturn_t prcm_interrupt_handler (int irq, void *dev_id)u32 wkst, irqstatus_mpu;u32 fclk, iclk; +/* Check if we woke up to serial console activity */ +omap_serial_check_wakeup (); +/* WKUP */ wkst =prm_read_mod_reg (WKUP_MOD ,PM_WKST );if (wkst) {
@@ -199,17 +203,21 @@ static void omap_sram_idle(void)omap2_gpio_prepare_for_retention (); -/* XXX This is for gpio fclk hack. Will be removed as gpio driver -* handles fcks correctly */ -if (clocks_off_while_idle) +if (clocks_off_while_idle) { +omap_serial_enable_clocks (0 ); +/* XXX This is for gpio fclk hack. Will be removed as +* gpio driver * handles fcks correctly */ per_gpio_clk_disable (); + }_omap_sram_idle (NULL , save_state, clocks_off_while_idle); -/* XXX This is for gpio fclk hack. Will be removed as gpio driver -* handles fcks correctly */ -if (clocks_off_while_idle) +if (clocks_off_while_idle) { +omap_serial_enable_clocks (1 ); +/* XXX This is for gpio fclk hack. Will be removed as +* gpio driver * handles fcks correctly */ per_gpio_clk_enable (); + }omap2_gpio_resume_after_retention (); }
@@ -238,8 +246,10 @@ static int omap3_fclks_active(void) fck_per =cm_read_mod_reg (OMAP3430_PER_MOD ,CM_FCLKEN ); -if (clocks_off_while_idle) +if (clocks_off_while_idle) {gpio_fclk_mask (&fck_per); +omap_serial_fclk_mask (&fck_core1, &fck_per); + }if (fck_core1 | fck_core3 | fck_sgx | fck_dss | fck_cam | fck_per | fck_usbhost)
@@ -255,6 +265,8 @@ static int omap3_can_sleep(void)return 0 ;if (atomic_read (&sleep_block) >0 )return 0 ; +if (!omap_serial_can_sleep ()) +return 0 ;return 1 ; }
arch/arm/mach-omap2/serial.c +148 -0
184 lines not on this page · raw message
include/asm-arm/arch-omap/common.h +3 -0
@@ -35,6 +35,9 @@ extern void omap_map_common_io(void);extern struct sys_timer omap_timer;extern void omap_serial_init (void );extern void omap_serial_enable_clocks (int enable); +extern int omap_serial_can_sleep (void ); +extern void omap_serial_fclk_mask (u32 *f1,u32 *f2); +void omap_serial_check_wakeup (void );#ifdef CONFIG_I2C_OMAP extern int omap_register_i2c_bus(int bus_id, u32 clkrate, struct i2c_board_info const *info,
Signature · 1 line
1.5.5
PATCH 6/6 34XX: PM: Workaround to enable autoidle for clocks and plls
In reply to Högander JouniThis workaround enables autoidle for interface clocks and plls. Also automatic control of external oscillator through sys_clkreq is enabled.
Proper fix to this is to generalize omap3_dpll_allow_idle, omap3_dpll_deny_idle, omap3_dpll_autoidle_read and call it for each clock on init.
--- arch/arm/mach-omap2/pm34xx.c | 120 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 120 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/pm34xx.c +120 -0
@@ -433,6 +433,126 @@ static void __init prcm_setup_regs(void) }else prm_write_mod_reg (0 ,GFX_MOD ,PM_WKDEP ); +/* XXX Enable interface clock autoidle for all modules. This +* should be done by clockfw */ +cm_write_mod_reg ( +OMAP3430ES2_AUTO_MMC3 | +OMAP3430ES2_AUTO_ICR | +OMAP3430_AUTO_AES2 | +OMAP3430_AUTO_SHA12 | +OMAP3430_AUTO_DES2 | +OMAP3430_AUTO_MMC2 | +OMAP3430_AUTO_MMC1 | +OMAP3430_AUTO_MSPRO | +OMAP3430_AUTO_HDQ | +OMAP3430_AUTO_MCSPI4 | +OMAP3430_AUTO_MCSPI3 | +OMAP3430_AUTO_MCSPI2 | +OMAP3430_AUTO_MCSPI1 | +OMAP3430_AUTO_I2C3 | +OMAP3430_AUTO_I2C2 | +OMAP3430_AUTO_I2C1 | +OMAP3430_AUTO_UART2 | +OMAP3430_AUTO_UART1 | +OMAP3430_AUTO_GPT11 | +OMAP3430_AUTO_GPT10 | +OMAP3430_AUTO_MCBSP5 | +OMAP3430_AUTO_MCBSP1 | +OMAP3430ES1_AUTO_FAC |/* This is es1 only */ +OMAP3430_AUTO_MAILBOXES | +OMAP3430_AUTO_OMAPCTRL | +OMAP3430ES1_AUTO_FSHOSTUSB | +OMAP3430_AUTO_HSOTGUSB | +OMAP3430ES1_AUTO_D2D |/* This is es1 only */ +OMAP3430_AUTO_SSI , +CORE_MOD ,CM_AUTOIDLE1 ); + +cm_write_mod_reg ( +OMAP3430_AUTO_PKA | +OMAP3430_AUTO_AES1 | +OMAP3430_AUTO_RNG | +OMAP3430_AUTO_SHA11 | +OMAP3430_AUTO_DES1 , +CORE_MOD ,CM_AUTOIDLE2 ); + +if (is_sil_rev_greater_than (OMAP3430_REV_ES1_0 )) { +cm_write_mod_reg ( +OMAP3430ES2_AUTO_USBTLL , +CORE_MOD ,CM_AUTOIDLE3 ); + } + +cm_write_mod_reg ( +OMAP3430_AUTO_WDT2 | +OMAP3430_AUTO_WDT1 | +OMAP3430_AUTO_GPIO1 | +OMAP3430_AUTO_32KSYNC | +OMAP3430_AUTO_GPT12 | +OMAP3430_AUTO_GPT1 , +WKUP_MOD ,CM_AUTOIDLE ); + +cm_write_mod_reg ( +OMAP3430_AUTO_DSS , +OMAP3430_DSS_MOD , +CM_AUTOIDLE ); + +cm_write_mod_reg ( +OMAP3430_AUTO_CAM , +OMAP3430_CAM_MOD , +CM_AUTOIDLE ); + +cm_write_mod_reg ( +OMAP3430_AUTO_GPIO6 | +OMAP3430_AUTO_GPIO5 | +OMAP3430_AUTO_GPIO4 | +OMAP3430_AUTO_GPIO3 | +OMAP3430_AUTO_GPIO2 | +OMAP3430_AUTO_WDT3 | +OMAP3430_AUTO_UART3 | +OMAP3430_AUTO_GPT9 | +OMAP3430_AUTO_GPT8 | +OMAP3430_AUTO_GPT7 | +OMAP3430_AUTO_GPT6 | +OMAP3430_AUTO_GPT5 | +OMAP3430_AUTO_GPT4 | +OMAP3430_AUTO_GPT3 | +OMAP3430_AUTO_GPT2 | +OMAP3430_AUTO_MCBSP4 | +OMAP3430_AUTO_MCBSP3 | +OMAP3430_AUTO_MCBSP2 , +OMAP3430_PER_MOD , +CM_AUTOIDLE ); + +if (is_sil_rev_greater_than (OMAP3430_REV_ES1_0 )) { +cm_write_mod_reg ( +OMAP3430ES2_AUTO_USBHOST , +OMAP3430ES2_USBHOST_MOD , +CM_AUTOIDLE ); + } + +/* XXX Set all plls to autoidle. This is needed until autoidle is +* enabled by clockfw */ +cm_write_mod_reg (1 <<OMAP3430_CLKTRCTRL_IVA2_SHIFT , +OMAP3430_IVA2_MOD , +CM_AUTOIDLE2 ); +cm_write_mod_reg (1 <<OMAP3430_AUTO_MPU_DPLL_SHIFT , +MPU_MOD , +CM_AUTOIDLE2 ); +cm_write_mod_reg ((1 <<OMAP3430_AUTO_PERIPH_DPLL_SHIFT ) | + (1 <<OMAP3430_AUTO_CORE_DPLL_SHIFT ), +PLL_MOD , +CM_AUTOIDLE ); +cm_write_mod_reg (1 <<OMAP3430ES2_AUTO_PERIPH2_DPLL_SHIFT , +PLL_MOD , +CM_AUTOIDLE2 ); + +/* XXX Enable control of expternal oscillator through +* sys_clkreq. I think clockfw should provide means to do this +*/ +prm_rmw_mod_reg_bits (OMAP_AUTOEXTCLKMODE_MASK , +1 <<OMAP_AUTOEXTCLKMODE_SHIFT , +OMAP3430_GR_MOD , +OMAP3_PRM_CLKSRC_CTRL_OFFSET ); +/* setup wakup source */ prm_write_mod_reg (OMAP3430_EN_IO |OMAP3430_EN_GPIO1 |OMAP3430_EN_GPT1 ,WKUP_MOD ,PM_WKEN );
Signature · 1 line
1.5.5
PATCH 1/4 34XX: PM: Workaround to check wether any fck is active before entering sleep
In reply to Högander JouniThis workaround shouldn't be needed when all drivers are configuring their sysconfig registers properly and using their clocks properly.
--- arch/arm/mach-omap2/pm34xx.c | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/pm34xx.c +37 -0
@@ -174,10 +174,47 @@ static void omap_sram_idle(void)omap2_gpio_resume_after_retention (); } +/* XXX This workaround shouldn't be needed when all drivers are configuring +* their sysconfig registers properly and using their clocks +* properly. */ +static int omap3_fclks_active (void ) +{ +u32 fck_core1 =0 , fck_core3 =0 , fck_sgx =0 , fck_dss =0 , + fck_cam =0 , fck_per =0 , fck_usbhost =0 ; + + fck_core1 =cm_read_mod_reg (CORE_MOD , +CM_FCLKEN1 ); +if (is_sil_rev_greater_than (OMAP3430_REV_ES1_0 )) { + fck_core3 =cm_read_mod_reg (CORE_MOD , +OMAP3430ES2_CM_FCLKEN3 ); + fck_sgx =cm_read_mod_reg (OMAP3430ES2_SGX_MOD , +CM_FCLKEN ); + fck_usbhost =cm_read_mod_reg (OMAP3430ES2_USBHOST_MOD , +CM_FCLKEN ); + }else + fck_sgx =cm_read_mod_reg (GFX_MOD , +OMAP3430ES2_CM_FCLKEN3 ); + fck_dss =cm_read_mod_reg (OMAP3430_DSS_MOD , +CM_FCLKEN ); + fck_cam =cm_read_mod_reg (OMAP3430_CAM_MOD , +CM_FCLKEN ); + fck_per =cm_read_mod_reg (OMAP3430_PER_MOD , +CM_FCLKEN ); +if (fck_core1 | fck_core3 | fck_sgx | fck_dss | + fck_cam | fck_per | fck_usbhost) +return 1 ; +return 0 ; +} +static int omap3_can_sleep (void ) {if (!enable_dyn_sleep)return 0 ; +/* XXX This workaround shouldn't be needed when all drivers are configuring +* their sysconfig registers properly and using their clocks +* properly. */ +if (omap3_fclks_active ()) +return 0 ;if (atomic_read (&sleep_block) >0 )return 0 ;return 1 ;
Signature · 1 line
1.5.5
PATCH 2/4 PM: Workaround for taking care of gpio clocks
In reply to Högander JouniIn omap3 gpios 2-6 are in per domain. Functional clocks for these should be disabled. This patch is needed until gpio driver disables gpio clocks.
GPIO modules in PER domain are not able to act as a wake up source if PER domain is in retention. PER domain sleep transition before MPU is prevented by leaving icks active. PER domain still enters retention together with MPU. When this happens IOPAD wake up mechanism is used for gpios.
--- arch/arm/mach-omap2/pm34xx.c | 54 +++++++++++++++++++++++++++++++++++++++++- 1 files changed, 53 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/pm34xx.c +53 -1
@@ -53,6 +53,36 @@ static void (*saved_idle)(void);static struct powerdomain *mpu_pwrdm; +/* XXX This is for gpio fclk hack. Will be removed as gpio driver +* handles fcks correctly */ +#define NUM_OF_PERGPIOS 5 +static struct clk *gpio_fcks[NUM_OF_PERGPIOS ]; + +/* XXX This is for gpio fclk hack. Will be removed as gpio driver +* handles fcks correctly */ +static void per_gpio_clk_enable (void ) +{ +int i; +for (i =1 ; i <NUM_OF_PERGPIOS +1 ; i++) +clk_enable (gpio_fcks[i-1 ]); +} + +/* XXX This is for gpio fclk hack. Will be removed as gpio driver +* handles fcks correctly */ +static void per_gpio_clk_disable (void ) +{ +int i; +for (i =1 ; i <NUM_OF_PERGPIOS +1 ; i++) +clk_disable (gpio_fcks[i-1 ]); +} + +/* XXX This is for gpio fclk hack. Will be removed as gpio driver +* handles fcks correctly */ +static void gpio_fclk_mask (u32 *fclk) +{ + *fclk &= ~(0x1f <<13 ); +} +/* PRCM Interrupt Handler for wakeups */ static irqreturn_t prcm_interrupt_handler (int irq,void *dev_id) {
@@ -169,8 +199,18 @@ static void omap_sram_idle(void)omap2_gpio_prepare_for_retention (); +/* XXX This is for gpio fclk hack. Will be removed as gpio driver +* handles fcks correctly */ +if (clocks_off_while_idle) +per_gpio_clk_disable (); +_omap_sram_idle (NULL , save_state); +/* XXX This is for gpio fclk hack. Will be removed as gpio driver +* handles fcks correctly */ +if (clocks_off_while_idle) +per_gpio_clk_enable (); +omap2_gpio_resume_after_retention (); }
@@ -200,6 +240,10 @@ static int omap3_fclks_active(void) CM_FCLKEN); fck_per =cm_read_mod_reg (OMAP3430_PER_MOD ,CM_FCLKEN ); + +if (clocks_off_while_idle) +gpio_fclk_mask (&fck_per); +if (fck_core1 | fck_core3 | fck_sgx | fck_dss | fck_cam | fck_per | fck_usbhost)return 1 ;
@@ -418,7 +462,8 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm)int __init omap3_pm_init (void ) {struct power_state *pwrst; -int ret; +char clk_name[11 ]; +int ret, i;printk (KERN_ERR "Power Management for TI OMAP3.\n" );
@@ -454,6 +499,13 @@ int __init omap3_pm_init(void) pm_idle = omap3_pm_idle; +/* XXX This is for gpio fclk hack. Will be removed as gpio driver +* handles fcks correctly */ +for (i =1 ; i <NUM_OF_PERGPIOS +1 ; i++) { +sprintf (clk_name,"gpio%d_fck" , i +1 ); + gpio_fcks[i-1 ] =clk_get (NULL , clk_name); + } + err1:return ret; err2:
Signature · 1 line
1.5.5
PATCH 3/4 Added sleep support to UART
In reply to Högander JouniFrom: Tero Kristo <[email protected]>
UART usage (e.g. serial console) now denies sleep for 5 seconds. This makes it possible to use serial console when dynamic idle is enabled. Write 1 to /sys/power/clocks_off_while_sleep to enable uart clock disable on idle. Without this omap won't enter retention.
Also moved code from pm-debug.c to serial.c, and made pm24xx.c use this new implementation.
--- arch/arm/mach-omap2/pm-debug.c | 132 -------------------------- arch/arm/mach-omap2/pm.h | 7 -- arch/arm/mach-omap2/pm24xx.c | 57 +++++++----- arch/arm/mach-omap2/pm34xx.c | 27 ++++-- arch/arm/mach-omap2/serial.c | 148 ++++++++++++++++++++++++++++++ arch/arm/plat-omap/include/mach/common.h | 3 + 6 files changed, 204 insertions(+), 170 deletions(-)
arch/arm/mach-omap2/pm-debug.c +0 -132
@@ -37,138 +37,6 @@#ifdef CONFIG_PM_DEBUG int omap2_pm_debug =0 ; -static int serial_console_clock_disabled; -static int serial_console_uart; -static unsigned int serial_console_next_disable; - -static struct clk *console_iclk, *console_fclk; - -static void serial_console_kick (void ) -{ - serial_console_next_disable =omap2_read_32k_sync_counter (); -/* Keep the clocks on for 4 secs */ - serial_console_next_disable +=4 *32768 ; -} - -static void serial_wait_tx (void ) -{ -static const unsigned long uart_bases[3 ] = { -0x4806a000 ,0x4806c000 ,0x4806e000 - }; -unsigned long lsr_reg; -int looped =0 ; - -/* Wait for TX FIFO and THR to get empty */ - lsr_reg =IO_ADDRESS (uart_bases[serial_console_uart -1 ] + (5 <<2 )); -while ((__raw_readb (lsr_reg) &0x60 ) !=0x60 ) - looped =1 ; -if (looped) -serial_console_kick (); -} - -u32 omap2_read_32k_sync_counter (void ) -{ -return omap_readl (OMAP2_32KSYNCT_BASE +0x0010 ); -} - -void serial_console_fclk_mask (u32 *f1,u32 *f2) -{ -switch (serial_console_uart) { -case 1 : - *f1 &= ~(1 <<21 ); -break ; -case 2 : - *f1 &= ~(1 <<22 ); -break ; -case 3 : - *f2 &= ~(1 <<2 ); -break ; - } -} - -void serial_console_sleep (int enable) -{ -if (console_iclk ==NULL || console_fclk ==NULL ) -return ; - -if (enable) { -BUG_ON (serial_console_clock_disabled); -if (clk_get_usecount (console_fclk) ==0 ) -return ; -if ((int ) serial_console_next_disable - (int )omap2_read_32k_sync_counter () >=0 ) -return ; -serial_wait_tx (); -clk_disable (console_iclk); -clk_disable (console_fclk); - serial_console_clock_disabled =1 ; - }else { -int serial_wakeup =0 ; -u32 l; - -switch (serial_console_uart) { -case 1 : - l =prm_read_mod_reg (CORE_MOD ,PM_WKST1 ); -if (l &OMAP24XX_ST_UART1 ) - serial_wakeup =1 ; -break ; -case 2 : - l =prm_read_mod_reg (CORE_MOD ,PM_WKST1 ); -if (l &OMAP24XX_ST_UART2 ) - serial_wakeup =1 ; -break ; -case 3 : - l =prm_read_mod_reg (CORE_MOD ,OMAP24XX_PM_WKST2 ); -if (l &OMAP24XX_ST_UART3 ) - serial_wakeup =1 ; -break ; - } -if (serial_wakeup) -serial_console_kick (); -if (!serial_console_clock_disabled) -return ; -clk_enable (console_iclk); -clk_enable (console_fclk); - serial_console_clock_disabled =0 ; - } -} - -void pm_init_serial_console (void ) -{ -const struct omap_serial_console_config *conf; -char name[16 ]; - - conf =omap_get_config (OMAP_TAG_SERIAL_CONSOLE , - struct omap_serial_console_config); -if (conf ==NULL ) -return ; -if (conf->console_uart >3 || conf->console_uart <1 ) -return ; - serial_console_uart = conf->console_uart; -sprintf (name,"uart%d_fck" , conf->console_uart); - console_fclk =clk_get (NULL , name); -if (IS_ERR (console_fclk)) - console_fclk =NULL ; - name[6 ] ='i' ; - console_iclk =clk_get (NULL , name); -if (IS_ERR (console_fclk)) - console_iclk =NULL ; -if (console_fclk ==NULL || console_iclk ==NULL ) { - serial_console_uart =0 ; -return ; - } -switch (serial_console_uart) { -case 1 : -prm_set_mod_reg_bits (OMAP24XX_ST_UART1 ,CORE_MOD ,PM_WKEN1 ); -break ; -case 2 : -prm_set_mod_reg_bits (OMAP24XX_ST_UART2 ,CORE_MOD ,PM_WKEN1 ); -break ; -case 3 : -prm_set_mod_reg_bits (OMAP24XX_ST_UART3 ,CORE_MOD ,OMAP24XX_PM_WKEN2 ); -break ; - } -} -#define DUMP_PRM_MOD_REG (mod, reg) \ regs[reg_count].name = #mod "." #reg; \ regs[reg_count++].val = prm_read_mod_reg(mod, reg)
arch/arm/mach-omap2/pm.h +0 -7
@@ -25,16 +25,9 @@ extern void omap2_allow_sleep(void);#ifdef CONFIG_PM_DEBUG -extern u32 omap2_read_32k_sync_counter (void );extern void omap2_pm_dump (int mode,int resume,unsigned int us); -extern void serial_console_fclk_mask (u32 *f1,u32 *f2); -extern void pm_init_serial_console (void ); -extern void serial_console_sleep (int enable);extern int omap2_pm_debug;#else -#define omap2_read_32k_sync_counter () 0 -#define serial_console_sleep (enable) do {} while (0); -#define pm_init_serial_console () do {} while (0);#define omap2_pm_dump (mode, resume, us) do {} while (0);#define serial_console_fclk_mask (f1, f2) do {} while (0);#define omap2_pm_debug 0
arch/arm/mach-omap2/pm24xx.c +34 -23
122 lines not on this page · raw message
arch/arm/mach-omap2/pm34xx.c +19 -8
@@ -29,6 +29,7 @@#include <mach/pm.h> #include <mach/clockdomain.h> #include <mach/powerdomain.h> +#include <mach/common.h> #include "cm.h" #include "cm-regbits-34xx.h"
@@ -89,6 +90,9 @@ static irqreturn_t prcm_interrupt_handler (int irq, void *dev_id)u32 wkst, irqstatus_mpu;u32 fclk, iclk; +/* Check if we woke up to serial console activity */ +omap_serial_check_wakeup (); +/* WKUP */ wkst =prm_read_mod_reg (WKUP_MOD ,PM_WKST );if (wkst) {
@@ -198,18 +202,21 @@ static void omap_sram_idle(void) }omap2_gpio_prepare_for_retention (); - -/* XXX This is for gpio fclk hack. Will be removed as gpio driver -* handles fcks correctly */ -if (clocks_off_while_idle) +if (clocks_off_while_idle) { +omap_serial_enable_clocks (0 ); +/* XXX This is for gpio fclk hack. Will be removed as +* gpio driver * handles fcks correctly */ per_gpio_clk_disable (); + }_omap_sram_idle (NULL , save_state); -/* XXX This is for gpio fclk hack. Will be removed as gpio driver -* handles fcks correctly */ -if (clocks_off_while_idle) +if (clocks_off_while_idle) { +omap_serial_enable_clocks (1 ); +/* XXX This is for gpio fclk hack. Will be removed as +* gpio driver * handles fcks correctly */ per_gpio_clk_enable (); + }omap2_gpio_resume_after_retention (); }
@@ -241,8 +248,10 @@ static int omap3_fclks_active(void) fck_per =cm_read_mod_reg (OMAP3430_PER_MOD ,CM_FCLKEN ); -if (clocks_off_while_idle) +if (clocks_off_while_idle) {gpio_fclk_mask (&fck_per); +omap_serial_fclk_mask (&fck_core1, &fck_per); + }if (fck_core1 | fck_core3 | fck_sgx | fck_dss | fck_cam | fck_per | fck_usbhost)
@@ -261,6 +270,8 @@ static int omap3_can_sleep(void)return 0 ;if (atomic_read (&sleep_block) >0 )return 0 ; +if (!omap_serial_can_sleep ()) +return 0 ;return 1 ; }
arch/arm/mach-omap2/serial.c +148 -0
184 lines not on this page · raw message
arch/arm/plat-omap/include/mach/common.h +3 -0
@@ -35,6 +35,9 @@ extern void omap_map_common_io(void);extern struct sys_timer omap_timer;extern void omap_serial_init (void );extern void omap_serial_enable_clocks (int enable); +extern int omap_serial_can_sleep (void ); +extern void omap_serial_fclk_mask (u32 *f1,u32 *f2); +void omap_serial_check_wakeup (void );#ifdef CONFIG_I2C_OMAP extern int omap_register_i2c_bus(int bus_id, u32 clkrate, struct i2c_board_info const *info,
Signature · 1 line
1.5.5
PATCH 4/4 34XX: PM: Workaround to enable autoidle for clocks and plls
In reply to Högander JouniFrom: ext Jouni Hogander <[email protected]>
This workaround enables autoidle for interface clocks and plls. Also automatic control of external oscillator through sys_clkreq is enabled.
Proper fix to this is to generalize omap3_dpll_allow_idle, omap3_dpll_deny_idle, omap3_dpll_autoidle_read and call it for each clock on init.
--- arch/arm/mach-omap2/pm34xx.c | 120 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 120 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/pm34xx.c +120 -0
@@ -438,6 +438,126 @@ static void __init prcm_setup_regs(void) }else prm_write_mod_reg (0 ,GFX_MOD ,PM_WKDEP ); +/* XXX Enable interface clock autoidle for all modules. This +* should be done by clockfw */ +cm_write_mod_reg ( +OMAP3430ES2_AUTO_MMC3 | +OMAP3430ES2_AUTO_ICR | +OMAP3430_AUTO_AES2 | +OMAP3430_AUTO_SHA12 | +OMAP3430_AUTO_DES2 | +OMAP3430_AUTO_MMC2 | +OMAP3430_AUTO_MMC1 | +OMAP3430_AUTO_MSPRO | +OMAP3430_AUTO_HDQ | +OMAP3430_AUTO_MCSPI4 | +OMAP3430_AUTO_MCSPI3 | +OMAP3430_AUTO_MCSPI2 | +OMAP3430_AUTO_MCSPI1 | +OMAP3430_AUTO_I2C3 | +OMAP3430_AUTO_I2C2 | +OMAP3430_AUTO_I2C1 | +OMAP3430_AUTO_UART2 | +OMAP3430_AUTO_UART1 | +OMAP3430_AUTO_GPT11 | +OMAP3430_AUTO_GPT10 | +OMAP3430_AUTO_MCBSP5 | +OMAP3430_AUTO_MCBSP1 | +OMAP3430ES1_AUTO_FAC |/* This is es1 only */ +OMAP3430_AUTO_MAILBOXES | +OMAP3430_AUTO_OMAPCTRL | +OMAP3430ES1_AUTO_FSHOSTUSB | +OMAP3430_AUTO_HSOTGUSB | +OMAP3430ES1_AUTO_D2D |/* This is es1 only */ +OMAP3430_AUTO_SSI , +CORE_MOD ,CM_AUTOIDLE1 ); + +cm_write_mod_reg ( +OMAP3430_AUTO_PKA | +OMAP3430_AUTO_AES1 | +OMAP3430_AUTO_RNG | +OMAP3430_AUTO_SHA11 | +OMAP3430_AUTO_DES1 , +CORE_MOD ,CM_AUTOIDLE2 ); + +if (is_sil_rev_greater_than (OMAP3430_REV_ES1_0 )) { +cm_write_mod_reg ( +OMAP3430ES2_AUTO_USBTLL , +CORE_MOD ,CM_AUTOIDLE3 ); + } + +cm_write_mod_reg ( +OMAP3430_AUTO_WDT2 | +OMAP3430_AUTO_WDT1 | +OMAP3430_AUTO_GPIO1 | +OMAP3430_AUTO_32KSYNC | +OMAP3430_AUTO_GPT12 | +OMAP3430_AUTO_GPT1 , +WKUP_MOD ,CM_AUTOIDLE ); + +cm_write_mod_reg ( +OMAP3430_AUTO_DSS , +OMAP3430_DSS_MOD , +CM_AUTOIDLE ); + +cm_write_mod_reg ( +OMAP3430_AUTO_CAM , +OMAP3430_CAM_MOD , +CM_AUTOIDLE ); + +cm_write_mod_reg ( +OMAP3430_AUTO_GPIO6 | +OMAP3430_AUTO_GPIO5 | +OMAP3430_AUTO_GPIO4 | +OMAP3430_AUTO_GPIO3 | +OMAP3430_AUTO_GPIO2 | +OMAP3430_AUTO_WDT3 | +OMAP3430_AUTO_UART3 | +OMAP3430_AUTO_GPT9 | +OMAP3430_AUTO_GPT8 | +OMAP3430_AUTO_GPT7 | +OMAP3430_AUTO_GPT6 | +OMAP3430_AUTO_GPT5 | +OMAP3430_AUTO_GPT4 | +OMAP3430_AUTO_GPT3 | +OMAP3430_AUTO_GPT2 | +OMAP3430_AUTO_MCBSP4 | +OMAP3430_AUTO_MCBSP3 | +OMAP3430_AUTO_MCBSP2 , +OMAP3430_PER_MOD , +CM_AUTOIDLE ); + +if (is_sil_rev_greater_than (OMAP3430_REV_ES1_0 )) { +cm_write_mod_reg ( +OMAP3430ES2_AUTO_USBHOST , +OMAP3430ES2_USBHOST_MOD , +CM_AUTOIDLE ); + } + +/* XXX Set all plls to autoidle. This is needed until autoidle is +* enabled by clockfw */ +cm_write_mod_reg (1 <<OMAP3430_CLKTRCTRL_IVA2_SHIFT , +OMAP3430_IVA2_MOD , +CM_AUTOIDLE2 ); +cm_write_mod_reg (1 <<OMAP3430_AUTO_MPU_DPLL_SHIFT , +MPU_MOD , +CM_AUTOIDLE2 ); +cm_write_mod_reg ((1 <<OMAP3430_AUTO_PERIPH_DPLL_SHIFT ) | + (1 <<OMAP3430_AUTO_CORE_DPLL_SHIFT ), +PLL_MOD , +CM_AUTOIDLE ); +cm_write_mod_reg (1 <<OMAP3430ES2_AUTO_PERIPH2_DPLL_SHIFT , +PLL_MOD , +CM_AUTOIDLE2 ); + +/* XXX Enable control of expternal oscillator through +* sys_clkreq. I think clockfw should provide means to do this +*/ +prm_rmw_mod_reg_bits (OMAP_AUTOEXTCLKMODE_MASK , +1 <<OMAP_AUTOEXTCLKMODE_SHIFT , +OMAP3430_GR_MOD , +OMAP3_PRM_CLKSRC_CTRL_OFFSET ); +/* setup wakup source */ prm_write_mod_reg (OMAP3430_EN_IO |OMAP3430_EN_GPIO1 |OMAP3430_EN_GPT1 ,WKUP_MOD ,PM_WKEN );
Signature · 1 line
1.5.5