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 <linux/err.h>
15 /* Offset for the firmware version within the TCPM */
16 #define DB8500_PRCMU_FW_VERSION_OFFSET 0xA4
17 #define DBX540_PRCMU_FW_VERSION_OFFSET 0xA8
19 /* PRCMU Wakeup defines */
20 enum prcmu_wakeup_index {
21 PRCMU_WAKEUP_INDEX_RTC,
22 PRCMU_WAKEUP_INDEX_RTT0,
23 PRCMU_WAKEUP_INDEX_RTT1,
24 PRCMU_WAKEUP_INDEX_HSI0,
25 PRCMU_WAKEUP_INDEX_HSI1,
26 PRCMU_WAKEUP_INDEX_USB,
27 PRCMU_WAKEUP_INDEX_ABB,
28 PRCMU_WAKEUP_INDEX_ABB_FIFO,
29 PRCMU_WAKEUP_INDEX_ARM,
30 PRCMU_WAKEUP_INDEX_CD_IRQ,
31 NUM_PRCMU_WAKEUP_INDICES
33 #define PRCMU_WAKEUP(_name) (BIT(PRCMU_WAKEUP_INDEX_##_name))
35 /* EPOD (power domain) IDs */
39 * - EPOD_ID_SVAMMDSP: power domain for SVA MMDSP
40 * - EPOD_ID_SVAPIPE: power domain for SVA pipe
41 * - EPOD_ID_SIAMMDSP: power domain for SIA MMDSP
42 * - EPOD_ID_SIAPIPE: power domain for SIA pipe
43 * - EPOD_ID_SGA: power domain for SGA
44 * - EPOD_ID_B2R2_MCDE: power domain for B2R2 and MCDE
45 * - EPOD_ID_ESRAM12: power domain for ESRAM 1 and 2
46 * - EPOD_ID_ESRAM34: power domain for ESRAM 3 and 4
47 * - NUM_EPOD_ID: number of power domains
49 * TODO: These should be prefixed.
51 #define EPOD_ID_SVAMMDSP 0
52 #define EPOD_ID_SVAPIPE 1
53 #define EPOD_ID_SIAMMDSP 2
54 #define EPOD_ID_SIAPIPE 3
56 #define EPOD_ID_B2R2_MCDE 5
57 #define EPOD_ID_ESRAM12 6
58 #define EPOD_ID_ESRAM34 7
62 * state definition for EPOD (power domain)
63 * - EPOD_STATE_NO_CHANGE: The EPOD should remain unchanged
64 * - EPOD_STATE_OFF: The EPOD is switched off
65 * - EPOD_STATE_RAMRET: The EPOD is switched off with its internal RAM in
67 * - EPOD_STATE_ON_CLK_OFF: The EPOD is switched on, clock is still off
68 * - EPOD_STATE_ON: Same as above, but with clock enabled
70 #define EPOD_STATE_NO_CHANGE 0x00
71 #define EPOD_STATE_OFF 0x01
72 #define EPOD_STATE_RAMRET 0x02
73 #define EPOD_STATE_ON_CLK_OFF 0x03
74 #define EPOD_STATE_ON 0x04
79 #define PRCMU_CLKSRC_CLK38M 0x00
80 #define PRCMU_CLKSRC_ACLK 0x01
81 #define PRCMU_CLKSRC_SYSCLK 0x02
82 #define PRCMU_CLKSRC_LCDCLK 0x03
83 #define PRCMU_CLKSRC_SDMMCCLK 0x04
84 #define PRCMU_CLKSRC_TVCLK 0x05
85 #define PRCMU_CLKSRC_TIMCLK 0x06
86 #define PRCMU_CLKSRC_CLK009 0x07
87 /* These are only valid for CLKOUT1: */
88 #define PRCMU_CLKSRC_SIAMMDSPCLK 0x40
89 #define PRCMU_CLKSRC_I2CCLK 0x41
90 #define PRCMU_CLKSRC_MSP02CLK 0x42
91 #define PRCMU_CLKSRC_ARMPLL_OBSCLK 0x43
92 #define PRCMU_CLKSRC_HSIRXCLK 0x44
93 #define PRCMU_CLKSRC_HSITXCLK 0x45
94 #define PRCMU_CLKSRC_ARMCLKFIX 0x46
95 #define PRCMU_CLKSRC_HDMICLK 0x47
137 PRCMU_NUM_REG_CLOCKS,
138 PRCMU_SYSCLK = PRCMU_NUM_REG_CLOCKS,
154 * enum prcmu_wdog_id - PRCMU watchdog IDs
155 * @PRCMU_WDOG_ALL: use all timers
156 * @PRCMU_WDOG_CPU1: use first CPU timer only
157 * @PRCMU_WDOG_CPU2: use second CPU timer conly
160 PRCMU_WDOG_ALL = 0x00,
161 PRCMU_WDOG_CPU1 = 0x01,
162 PRCMU_WDOG_CPU2 = 0x02,
166 * enum ape_opp - APE OPP states definition
168 * @APE_NO_CHANGE: The APE operating point is unchanged
169 * @APE_100_OPP: The new APE operating point is ape100opp
171 * @APE_50_PARTLY_25_OPP: 50%, except some clocks at 25%.
175 APE_NO_CHANGE = 0x01,
178 APE_50_PARTLY_25_OPP = 0xFF,
182 * enum arm_opp - ARM OPP states definition
184 * @ARM_NO_CHANGE: The ARM operating point is unchanged
185 * @ARM_100_OPP: The new ARM operating point is arm100opp
186 * @ARM_50_OPP: The new ARM operating point is arm50opp
187 * @ARM_MAX_OPP: Operating point is "max" (more than 100)
188 * @ARM_MAX_FREQ100OPP: Set max opp if available, else 100
189 * @ARM_EXTCLK: The new ARM operating point is armExtClk
193 ARM_NO_CHANGE = 0x01,
197 ARM_MAX_FREQ100OPP = 0x05,
202 * enum ddr_opp - DDR OPP states definition
203 * @DDR_100_OPP: The new DDR operating point is ddr100opp
204 * @DDR_50_OPP: The new DDR operating point is ddr50opp
205 * @DDR_25_OPP: The new DDR operating point is ddr25opp
214 * Definitions for controlling ESRAM0 in deep sleep.
216 #define ESRAM0_DEEP_SLEEP_STATE_OFF 1
217 #define ESRAM0_DEEP_SLEEP_STATE_RET 2
220 * enum ddr_pwrst - DDR power states definition
221 * @DDR_PWR_STATE_UNCHANGED: SDRAM and DDR controller state is unchanged
223 * @DDR_PWR_STATE_OFFLOWLAT:
224 * @DDR_PWR_STATE_OFFHIGHLAT:
227 DDR_PWR_STATE_UNCHANGED = 0x00,
228 DDR_PWR_STATE_ON = 0x01,
229 DDR_PWR_STATE_OFFLOWLAT = 0x02,
230 DDR_PWR_STATE_OFFHIGHLAT = 0x03
233 #define DB8500_PRCMU_LEGACY_OFFSET 0xDD4
237 bool enable_set_ddr_opp;
238 bool enable_ape_opp_100_voltage;
239 struct ab8500_platform_data *ab_platdata;
247 #define PRCMU_FW_PROJECT_U8500 2
248 #define PRCMU_FW_PROJECT_U8400 3
249 #define PRCMU_FW_PROJECT_U9500 4 /* Customer specific */
250 #define PRCMU_FW_PROJECT_U8500_MBB 5
251 #define PRCMU_FW_PROJECT_U8500_C1 6
252 #define PRCMU_FW_PROJECT_U8500_C2 7
253 #define PRCMU_FW_PROJECT_U8500_C3 8
254 #define PRCMU_FW_PROJECT_U8500_C4 9
255 #define PRCMU_FW_PROJECT_U9500_MBL 10
256 #define PRCMU_FW_PROJECT_U8500_MBL 11 /* Customer specific */
257 #define PRCMU_FW_PROJECT_U8500_MBL2 12 /* Customer specific */
258 #define PRCMU_FW_PROJECT_U8520 13
259 #define PRCMU_FW_PROJECT_U8420 14
260 #define PRCMU_FW_PROJECT_A9420 20
261 /* [32..63] 9540 and derivatives */
262 #define PRCMU_FW_PROJECT_U9540 32
263 /* [64..95] 8540 and derivatives */
264 #define PRCMU_FW_PROJECT_L8540 64
265 /* [96..126] 8580 and derivatives */
266 #define PRCMU_FW_PROJECT_L8580 96
268 #define PRCMU_FW_PROJECT_NAME_LEN 20
269 struct prcmu_fw_version {
270 u32 project; /* Notice, project shifted with 8 on ux540 */
274 char project_name[PRCMU_FW_PROJECT_NAME_LEN];
277 #include <linux/mfd/db8500-prcmu.h>
279 #if defined(CONFIG_UX500_SOC_DB8500)
281 static inline void prcmu_early_init(u32 phy_base, u32 size)
283 return db8500_prcmu_early_init(phy_base, size);
286 static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk,
289 return db8500_prcmu_set_power_state(state, keep_ulp_clk,
293 static inline u8 prcmu_get_power_state_result(void)
295 return db8500_prcmu_get_power_state_result();
298 static inline int prcmu_set_epod(u16 epod_id, u8 epod_state)
300 return db8500_prcmu_set_epod(epod_id, epod_state);
303 static inline void prcmu_enable_wakeups(u32 wakeups)
305 db8500_prcmu_enable_wakeups(wakeups);
308 static inline void prcmu_disable_wakeups(void)
310 prcmu_enable_wakeups(0);
313 static inline void prcmu_config_abb_event_readout(u32 abb_events)
315 db8500_prcmu_config_abb_event_readout(abb_events);
318 static inline void prcmu_get_abb_event_buffer(void __iomem **buf)
320 db8500_prcmu_get_abb_event_buffer(buf);
323 int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size);
324 int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size);
325 int prcmu_abb_write_masked(u8 slave, u8 reg, u8 *value, u8 *mask, u8 size);
327 int prcmu_config_clkout(u8 clkout, u8 source, u8 div);
329 static inline int prcmu_request_clock(u8 clock, bool enable)
331 return db8500_prcmu_request_clock(clock, enable);
334 unsigned long prcmu_clock_rate(u8 clock);
335 long prcmu_round_clock_rate(u8 clock, unsigned long rate);
336 int prcmu_set_clock_rate(u8 clock, unsigned long rate);
338 static inline int prcmu_set_ddr_opp(u8 opp)
340 return db8500_prcmu_set_ddr_opp(opp);
342 static inline int prcmu_get_ddr_opp(void)
344 return db8500_prcmu_get_ddr_opp();
347 static inline int prcmu_set_arm_opp(u8 opp)
349 return db8500_prcmu_set_arm_opp(opp);
352 static inline int prcmu_get_arm_opp(void)
354 return db8500_prcmu_get_arm_opp();
357 static inline int prcmu_set_ape_opp(u8 opp)
359 return db8500_prcmu_set_ape_opp(opp);
362 static inline int prcmu_get_ape_opp(void)
364 return db8500_prcmu_get_ape_opp();
367 static inline int prcmu_request_ape_opp_100_voltage(bool enable)
369 return db8500_prcmu_request_ape_opp_100_voltage(enable);
372 static inline void prcmu_system_reset(u16 reset_code)
374 return db8500_prcmu_system_reset(reset_code);
377 static inline u16 prcmu_get_reset_code(void)
379 return db8500_prcmu_get_reset_code();
382 int prcmu_ac_wake_req(void);
383 void prcmu_ac_sleep_req(void);
384 static inline void prcmu_modem_reset(void)
386 return db8500_prcmu_modem_reset();
389 static inline bool prcmu_is_ac_wake_requested(void)
391 return db8500_prcmu_is_ac_wake_requested();
394 static inline int prcmu_set_display_clocks(void)
396 return db8500_prcmu_set_display_clocks();
399 static inline int prcmu_disable_dsipll(void)
401 return db8500_prcmu_disable_dsipll();
404 static inline int prcmu_enable_dsipll(void)
406 return db8500_prcmu_enable_dsipll();
409 static inline int prcmu_config_esram0_deep_sleep(u8 state)
411 return db8500_prcmu_config_esram0_deep_sleep(state);
414 static inline int prcmu_config_hotdog(u8 threshold)
416 return db8500_prcmu_config_hotdog(threshold);
419 static inline int prcmu_config_hotmon(u8 low, u8 high)
421 return db8500_prcmu_config_hotmon(low, high);
424 static inline int prcmu_start_temp_sense(u16 cycles32k)
426 return db8500_prcmu_start_temp_sense(cycles32k);
429 static inline int prcmu_stop_temp_sense(void)
431 return db8500_prcmu_stop_temp_sense();
434 static inline u32 prcmu_read(unsigned int reg)
436 return db8500_prcmu_read(reg);
439 static inline void prcmu_write(unsigned int reg, u32 value)
441 db8500_prcmu_write(reg, value);
444 static inline void prcmu_write_masked(unsigned int reg, u32 mask, u32 value)
446 db8500_prcmu_write_masked(reg, mask, value);
449 static inline int prcmu_enable_a9wdog(u8 id)
451 return db8500_prcmu_enable_a9wdog(id);
454 static inline int prcmu_disable_a9wdog(u8 id)
456 return db8500_prcmu_disable_a9wdog(id);
459 static inline int prcmu_kick_a9wdog(u8 id)
461 return db8500_prcmu_kick_a9wdog(id);
464 static inline int prcmu_load_a9wdog(u8 id, u32 timeout)
466 return db8500_prcmu_load_a9wdog(id, timeout);
469 static inline int prcmu_config_a9wdog(u8 num, bool sleep_auto_off)
471 return db8500_prcmu_config_a9wdog(num, sleep_auto_off);
475 static inline void prcmu_early_init(u32 phy_base, u32 size) {}
477 static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk,
483 static inline int prcmu_set_epod(u16 epod_id, u8 epod_state)
488 static inline void prcmu_enable_wakeups(u32 wakeups) {}
490 static inline void prcmu_disable_wakeups(void) {}
492 static inline int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size)
497 static inline int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
502 static inline int prcmu_abb_write_masked(u8 slave, u8 reg, u8 *value, u8 *mask,
508 static inline int prcmu_config_clkout(u8 clkout, u8 source, u8 div)
513 static inline int prcmu_request_clock(u8 clock, bool enable)
518 static inline long prcmu_round_clock_rate(u8 clock, unsigned long rate)
523 static inline int prcmu_set_clock_rate(u8 clock, unsigned long rate)
528 static inline unsigned long prcmu_clock_rate(u8 clock)
533 static inline int prcmu_set_ape_opp(u8 opp)
538 static inline int prcmu_get_ape_opp(void)
543 static inline int prcmu_request_ape_opp_100_voltage(bool enable)
548 static inline int prcmu_set_arm_opp(u8 opp)
553 static inline int prcmu_get_arm_opp(void)
558 static inline int prcmu_set_ddr_opp(u8 opp)
563 static inline int prcmu_get_ddr_opp(void)
568 static inline void prcmu_system_reset(u16 reset_code) {}
570 static inline u16 prcmu_get_reset_code(void)
575 static inline int prcmu_ac_wake_req(void)
580 static inline void prcmu_ac_sleep_req(void) {}
582 static inline void prcmu_modem_reset(void) {}
584 static inline bool prcmu_is_ac_wake_requested(void)
589 static inline int prcmu_set_display_clocks(void)
594 static inline int prcmu_disable_dsipll(void)
599 static inline int prcmu_enable_dsipll(void)
604 static inline int prcmu_config_esram0_deep_sleep(u8 state)
609 static inline void prcmu_config_abb_event_readout(u32 abb_events) {}
611 static inline void prcmu_get_abb_event_buffer(void __iomem **buf)
616 static inline int prcmu_config_hotdog(u8 threshold)
621 static inline int prcmu_config_hotmon(u8 low, u8 high)
626 static inline int prcmu_start_temp_sense(u16 cycles32k)
631 static inline int prcmu_stop_temp_sense(void)
636 static inline u32 prcmu_read(unsigned int reg)
641 static inline void prcmu_write(unsigned int reg, u32 value) {}
643 static inline void prcmu_write_masked(unsigned int reg, u32 mask, u32 value) {}
647 static inline void prcmu_set(unsigned int reg, u32 bits)
649 prcmu_write_masked(reg, bits, bits);
652 static inline void prcmu_clear(unsigned int reg, u32 bits)
654 prcmu_write_masked(reg, bits, 0);
657 /* PRCMU QoS APE OPP class */
658 #define PRCMU_QOS_APE_OPP 1
659 #define PRCMU_QOS_DDR_OPP 2
660 #define PRCMU_QOS_ARM_OPP 3
661 #define PRCMU_QOS_DEFAULT_VALUE -1
663 #ifdef CONFIG_DBX500_PRCMU_QOS_POWER
665 unsigned long prcmu_qos_get_cpufreq_opp_delay(void);
666 void prcmu_qos_set_cpufreq_opp_delay(unsigned long);
667 void prcmu_qos_force_opp(int, s32);
668 int prcmu_qos_requirement(int pm_qos_class);
669 int prcmu_qos_add_requirement(int pm_qos_class, char *name, s32 value);
670 int prcmu_qos_update_requirement(int pm_qos_class, char *name, s32 new_value);
671 void prcmu_qos_remove_requirement(int pm_qos_class, char *name);
672 int prcmu_qos_add_notifier(int prcmu_qos_class,
673 struct notifier_block *notifier);
674 int prcmu_qos_remove_notifier(int prcmu_qos_class,
675 struct notifier_block *notifier);
679 static inline unsigned long prcmu_qos_get_cpufreq_opp_delay(void)
684 static inline void prcmu_qos_set_cpufreq_opp_delay(unsigned long n) {}
686 static inline void prcmu_qos_force_opp(int prcmu_qos_class, s32 i) {}
688 static inline int prcmu_qos_requirement(int prcmu_qos_class)
693 static inline int prcmu_qos_add_requirement(int prcmu_qos_class,
694 char *name, s32 value)
699 static inline int prcmu_qos_update_requirement(int prcmu_qos_class,
700 char *name, s32 new_value)
705 static inline void prcmu_qos_remove_requirement(int prcmu_qos_class, char *name)
709 static inline int prcmu_qos_add_notifier(int prcmu_qos_class,
710 struct notifier_block *notifier)
714 static inline int prcmu_qos_remove_notifier(int prcmu_qos_class,
715 struct notifier_block *notifier)
722 #endif /* __MACH_PRCMU_H */