1
2
3
4
5
6
7
8
9
10
11
12
13
14 #ifndef __ARCH_ARM_MACH_OMAP2_POWERDOMAIN_H
15 #define __ARCH_ARM_MACH_OMAP2_POWERDOMAIN_H
16
17 #include <linux/types.h>
18 #include <linux/list.h>
19 #include <linux/spinlock.h>
20
21
22 #define PWRDM_POWER_OFF 0x0
23 #define PWRDM_POWER_RET 0x1
24 #define PWRDM_POWER_INACTIVE 0x2
25 #define PWRDM_POWER_ON 0x3
26
27 #define PWRDM_MAX_PWRSTS 4
28
29
30 #define PWRSTS_ON (1 << PWRDM_POWER_ON)
31 #define PWRSTS_INACTIVE (1 << PWRDM_POWER_INACTIVE)
32 #define PWRSTS_RET (1 << PWRDM_POWER_RET)
33 #define PWRSTS_OFF (1 << PWRDM_POWER_OFF)
34
35 #define PWRSTS_OFF_ON (PWRSTS_OFF | PWRSTS_ON)
36 #define PWRSTS_OFF_RET (PWRSTS_OFF | PWRSTS_RET)
37 #define PWRSTS_RET_ON (PWRSTS_RET | PWRSTS_ON)
38 #define PWRSTS_OFF_RET_ON (PWRSTS_OFF_RET | PWRSTS_ON)
39 #define PWRSTS_INA_ON (PWRSTS_INACTIVE | PWRSTS_ON)
40
41
42
43
44
45
46
47
48
49
50
51
52
53 #define PWRDM_HAS_HDWR_SAR BIT(0)
54 #define PWRDM_HAS_MPU_QUIRK BIT(1)
55 #define PWRDM_HAS_LOWPOWERSTATECHANGE BIT(2)
56
57
58
59
60
61 #define PWRDM_MAX_MEM_BANKS 5
62
63
64
65
66
67 #define PWRDM_MAX_CLKDMS 11
68
69
70 #define PWRDM_TRANSITION_BAILOUT 100000
71
72 struct clockdomain;
73 struct powerdomain;
74 struct voltagedomain;
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109 struct powerdomain {
110 const char *name;
111 union {
112 const char *name;
113 struct voltagedomain *ptr;
114 } voltdm;
115 const s16 prcm_offs;
116 const u8 pwrsts;
117 const u8 pwrsts_logic_ret;
118 const u8 flags;
119 const u8 banks;
120 const u8 pwrsts_mem_ret[PWRDM_MAX_MEM_BANKS];
121 const u8 pwrsts_mem_on[PWRDM_MAX_MEM_BANKS];
122 const u8 prcm_partition;
123 struct clockdomain *pwrdm_clkdms[PWRDM_MAX_CLKDMS];
124 struct list_head node;
125 struct list_head voltdm_node;
126 int state;
127 unsigned state_counter[PWRDM_MAX_PWRSTS];
128 unsigned ret_logic_off_counter;
129 unsigned ret_mem_off_counter[PWRDM_MAX_MEM_BANKS];
130 spinlock_t _lock;
131 unsigned long _lock_flags;
132 const u8 pwrstctrl_offs;
133 const u8 pwrstst_offs;
134 const u32 logicretstate_mask;
135 const u32 mem_on_mask[PWRDM_MAX_MEM_BANKS];
136 const u32 mem_ret_mask[PWRDM_MAX_MEM_BANKS];
137 const u32 mem_pwrst_mask[PWRDM_MAX_MEM_BANKS];
138 const u32 mem_retst_mask[PWRDM_MAX_MEM_BANKS];
139
140 #ifdef CONFIG_PM_DEBUG
141 s64 timer;
142 s64 state_timer[PWRDM_MAX_PWRSTS];
143 #endif
144 u32 context;
145 };
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179 struct pwrdm_ops {
180 int (*pwrdm_set_next_pwrst)(struct powerdomain *pwrdm, u8 pwrst);
181 int (*pwrdm_read_next_pwrst)(struct powerdomain *pwrdm);
182 int (*pwrdm_read_pwrst)(struct powerdomain *pwrdm);
183 int (*pwrdm_read_prev_pwrst)(struct powerdomain *pwrdm);
184 int (*pwrdm_set_logic_retst)(struct powerdomain *pwrdm, u8 pwrst);
185 int (*pwrdm_set_mem_onst)(struct powerdomain *pwrdm, u8 bank, u8 pwrst);
186 int (*pwrdm_set_mem_retst)(struct powerdomain *pwrdm, u8 bank, u8 pwrst);
187 int (*pwrdm_read_logic_pwrst)(struct powerdomain *pwrdm);
188 int (*pwrdm_read_prev_logic_pwrst)(struct powerdomain *pwrdm);
189 int (*pwrdm_read_logic_retst)(struct powerdomain *pwrdm);
190 int (*pwrdm_read_mem_pwrst)(struct powerdomain *pwrdm, u8 bank);
191 int (*pwrdm_read_prev_mem_pwrst)(struct powerdomain *pwrdm, u8 bank);
192 int (*pwrdm_read_mem_retst)(struct powerdomain *pwrdm, u8 bank);
193 int (*pwrdm_clear_all_prev_pwrst)(struct powerdomain *pwrdm);
194 int (*pwrdm_enable_hdwr_sar)(struct powerdomain *pwrdm);
195 int (*pwrdm_disable_hdwr_sar)(struct powerdomain *pwrdm);
196 int (*pwrdm_set_lowpwrstchange)(struct powerdomain *pwrdm);
197 int (*pwrdm_wait_transition)(struct powerdomain *pwrdm);
198 int (*pwrdm_has_voltdm)(void);
199 void (*pwrdm_save_context)(struct powerdomain *pwrdm);
200 void (*pwrdm_restore_context)(struct powerdomain *pwrdm);
201 };
202
203 int pwrdm_register_platform_funcs(struct pwrdm_ops *custom_funcs);
204 int pwrdm_register_pwrdms(struct powerdomain **pwrdm_list);
205 int pwrdm_complete_init(void);
206
207 struct powerdomain *pwrdm_lookup(const char *name);
208
209 int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user),
210 void *user);
211 int pwrdm_for_each_nolock(int (*fn)(struct powerdomain *pwrdm, void *user),
212 void *user);
213
214 int pwrdm_add_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm);
215
216 int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm);
217
218 u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
219 bool is_logic_state, u8 req_state);
220
221 int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst);
222 int pwrdm_read_next_pwrst(struct powerdomain *pwrdm);
223 int pwrdm_read_pwrst(struct powerdomain *pwrdm);
224 int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm);
225 int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm);
226
227 int pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst);
228 int pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank, u8 pwrst);
229 int pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank, u8 pwrst);
230
231 int pwrdm_read_logic_pwrst(struct powerdomain *pwrdm);
232 int pwrdm_read_prev_logic_pwrst(struct powerdomain *pwrdm);
233 int pwrdm_read_logic_retst(struct powerdomain *pwrdm);
234 int pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank);
235 int pwrdm_read_prev_mem_pwrst(struct powerdomain *pwrdm, u8 bank);
236 int pwrdm_read_mem_retst(struct powerdomain *pwrdm, u8 bank);
237
238 int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm);
239 int pwrdm_disable_hdwr_sar(struct powerdomain *pwrdm);
240 bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm);
241
242 int pwrdm_state_switch_nolock(struct powerdomain *pwrdm);
243 int pwrdm_state_switch(struct powerdomain *pwrdm);
244 int pwrdm_pre_transition(struct powerdomain *pwrdm);
245 int pwrdm_post_transition(struct powerdomain *pwrdm);
246 int pwrdm_get_context_loss_count(struct powerdomain *pwrdm);
247 bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm);
248
249 extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u8 state);
250
251 extern void omap242x_powerdomains_init(void);
252 extern void omap243x_powerdomains_init(void);
253 extern void omap3xxx_powerdomains_init(void);
254 extern void am33xx_powerdomains_init(void);
255 extern void omap44xx_powerdomains_init(void);
256 extern void omap54xx_powerdomains_init(void);
257 extern void dra7xx_powerdomains_init(void);
258 void am43xx_powerdomains_init(void);
259
260 extern struct pwrdm_ops omap2_pwrdm_operations;
261 extern struct pwrdm_ops omap3_pwrdm_operations;
262 extern struct pwrdm_ops am33xx_pwrdm_operations;
263 extern struct pwrdm_ops omap4_pwrdm_operations;
264
265
266 extern u32 omap2_pwrdm_get_mem_bank_onstate_mask(u8 bank);
267 extern u32 omap2_pwrdm_get_mem_bank_retst_mask(u8 bank);
268 extern u32 omap2_pwrdm_get_mem_bank_stst_mask(u8 bank);
269
270 extern struct powerdomain wkup_omap2_pwrdm;
271 extern struct powerdomain gfx_omap2_pwrdm;
272
273 extern void pwrdm_lock(struct powerdomain *pwrdm);
274 extern void pwrdm_unlock(struct powerdomain *pwrdm);
275
276 extern void pwrdms_save_context(void);
277 extern void pwrdms_restore_context(void);
278
279 extern void pwrdms_lost_power(void);
280 #endif