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_HVACLK, /* Ux540 only */
138 PRCMU_G1CLK, /* Ux540 only */
142 PRCMU_NUM_REG_CLOCKS,
143 PRCMU_SYSCLK = PRCMU_NUM_REG_CLOCKS,
156 /* LCD DSI PLL - Ux540 only */
160 PRCMU_DSI0ESCCLK_LCD,
161 PRCMU_DSI1ESCCLK_LCD,
162 PRCMU_DSI2ESCCLK_LCD,
166 * enum prcmu_wdog_id - PRCMU watchdog IDs
167 * @PRCMU_WDOG_ALL: use all timers
168 * @PRCMU_WDOG_CPU1: use first CPU timer only
169 * @PRCMU_WDOG_CPU2: use second CPU timer conly
172 PRCMU_WDOG_ALL = 0x00,
173 PRCMU_WDOG_CPU1 = 0x01,
174 PRCMU_WDOG_CPU2 = 0x02,
178 * enum ape_opp - APE OPP states definition
180 * @APE_NO_CHANGE: The APE operating point is unchanged
181 * @APE_100_OPP: The new APE operating point is ape100opp
183 * @APE_50_PARTLY_25_OPP: 50%, except some clocks at 25%.
187 APE_NO_CHANGE = 0x01,
190 APE_50_PARTLY_25_OPP = 0xFF,
194 * enum arm_opp - ARM OPP states definition
196 * @ARM_NO_CHANGE: The ARM operating point is unchanged
197 * @ARM_100_OPP: The new ARM operating point is arm100opp
198 * @ARM_50_OPP: The new ARM operating point is arm50opp
199 * @ARM_MAX_OPP: Operating point is "max" (more than 100)
200 * @ARM_MAX_FREQ100OPP: Set max opp if available, else 100
201 * @ARM_EXTCLK: The new ARM operating point is armExtClk
205 ARM_NO_CHANGE = 0x01,
209 ARM_MAX_FREQ100OPP = 0x05,
214 * enum ddr_opp - DDR OPP states definition
215 * @DDR_100_OPP: The new DDR operating point is ddr100opp
216 * @DDR_50_OPP: The new DDR operating point is ddr50opp
217 * @DDR_25_OPP: The new DDR operating point is ddr25opp
226 * Definitions for controlling ESRAM0 in deep sleep.
228 #define ESRAM0_DEEP_SLEEP_STATE_OFF 1
229 #define ESRAM0_DEEP_SLEEP_STATE_RET 2
232 * enum ddr_pwrst - DDR power states definition
233 * @DDR_PWR_STATE_UNCHANGED: SDRAM and DDR controller state is unchanged
235 * @DDR_PWR_STATE_OFFLOWLAT:
236 * @DDR_PWR_STATE_OFFHIGHLAT:
239 DDR_PWR_STATE_UNCHANGED = 0x00,
240 DDR_PWR_STATE_ON = 0x01,
241 DDR_PWR_STATE_OFFLOWLAT = 0x02,
242 DDR_PWR_STATE_OFFHIGHLAT = 0x03
245 #define DB8500_PRCMU_LEGACY_OFFSET 0xDD4
249 bool enable_set_ddr_opp;
250 bool enable_ape_opp_100_voltage;
251 struct ab8500_platform_data *ab_platdata;
259 #define PRCMU_FW_PROJECT_U8500 2
260 #define PRCMU_FW_PROJECT_U8400 3
261 #define PRCMU_FW_PROJECT_U9500 4 /* Customer specific */
262 #define PRCMU_FW_PROJECT_U8500_MBB 5
263 #define PRCMU_FW_PROJECT_U8500_C1 6
264 #define PRCMU_FW_PROJECT_U8500_C2 7
265 #define PRCMU_FW_PROJECT_U8500_C3 8
266 #define PRCMU_FW_PROJECT_U8500_C4 9
267 #define PRCMU_FW_PROJECT_U9500_MBL 10
268 #define PRCMU_FW_PROJECT_U8500_MBL 11 /* Customer specific */
269 #define PRCMU_FW_PROJECT_U8500_MBL2 12 /* Customer specific */
270 #define PRCMU_FW_PROJECT_U8520 13
271 #define PRCMU_FW_PROJECT_U8420 14
272 #define PRCMU_FW_PROJECT_A9420 20
273 /* [32..63] 9540 and derivatives */
274 #define PRCMU_FW_PROJECT_U9540 32
275 /* [64..95] 8540 and derivatives */
276 #define PRCMU_FW_PROJECT_L8540 64
277 /* [96..126] 8580 and derivatives */
278 #define PRCMU_FW_PROJECT_L8580 96
280 #define PRCMU_FW_PROJECT_NAME_LEN 20
281 struct prcmu_fw_version {
282 u32 project; /* Notice, project shifted with 8 on ux540 */
286 char project_name[PRCMU_FW_PROJECT_NAME_LEN];
289 #include <linux/mfd/db8500-prcmu.h>
291 #if defined(CONFIG_UX500_SOC_DB8500)
293 static inline void prcmu_early_init(u32 phy_base, u32 size)
295 return db8500_prcmu_early_init(phy_base, size);
298 static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk,
301 return db8500_prcmu_set_power_state(state, keep_ulp_clk,
305 static inline u8 prcmu_get_power_state_result(void)
307 return db8500_prcmu_get_power_state_result();
310 static inline int prcmu_set_epod(u16 epod_id, u8 epod_state)
312 return db8500_prcmu_set_epod(epod_id, epod_state);
315 static inline void prcmu_enable_wakeups(u32 wakeups)
317 db8500_prcmu_enable_wakeups(wakeups);
320 static inline void prcmu_disable_wakeups(void)
322 prcmu_enable_wakeups(0);
325 static inline void prcmu_config_abb_event_readout(u32 abb_events)
327 db8500_prcmu_config_abb_event_readout(abb_events);
330 static inline void prcmu_get_abb_event_buffer(void __iomem **buf)
332 db8500_prcmu_get_abb_event_buffer(buf);
335 int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size);
336 int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size);
337 int prcmu_abb_write_masked(u8 slave, u8 reg, u8 *value, u8 *mask, u8 size);
339 int prcmu_config_clkout(u8 clkout, u8 source, u8 div);
341 static inline int prcmu_request_clock(u8 clock, bool enable)
343 return db8500_prcmu_request_clock(clock, enable);
346 unsigned long prcmu_clock_rate(u8 clock);
347 long prcmu_round_clock_rate(u8 clock, unsigned long rate);
348 int prcmu_set_clock_rate(u8 clock, unsigned long rate);
350 static inline int prcmu_set_ddr_opp(u8 opp)
352 return db8500_prcmu_set_ddr_opp(opp);
354 static inline int prcmu_get_ddr_opp(void)
356 return db8500_prcmu_get_ddr_opp();
359 static inline int prcmu_set_arm_opp(u8 opp)
361 return db8500_prcmu_set_arm_opp(opp);
364 static inline int prcmu_get_arm_opp(void)
366 return db8500_prcmu_get_arm_opp();
369 static inline int prcmu_set_ape_opp(u8 opp)
371 return db8500_prcmu_set_ape_opp(opp);
374 static inline int prcmu_get_ape_opp(void)
376 return db8500_prcmu_get_ape_opp();
379 static inline int prcmu_request_ape_opp_100_voltage(bool enable)
381 return db8500_prcmu_request_ape_opp_100_voltage(enable);
384 static inline void prcmu_system_reset(u16 reset_code)
386 return db8500_prcmu_system_reset(reset_code);
389 static inline u16 prcmu_get_reset_code(void)
391 return db8500_prcmu_get_reset_code();
394 int prcmu_ac_wake_req(void);
395 void prcmu_ac_sleep_req(void);
396 static inline void prcmu_modem_reset(void)
398 return db8500_prcmu_modem_reset();
401 static inline bool prcmu_is_ac_wake_requested(void)
403 return db8500_prcmu_is_ac_wake_requested();
406 static inline int prcmu_set_display_clocks(void)
408 return db8500_prcmu_set_display_clocks();
411 static inline int prcmu_disable_dsipll(void)
413 return db8500_prcmu_disable_dsipll();
416 static inline int prcmu_enable_dsipll(void)
418 return db8500_prcmu_enable_dsipll();
421 static inline int prcmu_config_esram0_deep_sleep(u8 state)
423 return db8500_prcmu_config_esram0_deep_sleep(state);
426 static inline int prcmu_config_hotdog(u8 threshold)
428 return db8500_prcmu_config_hotdog(threshold);
431 static inline int prcmu_config_hotmon(u8 low, u8 high)
433 return db8500_prcmu_config_hotmon(low, high);
436 static inline int prcmu_start_temp_sense(u16 cycles32k)
438 return db8500_prcmu_start_temp_sense(cycles32k);
441 static inline int prcmu_stop_temp_sense(void)
443 return db8500_prcmu_stop_temp_sense();
446 static inline u32 prcmu_read(unsigned int reg)
448 return db8500_prcmu_read(reg);
451 static inline void prcmu_write(unsigned int reg, u32 value)
453 db8500_prcmu_write(reg, value);
456 static inline void prcmu_write_masked(unsigned int reg, u32 mask, u32 value)
458 db8500_prcmu_write_masked(reg, mask, value);
461 static inline int prcmu_enable_a9wdog(u8 id)
463 return db8500_prcmu_enable_a9wdog(id);
466 static inline int prcmu_disable_a9wdog(u8 id)
468 return db8500_prcmu_disable_a9wdog(id);
471 static inline int prcmu_kick_a9wdog(u8 id)
473 return db8500_prcmu_kick_a9wdog(id);
476 static inline int prcmu_load_a9wdog(u8 id, u32 timeout)
478 return db8500_prcmu_load_a9wdog(id, timeout);
481 static inline int prcmu_config_a9wdog(u8 num, bool sleep_auto_off)
483 return db8500_prcmu_config_a9wdog(num, sleep_auto_off);
487 static inline void prcmu_early_init(u32 phy_base, u32 size) {}
489 static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk,
495 static inline int prcmu_set_epod(u16 epod_id, u8 epod_state)
500 static inline void prcmu_enable_wakeups(u32 wakeups) {}
502 static inline void prcmu_disable_wakeups(void) {}
504 static inline int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size)
509 static inline int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
514 static inline int prcmu_abb_write_masked(u8 slave, u8 reg, u8 *value, u8 *mask,
520 static inline int prcmu_config_clkout(u8 clkout, u8 source, u8 div)
525 static inline int prcmu_request_clock(u8 clock, bool enable)
530 static inline long prcmu_round_clock_rate(u8 clock, unsigned long rate)
535 static inline int prcmu_set_clock_rate(u8 clock, unsigned long rate)
540 static inline unsigned long prcmu_clock_rate(u8 clock)
545 static inline int prcmu_set_ape_opp(u8 opp)
550 static inline int prcmu_get_ape_opp(void)
555 static inline int prcmu_request_ape_opp_100_voltage(bool enable)
560 static inline int prcmu_set_arm_opp(u8 opp)
565 static inline int prcmu_get_arm_opp(void)
570 static inline int prcmu_set_ddr_opp(u8 opp)
575 static inline int prcmu_get_ddr_opp(void)
580 static inline void prcmu_system_reset(u16 reset_code) {}
582 static inline u16 prcmu_get_reset_code(void)
587 static inline int prcmu_ac_wake_req(void)
592 static inline void prcmu_ac_sleep_req(void) {}
594 static inline void prcmu_modem_reset(void) {}
596 static inline bool prcmu_is_ac_wake_requested(void)
601 static inline int prcmu_set_display_clocks(void)
606 static inline int prcmu_disable_dsipll(void)
611 static inline int prcmu_enable_dsipll(void)
616 static inline int prcmu_config_esram0_deep_sleep(u8 state)
621 static inline void prcmu_config_abb_event_readout(u32 abb_events) {}
623 static inline void prcmu_get_abb_event_buffer(void __iomem **buf)
628 static inline int prcmu_config_hotdog(u8 threshold)
633 static inline int prcmu_config_hotmon(u8 low, u8 high)
638 static inline int prcmu_start_temp_sense(u16 cycles32k)
643 static inline int prcmu_stop_temp_sense(void)
648 static inline u32 prcmu_read(unsigned int reg)
653 static inline void prcmu_write(unsigned int reg, u32 value) {}
655 static inline void prcmu_write_masked(unsigned int reg, u32 mask, u32 value) {}
659 static inline void prcmu_set(unsigned int reg, u32 bits)
661 prcmu_write_masked(reg, bits, bits);
664 static inline void prcmu_clear(unsigned int reg, u32 bits)
666 prcmu_write_masked(reg, bits, 0);
669 /* PRCMU QoS APE OPP class */
670 #define PRCMU_QOS_APE_OPP 1
671 #define PRCMU_QOS_DDR_OPP 2
672 #define PRCMU_QOS_ARM_OPP 3
673 #define PRCMU_QOS_DEFAULT_VALUE -1
675 #ifdef CONFIG_DBX500_PRCMU_QOS_POWER
677 unsigned long prcmu_qos_get_cpufreq_opp_delay(void);
678 void prcmu_qos_set_cpufreq_opp_delay(unsigned long);
679 void prcmu_qos_force_opp(int, s32);
680 int prcmu_qos_requirement(int pm_qos_class);
681 int prcmu_qos_add_requirement(int pm_qos_class, char *name, s32 value);
682 int prcmu_qos_update_requirement(int pm_qos_class, char *name, s32 new_value);
683 void prcmu_qos_remove_requirement(int pm_qos_class, char *name);
684 int prcmu_qos_add_notifier(int prcmu_qos_class,
685 struct notifier_block *notifier);
686 int prcmu_qos_remove_notifier(int prcmu_qos_class,
687 struct notifier_block *notifier);
691 static inline unsigned long prcmu_qos_get_cpufreq_opp_delay(void)
696 static inline void prcmu_qos_set_cpufreq_opp_delay(unsigned long n) {}
698 static inline void prcmu_qos_force_opp(int prcmu_qos_class, s32 i) {}
700 static inline int prcmu_qos_requirement(int prcmu_qos_class)
705 static inline int prcmu_qos_add_requirement(int prcmu_qos_class,
706 char *name, s32 value)
711 static inline int prcmu_qos_update_requirement(int prcmu_qos_class,
712 char *name, s32 new_value)
717 static inline void prcmu_qos_remove_requirement(int prcmu_qos_class, char *name)
721 static inline int prcmu_qos_add_notifier(int prcmu_qos_class,
722 struct notifier_block *notifier)
726 static inline int prcmu_qos_remove_notifier(int prcmu_qos_class,
727 struct notifier_block *notifier)
734 #endif /* __MACH_PRCMU_H */