2 * r8a7779 Power management support
4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Copyright (C) 2011 Magnus Damm
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
13 #include <linux/suspend.h>
14 #include <linux/err.h>
15 #include <linux/pm_clock.h>
16 #include <linux/pm_domain.h>
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/irq.h>
20 #include <linux/interrupt.h>
21 #include <linux/console.h>
33 struct r8a7779_pm_domain
{
34 struct generic_pm_domain genpd
;
35 struct rcar_sysc_ch ch
;
38 static inline struct rcar_sysc_ch
*to_r8a7779_ch(struct generic_pm_domain
*d
)
40 return &container_of(d
, struct r8a7779_pm_domain
, genpd
)->ch
;
43 #if defined(CONFIG_PM) || defined(CONFIG_SMP)
45 static void __init
r8a7779_sysc_init(void)
47 void __iomem
*base
= rcar_sysc_init(0xffd85000);
49 /* enable all interrupt sources, but do not use interrupt handler */
50 iowrite32(0x0131000e, base
+ SYSCIER
);
51 iowrite32(0, base
+ SYSCIMR
);
54 #else /* CONFIG_PM || CONFIG_SMP */
56 static inline void r8a7779_sysc_init(void) {}
58 #endif /* CONFIG_PM || CONFIG_SMP */
62 static int pd_power_down(struct generic_pm_domain
*genpd
)
64 return rcar_sysc_power_down(to_r8a7779_ch(genpd
));
67 static int pd_power_up(struct generic_pm_domain
*genpd
)
69 return rcar_sysc_power_up(to_r8a7779_ch(genpd
));
72 static bool pd_is_off(struct generic_pm_domain
*genpd
)
74 return rcar_sysc_power_is_off(to_r8a7779_ch(genpd
));
77 static bool pd_active_wakeup(struct device
*dev
)
82 static void r8a7779_init_pm_domain(struct r8a7779_pm_domain
*r8a7779_pd
)
84 struct generic_pm_domain
*genpd
= &r8a7779_pd
->genpd
;
86 genpd
->flags
= GENPD_FLAG_PM_CLK
;
87 pm_genpd_init(genpd
, NULL
, false);
88 genpd
->dev_ops
.active_wakeup
= pd_active_wakeup
;
89 genpd
->power_off
= pd_power_down
;
90 genpd
->power_on
= pd_power_up
;
92 if (pd_is_off(&r8a7779_pd
->genpd
))
93 pd_power_up(&r8a7779_pd
->genpd
);
96 static struct r8a7779_pm_domain r8a7779_pm_domains
[] = {
100 .chan_offs
= 0x80, /* PWRSR1 .. PWRER1 */
101 .isr_bit
= 16, /* SH4A */
107 .chan_offs
= 0xc0, /* PWRSR2 .. PWRER2 */
108 .isr_bit
= 20, /* SGX */
112 .genpd
.name
= "VDP1",
114 .chan_offs
= 0x100, /* PWRSR3 .. PWRER3 */
115 .isr_bit
= 21, /* VDP */
119 .genpd
.name
= "IMPX3",
121 .chan_offs
= 0x140, /* PWRSR4 .. PWRER4 */
122 .isr_bit
= 24, /* IMP */
127 void __init
r8a7779_init_pm_domains(void)
131 for (j
= 0; j
< ARRAY_SIZE(r8a7779_pm_domains
); j
++)
132 r8a7779_init_pm_domain(&r8a7779_pm_domains
[j
]);
135 #endif /* CONFIG_PM */
137 void __init
r8a7779_pm_init(void)