]>
Commit | Line | Data |
---|---|---|
a662c082 MD |
1 | /* |
2 | * r8a7779 Power management support | |
3 | * | |
4 | * Copyright (C) 2011 Renesas Solutions Corp. | |
5 | * Copyright (C) 2011 Magnus Damm | |
6 | * | |
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 | |
9 | * for more details. | |
10 | */ | |
11 | ||
12 | #include <linux/pm.h> | |
13 | #include <linux/suspend.h> | |
14 | #include <linux/err.h> | |
15 | #include <linux/pm_clock.h> | |
585c09df | 16 | #include <linux/pm_domain.h> |
a662c082 MD |
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> | |
1b55353c | 22 | |
a662c082 | 23 | #include <asm/io.h> |
1b55353c | 24 | |
fd44aa5e | 25 | #include "common.h" |
585c09df | 26 | #include "pm-rcar.h" |
1b55353c | 27 | #include "r8a7779.h" |
a662c082 | 28 | |
a662c082 | 29 | /* SYSC */ |
a662c082 MD |
30 | #define SYSCIER 0x0c |
31 | #define SYSCIMR 0x10 | |
a662c082 | 32 | |
585c09df MD |
33 | struct r8a7779_pm_domain { |
34 | struct generic_pm_domain genpd; | |
35 | struct rcar_sysc_ch ch; | |
36 | }; | |
37 | ||
5afcd90f GU |
38 | static inline |
39 | const struct rcar_sysc_ch *to_r8a7779_ch(struct generic_pm_domain *d) | |
585c09df MD |
40 | { |
41 | return &container_of(d, struct r8a7779_pm_domain, genpd)->ch; | |
42 | } | |
43 | ||
f40aaf6d MD |
44 | #if defined(CONFIG_PM) || defined(CONFIG_SMP) |
45 | ||
a662c082 MD |
46 | static void __init r8a7779_sysc_init(void) |
47 | { | |
a6557eb7 | 48 | void __iomem *base = rcar_sysc_init(0xffd85000); |
a662c082 MD |
49 | |
50 | /* enable all interrupt sources, but do not use interrupt handler */ | |
a6557eb7 MD |
51 | iowrite32(0x0131000e, base + SYSCIER); |
52 | iowrite32(0, base + SYSCIMR); | |
a662c082 MD |
53 | } |
54 | ||
f40aaf6d MD |
55 | #else /* CONFIG_PM || CONFIG_SMP */ |
56 | ||
57 | static inline void r8a7779_sysc_init(void) {} | |
58 | ||
59 | #endif /* CONFIG_PM || CONFIG_SMP */ | |
60 | ||
61 | #ifdef CONFIG_PM | |
62 | ||
a662c082 MD |
63 | static int pd_power_down(struct generic_pm_domain *genpd) |
64 | { | |
a6557eb7 | 65 | return rcar_sysc_power_down(to_r8a7779_ch(genpd)); |
a662c082 MD |
66 | } |
67 | ||
68 | static int pd_power_up(struct generic_pm_domain *genpd) | |
69 | { | |
a6557eb7 | 70 | return rcar_sysc_power_up(to_r8a7779_ch(genpd)); |
a662c082 MD |
71 | } |
72 | ||
73 | static bool pd_is_off(struct generic_pm_domain *genpd) | |
74 | { | |
a6557eb7 | 75 | return rcar_sysc_power_is_off(to_r8a7779_ch(genpd)); |
a662c082 MD |
76 | } |
77 | ||
78 | static bool pd_active_wakeup(struct device *dev) | |
79 | { | |
80 | return true; | |
81 | } | |
82 | ||
45e5ca57 | 83 | static void r8a7779_init_pm_domain(struct r8a7779_pm_domain *r8a7779_pd) |
a662c082 MD |
84 | { |
85 | struct generic_pm_domain *genpd = &r8a7779_pd->genpd; | |
86 | ||
87 | pm_genpd_init(genpd, NULL, false); | |
a662c082 | 88 | genpd->dev_ops.active_wakeup = pd_active_wakeup; |
a662c082 MD |
89 | genpd->power_off = pd_power_down; |
90 | genpd->power_on = pd_power_up; | |
91 | ||
92 | if (pd_is_off(&r8a7779_pd->genpd)) | |
93 | pd_power_up(&r8a7779_pd->genpd); | |
94 | } | |
95 | ||
45e5ca57 RW |
96 | static struct r8a7779_pm_domain r8a7779_pm_domains[] = { |
97 | { | |
98 | .genpd.name = "SH4A", | |
99 | .ch = { | |
100 | .chan_offs = 0x80, /* PWRSR1 .. PWRER1 */ | |
101 | .isr_bit = 16, /* SH4A */ | |
102 | }, | |
103 | }, | |
104 | { | |
105 | .genpd.name = "SGX", | |
106 | .ch = { | |
107 | .chan_offs = 0xc0, /* PWRSR2 .. PWRER2 */ | |
108 | .isr_bit = 20, /* SGX */ | |
109 | }, | |
110 | }, | |
111 | { | |
112 | .genpd.name = "VDP1", | |
113 | .ch = { | |
114 | .chan_offs = 0x100, /* PWRSR3 .. PWRER3 */ | |
115 | .isr_bit = 21, /* VDP */ | |
116 | }, | |
117 | }, | |
118 | { | |
119 | .genpd.name = "IMPX3", | |
120 | .ch = { | |
121 | .chan_offs = 0x140, /* PWRSR4 .. PWRER4 */ | |
122 | .isr_bit = 24, /* IMP */ | |
123 | }, | |
124 | }, | |
a662c082 MD |
125 | }; |
126 | ||
45e5ca57 RW |
127 | void __init r8a7779_init_pm_domains(void) |
128 | { | |
129 | int j; | |
a662c082 | 130 | |
45e5ca57 RW |
131 | for (j = 0; j < ARRAY_SIZE(r8a7779_pm_domains); j++) |
132 | r8a7779_init_pm_domain(&r8a7779_pm_domains[j]); | |
133 | } | |
a662c082 | 134 | |
a662c082 MD |
135 | #endif /* CONFIG_PM */ |
136 | ||
137 | void __init r8a7779_pm_init(void) | |
138 | { | |
f40aaf6d MD |
139 | static int once; |
140 | ||
141 | if (!once++) | |
142 | r8a7779_sysc_init(); | |
a662c082 | 143 | } |