2 * Copyright (C) ST Ericsson SA 2011
4 * License Terms: GNU General Public License v2
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 */
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
52 #define EPOD_ID_B2R2_MCDE 5
53 #define EPOD_ID_ESRAM12 6
54 #define EPOD_ID_ESRAM34 7
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
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
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
142 PRCMU_NUM_REG_CLOCKS
,
143 PRCMU_SYSCLK
= PRCMU_NUM_REG_CLOCKS
,
151 * enum ape_opp - APE OPP states definition
153 * @APE_NO_CHANGE: The APE operating point is unchanged
154 * @APE_100_OPP: The new APE operating point is ape100opp
159 APE_NO_CHANGE
= 0x01,
165 * enum arm_opp - ARM OPP states definition
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
176 ARM_NO_CHANGE
= 0x01,
180 ARM_MAX_FREQ100OPP
= 0x05,
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
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
206 * @DDR_PWR_STATE_OFFLOWLAT:
207 * @DDR_PWR_STATE_OFFHIGHLAT:
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();
226 return db8500_prcmu_early_init();
229 static inline int prcmu_set_power_state(u8 state
, bool keep_ulp_clk
,
232 if (machine_is_u5500())
233 return db5500_prcmu_set_power_state(state
, keep_ulp_clk
,
236 return db8500_prcmu_set_power_state(state
, keep_ulp_clk
,
240 static inline int prcmu_set_epod(u16 epod_id
, u8 epod_state
)
242 if (machine_is_u5500())
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
);
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
);
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
);
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
);
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())
300 return db8500_prcmu_set_arm_opp(opp
);
303 static inline int prcmu_get_arm_opp(void)
305 if (machine_is_u5500())
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
);
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();
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();
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();
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();
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();
359 return db8500_prcmu_enable_dsipll();
362 static inline int prcmu_config_esram0_deep_sleep(u8 state
)
364 if (machine_is_u5500())
367 return db8500_prcmu_config_esram0_deep_sleep(state
);
371 static inline void __init
prcmu_early_init(void) {}
373 static inline int prcmu_set_power_state(u8 state
, bool keep_ulp_clk
,
379 static inline int prcmu_set_epod(u16 epod_id
, u8 epod_state
)
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
)
393 static inline int prcmu_abb_write(u8 slave
, u8 reg
, u8
*value
, u8 size
)
398 static inline int prcmu_config_clkout(u8 clkout
, u8 source
, u8 div
)
403 static inline int prcmu_request_clock(u8 clock
, bool enable
)
408 static inline int prcmu_set_ape_opp(u8 opp
)
413 static inline int prcmu_get_ape_opp(void)
418 static inline int prcmu_set_arm_opp(u8 opp
)
423 static inline int prcmu_get_arm_opp(void)
428 static inline int prcmu_set_ddr_opp(u8 opp
)
433 static inline int prcmu_get_ddr_opp(void)
438 static inline void prcmu_system_reset(u16 reset_code
) {}
440 static inline u16
prcmu_get_reset_code(void)
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)
456 static inline int prcmu_set_display_clocks(void)
461 static inline int prcmu_disable_dsipll(void)
466 static inline int prcmu_enable_dsipll(void)
471 static inline int prcmu_config_esram0_deep_sleep(u8 state
)
476 static inline void prcmu_config_abb_event_readout(u32 abb_events
) {}
478 static inline void prcmu_get_abb_event_buffer(void __iomem
**buf
)
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
);
506 static inline unsigned long prcmu_qos_get_cpufreq_opp_delay(void)
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
)
520 static inline int prcmu_qos_add_requirement(int prcmu_qos_class
,
521 char *name
, s32 value
)
526 static inline int prcmu_qos_update_requirement(int prcmu_qos_class
,
527 char *name
, s32 new_value
)
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
)
541 static inline int prcmu_qos_remove_notifier(int prcmu_qos_class
,
542 struct notifier_block
*notifier
)
549 #endif /* __MACH_PRCMU_H */