diff options
Diffstat (limited to 'arch/arm/mach-shmobile/pm-sh7372.c')
-rw-r--r-- | arch/arm/mach-shmobile/pm-sh7372.c | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/arch/arm/mach-shmobile/pm-sh7372.c b/arch/arm/mach-shmobile/pm-sh7372.c index 79612737c5b2..34bbcbfb1706 100644 --- a/arch/arm/mach-shmobile/pm-sh7372.c +++ b/arch/arm/mach-shmobile/pm-sh7372.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
21 | #include <linux/irq.h> | 21 | #include <linux/irq.h> |
22 | #include <linux/bitrev.h> | 22 | #include <linux/bitrev.h> |
23 | #include <linux/console.h> | ||
23 | #include <asm/system.h> | 24 | #include <asm/system.h> |
24 | #include <asm/io.h> | 25 | #include <asm/io.h> |
25 | #include <asm/tlbflush.h> | 26 | #include <asm/tlbflush.h> |
@@ -106,9 +107,8 @@ static int pd_power_down(struct generic_pm_domain *genpd) | |||
106 | return 0; | 107 | return 0; |
107 | } | 108 | } |
108 | 109 | ||
109 | static int pd_power_up(struct generic_pm_domain *genpd) | 110 | static int __pd_power_up(struct sh7372_pm_domain *sh7372_pd, bool do_resume) |
110 | { | 111 | { |
111 | struct sh7372_pm_domain *sh7372_pd = to_sh7372_pd(genpd); | ||
112 | unsigned int mask = 1 << sh7372_pd->bit_shift; | 112 | unsigned int mask = 1 << sh7372_pd->bit_shift; |
113 | unsigned int retry_count; | 113 | unsigned int retry_count; |
114 | int ret = 0; | 114 | int ret = 0; |
@@ -123,13 +123,13 @@ static int pd_power_up(struct generic_pm_domain *genpd) | |||
123 | 123 | ||
124 | for (retry_count = 2 * PSTR_RETRIES; retry_count; retry_count--) { | 124 | for (retry_count = 2 * PSTR_RETRIES; retry_count; retry_count--) { |
125 | if (!(__raw_readl(SWUCR) & mask)) | 125 | if (!(__raw_readl(SWUCR) & mask)) |
126 | goto out; | 126 | break; |
127 | if (retry_count > PSTR_RETRIES) | 127 | if (retry_count > PSTR_RETRIES) |
128 | udelay(PSTR_DELAY_US); | 128 | udelay(PSTR_DELAY_US); |
129 | else | 129 | else |
130 | cpu_relax(); | 130 | cpu_relax(); |
131 | } | 131 | } |
132 | if (__raw_readl(SWUCR) & mask) | 132 | if (!retry_count) |
133 | ret = -EIO; | 133 | ret = -EIO; |
134 | 134 | ||
135 | if (!sh7372_pd->no_debug) | 135 | if (!sh7372_pd->no_debug) |
@@ -137,12 +137,17 @@ static int pd_power_up(struct generic_pm_domain *genpd) | |||
137 | mask, __raw_readl(PSTR)); | 137 | mask, __raw_readl(PSTR)); |
138 | 138 | ||
139 | out: | 139 | out: |
140 | if (ret == 0 && sh7372_pd->resume) | 140 | if (ret == 0 && sh7372_pd->resume && do_resume) |
141 | sh7372_pd->resume(); | 141 | sh7372_pd->resume(); |
142 | 142 | ||
143 | return ret; | 143 | return ret; |
144 | } | 144 | } |
145 | 145 | ||
146 | static int pd_power_up(struct generic_pm_domain *genpd) | ||
147 | { | ||
148 | return __pd_power_up(to_sh7372_pd(genpd), true); | ||
149 | } | ||
150 | |||
146 | static void sh7372_a4r_suspend(void) | 151 | static void sh7372_a4r_suspend(void) |
147 | { | 152 | { |
148 | sh7372_intcs_suspend(); | 153 | sh7372_intcs_suspend(); |
@@ -174,7 +179,7 @@ void sh7372_init_pm_domain(struct sh7372_pm_domain *sh7372_pd) | |||
174 | genpd->active_wakeup = pd_active_wakeup; | 179 | genpd->active_wakeup = pd_active_wakeup; |
175 | genpd->power_off = pd_power_down; | 180 | genpd->power_off = pd_power_down; |
176 | genpd->power_on = pd_power_up; | 181 | genpd->power_on = pd_power_up; |
177 | genpd->power_on(&sh7372_pd->genpd); | 182 | __pd_power_up(sh7372_pd, false); |
178 | } | 183 | } |
179 | 184 | ||
180 | void sh7372_add_device_to_domain(struct sh7372_pm_domain *sh7372_pd, | 185 | void sh7372_add_device_to_domain(struct sh7372_pm_domain *sh7372_pd, |
@@ -227,11 +232,23 @@ struct sh7372_pm_domain sh7372_a3sp = { | |||
227 | .no_debug = true, | 232 | .no_debug = true, |
228 | }; | 233 | }; |
229 | 234 | ||
235 | static void sh7372_a3sp_init(void) | ||
236 | { | ||
237 | /* serial consoles make use of SCIF hardware located in A3SP, | ||
238 | * keep such power domain on if "no_console_suspend" is set. | ||
239 | */ | ||
240 | sh7372_a3sp.stay_on = !console_suspend_enabled; | ||
241 | } | ||
242 | |||
230 | struct sh7372_pm_domain sh7372_a3sg = { | 243 | struct sh7372_pm_domain sh7372_a3sg = { |
231 | .bit_shift = 13, | 244 | .bit_shift = 13, |
232 | }; | 245 | }; |
233 | 246 | ||
234 | #endif /* CONFIG_PM */ | 247 | #else /* !CONFIG_PM */ |
248 | |||
249 | static inline void sh7372_a3sp_init(void) {} | ||
250 | |||
251 | #endif /* !CONFIG_PM */ | ||
235 | 252 | ||
236 | #if defined(CONFIG_SUSPEND) || defined(CONFIG_CPU_IDLE) | 253 | #if defined(CONFIG_SUSPEND) || defined(CONFIG_CPU_IDLE) |
237 | static int sh7372_do_idle_core_standby(unsigned long unused) | 254 | static int sh7372_do_idle_core_standby(unsigned long unused) |
@@ -402,22 +419,18 @@ static void sh7372_setup_a3sm(unsigned long msk, unsigned long msk2) | |||
402 | 419 | ||
403 | #ifdef CONFIG_CPU_IDLE | 420 | #ifdef CONFIG_CPU_IDLE |
404 | 421 | ||
405 | static void sh7372_cpuidle_setup(struct cpuidle_device *dev) | 422 | static void sh7372_cpuidle_setup(struct cpuidle_driver *drv) |
406 | { | 423 | { |
407 | struct cpuidle_state *state; | 424 | struct cpuidle_state *state = &drv->states[drv->state_count]; |
408 | int i = dev->state_count; | ||
409 | 425 | ||
410 | state = &dev->states[i]; | ||
411 | snprintf(state->name, CPUIDLE_NAME_LEN, "C2"); | 426 | snprintf(state->name, CPUIDLE_NAME_LEN, "C2"); |
412 | strncpy(state->desc, "Core Standby Mode", CPUIDLE_DESC_LEN); | 427 | strncpy(state->desc, "Core Standby Mode", CPUIDLE_DESC_LEN); |
413 | state->exit_latency = 10; | 428 | state->exit_latency = 10; |
414 | state->target_residency = 20 + 10; | 429 | state->target_residency = 20 + 10; |
415 | state->power_usage = 1; /* perhaps not */ | 430 | state->flags = CPUIDLE_FLAG_TIME_VALID; |
416 | state->flags = 0; | 431 | shmobile_cpuidle_modes[drv->state_count] = sh7372_enter_core_standby; |
417 | state->flags |= CPUIDLE_FLAG_TIME_VALID; | ||
418 | shmobile_cpuidle_modes[i] = sh7372_enter_core_standby; | ||
419 | 432 | ||
420 | dev->state_count = i + 1; | 433 | drv->state_count++; |
421 | } | 434 | } |
422 | 435 | ||
423 | static void sh7372_cpuidle_init(void) | 436 | static void sh7372_cpuidle_init(void) |
@@ -469,6 +482,8 @@ void __init sh7372_pm_init(void) | |||
469 | /* do not convert A3SM, A3SP, A3SG, A4R power down into A4S */ | 482 | /* do not convert A3SM, A3SP, A3SG, A4R power down into A4S */ |
470 | __raw_writel(0, PDNSEL); | 483 | __raw_writel(0, PDNSEL); |
471 | 484 | ||
485 | sh7372_a3sp_init(); | ||
486 | |||
472 | sh7372_suspend_init(); | 487 | sh7372_suspend_init(); |
473 | sh7372_cpuidle_init(); | 488 | sh7372_cpuidle_init(); |
474 | } | 489 | } |