ARM: exynos: cpuidle: Move the driver to drivers/cpuidle
Subsystems (5)
cover ARM: exynos: cpuidle: Move the driver to drivers/cpuidle
This patchset relies on the cpm_pm notifier to initiate the powerdown sequence operations from pm.c instead cpuidle.c. Thus the cpuidle driver is no longer dependent from arch specific code as everything is called from the pm.c file.
The patchset applies on top of v3.14.
Tested on exynos4: 4210
Tested on exynos5: 5250
Daniel Lezcano (17):
ARM: exynos: cpuidle: Prevent forward declaration
ARM: exynos: cpuidle: use cpuidle_register
ARM: exynos: cpuidle: change function name prefix
ARM: exynos: cpuidle: encapsulate register access inside a function
ARM: exynos: cpuidle: Move some code inside the idle_finisher
ARM: exynos: cpuidle: Fix S5P_WAKEUP_STAT call
ARM: exynos: cpuidle: Use the cpu_pm notifier
ARM: exynos: cpuidle: Move scu_enable in the cpu_pm notifier
ARM: exynos: cpuidle: Remove ifdef for scu_enable
ARM: exynos: cpuidle: Move exynos_set_wakeupmask in the cpu_pm
notifier
ARM: exynos: cpuidle: Move the power sequence call in the cpu_pm
notifier
ARM: exynos: cpuidle: Move S5P_CHECK_AFTR in a header
ARM: exynos: cpuidle: Move clock setup to pm.c
ARM: exynos: cpuidle: Move the boot vector in pm.c
ARM: exynos: cpuidle: Pass the AFTR callback to the platform_data
ARM: exynos: cpuidle: Move the driver to drivers/cpuidle directory
ARM: exynos: config: Enable cpuidle
arch/arm/configs/exynos_defconfig | 1 + arch/arm/mach-exynos/Makefile | 1 - arch/arm/mach-exynos/common.c | 5 +- arch/arm/mach-exynos/common.h | 1 + arch/arm/mach-exynos/cpuidle.c | 256 ------------------------------------- arch/arm/mach-exynos/pm.c | 191 ++++++++++++++++++++++----- arch/arm/mach-exynos/pmu.c | 6 + arch/arm/mach-exynos/regs-pmu.h | 1 + drivers/cpuidle/Kconfig.arm | 7 + drivers/cpuidle/Makefile | 1 + drivers/cpuidle/cpuidle-exynos.c | 102 +++++++++++++++ 11 files changed, 281 insertions(+), 291 deletions(-) delete mode 100644 arch/arm/mach-exynos/cpuidle.c create mode 100644 drivers/cpuidle/cpuidle-exynos.c
Signature · 1 line
1.7.9.5
PATCH 1/17 ARM: exynos: cpuidle: Prevent forward declaration
Move the structure below the 'exynos4_enter_lowpower' function so no more need of forward declaration.
--- arch/arm/mach-exynos/cpuidle.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)
arch/arm/mach-exynos/cpuidle.c +18 -22
@@ -60,30 +60,8 @@#define PWR_CTRL2_CORE2_UP_RATIO (1 << 4)#define PWR_CTRL2_CORE1_UP_RATIO (1 << 0) -static int exynos4_enter_lowpower (struct cpuidle_device *dev, -struct cpuidle_driver *drv, -int index); - static DEFINE_PER_CPU(struct cpuidle_device, exynos4_cpuidle_device); -static struct cpuidle_driver exynos4_idle_driver = { - .name ="exynos4_idle" , - .owner =THIS_MODULE , - .states = { - [0 ] =ARM_CPUIDLE_WFI_STATE , - [1 ] = { - .enter = exynos4_enter_lowpower, - .exit_latency =300 , - .target_residency =100000 , - .flags =CPUIDLE_FLAG_TIME_VALID , - .name ="C1" , - .desc ="ARM power down" , - }, - }, - .state_count =2 , - .safe_state_index =0 , -}; -/* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */ static void exynos4_set_wakeupmask (void ) {
@@ -214,6 +192,24 @@ static void __init exynos5_core_down_clk(void)__raw_writel (tmp,EXYNOS5_PWR_CTRL2 ); } +static struct cpuidle_driver exynos4_idle_driver = { + .name ="exynos4_idle" , + .owner =THIS_MODULE , + .states = { + [0 ] =ARM_CPUIDLE_WFI_STATE , + [1 ] = { + .enter = exynos4_enter_lowpower, + .exit_latency =300 , + .target_residency =100000 , + .flags =CPUIDLE_FLAG_TIME_VALID , + .name ="C1" , + .desc ="ARM power down" , + }, + }, + .state_count =2 , + .safe_state_index =0 , +}; +static int exynos_cpuidle_probe (struct platform_device *pdev) {int cpu_id, ret;
Signature · 1 line
1.7.9.5
PATCH 1/17 ARM: exynos: cpuidle: Prevent forward declaration
Quoted 58 lines · Daniel Lezcano
Move the structure below the '
exynos4_enter_lowpower' function so no more need of forward declaration.Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/cpuidle.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)arch/arm/mach-exynos/cpuidle.c +11
-22@@ -60,30 +60,8 @@#define PWR_CTRL2_CORE2_UP_RATIO (1 << 4)#define PWR_CTRL2_CORE1_UP_RATIO (1 << 0) -static int exynos4_enter_lowpower (struct cpuidle_device *dev, -struct cpuidle_driver *drv, -int index); - static DEFINE_PER_CPU(struct cpuidle_device, exynos4_cpuidle_device); -static struct cpuidle_driver exynos4_idle_driver = { - .name ="exynos4_idle" , - .owner =THIS_MODULE , - .states = { - [0 ] =ARM_CPUIDLE_WFI_STATE , - [1 ] = { - .enter = exynos4_enter_lowpower, - .exit_latency =300 , - .target_residency =100000 , - .flags =CPUIDLE_FLAG_TIME_VALID , - .name ="C1" , - .desc ="ARM power down" , - }, - }, - .state_count =2 , - .safe_state_index =0 , -}; -/* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */ static void exynos4_set_wakeupmask (void ) {@@ -214,6 +192,24 @@ static void __init exynos5_core_down_clk(void)__raw_writel (tmp,EXYNOS5_PWR_CTRL2 ); } +static struct cpuidle_driver exynos4_idle_driver = { + .name ="exynos4_idle" , + .owner =THIS_MODULE , + .states = { + [0 ] =ARM_CPUIDLE_WFI_STATE , + [1 ] = { + .enter = exynos4_enter_lowpower, + .exit_latency =300 , + .target_residency =100000 , + .flags =CPUIDLE_FLAG_TIME_VALID , + .name ="C1" ,
arch/arm/mach-exynos/cpuidle.c static void __init exynos5_core_down_clk(void) · line 215
Quoted 10 lines
arch/arm/mach-exynos/cpuidle.c +7
-0+ .desc = "ARM power down", + }, + }, + .state_count = 2, + .safe_state_index = 0, +}; +static int exynos_cpuidle_probe (struct platform_device *pdev) {int cpu_id, ret;
PATCH 2/17 ARM: exynos: cpuidle: use cpuidle_register
In reply to Daniel LezcanoUse the cpuidle generic function 'cpuidle_register'. That saves us from some extra lines of code and unneeded variables.
--- arch/arm/mach-exynos/cpuidle.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
arch/arm/mach-exynos/cpuidle.c +2 -16
@@ -60,8 +60,6 @@#define PWR_CTRL2_CORE2_UP_RATIO (1 << 4)#define PWR_CTRL2_CORE1_UP_RATIO (1 << 0) -static DEFINE_PER_CPU(struct cpuidle_device, exynos4_cpuidle_device); -/* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */ static void exynos4_set_wakeupmask (void ) {
@@ -212,8 +210,7 @@ static struct cpuidle_driver exynos4_idle_driver = {static int exynos_cpuidle_probe (struct platform_device *pdev) { -int cpu_id, ret; -struct cpuidle_device *device; +int ret;if (soc_is_exynos5250 ())exynos5_core_down_clk ();
@@ -221,23 +218,12 @@ static int exynos_cpuidle_probe(struct platform_device *pdev)if (soc_is_exynos5440 ()) exynos4_idle_driver.state_count =1 ; - ret =cpuidle_register_driver (&exynos4_idle_driver); + ret =cpuidle_register (&exynos4_idle_driver,NULL );if (ret) {dev_err (&pdev->dev,"failed to register cpuidle driver\n" );return ret; } -for_each_online_cpu (cpu_id) { - device = &per_cpu (exynos4_cpuidle_device, cpu_id); - device->cpu = cpu_id; - - ret =cpuidle_register_device (device); -if (ret) { -dev_err (&pdev->dev,"failed to register cpuidle device\n" ); -return ret; - } - } -return 0 ; }
Signature · 1 line
1.7.9.5
PATCH 2/17 ARM: exynos: cpuidle: use cpuidle_register
Quoted 7 lines · Daniel Lezcano
Use the cpuidle generic function '
cpuidle_register'. That saves us from some extra lines of code and unneeded variables.Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/cpuidle.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
PATCH 3/17 ARM: exynos: cpuidle: change function name prefix
In reply to Daniel LezcanoThe driver was initially written for exynos4 but the driver is used also for exynos5.
Change the function prefix name exynos4 -> exynos
--- arch/arm/mach-exynos/cpuidle.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
arch/arm/mach-exynos/cpuidle.c +10 -10
@@ -61,7 +61,7 @@#define PWR_CTRL2_CORE1_UP_RATIO (1 << 0)/* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */ -static void exynos4_set_wakeupmask (void ) +static void exynos_set_wakeupmask (void ) {__raw_writel (0x0000ff3e ,S5P_WAKEUP_MASK ); }
@@ -92,13 +92,13 @@ static int idle_finisher(unsigned long flags)return 1 ; } -static int exynos4_enter_core0_aftr (struct cpuidle_device *dev, +static int exynos_enter_core0_aftr (struct cpuidle_device *dev,struct cpuidle_driver *drv,int index) {unsigned long tmp; -exynos4_set_wakeupmask (); +exynos_set_wakeupmask ();/* Set value of power down register for aftr mode */ exynos_sys_powerdown_conf (SYS_AFTR );
@@ -142,7 +142,7 @@ static int exynos4_enter_core0_aftr(struct cpuidle_device *dev,return index; } -static int exynos4_enter_lowpower (struct cpuidle_device *dev, +static int exynos_enter_lowpower (struct cpuidle_device *dev,struct cpuidle_driver *drv,int index) {
@@ -155,7 +155,7 @@ static int exynos4_enter_lowpower(struct cpuidle_device *dev,if (new_index ==0 )return arm_cpuidle_simple_enter (dev, drv, new_index);else -return exynos4_enter_core0_aftr (dev, drv, new_index); +return exynos_enter_core0_aftr (dev, drv, new_index); }static void __init exynos5_core_down_clk (void )
@@ -190,13 +190,13 @@ static void __init exynos5_core_down_clk(void)__raw_writel (tmp,EXYNOS5_PWR_CTRL2 ); } -static struct cpuidle_driver exynos4_idle_driver = { - .name ="exynos4_idle" , +static struct cpuidle_driver exynos_idle_driver = { + .name ="exynos_idle" , .owner =THIS_MODULE , .states = { [0 ] =ARM_CPUIDLE_WFI_STATE , [1 ] = { - .enter = exynos4_enter_lowpower, + .enter = exynos_enter_lowpower, .exit_latency =300 , .target_residency =100000 , .flags =CPUIDLE_FLAG_TIME_VALID ,
@@ -216,9 +216,9 @@ static int exynos_cpuidle_probe(struct platform_device *pdev)exynos5_core_down_clk ();if (soc_is_exynos5440 ()) - exynos4_idle_driver.state_count =1 ; + exynos_idle_driver.state_count =1 ; - ret =cpuidle_register (&exynos4_idle_driver,NULL ); + ret =cpuidle_register (&exynos_idle_driver,NULL );if (ret) {dev_err (&pdev->dev,"failed to register cpuidle driver\n" );return ret;
Signature · 1 line
1.7.9.5
PATCH 3/17 ARM: exynos: cpuidle: change function name prefix
Quoted 9 lines · Daniel Lezcano
The driver was initially written for exynos4 but the driver is used also for exynos5.
Change the function prefix name exynos4 -> exynos
Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/cpuidle.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
PATCH 4/17 ARM: exynos: cpuidle: encapsulate register access inside a function
In reply to Daniel LezcanoThat makes the code cleaner and encapsulted. The function will be reused in the next patch.
--- arch/arm/mach-exynos/pm.c | 65 ++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 24 deletions(-)
arch/arm/mach-exynos/pm.c +41 -24
@@ -102,6 +102,42 @@ static struct sleep_save exynos_core_save[] = {/* For Cortex-A9 Diagnostic and Power control register */ static unsigned int save_arm_register[2 ]; +static void exynos_cpu_save_register (void ) +{ +unsigned long tmp; + +/* Save Power control register */ + asm ("mrc p15, 0, %0, c15, c0, 0" + :"=r" (tmp) : :"cc" ); + + save_arm_register[0 ] = tmp; + +/* Save Diagnostic register */ + asm ("mrc p15, 0, %0, c15, c0, 1" + :"=r" (tmp) : :"cc" ); + + save_arm_register[1 ] = tmp; +} + +static void exynos_cpu_restore_register (void ) +{ +unsigned long tmp; + +/* Restore Power control register */ + tmp = save_arm_register[0 ]; + + asmvolatile ("mcr p15, 0, %0, c15, c0, 0" + : :"r" (tmp) + :"cc" ); + +/* Restore Diagnostic register */ + tmp = save_arm_register[1 ]; + + asmvolatile ("mcr p15, 0, %0, c15, c0, 1" + : :"r" (tmp) + :"cc" ); +} +static int exynos_cpu_suspend (unsigned long arg) {#ifdef CONFIG_CACHE_L2X0
@@ -279,17 +315,8 @@ static int exynos_pm_suspend(void) tmp = (S5P_USE_STANDBY_WFI0 |S5P_USE_STANDBY_WFE0 );__raw_writel (tmp,S5P_CENTRAL_SEQ_OPTION ); -if (!soc_is_exynos5250 ()) { -/* Save Power control register */ - asm ("mrc p15, 0, %0, c15, c0, 0" - :"=r" (tmp) : :"cc" ); - save_arm_register[0 ] = tmp; - -/* Save Diagnostic register */ - asm ("mrc p15, 0, %0, c15, c0, 1" - :"=r" (tmp) : :"cc" ); - save_arm_register[1 ] = tmp; - } +if (!soc_is_exynos5250 ()) +exynos_cpu_save_register ();return 0 ; }
@@ -313,19 +340,9 @@ static void exynos_pm_resume(void)/* No need to perform below restore code */ goto early_wakeup; } -if (!soc_is_exynos5250 ()) { -/* Restore Power control register */ - tmp = save_arm_register[0 ]; - asmvolatile ("mcr p15, 0, %0, c15, c0, 0" - : :"r" (tmp) - :"cc" ); - -/* Restore Diagnostic register */ - tmp = save_arm_register[1 ]; - asmvolatile ("mcr p15, 0, %0, c15, c0, 1" - : :"r" (tmp) - :"cc" ); - } + +if (!soc_is_exynos5250 ()) +exynos_cpu_restore_register ();/* For release retention */
Signature · 1 line
1.7.9.5
PATCH 4/17 ARM: exynos: cpuidle: encapsulate register access inside a function
Quoted 7 lines · Daniel Lezcano
That makes the code cleaner and encapsulted. The function will be reused in the next patch.
Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/pm.c | 65 ++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 24 deletions(-)
PATCH 5/17 ARM: exynos: cpuidle: Move some code inside the idle_finisher
In reply to Daniel LezcanoMove the code around to differentiate different section of code and prepare it to be factored out in the next patches.
--- arch/arm/mach-exynos/cpuidle.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
arch/arm/mach-exynos/cpuidle.c +9 -8
@@ -88,7 +88,16 @@ static void restore_cpu_arch_register(void)static int idle_finisher (unsigned long flags) { +exynos_set_wakeupmask (); + +__raw_writel (virt_to_phys (s3c_cpu_resume),REG_DIRECTGO_ADDR ); +__raw_writel (S5P_CHECK_AFTR ,REG_DIRECTGO_FLAG ); + +/* Set value of power down register for aftr mode */ +exynos_sys_powerdown_conf (SYS_AFTR ); +cpu_do_idle (); +return 1 ; }
@@ -98,14 +107,6 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev, {unsigned long tmp; -exynos_set_wakeupmask (); - -/* Set value of power down register for aftr mode */ -exynos_sys_powerdown_conf (SYS_AFTR ); - -__raw_writel (virt_to_phys (s3c_cpu_resume),REG_DIRECTGO_ADDR ); -__raw_writel (S5P_CHECK_AFTR ,REG_DIRECTGO_FLAG ); -save_cpu_arch_register ();/* Setting Central Sequence Register for power down mode */
Signature · 1 line
1.7.9.5
PATCH 5/17 ARM: exynos: cpuidle: Move some code inside the idle_finisher
Quoted 13 lines · Daniel Lezcano
Move the code around to differentiate different section of code and prepare it to be factored out in the next patches.
Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/cpuidle.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)arch/arm/mach-exynos/cpuidle.c +0
-0
arch/arm/mach-exynos/cpuidle.c static void restore_cpu_arch_register(void) · line 97
Quoted 10 lines
arch/arm/mach-exynos/cpuidle.c +7
-0@@ -88,7 +88,16 @@ static void restore_cpu_arch_register(void)static int idle_finisher (unsigned long flags) { +exynos_set_wakeupmask (); + +__raw_writel (virt_to_phys (s3c_cpu_resume),REG_DIRECTGO_ADDR ); +__raw_writel (S5P_CHECK_AFTR ,REG_DIRECTGO_FLAG ); + +/* Set value of power down register for aftr mode */ +exynos_sys_powerdown_conf (SYS_AFTR );
Just to highlight this, you have changed the order in which these things were done earlier.. In case that have any side effects.
Quoted 10 lines
arch/arm/mach-exynos/cpuidle.c +1
-1cpu_do_idle (); +return 1 ; }@@ -98,14 +107,6 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev, {unsigned long tmp; -exynos_set_wakeupmask ();
arch/arm/mach-exynos/cpuidle.c static int exynos_enter_core0_aftr(struct cpuidle_device *dev, · line 112
Quoted 10 lines
arch/arm/mach-exynos/cpuidle.c +0
-7- -/* Set value of power down register for aftr mode */ -exynos_sys_powerdown_conf (SYS_AFTR ); - -__raw_writel (virt_to_phys (s3c_cpu_resume),REG_DIRECTGO_ADDR ); -__raw_writel (S5P_CHECK_AFTR ,REG_DIRECTGO_FLAG ); -save_cpu_arch_register ();/* Setting Central Sequence Register for power down mode */
Here as well, we do all above (-) things after this sequence now:
save_cpu_arch_register();
/* Setting Central Sequence Register for power down mode */ tmp = __raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION); tmp &= ~S5P_CENTRAL_LOWPWR_CFG;__raw_writel(tmp, S5P_CENTRAL_SEQ_CONFIGURATION);
cpu_pm_enter();
Probably mention that in log too, that it doesn't have any side effects?
PATCH 5/17 ARM: exynos: cpuidle: Move some code inside the idle_finisher
Quoted 15 lines · Viresh Kumar
Quoted 14 lines · Daniel Lezcano
Move the code around to differentiate different section of code and prepare it to be factored out in the next patches.
Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/cpuidle.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)arch/arm/mach-exynos/cpuidle.c +0
-0@@ -88,7 +88,16 @@ static void restore_cpu_arch_register(void)
Quoted 12 lines
arch/arm/mach-exynos/cpuidle.c static void restore_cpu_arch_register(void) · line 97
Quoted 9 lines
arch/arm/mach-exynos/cpuidle.c +7
-0static int idle_finisher (unsigned long flags) { +exynos_set_wakeupmask (); + +__raw_writel (virt_to_phys (s3c_cpu_resume),REG_DIRECTGO_ADDR ); +__raw_writel (S5P_CHECK_AFTR ,REG_DIRECTGO_FLAG ); + +/* Set value of power down register for aftr mode */ +exynos_sys_powerdown_conf (SYS_AFTR );Just to highlight this, you have changed the order in which these things were done earlier.. In case that have any side effects.
Yes, that's correct. I changed the order. That doesn't have a side effect because the calls are independent. The important call is cpu_do_idle() which must be done the last.
Quoted 36 lines
Quoted 10 lines
arch/arm/mach-exynos/cpuidle.c +1
-1cpu_do_idle (); +return 1 ; }@@ -98,14 +107,6 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev, {unsigned long tmp; -exynos_set_wakeupmask ();arch/arm/mach-exynos/cpuidle.c static int exynos_enter_core0_aftr(struct cpuidle_device *dev, · line 112
Quoted 10 lines
arch/arm/mach-exynos/cpuidle.c +0
-7- -/* Set value of power down register for aftr mode */ -exynos_sys_powerdown_conf (SYS_AFTR ); - -__raw_writel (virt_to_phys (s3c_cpu_resume),REG_DIRECTGO_ADDR ); -__raw_writel (S5P_CHECK_AFTR ,REG_DIRECTGO_FLAG ); -save_cpu_arch_register ();/* Setting Central Sequence Register for power down mode */ Here as well, we do all above (-) things after this sequence now:
save_cpu_arch_register();/* Setting Central Sequence Register for power down mode */ tmp =
__raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION); tmp &= ~S5P_CENTRAL_LOWPWR_CFG;__raw_writel(tmp, S5P_CENTRAL_SEQ_CONFIGURATION);
cpu_pm_enter();Probably mention that in log too, that it doesn't have any side effects?
Reviewed-by Viresh Kumar <[email protected]>
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
PATCH 6/17 ARM: exynos: cpuidle: Fix S5P_WAKEUP_STAT call
In reply to Daniel LezcanoThis function should be called only when the powerdown sequence fails.
Even if the current code does not hurt, by moving this line, we have the same code than the one in pm.c.
--- arch/arm/mach-exynos/cpuidle.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/arm/mach-exynos/cpuidle.c +2 -3
@@ -135,11 +135,10 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev,if (!(tmp &S5P_CENTRAL_LOWPWR_CFG )) { tmp |=S5P_CENTRAL_LOWPWR_CFG ;__raw_writel (tmp,S5P_CENTRAL_SEQ_CONFIGURATION ); +/* Clear wakeup state register */ +__raw_writel (0x0 ,S5P_WAKEUP_STAT ); } -/* Clear wakeup state register */ -__raw_writel (0x0 ,S5P_WAKEUP_STAT ); -return index; }
Signature · 1 line
1.7.9.5
PATCH 6/17 ARM: exynos: cpuidle: Fix S5P_WAKEUP_STAT call
Quoted 17 lines · Daniel Lezcano
This function should be called only when the powerdown sequence fails.
Even if the current code does not hurt, by moving this line, we have the same code than the one in
pm.c.Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/cpuidle.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)arch/arm/mach-exynos/cpuidle.c +0
-0@@ -135,11 +135,10 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev,if (!(tmp &S5P_CENTRAL_LOWPWR_CFG )) { tmp |=S5P_CENTRAL_LOWPWR_CFG ;
arch/arm/mach-exynos/cpuidle.c static int exynos_enter_core0_aftr(struct cpuidle_device *dev, · line 143
Quoted 10 lines
arch/arm/mach-exynos/cpuidle.c +2
-3__raw_writel (tmp,S5P_CENTRAL_SEQ_CONFIGURATION ); +/* Clear wakeup state register */ +__raw_writel (0x0 ,S5P_WAKEUP_STAT ); } -/* Clear wakeup state register */ -__raw_writel (0x0 ,S5P_WAKEUP_STAT ); -return index; }
PATCH 7/17 ARM: exynos: cpuidle: Use the cpu_pm notifier
In reply to Daniel LezcanoUse the cpu_pm_enter/exit notifier to group some pm code inside the pm file.
The save and restore code is duplicated across pm.c and cpuidle.c. By using the cpu_pm notifier, we can factor out the routine.
--- arch/arm/mach-exynos/cpuidle.c | 24 ------------------------ arch/arm/mach-exynos/pm.c | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 24 deletions(-)
arch/arm/mach-exynos/cpuidle.c +0 -24
@@ -66,26 +66,6 @@ static void exynos_set_wakeupmask(void)__raw_writel (0x0000ff3e ,S5P_WAKEUP_MASK ); } -static unsigned int g_pwr_ctrl, g_diag_reg; - -static void save_cpu_arch_register (void ) -{ -/*read power control register*/ - asm("mrc p15, 0, %0, c15, c0, 0" :"=r" (g_pwr_ctrl) : :"cc" ); -/*read diagnostic register*/ - asm("mrc p15, 0, %0, c15, c0, 1" :"=r" (g_diag_reg) : :"cc" ); -return ; -} - -static void restore_cpu_arch_register (void ) -{ -/*write power control register*/ - asm("mcr p15, 0, %0, c15, c0, 0" : :"r" (g_pwr_ctrl) :"cc" ); -/*write diagnostic register*/ - asm("mcr p15, 0, %0, c15, c0, 1" : :"r" (g_diag_reg) :"cc" ); -return ; -} -static int idle_finisher (unsigned long flags) {exynos_set_wakeupmask ();
@@ -107,8 +87,6 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev, {unsigned long tmp; -save_cpu_arch_register (); -/* Setting Central Sequence Register for power down mode */ tmp =__raw_readl (S5P_CENTRAL_SEQ_CONFIGURATION ); tmp &= ~S5P_CENTRAL_LOWPWR_CFG ;
@@ -123,8 +101,6 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev,#endif cpu_pm_exit (); -restore_cpu_arch_register (); -/* * If PMU failed while entering sleep mode, WFI will be * ignored by PMU and then exiting cpu_do_idle().
arch/arm/mach-exynos/pm.c +23 -0
@@ -16,6 +16,7 @@#include <linux/init.h> #include <linux/suspend.h> #include <linux/syscore_ops.h> +#include <linux/cpu_pm.h> #include <linux/io.h> #include <linux/err.h> #include <linux/clk.h>
@@ -376,16 +377,38 @@ early_wakeup:return ; } +static int exynos_cpu_pm_notifier (struct notifier_block *self, +unsigned long cmd,void *v) +{ +switch (cmd) { +case CPU_PM_ENTER : +exynos_cpu_save_register (); +break ; + +case CPU_PM_EXIT : +exynos_cpu_restore_register (); +break ; + } + +return NOTIFY_OK ; +} +static struct syscore_ops exynos_pm_syscore_ops = { .suspend = exynos_pm_suspend, .resume = exynos_pm_resume, }; +static struct notifier_block exynos_cpu_pm_notifier_block = { + .notifier_call = exynos_cpu_pm_notifier, +};static __init int exynos_pm_syscore_init (void ) {if (soc_is_exynos5440 ())return 0 ; +if (!soc_is_exynos5250 ()) +cpu_pm_register_notifier (&exynos_cpu_pm_notifier_block); +register_syscore_ops (&exynos_pm_syscore_ops);return 0 ; }
Signature · 1 line
1.7.9.5
PATCH 8/17 ARM: exynos: cpuidle: Move scu_enable in the cpu_pm notifier
In reply to Daniel LezcanoWe make the cpuidle code less arch dependent.
--- arch/arm/mach-exynos/cpuidle.c | 6 ------ arch/arm/mach-exynos/pm.c | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-)
arch/arm/mach-exynos/cpuidle.c +0 -6
@@ -18,7 +18,6 @@#include <linux/platform_device.h> #include <asm/proc-fns.h> -#include <asm/smp_scu.h> #include <asm/suspend.h> #include <asm/unified.h> #include <asm/cpuidle.h>
@@ -94,11 +93,6 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev,cpu_pm_enter ();cpu_suspend (0 , idle_finisher); - -#ifdef CONFIG_SMP -if (!soc_is_exynos5250 ()) -scu_enable (S5P_VA_SCU ); -#endif cpu_pm_exit ();/*
arch/arm/mach-exynos/pm.c +3 -0
@@ -386,6 +386,9 @@ static int exynos_cpu_pm_notifier(struct notifier_block *self,break ;case CPU_PM_EXIT : +#ifdef CONFIG_SMP +scu_enable (S5P_VA_SCU ); +#endif exynos_cpu_restore_register ();break ; }
Signature · 1 line
1.7.9.5
PATCH 8/17 ARM: exynos: cpuidle: Move scu_enable in the cpu_pm notifier
Quoted 37 lines · Daniel Lezcano
We make the cpuidle code less arch dependent.
Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/cpuidle.c | 6 ------ arch/arm/mach-exynos/pm.c | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-)arch/arm/mach-exynos/cpuidle.c +0
-6@@ -18,7 +18,6 @@#include <linux/platform_device.h> #include <asm/proc-fns.h> -#include <asm/smp_scu.h> #include <asm/suspend.h> #include <asm/unified.h> #include <asm/cpuidle.h> @@ -94,11 +93,6 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev,cpu_pm_enter ();cpu_suspend (0 , idle_finisher); - -#ifdef CONFIG_SMP -if (!soc_is_exynos5250 ()) -scu_enable (S5P_VA_SCU ); -#endif cpu_pm_exit ();/* arch/arm/mach-exynos/pm.c +0
-0
arch/arm/mach-exynos/pm.c static int exynos_cpu_pm_notifier(struct notifier_block *self, · line 390
Quoted 5 lines
arch/arm/mach-exynos/pm.c +2
-0@@ -386,6 +386,9 @@ static int exynos_cpu_pm_notifier(struct notifier_block *self,break ;case CPU_PM_EXIT : +#ifdef CONFIG_SMP +scu_enable (S5P_VA_SCU );
We used to do this only when: !soc_is_exynos5250(). Why this changed?
arch/arm/mach-exynos/pm.c static int exynos_cpu_pm_notifier(struct notifier_block *self, · line 391
Quoted 1 line
arch/arm/mach-exynos/pm.c +1
-0+#endif
You don't need these #ifdefs here.. How would you reach here on a non SMP system?
Quoted 11 lines
arch/arm/mach-exynos/pm.c +0
-1exynos_cpu_restore_register ();break ; } --1.7.9.5
_______________________________________________
linaro-kernel mailing list
linaro-kernel at lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-kernel
PATCH 8/17 ARM: exynos: cpuidle: Move scu_enable in the cpu_pm notifier
Quoted 40 lines · Viresh Kumar
Quoted 39 lines · Daniel Lezcano
We make the cpuidle code less arch dependent.
Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/cpuidle.c | 6 ------ arch/arm/mach-exynos/pm.c | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-)arch/arm/mach-exynos/cpuidle.c +0
-6@@ -18,7 +18,6 @@#include <linux/platform_device.h> #include <asm/proc-fns.h> -#include <asm/smp_scu.h> #include <asm/suspend.h> #include <asm/unified.h> #include <asm/cpuidle.h> @@ -94,11 +93,6 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev,cpu_pm_enter ();cpu_suspend (0 , idle_finisher); - -#ifdef CONFIG_SMP -if (!soc_is_exynos5250 ()) -scu_enable (S5P_VA_SCU ); -#endif cpu_pm_exit ();/* arch/arm/mach-exynos/pm.c +0
-0@@ -386,6 +386,9 @@ static int exynos_cpu_pm_notifier(struct notifier_block *self,break ;
Quoted 6 lines
arch/arm/mach-exynos/pm.c static int exynos_cpu_pm_notifier(struct notifier_block *self, · line 390
Quoted 3 lines
arch/arm/mach-exynos/pm.c +2
-0case CPU_PM_EXIT : +#ifdef CONFIG_SMP +scu_enable (S5P_VA_SCU );We used to do this only when: !soc_is_exynos5250(). Why this changed?
Because the pm_notifier is registered if !soc_is_exynos5250()
Quoted 16 lines
arch/arm/mach-exynos/pm.c static int exynos_cpu_pm_notifier(struct notifier_block *self, · line 391
Quoted 1 line
arch/arm/mach-exynos/pm.c +1
-0+#endif You don't need these #ifdefs here.. How would you reach here on a non SMP system?
Quoted 11 lines
arch/arm/mach-exynos/pm.c +0
-1exynos_cpu_restore_register ();break ; } --1.7.9.5
_______________________________________________
linaro-kernel mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/linaro-kernel
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
PATCH 9/17 ARM: exynos: cpuidle: Remove ifdef for scu_enable
In reply to Daniel LezcanoThe scu_enable function is already a noop in the scu's header file is CONFIG_SMP=n, so no need to use these macros in the code.
--- arch/arm/mach-exynos/pm.c | 5 ----- 1 file changed, 5 deletions(-)
arch/arm/mach-exynos/pm.c +0 -5
@@ -363,10 +363,7 @@ static void exynos_pm_resume(void)if (!soc_is_exynos5250 ()) {exynos4_restore_pll (); - -#ifdef CONFIG_SMP scu_enable (S5P_VA_SCU ); -#endif } early_wakeup:
@@ -386,9 +383,7 @@ static int exynos_cpu_pm_notifier(struct notifier_block *self,break ;case CPU_PM_EXIT : -#ifdef CONFIG_SMP scu_enable (S5P_VA_SCU ); -#endif exynos_cpu_restore_register ();break ; }
Signature · 1 line
1.7.9.5
PATCH 9/17 ARM: exynos: cpuidle: Remove ifdef for scu_enable
Quoted 24 lines · Daniel Lezcano
The
scu_enablefunction is already a noop in the scu's header file isCONFIG_SMP=n, so no need to use these macros in the code.Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/pm.c | 5 ----- 1 file changed, 5 deletions(-)arch/arm/mach-exynos/pm.c +0
-3@@ -363,10 +363,7 @@ static void exynos_pm_resume(void)if (!soc_is_exynos5250 ()) {exynos4_restore_pll (); - -#ifdef CONFIG_SMP scu_enable (S5P_VA_SCU ); -#endif } early_wakeup:
arch/arm/mach-exynos/pm.c static int exynos_cpu_pm_notifier(struct notifier_block *self, · line 391
Quoted 6 lines
arch/arm/mach-exynos/pm.c +0
-2@@ -386,9 +383,7 @@ static int exynos_cpu_pm_notifier(struct notifier_block *self,break ;case CPU_PM_EXIT : -#ifdef CONFIG_SMP scu_enable (S5P_VA_SCU ); -#endif
Ahh you are removing them here :)
arch/arm/mach-exynos/pm.c static int exynos_cpu_pm_notifier(struct notifier_block *self, · line 389
Quoted 3 lines
arch/arm/mach-exynos/pm.c +0
-0exynos_cpu_restore_register ();break ; }
PATCH 10/17 ARM: exynos: cpuidle: Move exynos_set_wakeupmask in the cpu_pm notifier
In reply to Daniel LezcanoLet's encapsulate more the PM code inside the PM file by moving the 'exynos_set_wakeupmask' function inside the pm.c and the call in the cpu_pm notifier.
--- arch/arm/mach-exynos/cpuidle.c | 7 ------- arch/arm/mach-exynos/pm.c | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-)
arch/arm/mach-exynos/cpuidle.c +0 -7
@@ -59,15 +59,8 @@#define PWR_CTRL2_CORE2_UP_RATIO (1 << 4)#define PWR_CTRL2_CORE1_UP_RATIO (1 << 0) -/* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */ -static void exynos_set_wakeupmask (void ) -{ -__raw_writel (0x0000ff3e ,S5P_WAKEUP_MASK ); -} -static int idle_finisher (unsigned long flags) { -exynos_set_wakeupmask ();__raw_writel (virt_to_phys (s3c_cpu_resume),REG_DIRECTGO_ADDR );__raw_writel (S5P_CHECK_AFTR ,REG_DIRECTGO_FLAG );
arch/arm/mach-exynos/pm.c +7 -0
@@ -374,12 +374,19 @@ early_wakeup:return ; } +/* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */ +static void exynos_set_wakeupmask (void ) +{ +__raw_writel (0x0000ff3e ,S5P_WAKEUP_MASK ); +} +static int exynos_cpu_pm_notifier (struct notifier_block *self,unsigned long cmd,void *v) {switch (cmd) {case CPU_PM_ENTER :exynos_cpu_save_register (); +exynos_set_wakeupmask ();break ;case CPU_PM_EXIT :
Signature · 1 line
1.7.9.5
PATCH 10/17 ARM: exynos: cpuidle: Move exynos_set_wakeupmask in the cpu_pm notifier
Quoted 18 lines · Daniel Lezcano
Let's encapsulate more the PM code inside the PM file by moving the '
exynos_set_wakeupmask' function inside thepm.cand the call in thecpu_pmnotifier.Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/cpuidle.c | 7 ------- arch/arm/mach-exynos/pm.c | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-)arch/arm/mach-exynos/cpuidle.c +0
-0@@ -59,15 +59,8 @@#define PWR_CTRL2_CORE2_UP_RATIO (1 << 4)#define PWR_CTRL2_CORE1_UP_RATIO (1 << 0)
arch/arm/mach-exynos/cpuidle.c line 64
Quoted 10 lines
arch/arm/mach-exynos/cpuidle.c +0
-7-/* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */ -static void exynos_set_wakeupmask (void ) -{ -__raw_writel (0x0000ff3e ,S5P_WAKEUP_MASK ); -} -static int idle_finisher (unsigned long flags) { -exynos_set_wakeupmask ();
Remove this blank line as well..
Quoted 16 lines
arch/arm/mach-exynos/cpuidle.c +0
-0__raw_writel (virt_to_phys (s3c_cpu_resume),REG_DIRECTGO_ADDR );__raw_writel (S5P_CHECK_AFTR ,REG_DIRECTGO_FLAG );arch/arm/mach-exynos/pm.c +6
-0@@ -374,12 +374,19 @@ early_wakeup:return ; } +/* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */ +static void exynos_set_wakeupmask (void ) +{ +__raw_writel (0x0000ff3e ,S5P_WAKEUP_MASK ); +} +
arch/arm/mach-exynos/pm.c early_wakeup: · line 392
Quoted 10 lines
arch/arm/mach-exynos/pm.c +1
-0static int exynos_cpu_pm_notifier (struct notifier_block *self,unsigned long cmd,void *v) {switch (cmd) {case CPU_PM_ENTER :exynos_cpu_save_register (); +exynos_set_wakeupmask ();break ;case CPU_PM_EXIT :
PATCH 11/17 ARM: exynos: cpuidle: Move the power sequence call in the cpu_pm notifier
In reply to Daniel LezcanoThe code to initiate and exit the powerdown sequence is the same in pm.c and cpuidle.c.
Let's split the common part in the pm.c and reuse it from the cpu_pm notifier.
That is one more step forward to make the cpuidle driver arch indenpendant.
--- arch/arm/mach-exynos/cpuidle.c | 21 --------------------- arch/arm/mach-exynos/pm.c | 22 ++++++++++++++++++---- 2 files changed, 18 insertions(+), 25 deletions(-)
arch/arm/mach-exynos/cpuidle.c +0 -21
@@ -77,31 +77,10 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev,struct cpuidle_driver *drv, int index) { -unsigned long tmp; - -/* Setting Central Sequence Register for power down mode */ - tmp =__raw_readl (S5P_CENTRAL_SEQ_CONFIGURATION ); - tmp &= ~S5P_CENTRAL_LOWPWR_CFG ; -__raw_writel (tmp,S5P_CENTRAL_SEQ_CONFIGURATION ); -cpu_pm_enter ();cpu_suspend (0 , idle_finisher);cpu_pm_exit (); -/* -* If PMU failed while entering sleep mode, WFI will be -* ignored by PMU and then exiting cpu_do_idle(). -* S5P_CENTRAL_LOWPWR_CFG bit will not be set automatically -* in this situation. -*/ - tmp =__raw_readl (S5P_CENTRAL_SEQ_CONFIGURATION ); -if (!(tmp &S5P_CENTRAL_LOWPWR_CFG )) { - tmp |=S5P_CENTRAL_LOWPWR_CFG ; -__raw_writel (tmp,S5P_CENTRAL_SEQ_CONFIGURATION ); -/* Clear wakeup state register */ -__raw_writel (0x0 ,S5P_WAKEUP_STAT ); - } -return index; }
arch/arm/mach-exynos/pm.c +18 -4
@@ -301,15 +301,19 @@ static __init int exynos_pm_drvinit(void) }arch_initcall (exynos_pm_drvinit); -static int exynos_pm_suspend (void ) +static void exynos_pm_central_suspend (void ) {unsigned long tmp;/* Setting Central Sequence Register for power down mode */ - tmp =__raw_readl (S5P_CENTRAL_SEQ_CONFIGURATION ); tmp &= ~S5P_CENTRAL_LOWPWR_CFG ;__raw_writel (tmp,S5P_CENTRAL_SEQ_CONFIGURATION ); +} + +static int exynos_pm_suspend (void ) +{ +unsigned long tmp;/* Setting SEQ_OPTION register */
@@ -322,7 +326,7 @@ static int exynos_pm_suspend(void)return 0 ; } -static void exynos_pm_resume (void ) +static int exynos_pm_central_resume (void ) {unsigned long tmp;
@@ -339,9 +343,17 @@ static void exynos_pm_resume(void)/* clear the wakeup state register */ __raw_writel (0x0 ,S5P_WAKEUP_STAT );/* No need to perform below restore code */ - goto early_wakeup; +return -1 ; } +return 0 ; +} + +static void exynos_pm_resume (void ) +{ +if (exynos_pm_central_resume ()) + goto early_wakeup; +if (!soc_is_exynos5250 ())exynos_cpu_restore_register ();
@@ -385,6 +397,7 @@ static int exynos_cpu_pm_notifier(struct notifier_block *self, {switch (cmd) {case CPU_PM_ENTER : +exynos_pm_central_suspend ();exynos_cpu_save_register ();exynos_set_wakeupmask ();break ;
@@ -392,6 +405,7 @@ static int exynos_cpu_pm_notifier(struct notifier_block *self,case CPU_PM_EXIT :scu_enable (S5P_VA_SCU );exynos_cpu_restore_register (); +exynos_pm_central_resume ();break ; }
Signature · 1 line
1.7.9.5
PATCH 11/17 ARM: exynos: cpuidle: Move the power sequence call in the cpu_pm notifier
Quoted 6 lines · Daniel Lezcano
The code to initiate and exit the powerdown sequence is the same in
pm.candcpuidle.c.Let's split the common part in the
pm.cand reuse it from thecpu_pmnotifier.That is one more step forward to make the cpuidle driver arch indenpendant.
s/indenpendant/independent
Quoted 106 lines
Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/cpuidle.c | 21 --------------------- arch/arm/mach-exynos/pm.c | 22 ++++++++++++++++++---- 2 files changed, 18 insertions(+), 25 deletions(-)arch/arm/mach-exynos/cpuidle.c +0
-21@@ -77,31 +77,10 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev,struct cpuidle_driver *drv, int index) { -unsigned long tmp; - -/* Setting Central Sequence Register for power down mode */ - tmp =__raw_readl (S5P_CENTRAL_SEQ_CONFIGURATION ); - tmp &= ~S5P_CENTRAL_LOWPWR_CFG ; -__raw_writel (tmp,S5P_CENTRAL_SEQ_CONFIGURATION ); -cpu_pm_enter ();cpu_suspend (0 , idle_finisher);cpu_pm_exit (); -/* -* If PMU failed while entering sleep mode, WFI will be -* ignored by PMU and then exiting cpu_do_idle(). -* S5P_CENTRAL_LOWPWR_CFG bit will not be set automatically -* in this situation. -*/ - tmp =__raw_readl (S5P_CENTRAL_SEQ_CONFIGURATION ); -if (!(tmp &S5P_CENTRAL_LOWPWR_CFG )) { - tmp |=S5P_CENTRAL_LOWPWR_CFG ; -__raw_writel (tmp,S5P_CENTRAL_SEQ_CONFIGURATION ); -/* Clear wakeup state register */ -__raw_writel (0x0 ,S5P_WAKEUP_STAT ); - } -return index; }arch/arm/mach-exynos/pm.c +17
-4@@ -301,15 +301,19 @@ static __init int exynos_pm_drvinit(void) }arch_initcall (exynos_pm_drvinit); -static int exynos_pm_suspend (void ) +static void exynos_pm_central_suspend (void ) {unsigned long tmp;/* Setting Central Sequence Register for power down mode */ - tmp =__raw_readl (S5P_CENTRAL_SEQ_CONFIGURATION ); tmp &= ~S5P_CENTRAL_LOWPWR_CFG ;__raw_writel (tmp,S5P_CENTRAL_SEQ_CONFIGURATION ); +} + +static int exynos_pm_suspend (void ) +{ +unsigned long tmp;/* Setting SEQ_OPTION register */ @@ -322,7 +326,7 @@ static int exynos_pm_suspend(void)return 0 ; } -static void exynos_pm_resume (void ) +static int exynos_pm_central_resume (void ) {unsigned long tmp;@@ -339,9 +343,17 @@ static void exynos_pm_resume(void)/* clear the wakeup state register */ __raw_writel (0x0 ,S5P_WAKEUP_STAT );/* No need to perform below restore code */ - goto early_wakeup; +return -1 ; } +return 0 ; +} + +static void exynos_pm_resume (void ) +{ +if (exynos_pm_central_resume ()) + goto early_wakeup; +if (!soc_is_exynos5250 ())exynos_cpu_restore_register ();@@ -385,6 +397,7 @@ static int exynos_cpu_pm_notifier(struct notifier_block *self, {switch (cmd) {case CPU_PM_ENTER : +exynos_pm_central_suspend ();exynos_cpu_save_register ();exynos_set_wakeupmask ();break ;
arch/arm/mach-exynos/pm.c static int exynos_cpu_pm_notifier(struct notifier_block *self, · line 409
Quoted 5 lines
arch/arm/mach-exynos/pm.c +1
-0@@ -392,6 +405,7 @@ static int exynos_cpu_pm_notifier(struct notifier_block *self,case CPU_PM_EXIT :scu_enable (S5P_VA_SCU );exynos_cpu_restore_register (); +exynos_pm_central_resume ();break ;
PATCH 12/17 ARM: exynos: cpuidle: Move S5P_CHECK_AFTR in a header
In reply to Daniel LezcanoMove the S5P_CHECK_AFTR definition to the header it belongs to.
--- arch/arm/mach-exynos/cpuidle.c | 2 -- arch/arm/mach-exynos/regs-pmu.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-)
arch/arm/mach-exynos/cpuidle.c +0 -2
@@ -38,8 +38,6 @@ S5P_INFORM6 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \ (S5P_VA_SYSRAM + 0x20) : S5P_INFORM1)) -#define S5P_CHECK_AFTR 0xFCBA0D10 -#define EXYNOS5_PWR_CTRL1 (S5P_VA_CMU + 0x01020)#define EXYNOS5_PWR_CTRL2 (S5P_VA_CMU + 0x01024)
arch/arm/mach-exynos/regs-pmu.h +1 -0
@@ -119,6 +119,7 @@#define S5P_INT_LOCAL_PWR_EN 0x7#define S5P_CHECK_SLEEP 0x00000BAD +#define S5P_CHECK_AFTR 0xFCBA0D10/* Only for EXYNOS4210 */ #define S5P_CMU_CLKSTOP_LCD1_LOWPWR S5P_PMUREG(0x1154)
Signature · 1 line
1.7.9.5
PATCH 12/17 ARM: exynos: cpuidle: Move S5P_CHECK_AFTR in a header
Quoted 7 lines · Daniel Lezcano
Move the
S5P_CHECK_AFTRdefinition to the header it belongs to.Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/cpuidle.c | 2 -- arch/arm/mach-exynos/regs-pmu.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-)
PATCH 13/17 ARM: exynos: cpuidle: Move clock setup to pm.c
In reply to Daniel LezcanoOne more step is moving the clock ratio setting at idle time in pm.c
The macro names have been changed to be consistent with the other macros name in the file.
Note, the clock divider was working only when cpuidle was enabled because it was in its init routine. With this change, the clock divider is set in the pm's init routine, so it will also operate when the cpuidle driver is not set, which is good.
--- arch/arm/mach-exynos/cpuidle.c | 54 --------------------------------------- arch/arm/mach-exynos/pm.c | 55 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 55 deletions(-)
arch/arm/mach-exynos/cpuidle.c +0 -54
@@ -38,25 +38,6 @@ S5P_INFORM6 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \ (S5P_VA_SYSRAM + 0x20) : S5P_INFORM1)) -#define EXYNOS5_PWR_CTRL1 (S5P_VA_CMU + 0x01020) -#define EXYNOS5_PWR_CTRL2 (S5P_VA_CMU + 0x01024) - -#define PWR_CTRL1_CORE2_DOWN_RATIO (7 << 28) -#define PWR_CTRL1_CORE1_DOWN_RATIO (7 << 16) -#define PWR_CTRL1_DIV2_DOWN_EN (1 << 9) -#define PWR_CTRL1_DIV1_DOWN_EN (1 << 8) -#define PWR_CTRL1_USE_CORE1_WFE (1 << 5) -#define PWR_CTRL1_USE_CORE0_WFE (1 << 4) -#define PWR_CTRL1_USE_CORE1_WFI (1 << 1) -#define PWR_CTRL1_USE_CORE0_WFI (1 << 0) - -#define PWR_CTRL2_DIV2_UP_EN (1 << 25) -#define PWR_CTRL2_DIV1_UP_EN (1 << 24) -#define PWR_CTRL2_DUR_STANDBY2_VAL (1 << 16) -#define PWR_CTRL2_DUR_STANDBY1_VAL (1 << 8) -#define PWR_CTRL2_CORE2_UP_RATIO (1 << 4) -#define PWR_CTRL2_CORE1_UP_RATIO (1 << 0) - static int idle_finisher(unsigned long flags) {
@@ -98,38 +79,6 @@ static int exynos_enter_lowpower(struct cpuidle_device *dev,return exynos_enter_core0_aftr (dev, drv, new_index); } -static void __init exynos5_core_down_clk (void ) -{ -unsigned int tmp; - -/* -* Enable arm clock down (in idle) and set arm divider -* ratios in WFI/WFE state. -*/ - tmp =PWR_CTRL1_CORE2_DOWN_RATIO | \ -PWR_CTRL1_CORE1_DOWN_RATIO | \ -PWR_CTRL1_DIV2_DOWN_EN | \ -PWR_CTRL1_DIV1_DOWN_EN | \ -PWR_CTRL1_USE_CORE1_WFE | \ -PWR_CTRL1_USE_CORE0_WFE | \ -PWR_CTRL1_USE_CORE1_WFI | \ -PWR_CTRL1_USE_CORE0_WFI ; -__raw_writel (tmp,EXYNOS5_PWR_CTRL1 ); - -/* -* Enable arm clock up (on exiting idle). Set arm divider -* ratios when not in idle along with the standby duration -* ratios. -*/ - tmp =PWR_CTRL2_DIV2_UP_EN | \ -PWR_CTRL2_DIV1_UP_EN | \ -PWR_CTRL2_DUR_STANDBY2_VAL | \ -PWR_CTRL2_DUR_STANDBY1_VAL | \ -PWR_CTRL2_CORE2_UP_RATIO | \ -PWR_CTRL2_CORE1_UP_RATIO ; -__raw_writel (tmp,EXYNOS5_PWR_CTRL2 ); -} -static struct cpuidle_driver exynos_idle_driver = { .name ="exynos_idle" , .owner =THIS_MODULE ,
@@ -152,9 +101,6 @@ static int exynos_cpuidle_probe(struct platform_device *pdev) {int ret; -if (soc_is_exynos5250 ()) -exynos5_core_down_clk (); -if (soc_is_exynos5440 ()) exynos_idle_driver.state_count =1 ;
arch/arm/mach-exynos/pm.c +54 -1
79 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 13/17 ARM: exynos: cpuidle: Move clock setup to pm.c
Quoted 10 lines · Daniel Lezcano
One more step is moving the clock ratio setting at idle time in
pm.cThe macro names have been changed to be consistent with the other macros name in the file.
Note, the clock divider was working only when cpuidle was enabled because it was in its init routine. With this change, the clock divider is set in the pm's init routine, so it will also operate when the cpuidle driver is not set, which is good.
Quoted 5 lines
Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/cpuidle.c | 54 --------------------------------------- arch/arm/mach-exynos/pm.c | 55 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 55 deletions(-)
PATCH 14/17 ARM: exynos: cpuidle: Move the boot vector in pm.c
In reply to Daniel LezcanoAs usual, move the boot vector setting in the pm.c file and use the cpu_pm notifier to set it up.
Remove the unused headers.
--- arch/arm/mach-exynos/cpuidle.c | 22 ---------------------- arch/arm/mach-exynos/pm.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 22 deletions(-)
arch/arm/mach-exynos/cpuidle.c +0 -22
@@ -8,42 +8,20 @@* published by the Free Software Foundation. */ -#include <linux/kernel.h> -#include <linux/init.h> #include <linux/cpuidle.h> #include <linux/cpu_pm.h> -#include <linux/io.h> -#include <linux/export.h> -#include <linux/time.h> #include <linux/platform_device.h> #include <asm/proc-fns.h> #include <asm/suspend.h> -#include <asm/unified.h> #include <asm/cpuidle.h> #include <plat/cpu.h> -#include <plat/pm.h> - -#include <mach/pm-core.h> -#include <mach/map.h> #include "common.h" -#include "regs-pmu.h" - -#define REG_DIRECTGO_ADDR (samsung_rev() == EXYNOS4210_REV_1_1 ? \ - S5P_INFORM7 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \ - (S5P_VA_SYSRAM + 0x24) : S5P_INFORM0)) -#define REG_DIRECTGO_FLAG (samsung_rev() == EXYNOS4210_REV_1_1 ? \ - S5P_INFORM6 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \ - (S5P_VA_SYSRAM + 0x20) : S5P_INFORM1))static int idle_finisher (unsigned long flags) { - -__raw_writel (virt_to_phys (s3c_cpu_resume),REG_DIRECTGO_ADDR ); -__raw_writel (S5P_CHECK_AFTR ,REG_DIRECTGO_FLAG ); -/* Set value of power down register for aftr mode */ exynos_sys_powerdown_conf (SYS_AFTR );
arch/arm/mach-exynos/pm.c +15 -0
@@ -79,6 +79,14 @@#define EXYNOS5_PWR_CTRL2_CORE2_UP_RATIO (1 << 4)#define EXYNOS5_PWR_CTRL2_CORE1_UP_RATIO (1 << 0) +#define EXYNOS_BOOT_VECTOR_ADDR (samsung_rev() == EXYNOS4210_REV_1_1 ? \ + S5P_INFORM7 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \ + (S5P_VA_SYSRAM + 0x24) : S5P_INFORM0)) + +#define EXYNOS_BOOT_VECTOR_FLAG (samsung_rev() == EXYNOS4210_REV_1_1 ? \ + S5P_INFORM6 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \ + (S5P_VA_SYSRAM + 0x20) : S5P_INFORM1)) +static const struct sleep_save exynos4_set_clksrc[] = { { .reg =EXYNOS4_CLKSRC_MASK_TOP , .val =0x00000001 , }, { .reg =EXYNOS4_CLKSRC_MASK_CAM , .val =0x11111111 , },
@@ -189,6 +197,12 @@ static void __init exynos5_core_down_clk(void)__raw_writel (tmp,EXYNOS5_PWR_CTRL2 ); } +static void exynos_cpu_set_boot_vector (void ) +{ +__raw_writel (virt_to_phys (s3c_cpu_resume),EXYNOS_BOOT_VECTOR_ADDR ); +__raw_writel (S5P_CHECK_AFTR ,EXYNOS_BOOT_VECTOR_FLAG ); +} +static int exynos_cpu_suspend (unsigned long arg) {#ifdef CONFIG_CACHE_L2X0
@@ -450,6 +464,7 @@ static int exynos_cpu_pm_notifier(struct notifier_block *self,exynos_pm_central_suspend ();exynos_cpu_save_register ();exynos_set_wakeupmask (); +exynos_cpu_set_boot_vector ();break ;case CPU_PM_EXIT :
Signature · 1 line
1.7.9.5
PATCH 14/17 ARM: exynos: cpuidle: Move the boot vector in pm.c
Quoted 10 lines · Daniel Lezcano
As usual, move the boot vector setting in the
pm.cfile and use thecpu_pmnotifier to set it up.Remove the unused headers.
Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/cpuidle.c | 22 ---------------------- arch/arm/mach-exynos/pm.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 22 deletions(-)
PATCH 15/17 ARM: exynos: cpuidle: Pass the AFTR callback to the platform_data
In reply to Daniel LezcanoNo more dependency on the arch code. The platform_data field is used to set the PM callback as the other cpuidle driver.
--- arch/arm/mach-exynos/common.c | 5 +++-- arch/arm/mach-exynos/common.h | 1 + arch/arm/mach-exynos/cpuidle.c | 8 ++++---- arch/arm/mach-exynos/pmu.c | 6 ++++++ 4 files changed, 14 insertions(+), 6 deletions(-)
arch/arm/mach-exynos/common.c +3 -2
@@ -294,8 +294,9 @@ void exynos5_restart(enum reboot_mode mode, const char *cmd) }static struct platform_device exynos_cpuidle = { - .name ="exynos_cpuidle" , - .id =-1 , + .name ="exynos_cpuidle" , + .dev.platform_data = exynos_sys_powerdown_aftr, + .id =-1 , };void __init exynos_cpuidle_init (void )
arch/arm/mach-exynos/common.h +1 -0
@@ -49,5 +49,6 @@ struct exynos_pmu_conf { };extern void exynos_sys_powerdown_conf (enum sys_powerdown mode); +extern void exynos_sys_powerdown_aftr (void );#endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */
arch/arm/mach-exynos/cpuidle.c +4 -4
@@ -18,13 +18,11 @@#include <plat/cpu.h> -#include "common.h" +static void (*exynos_aftr)(void );static int idle_finisher (unsigned long flags) { -/* Set value of power down register for aftr mode */ -exynos_sys_powerdown_conf (SYS_AFTR ); - +exynos_aftr ();cpu_do_idle ();return 1 ;
@@ -82,6 +80,8 @@ static int exynos_cpuidle_probe(struct platform_device *pdev)if (soc_is_exynos5440 ()) exynos_idle_driver.state_count =1 ; + exynos_aftr = (void *)(pdev->dev.platform_data); + ret =cpuidle_register (&exynos_idle_driver,NULL );if (ret) {dev_err (&pdev->dev,"failed to register cpuidle driver\n" );
arch/arm/mach-exynos/pmu.c +6 -0
@@ -389,6 +389,12 @@ void exynos_sys_powerdown_conf(enum sys_powerdown mode) } } +/* Set value of power down register for aftr mode */ +void exynos_sys_powerdown_aftr (void ) +{ +exynos_sys_powerdown_conf (SYS_AFTR ); +} +static int __init exynos_pmu_init (void ) {unsigned int value;
Signature · 1 line
1.7.9.5
PATCH 15/17 ARM: exynos: cpuidle: Pass the AFTR callback to the platform_data
Quoted 10 lines · Daniel Lezcano
No more dependency on the arch code. The
platform_datafield is used to set the PM callback as the other cpuidle driver.Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/common.c | 5 +++-- arch/arm/mach-exynos/common.h | 1 + arch/arm/mach-exynos/cpuidle.c | 8 ++++---- arch/arm/mach-exynos/pmu.c | 6 ++++++ 4 files changed, 14 insertions(+), 6 deletions(-)
PATCH 16/17 ARM: exynos: cpuidle: Move the driver to drivers/cpuidle directory
In reply to Daniel Lezcano--- arch/arm/mach-exynos/Makefile | 1 - drivers/cpuidle/Kconfig.arm | 7 +++++++ drivers/cpuidle/Makefile | 1 + .../cpuidle.c => drivers/cpuidle/cpuidle-exynos.c | 0 4 files changed, 8 insertions(+), 1 deletion(-) rename arch/arm/mach-exynos/cpuidle.c => drivers/cpuidle/cpuidle-exynos.c (100%)
arch/arm/mach-exynos/Makefile +0 -1
@@ -16,7 +16,6 @@ obj-$(CONFIG_ARCH_EXYNOS) += common.o obj-$(CONFIG_S5P_PM) += pm.o obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o -obj-$(CONFIG_CPU_IDLE) += cpuidle.o obj-$(CONFIG_ARCH_EXYNOS) += pmu.o
drivers/cpuidle/Kconfig.arm +7 -0
@@ -44,3 +44,10 @@ config ARM_AT91_CPUIDLE depends on ARCH_AT91 help Select this to enable cpuidle for AT91 processors + +config ARM_EXYNOS_CPUIDLE + bool "Cpu Idle Driver for the Exynos processors" + default y + depends on ARCH_EXYNOS + help + Select this to enable cpuidle for Exynos processors
drivers/cpuidle/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_ARM_KIRKWOOD_CPUIDLE) += cpuidle-kirkwood.o obj-$(CONFIG_ARM_ZYNQ_CPUIDLE) += cpuidle-zynq.o obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o obj-$(CONFIG_ARM_AT91_CPUIDLE) += cpuidle-at91.o +obj-$(CONFIG_ARM_EXYNOS_CPUIDLE) += cpuidle-exynos.o ############################################################################### # POWERPC drivers
drivers/cpuidle/cpuidle-exynos.c renamed from arch/arm/mach-exynos/cpuidle.c +0 -0
Signature · 1 line
1.7.9.5
PATCH 16/17 ARM: exynos: cpuidle: Move the driver to drivers/cpuidle directory
On 4 April 2014 13:18, Daniel Lezcano <[email protected]> wrote:
Maybe a few lines here on why this is important..
Quoted 8 lines
Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/mach-exynos/Makefile | 1 - drivers/cpuidle/Kconfig.arm | 7 +++++++ drivers/cpuidle/Makefile | 1 + .../cpuidle.c => drivers/cpuidle/cpuidle-exynos.c | 0 4 files changed, 8 insertions(+), 1 deletion(-) rename arch/arm/mach-exynos/cpuidle.c => drivers/cpuidle/cpuidle-exynos.c (100%)
PATCH 17/17 ARM: exynos: config: Enable cpuidle
In reply to Daniel LezcanoThe cpuidle driver is broken since v3.11 and now we are at v3.14.
Default the cpuidle driver to favorize a better detection next time.
--- arch/arm/configs/exynos_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/configs/exynos_defconfig +1 -0
@@ -132,3 +132,4 @@ CONFIG_DEBUG_INFO=y CONFIG_DEBUG_USER=y CONFIG_CRYPTO_SHA256=y CONFIG_CRC_CCITT=y +CONFIG_CPU_IDLE=y
Signature · 1 line
1.7.9.5
PATCH 17/17 ARM: exynos: config: Enable cpuidle
Quoted 8 lines · Daniel Lezcano
The cpuidle driver is broken since v3.11 and now we are at v3.14.
Default the cpuidle driver to favorize a better detection next time.
Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/configs/exynos_defconfig | 1 + 1 file changed, 1 insertion(+)
PATCH 17/17 ARM: exynos: config: Enable cpuidle
Quoted 11 lines · Viresh Kumar
Quoted 8 lines · Daniel Lezcano
The cpuidle driver is broken since v3.11 and now we are at v3.14.
Default the cpuidle driver to favorize a better detection next time.
Signed-off-by Daniel Lezcano <[email protected]>--- arch/arm/configs/exynos_defconfig | 1 + 1 file changed, 1 insertion(+)Reviewed-by Viresh Kumar <[email protected]>
Thanks Viresh for the review !
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
cover ARM: exynos: cpuidle: Move the driver to drivers/cpuidle
In reply to Daniel LezcanoHi Daniel,
Quoted 5 lines · Daniel Lezcano
This patchset relies on the
cpm_pmnotifier to initiate the powerdown sequence operations frompm.cinsteadcpuidle.c. Thus the cpuidle driver is no longer dependent from arch specific code as everything is called from thepm.cfile.The patchset applies on top of v3.14.
It would be good to have this patch series based on Kukjin's for-next which has several
changes like code refactoring and consolidation including Tomasz Figa's PM consolidation
patches applied and would be merged in 3.15-rc1 release.
Signature · 2 lines
With warm regards, Sachin
cover ARM: exynos: cpuidle: Move the driver to drivers/cpuidle
Quoted 7 lines · Sachin Kamat
Hi Daniel,
Quoted 4 lines · Daniel Lezcano
This patchset relies on the
cpm_pmnotifier to initiate the powerdown sequence operations frompm.cinsteadcpuidle.c. Thus the cpuidle driver is no longer dependent from arch specific code as everything is called from thepm.cfile.
Quoted 7 lines
Quoted 1 line
The patchset applies on top of v3.14.
It would be good to have this patch series based on Kukjin's for-next which has several
changes like code refactoring and consolidation including Tomasz Figa's PM consolidation
patches applied and would be merged in 3.15-rc1 release.
Ok, thanks for the heads up.
-- Daniel
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog