14 #include <linux/module.h>
15 #include <linux/list.h>
17 #include <linux/slab.h>
26 #include <asm/tlbflush.h>
27 #include <asm/suspend.h>
28 #include <mach/common.h>
33 #define DBGREG1 IOMEM(0xe6100020)
34 #define DBGREG9 IOMEM(0xe6100040)
37 #define SYSTBCR IOMEM(0xe6150024)
38 #define MSTPSR0 IOMEM(0xe6150030)
39 #define MSTPSR1 IOMEM(0xe6150038)
40 #define MSTPSR2 IOMEM(0xe6150040)
41 #define MSTPSR3 IOMEM(0xe6150048)
42 #define MSTPSR4 IOMEM(0xe615004c)
43 #define PLLC01STPCR IOMEM(0xe61500c8)
46 #define SBAR IOMEM(0xe6180020)
47 #define WUPRMSK IOMEM(0xe6180028)
48 #define WUPSMSK IOMEM(0xe618002c)
49 #define WUPSMSK2 IOMEM(0xe6180048)
50 #define WUPSFAC IOMEM(0xe6180098)
51 #define IRQCR IOMEM(0xe618022c)
52 #define IRQCR2 IOMEM(0xe6180238)
53 #define IRQCR3 IOMEM(0xe6180244)
54 #define IRQCR4 IOMEM(0xe6180248)
55 #define PDNSEL IOMEM(0xe6180254)
58 #define ICR1A IOMEM(0xe6900000)
59 #define ICR2A IOMEM(0xe6900004)
60 #define ICR3A IOMEM(0xe6900008)
61 #define ICR4A IOMEM(0xe690000c)
62 #define INTMSK00A IOMEM(0xe6900040)
63 #define INTMSK10A IOMEM(0xe6900044)
64 #define INTMSK20A IOMEM(0xe6900048)
65 #define INTMSK30A IOMEM(0xe690004c)
69 #define SMFRAM 0xe6a70000
72 #define APARMBAREA IOMEM(0xe6f10020)
76 #define PM_DOMAIN_ON_OFF_LATENCY_NS 250000
78 static int sh7372_a4r_pd_suspend(
void)
85 static bool a4s_suspend_ready;
87 static int sh7372_a4s_pd_suspend(
void)
96 a4s_suspend_ready =
true;
100 static void sh7372_a4s_pd_resume(
void)
102 a4s_suspend_ready =
false;
105 static int sh7372_a3sp_pd_suspend(
void)
116 .
genpd.name =
"A4LC",
117 .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
118 .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
122 .genpd.name =
"A4MP",
123 .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
124 .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
129 .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
130 .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
135 .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
136 .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
138 .suspend = sh7372_a4r_pd_suspend,
142 .genpd.name =
"A3RV",
143 .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
144 .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
148 .genpd.name =
"A3RI",
149 .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
150 .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
155 .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
156 .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
160 .suspend = sh7372_a4s_pd_suspend,
161 .resume = sh7372_a4s_pd_resume,
164 .genpd.name =
"A3SP",
165 .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
166 .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
170 .suspend = sh7372_a3sp_pd_suspend,
173 .genpd.name =
"A3SG",
174 .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
175 .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
180 void __init sh7372_init_pm_domains(
void)
191 #if defined(CONFIG_SUSPEND) || defined(CONFIG_CPU_IDLE)
192 static void sh7372_set_reset_vector(
unsigned long address)
199 static void sh7372_enter_sysc(
int pllc0_on,
unsigned long sleep_mode)
214 static int sh7372_sysc_valid(
unsigned long *mskp,
unsigned long *msk2p)
216 unsigned long mstpsr0, mstpsr1, mstpsr2, mstpsr3, mstpsr4;
217 unsigned long msk, msk2;
222 if ((mstpsr0 & 0x00000003) != 0x00000003) {
223 pr_debug(
"sh7372 mstpsr0 0x%08lx\n", mstpsr0);
228 if ((mstpsr1 & 0xff079b7f) != 0xff079b7f) {
229 pr_debug(
"sh7372 mstpsr1 0x%08lx\n", mstpsr1);
234 if ((mstpsr2 & 0x000741ff) != 0x000741ff) {
235 pr_debug(
"sh7372 mstpsr2 0x%08lx\n", mstpsr2);
240 if ((mstpsr3 & 0x1a60f010) != 0x1a60f010) {
241 pr_debug(
"sh7372 mstpsr3 0x%08lx\n", mstpsr3);
246 if ((mstpsr4 & 0x00008cf0) != 0x00008cf0) {
247 pr_debug(
"sh7372 mstpsr4 0x%08lx\n", mstpsr4);
256 if ((mstpsr2 & (1 << 23)) == 0)
259 if ((mstpsr2 & (1 << 12)) == 0)
262 if ((mstpsr4 & (1 << 3)) == 0)
265 if ((mstpsr1 & (1 << 24)) == 0)
268 if ((mstpsr3 & (1 << 29)) == 0)
271 if ((mstpsr4 & (1 << 0)) == 0)
274 if ((mstpsr2 & (1 << 13)) == 0)
283 static void sh7372_icr_to_irqcr(
unsigned long icr,
u16 *irqcr1p,
u16 *irqcr2p)
292 for (k = 0; k <= 7; k++) {
293 tmp = (icr >> ((7 -
k) * 4)) & 0xf;
294 irqcr1 |= (tmp & 0x03) << (k * 2);
295 irqcr2 |= (tmp >> 2) << (k * 2);
302 static void sh7372_setup_sysc(
unsigned long msk,
unsigned long msk2)
304 u16 irqcrx_low, irqcrx_high, irqcry_low, irqcry_high;
312 msk = (~msk & 0xc030000f) | (tmp << 4);
326 msk2 = (~msk2 & 0x00030000) | tmp;
336 static void sh7372_enter_a3sm_common(
int pllc0_on)
339 sh7372_setup_sysc(1 << 0, 0);
341 sh7372_enter_sysc(pllc0_on, 1 << 12);
344 static void sh7372_enter_a4s_common(
int pllc0_on)
347 sh7372_set_reset_vector(
SMFRAM);
348 sh7372_enter_sysc(pllc0_on, 1 << 10);
352 static void sh7372_pm_setup_smfram(
void)
357 static inline void sh7372_pm_setup_smfram(
void) {}
360 #ifdef CONFIG_CPU_IDLE
361 static int sh7372_do_idle_core_standby(
unsigned long unused)
386 sh7372_enter_a3sm_common(1);
393 sh7372_enter_a3sm_common(0);
400 unsigned long msk, msk2;
402 if (!sh7372_sysc_valid(&msk, &msk2))
403 return sh7372_enter_a3sm_pll_off(dev, drv, index);
405 sh7372_setup_sysc(msk, msk2);
406 sh7372_enter_a4s_common(0);
411 .
name =
"sh7372_cpuidle",
413 .en_core_tk_irqen = 1,
415 .safe_state_index = 0,
420 .desc =
"Core Standby Mode",
422 .target_residency = 20 + 10,
424 .enter = sh7372_enter_core_standby,
428 .desc =
"A3SM PLL ON",
430 .target_residency = 30 + 20,
432 .enter = sh7372_enter_a3sm_pll_on,
436 .desc =
"A3SM PLL OFF",
438 .target_residency = 30 + 120,
440 .enter = sh7372_enter_a3sm_pll_off,
444 .desc =
"A4S PLL OFF",
446 .target_residency = 30 + 240,
448 .enter = sh7372_enter_a4s,
453 static void sh7372_cpuidle_init(
void)
458 static void sh7372_cpuidle_init(
void) {}
461 #ifdef CONFIG_SUSPEND
464 unsigned long msk, msk2;
467 if (sh7372_sysc_valid(&msk, &msk2) && a4s_suspend_ready) {
469 sh7372_setup_sysc(msk, msk2);
473 sh7372_enter_a4s_common(0);
479 sh7372_enter_a3sm_common(0);
490 unsigned long pm_event,
void *
unused)
500 pm_genpd_name_poweron(
"A4R");
503 pm_genpd_poweroff_unused();
510 static void sh7372_suspend_init(
void)
516 static void sh7372_suspend_init(
void) {}
529 sh7372_pm_setup_smfram();
531 sh7372_suspend_init();
532 sh7372_cpuidle_init();
537 shmobile_init_late();