2 * OMAP2/3 Power Management Routines
4 * Copyright (C) 2008 Nokia Corporation
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 #ifndef __ARCH_ARM_MACH_OMAP2_PM_H
12 #define __ARCH_ARM_MACH_OMAP2_PM_H
14 #include <linux/err.h>
16 #include "powerdomain.h"
18 extern void *omap3_secure_ram_storage
;
19 extern void omap3_pm_off_mode_enable(int);
20 extern void omap_sram_idle(bool suspend
);
21 extern int omap3_can_sleep(void);
22 extern int omap_set_pwrdm_state(struct powerdomain
*pwrdm
, u32 state
);
23 extern int omap3_idle_init(void);
24 extern int omap4_idle_init(void);
25 extern void omap4_enter_sleep(unsigned int cpu
, unsigned int power_state
,
27 extern void omap4_trigger_ioctrl(void);
28 extern u32 omap4_device_off_counter
;
31 extern void omap4_device_set_state_off(u8 enable
);
32 extern bool omap4_device_prev_state_off(void);
33 extern bool omap4_device_next_state_off(void);
34 extern void omap4_device_clear_prev_off_state(void);
36 static inline void omap4_device_set_state_off(u8 enable
)
39 static inline bool omap4_device_prev_state_off(void)
43 static inline bool omap4_device_next_state_off(void)
49 #if defined(CONFIG_PM_OPP)
50 extern int omap3_opp_init(void);
51 extern int omap4_opp_init(void);
53 static inline int omap3_opp_init(void)
57 static inline int omap4_opp_init(void)
64 int omap4_pm_cold_reset(char *reason
);
66 int omap4_pm_cold_reset(char *reason
)
73 * cpuidle mach specific parameters
75 * The board code can override the default C-states definition using
76 * omap3_pm_init_cpuidle
78 struct cpuidle_params
{
79 u32 exit_latency
; /* exit_latency = sleep + wake-up latencies */
81 u8 valid
; /* validates the C-state */
84 #if defined(CONFIG_PM) && defined(CONFIG_CPU_IDLE)
85 extern void omap3_pm_init_cpuidle(struct cpuidle_params
*cpuidle_board_params
);
88 inline void omap3_pm_init_cpuidle(struct cpuidle_params
*cpuidle_board_params
)
93 extern int omap3_pm_get_suspend_state(struct powerdomain
*pwrdm
);
94 extern int omap3_pm_set_suspend_state(struct powerdomain
*pwrdm
, int state
);
96 extern u32 wakeup_timer_seconds
;
97 extern u32 wakeup_timer_milliseconds
;
98 extern struct omap_dm_timer
*gptimer_wakeup
;
100 #ifdef CONFIG_PM_DEBUG
101 extern void omap2_pm_dump(int mode
, int resume
, unsigned int us
);
102 extern void omap2_pm_wakeup_on_timer(u32 seconds
, u32 milliseconds
);
103 extern int omap2_pm_debug
;
104 extern u32 sleep_while_idle
;
106 #define omap2_pm_dump(mode, resume, us) do {} while (0);
107 #define omap2_pm_wakeup_on_timer(seconds, milliseconds) do {} while (0);
108 #define omap2_pm_debug 0
109 #define sleep_while_idle 0
111 #ifdef CONFIG_PM_ADVANCED_DEBUG
112 extern void omap4_pm_suspend_save_regs(void);
114 static inline void omap4_pm_suspend_save_regs(void) { }
117 #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
118 extern void pm_dbg_update_time(struct powerdomain
*pwrdm
, int prev
);
119 extern int pm_dbg_regset_save(int reg_set
);
120 extern int pm_dbg_regset_init(int reg_set
);
122 #define pm_dbg_update_time(pwrdm, prev) do {} while (0);
123 #define pm_dbg_regset_save(reg_set) do {} while (0);
124 #define pm_dbg_regset_init(reg_set) do {} while (0);
125 #endif /* CONFIG_PM_DEBUG */
127 extern void omap24xx_idle_loop_suspend(void);
129 extern void omap24xx_cpu_suspend(u32 dll_ctrl
, void __iomem
*sdrc_dlla_ctrl
,
130 void __iomem
*sdrc_power
);
131 extern void omap34xx_cpu_suspend(u32
*addr
, int save_state
);
132 extern int save_secure_ram_context(u32
*addr
);
133 extern void omap3_save_scratchpad_contents(void);
135 extern unsigned int omap24xx_idle_loop_suspend_sz
;
136 extern unsigned int save_secure_ram_context_sz
;
137 extern unsigned int omap24xx_cpu_suspend_sz
;
138 extern unsigned int omap34xx_cpu_suspend_sz
;
140 #define PM_RTA_ERRATUM_i608 (1 << 0)
141 #define PM_SDRC_WAKEUP_ERRATUM_i583 (1 << 1)
143 #if defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP3)
144 extern u16 pm34xx_errata
;
145 #define IS_PM34XX_ERRATUM(id) (pm34xx_errata & (id))
146 extern void enable_omap3630_toggle_l2_on_restore(void);
148 #define IS_PM34XX_ERRATUM(id) 0
149 static inline void enable_omap3630_toggle_l2_on_restore(void) { }
150 #endif /* defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP3) */
152 #ifdef CONFIG_OMAP_SMARTREFLEX
153 extern int omap_devinit_smartreflex(void);
154 extern void omap_enable_smartreflex_on_init(void);
156 static inline int omap_devinit_smartreflex(void)
161 static inline void omap_enable_smartreflex_on_init(void) {}
165 * struct omap_pmic_map - Describe the OMAP PMIC data for OMAP
166 * @name: name of the voltage domain
167 * @pmic_data: pmic data associated with it
168 * @omap_chip: initialize with OMAP_CHIP_INIT the OMAP chips this data maps to
169 * @special_action: callback for any specific action to take for that map
171 * Since we support multiple PMICs each potentially functioning on multiple
172 * OMAP devices, we describe the parameters in a map allowing us to reuse the
175 struct omap_pmic_map
{
177 struct omap_voltdm_pmic
*pmic_data
;
178 struct omap_chip_id omap_chip
;
179 int (*special_action
)(struct voltagedomain
*);
183 * struct omap_pmic_description - Describe low power behavior of the PMIC
184 * @pmic_lp_tshut: Time rounded up to uSec for the PMIC to
185 * go to low power after the LDOs are pulled to
186 * appropriate state. Note: this is not the same as
187 * voltage rampdown time, instead, consider the
188 * PMIC to have switched it's LDOs down, this is
189 * time taken to reach it's lowest power state(say
191 * @pmic_lp_tstart: Time rounded up to uSec for the PMIC to
192 * provide be ready for operation from low power
193 * state. Note: this is not the same as voltage
194 * rampup time, instead, consider the PMIC to be
195 * in lowest power state(say OFF), this is the time
196 * required for it to become ready for it's DCDCs
197 * or LDOs to start operation.
199 struct omap_pmic_description
{
205 extern int omap_pmic_register_data(struct omap_pmic_map
*map
,
206 struct omap_pmic_description
*desc
);
208 static inline int omap_pmic_register_data(struct omap_pmic_map
*map
,
209 struct omap_pmic_description
*desc
)
214 extern void omap_pmic_data_init(void);
216 extern int omap_pmic_update(struct omap_pmic_map
*tmp_map
, char *name
,
217 u32 old_chip_id
, u32 new_chip_id
);
219 #ifdef CONFIG_TWL4030_CORE
220 extern int omap_twl_init(void);
221 extern int omap3_twl_set_sr_bit(bool enable
);
222 extern int omap_twl_pmic_update(char *name
, u32 old_chip_id
, u32 new_chip_id
);
224 static inline int omap_twl_init(void)
228 static inline int omap_twl_pmic_update(char *name
, u32 old_chip_id
,
235 #ifdef CONFIG_OMAP_TPS6236X
236 extern int omap_tps6236x_board_setup(bool use_62361
, int gpio_vsel0
,
237 int gpio_vsel1
, int pull0
, int pull1
);
238 extern int omap_tps6236x_init(void);
240 extern int omap_tps6236x_update(char *name
, u32 old_chip_id
, u32 new_chip_id
);
242 static inline int omap_tps6236x_board_setup(bool use_62361
, int gpio_vsel0
,
243 int gpio_vsel1
, int pull0
, int pull1
)
247 static inline int omap_tps6236x_init(void)
251 static inline int omap_tps6236x_update(char *name
, u32 old_chip_id
,
258 extern int omap4_ldo_trim_configure(void);
261 extern bool omap_pm_is_ready_status
;
263 * omap_pm_is_ready() - tells if OMAP pm framework is done it's initialization
265 * In few cases, to sequence operations properly, we'd like to know if OMAP's PM
266 * framework has completed all it's expected initializations.
268 static inline bool omap_pm_is_ready(void)
270 return omap_pm_is_ready_status
;
272 extern int omap_pm_get_osc_lp_time(u32
*tstart
, u32
*tshut
);
273 extern int omap_pm_get_pmic_lp_time(u32
*tstart
, u32
*tshut
);
274 extern void omap_pm_set_osc_lp_time(u32 tstart
, u32 tshut
);
275 extern void omap_pm_set_pmic_lp_time(u32 tstart
, u32 tshut
);
277 static inline bool omap_pm_is_ready(void)
281 static inline int omap_pm_get_osc_lp_time(u32
*tstart
, u32
*tshut
)
285 static inline int omap_pm_get_pmic_lp_time(u32
*tstart
, u32
*tshut
)
289 static inline void omap_pm_set_osc_lp_time(u32 tstart
, u32 tshut
) { }
290 static inline void omap_pm_set_pmic_lp_time(u32 tstart
, u32 tshut
) { }