OMAPDSS: VENC: fix NULL pointer dereference in DSS2 VENC sysfs debug attr on OMAP4
[zen-stable.git] / include / linux / mfd / dbx500-prcmu.h
blobbac942f959c18221588dd8f87620bd983282dde4
1 /*
2 * Copyright (C) ST Ericsson SA 2011
4 * License Terms: GNU General Public License v2
6 * STE Ux500 PRCMU API
7 */
8 #ifndef __MACH_PRCMU_H
9 #define __MACH_PRCMU_H
11 #include <linux/interrupt.h>
12 #include <linux/notifier.h>
13 #include <asm/mach-types.h>
15 /* PRCMU Wakeup defines */
16 enum prcmu_wakeup_index {
17 PRCMU_WAKEUP_INDEX_RTC,
18 PRCMU_WAKEUP_INDEX_RTT0,
19 PRCMU_WAKEUP_INDEX_RTT1,
20 PRCMU_WAKEUP_INDEX_HSI0,
21 PRCMU_WAKEUP_INDEX_HSI1,
22 PRCMU_WAKEUP_INDEX_USB,
23 PRCMU_WAKEUP_INDEX_ABB,
24 PRCMU_WAKEUP_INDEX_ABB_FIFO,
25 PRCMU_WAKEUP_INDEX_ARM,
26 PRCMU_WAKEUP_INDEX_CD_IRQ,
27 NUM_PRCMU_WAKEUP_INDICES
29 #define PRCMU_WAKEUP(_name) (BIT(PRCMU_WAKEUP_INDEX_##_name))
31 /* EPOD (power domain) IDs */
34 * DB8500 EPODs
35 * - EPOD_ID_SVAMMDSP: power domain for SVA MMDSP
36 * - EPOD_ID_SVAPIPE: power domain for SVA pipe
37 * - EPOD_ID_SIAMMDSP: power domain for SIA MMDSP
38 * - EPOD_ID_SIAPIPE: power domain for SIA pipe
39 * - EPOD_ID_SGA: power domain for SGA
40 * - EPOD_ID_B2R2_MCDE: power domain for B2R2 and MCDE
41 * - EPOD_ID_ESRAM12: power domain for ESRAM 1 and 2
42 * - EPOD_ID_ESRAM34: power domain for ESRAM 3 and 4
43 * - NUM_EPOD_ID: number of power domains
45 * TODO: These should be prefixed.
47 #define EPOD_ID_SVAMMDSP 0
48 #define EPOD_ID_SVAPIPE 1
49 #define EPOD_ID_SIAMMDSP 2
50 #define EPOD_ID_SIAPIPE 3
51 #define EPOD_ID_SGA 4
52 #define EPOD_ID_B2R2_MCDE 5
53 #define EPOD_ID_ESRAM12 6
54 #define EPOD_ID_ESRAM34 7
55 #define NUM_EPOD_ID 8
58 * DB5500 EPODs
60 #define DB5500_EPOD_ID_BASE 0x0100
61 #define DB5500_EPOD_ID_SGA (DB5500_EPOD_ID_BASE + 0)
62 #define DB5500_EPOD_ID_HVA (DB5500_EPOD_ID_BASE + 1)
63 #define DB5500_EPOD_ID_SIA (DB5500_EPOD_ID_BASE + 2)
64 #define DB5500_EPOD_ID_DISP (DB5500_EPOD_ID_BASE + 3)
65 #define DB5500_EPOD_ID_ESRAM12 (DB5500_EPOD_ID_BASE + 6)
66 #define DB5500_NUM_EPOD_ID 7
69 * state definition for EPOD (power domain)
70 * - EPOD_STATE_NO_CHANGE: The EPOD should remain unchanged
71 * - EPOD_STATE_OFF: The EPOD is switched off
72 * - EPOD_STATE_RAMRET: The EPOD is switched off with its internal RAM in
73 * retention
74 * - EPOD_STATE_ON_CLK_OFF: The EPOD is switched on, clock is still off
75 * - EPOD_STATE_ON: Same as above, but with clock enabled
77 #define EPOD_STATE_NO_CHANGE 0x00
78 #define EPOD_STATE_OFF 0x01
79 #define EPOD_STATE_RAMRET 0x02
80 #define EPOD_STATE_ON_CLK_OFF 0x03
81 #define EPOD_STATE_ON 0x04
84 * CLKOUT sources
86 #define PRCMU_CLKSRC_CLK38M 0x00
87 #define PRCMU_CLKSRC_ACLK 0x01
88 #define PRCMU_CLKSRC_SYSCLK 0x02
89 #define PRCMU_CLKSRC_LCDCLK 0x03
90 #define PRCMU_CLKSRC_SDMMCCLK 0x04
91 #define PRCMU_CLKSRC_TVCLK 0x05
92 #define PRCMU_CLKSRC_TIMCLK 0x06
93 #define PRCMU_CLKSRC_CLK009 0x07
94 /* These are only valid for CLKOUT1: */
95 #define PRCMU_CLKSRC_SIAMMDSPCLK 0x40
96 #define PRCMU_CLKSRC_I2CCLK 0x41
97 #define PRCMU_CLKSRC_MSP02CLK 0x42
98 #define PRCMU_CLKSRC_ARMPLL_OBSCLK 0x43
99 #define PRCMU_CLKSRC_HSIRXCLK 0x44
100 #define PRCMU_CLKSRC_HSITXCLK 0x45
101 #define PRCMU_CLKSRC_ARMCLKFIX 0x46
102 #define PRCMU_CLKSRC_HDMICLK 0x47
105 * Clock identifiers.
107 enum prcmu_clock {
108 PRCMU_SGACLK,
109 PRCMU_UARTCLK,
110 PRCMU_MSP02CLK,
111 PRCMU_MSP1CLK,
112 PRCMU_I2CCLK,
113 PRCMU_SDMMCCLK,
114 PRCMU_SLIMCLK,
115 PRCMU_PER1CLK,
116 PRCMU_PER2CLK,
117 PRCMU_PER3CLK,
118 PRCMU_PER5CLK,
119 PRCMU_PER6CLK,
120 PRCMU_PER7CLK,
121 PRCMU_LCDCLK,
122 PRCMU_BMLCLK,
123 PRCMU_HSITXCLK,
124 PRCMU_HSIRXCLK,
125 PRCMU_HDMICLK,
126 PRCMU_APEATCLK,
127 PRCMU_APETRACECLK,
128 PRCMU_MCDECLK,
129 PRCMU_IPI2CCLK,
130 PRCMU_DSIALTCLK,
131 PRCMU_DMACLK,
132 PRCMU_B2R2CLK,
133 PRCMU_TVCLK,
134 PRCMU_SSPCLK,
135 PRCMU_RNGCLK,
136 PRCMU_UICCCLK,
137 PRCMU_PWMCLK,
138 PRCMU_IRDACLK,
139 PRCMU_IRRCCLK,
140 PRCMU_SIACLK,
141 PRCMU_SVACLK,
142 PRCMU_NUM_REG_CLOCKS,
143 PRCMU_SYSCLK = PRCMU_NUM_REG_CLOCKS,
144 PRCMU_TIMCLK,
145 PRCMU_PLLSOC0,
146 PRCMU_PLLSOC1,
147 PRCMU_PLLDDR,
151 * enum ape_opp - APE OPP states definition
152 * @APE_OPP_INIT:
153 * @APE_NO_CHANGE: The APE operating point is unchanged
154 * @APE_100_OPP: The new APE operating point is ape100opp
155 * @APE_50_OPP: 50%
157 enum ape_opp {
158 APE_OPP_INIT = 0x00,
159 APE_NO_CHANGE = 0x01,
160 APE_100_OPP = 0x02,
161 APE_50_OPP = 0x03
165 * enum arm_opp - ARM OPP states definition
166 * @ARM_OPP_INIT:
167 * @ARM_NO_CHANGE: The ARM operating point is unchanged
168 * @ARM_100_OPP: The new ARM operating point is arm100opp
169 * @ARM_50_OPP: The new ARM operating point is arm50opp
170 * @ARM_MAX_OPP: Operating point is "max" (more than 100)
171 * @ARM_MAX_FREQ100OPP: Set max opp if available, else 100
172 * @ARM_EXTCLK: The new ARM operating point is armExtClk
174 enum arm_opp {
175 ARM_OPP_INIT = 0x00,
176 ARM_NO_CHANGE = 0x01,
177 ARM_100_OPP = 0x02,
178 ARM_50_OPP = 0x03,
179 ARM_MAX_OPP = 0x04,
180 ARM_MAX_FREQ100OPP = 0x05,
181 ARM_EXTCLK = 0x07
185 * enum ddr_opp - DDR OPP states definition
186 * @DDR_100_OPP: The new DDR operating point is ddr100opp
187 * @DDR_50_OPP: The new DDR operating point is ddr50opp
188 * @DDR_25_OPP: The new DDR operating point is ddr25opp
190 enum ddr_opp {
191 DDR_100_OPP = 0x00,
192 DDR_50_OPP = 0x01,
193 DDR_25_OPP = 0x02,
197 * Definitions for controlling ESRAM0 in deep sleep.
199 #define ESRAM0_DEEP_SLEEP_STATE_OFF 1
200 #define ESRAM0_DEEP_SLEEP_STATE_RET 2
203 * enum ddr_pwrst - DDR power states definition
204 * @DDR_PWR_STATE_UNCHANGED: SDRAM and DDR controller state is unchanged
205 * @DDR_PWR_STATE_ON:
206 * @DDR_PWR_STATE_OFFLOWLAT:
207 * @DDR_PWR_STATE_OFFHIGHLAT:
209 enum ddr_pwrst {
210 DDR_PWR_STATE_UNCHANGED = 0x00,
211 DDR_PWR_STATE_ON = 0x01,
212 DDR_PWR_STATE_OFFLOWLAT = 0x02,
213 DDR_PWR_STATE_OFFHIGHLAT = 0x03
216 #include <linux/mfd/db8500-prcmu.h>
217 #include <linux/mfd/db5500-prcmu.h>
219 #if defined(CONFIG_UX500_SOC_DB8500) || defined(CONFIG_UX500_SOC_DB5500)
221 static inline void __init prcmu_early_init(void)
223 if (machine_is_u5500())
224 return db5500_prcmu_early_init();
225 else
226 return db8500_prcmu_early_init();
229 static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk,
230 bool keep_ap_pll)
232 if (machine_is_u5500())
233 return db5500_prcmu_set_power_state(state, keep_ulp_clk,
234 keep_ap_pll);
235 else
236 return db8500_prcmu_set_power_state(state, keep_ulp_clk,
237 keep_ap_pll);
240 static inline int prcmu_set_epod(u16 epod_id, u8 epod_state)
242 if (machine_is_u5500())
243 return -EINVAL;
244 else
245 return db8500_prcmu_set_epod(epod_id, epod_state);
248 static inline void prcmu_enable_wakeups(u32 wakeups)
250 if (machine_is_u5500())
251 db5500_prcmu_enable_wakeups(wakeups);
252 else
253 db8500_prcmu_enable_wakeups(wakeups);
256 static inline void prcmu_disable_wakeups(void)
258 prcmu_enable_wakeups(0);
261 static inline void prcmu_config_abb_event_readout(u32 abb_events)
263 if (machine_is_u5500())
264 db5500_prcmu_config_abb_event_readout(abb_events);
265 else
266 db8500_prcmu_config_abb_event_readout(abb_events);
269 static inline void prcmu_get_abb_event_buffer(void __iomem **buf)
271 if (machine_is_u5500())
272 db5500_prcmu_get_abb_event_buffer(buf);
273 else
274 db8500_prcmu_get_abb_event_buffer(buf);
277 int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size);
278 int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size);
280 int prcmu_config_clkout(u8 clkout, u8 source, u8 div);
282 static inline int prcmu_request_clock(u8 clock, bool enable)
284 if (machine_is_u5500())
285 return db5500_prcmu_request_clock(clock, enable);
286 else
287 return db8500_prcmu_request_clock(clock, enable);
290 int prcmu_set_ape_opp(u8 opp);
291 int prcmu_get_ape_opp(void);
292 int prcmu_set_ddr_opp(u8 opp);
293 int prcmu_get_ddr_opp(void);
295 static inline int prcmu_set_arm_opp(u8 opp)
297 if (machine_is_u5500())
298 return -EINVAL;
299 else
300 return db8500_prcmu_set_arm_opp(opp);
303 static inline int prcmu_get_arm_opp(void)
305 if (machine_is_u5500())
306 return -EINVAL;
307 else
308 return db8500_prcmu_get_arm_opp();
311 static inline void prcmu_system_reset(u16 reset_code)
313 if (machine_is_u5500())
314 return db5500_prcmu_system_reset(reset_code);
315 else
316 return db8500_prcmu_system_reset(reset_code);
319 static inline u16 prcmu_get_reset_code(void)
321 if (machine_is_u5500())
322 return db5500_prcmu_get_reset_code();
323 else
324 return db8500_prcmu_get_reset_code();
327 void prcmu_ac_wake_req(void);
328 void prcmu_ac_sleep_req(void);
329 void prcmu_modem_reset(void);
330 static inline bool prcmu_is_ac_wake_requested(void)
332 if (machine_is_u5500())
333 return db5500_prcmu_is_ac_wake_requested();
334 else
335 return db8500_prcmu_is_ac_wake_requested();
338 static inline int prcmu_set_display_clocks(void)
340 if (machine_is_u5500())
341 return db5500_prcmu_set_display_clocks();
342 else
343 return db8500_prcmu_set_display_clocks();
346 static inline int prcmu_disable_dsipll(void)
348 if (machine_is_u5500())
349 return db5500_prcmu_disable_dsipll();
350 else
351 return db8500_prcmu_disable_dsipll();
354 static inline int prcmu_enable_dsipll(void)
356 if (machine_is_u5500())
357 return db5500_prcmu_enable_dsipll();
358 else
359 return db8500_prcmu_enable_dsipll();
362 static inline int prcmu_config_esram0_deep_sleep(u8 state)
364 if (machine_is_u5500())
365 return -EINVAL;
366 else
367 return db8500_prcmu_config_esram0_deep_sleep(state);
369 #else
371 static inline void __init prcmu_early_init(void) {}
373 static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk,
374 bool keep_ap_pll)
376 return 0;
379 static inline int prcmu_set_epod(u16 epod_id, u8 epod_state)
381 return 0;
384 static inline void prcmu_enable_wakeups(u32 wakeups) {}
386 static inline void prcmu_disable_wakeups(void) {}
388 static inline int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size)
390 return -ENOSYS;
393 static inline int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
395 return -ENOSYS;
398 static inline int prcmu_config_clkout(u8 clkout, u8 source, u8 div)
400 return 0;
403 static inline int prcmu_request_clock(u8 clock, bool enable)
405 return 0;
408 static inline int prcmu_set_ape_opp(u8 opp)
410 return 0;
413 static inline int prcmu_get_ape_opp(void)
415 return APE_100_OPP;
418 static inline int prcmu_set_arm_opp(u8 opp)
420 return 0;
423 static inline int prcmu_get_arm_opp(void)
425 return ARM_100_OPP;
428 static inline int prcmu_set_ddr_opp(u8 opp)
430 return 0;
433 static inline int prcmu_get_ddr_opp(void)
435 return DDR_100_OPP;
438 static inline void prcmu_system_reset(u16 reset_code) {}
440 static inline u16 prcmu_get_reset_code(void)
442 return 0;
445 static inline void prcmu_ac_wake_req(void) {}
447 static inline void prcmu_ac_sleep_req(void) {}
449 static inline void prcmu_modem_reset(void) {}
451 static inline bool prcmu_is_ac_wake_requested(void)
453 return false;
456 static inline int prcmu_set_display_clocks(void)
458 return 0;
461 static inline int prcmu_disable_dsipll(void)
463 return 0;
466 static inline int prcmu_enable_dsipll(void)
468 return 0;
471 static inline int prcmu_config_esram0_deep_sleep(u8 state)
473 return 0;
476 static inline void prcmu_config_abb_event_readout(u32 abb_events) {}
478 static inline void prcmu_get_abb_event_buffer(void __iomem **buf)
480 *buf = NULL;
483 #endif
485 /* PRCMU QoS APE OPP class */
486 #define PRCMU_QOS_APE_OPP 1
487 #define PRCMU_QOS_DDR_OPP 2
488 #define PRCMU_QOS_DEFAULT_VALUE -1
490 #ifdef CONFIG_UX500_PRCMU_QOS_POWER
492 unsigned long prcmu_qos_get_cpufreq_opp_delay(void);
493 void prcmu_qos_set_cpufreq_opp_delay(unsigned long);
494 void prcmu_qos_force_opp(int, s32);
495 int prcmu_qos_requirement(int pm_qos_class);
496 int prcmu_qos_add_requirement(int pm_qos_class, char *name, s32 value);
497 int prcmu_qos_update_requirement(int pm_qos_class, char *name, s32 new_value);
498 void prcmu_qos_remove_requirement(int pm_qos_class, char *name);
499 int prcmu_qos_add_notifier(int prcmu_qos_class,
500 struct notifier_block *notifier);
501 int prcmu_qos_remove_notifier(int prcmu_qos_class,
502 struct notifier_block *notifier);
504 #else
506 static inline unsigned long prcmu_qos_get_cpufreq_opp_delay(void)
508 return 0;
511 static inline void prcmu_qos_set_cpufreq_opp_delay(unsigned long n) {}
513 static inline void prcmu_qos_force_opp(int prcmu_qos_class, s32 i) {}
515 static inline int prcmu_qos_requirement(int prcmu_qos_class)
517 return 0;
520 static inline int prcmu_qos_add_requirement(int prcmu_qos_class,
521 char *name, s32 value)
523 return 0;
526 static inline int prcmu_qos_update_requirement(int prcmu_qos_class,
527 char *name, s32 new_value)
529 return 0;
532 static inline void prcmu_qos_remove_requirement(int prcmu_qos_class, char *name)
536 static inline int prcmu_qos_add_notifier(int prcmu_qos_class,
537 struct notifier_block *notifier)
539 return 0;
541 static inline int prcmu_qos_remove_notifier(int prcmu_qos_class,
542 struct notifier_block *notifier)
544 return 0;
547 #endif
549 #endif /* __MACH_PRCMU_H */