22 #include <mach/common.h>
25 static void __iomem *r8a7779_sysc_base;
39 #define PWRSR_OFFS 0x00
40 #define PWROFFCR_OFFS 0x04
41 #define PWRONCR_OFFS 0x0c
42 #define PWRER_OFFS 0x14
44 #define SYSCSR_RETRIES 100
45 #define SYSCSR_DELAY_US 1
47 #define SYSCISR_RETRIES 1000
48 #define SYSCISR_DELAY_US 1
50 #if defined(CONFIG_PM) || defined(CONFIG_SMP)
54 static int r8a7779_sysc_pwr_on_off(
struct r8a7779_pm_ch *r8a7779_ch,
55 int sr_bit,
int reg_offs)
65 if (k == SYSCSR_RETRIES)
69 r8a7779_sysc_base + r8a7779_ch->
chan_offs + reg_offs);
74 static int r8a7779_sysc_pwr_off(
struct r8a7779_pm_ch *r8a7779_ch)
79 static int r8a7779_sysc_pwr_on(
struct r8a7779_pm_ch *r8a7779_ch)
81 return r8a7779_sysc_pwr_on_off(r8a7779_ch, 1,
PWRONCR_OFFS);
84 static int r8a7779_sysc_update(
struct r8a7779_pm_ch *r8a7779_ch,
87 unsigned int isr_mask = 1 << r8a7779_ch->
isr_bit;
88 unsigned int chan_mask = 1 << r8a7779_ch->
chan_bit;
99 ret = on_off_fn(r8a7779_ch);
103 status =
ioread32(r8a7779_sysc_base +
105 }
while (status & chan_mask);
113 if (k == SYSCISR_RETRIES)
119 spin_unlock_irqrestore(&r8a7779_sysc_lock, flags);
121 pr_debug(
"r8a7779 power domain %d: %02x %02x %02x %02x %02x -> %d\n",
132 return r8a7779_sysc_update(r8a7779_ch, r8a7779_sysc_pwr_off);
137 return r8a7779_sysc_update(r8a7779_ch, r8a7779_sysc_pwr_on);
140 static void __init r8a7779_sysc_init(
void)
143 if (!r8a7779_sysc_base)
144 panic(
"unable to ioremap r8a7779 SYSC hardware block\n");
153 static inline void r8a7779_sysc_init(
void) {}
175 if (st & (1 << r8a7779_ch->
chan_bit))
181 static bool pd_active_wakeup(
struct device *
dev)
193 genpd->
dev_ops.active_wakeup = pd_active_wakeup;
198 if (pd_is_off(&r8a7779_pd->
genpd))
199 pd_power_up(&r8a7779_pd->
genpd);
204 .
genpd.name =
"SH4A",
218 .genpd.name =
"VDP1",
225 .genpd.name =
"IMPX3",
233 void __init r8a7779_init_pm_domains(
void)
237 for (j = 0; j <
ARRAY_SIZE(r8a7779_pm_domains); j++)
238 r8a7779_init_pm_domain(&r8a7779_pm_domains[j]);