blob: c90d8d15b761f37ae63f71a559888f2b466b7a42 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/*
Amy Maloche4c994c92012-02-15 09:56:15 -08002 * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#ifndef __MFD_PM8XXX_MISC_H__
15#define __MFD_PM8XXX_MISC_H__
16
17#include <linux/err.h>
18
19#define PM8XXX_MISC_DEV_NAME "pm8xxx-misc"
20
21/**
22 * struct pm8xxx_misc_platform_data - PM8xxx misc driver platform data
23 * @priority: PMIC prority level in a multi-PMIC system. Lower value means
24 * greater priority. Actions are performed from highest to lowest
25 * priority PMIC.
26 */
27struct pm8xxx_misc_platform_data {
28 int priority;
29};
30
Anirudh Ghayal5213eb82011-10-24 14:44:58 +053031enum pm8xxx_uart_path_sel {
32 UART_NONE,
33 UART_TX1_RX1,
34 UART_TX2_RX2,
35 UART_TX3_RX3,
36};
37
Anirudh Ghayal7b382292011-11-01 14:08:34 +053038enum pm8xxx_coincell_chg_voltage {
39 PM8XXX_COINCELL_VOLTAGE_3p2V = 1,
40 PM8XXX_COINCELL_VOLTAGE_3p1V,
41 PM8XXX_COINCELL_VOLTAGE_3p0V,
42 PM8XXX_COINCELL_VOLTAGE_2p5V = 16
43};
44
45enum pm8xxx_coincell_chg_resistor {
46 PM8XXX_COINCELL_RESISTOR_2100_OHMS,
47 PM8XXX_COINCELL_RESISTOR_1700_OHMS,
48 PM8XXX_COINCELL_RESISTOR_1200_OHMS,
49 PM8XXX_COINCELL_RESISTOR_800_OHMS
50};
51
52enum pm8xxx_coincell_chg_state {
53 PM8XXX_COINCELL_CHG_DISABLE,
54 PM8XXX_COINCELL_CHG_ENABLE
55};
56
57struct pm8xxx_coincell_chg {
58 enum pm8xxx_coincell_chg_state state;
59 enum pm8xxx_coincell_chg_voltage voltage;
60 enum pm8xxx_coincell_chg_resistor resistor;
61};
62
Anirudh Ghayalbfbaf822011-11-01 14:28:34 +053063enum pm8xxx_smpl_delay {
64 PM8XXX_SMPL_DELAY_0p5,
65 PM8XXX_SMPL_DELAY_1p0,
66 PM8XXX_SMPL_DELAY_1p5,
67 PM8XXX_SMPL_DELAY_2p0,
68};
69
Anirudh Ghayala4262a32011-11-10 00:02:18 +053070enum pm8xxx_pon_config {
71 PM8XXX_DISABLE_HARD_RESET = 0,
72 PM8XXX_SHUTDOWN_ON_HARD_RESET,
73 PM8XXX_RESTART_ON_HARD_RESET,
74};
75
Amy Maloche4c994c92012-02-15 09:56:15 -080076enum pm8xxx_aux_clk_id {
77 CLK_MP3_1,
78 CLK_MP3_2,
79};
80
81enum pm8xxx_aux_clk_div {
82 X0_DIV_NONE,
83 XO_DIV_1,
84 XO_DIV_2,
85 XO_DIV_4,
86 XO_DIV_8,
87 XO_DIV_16,
88 XO_DIV_32,
89 XO_DIV_64,
90};
91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070092#if defined(CONFIG_MFD_PM8XXX_MISC) || defined(CONFIG_MFD_PM8XXX_MISC_MODULE)
93
94/**
95 * pm8xxx_reset_pwr_off - switch all PM8XXX PMIC chips attached to the system to
96 * either reset or shutdown when they are turned off
97 * @reset: 0 = shudown the PMICs, 1 = shutdown and then restart the PMICs
98 *
99 * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
100 */
101int pm8xxx_reset_pwr_off(int reset);
102
Anirudh Ghayal5213eb82011-10-24 14:44:58 +0530103int pm8xxx_uart_gpio_mux_ctrl(enum pm8xxx_uart_path_sel uart_path_sel);
104
Anirudh Ghayal7b382292011-11-01 14:08:34 +0530105/**
106 * pm8xxx_coincell_chg_config - Disables or enables the coincell charger, and
107 * configures its voltage and resistor settings.
108 * @chg_config: Holds both voltage and resistor values, and a
109 * switch to change the state of charger.
110 * If state is to disable the charger then
111 * both voltage and resistor are disregarded.
112 *
113 * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
114 */
115int pm8xxx_coincell_chg_config(struct pm8xxx_coincell_chg *chg_config);
116
Anirudh Ghayalbfbaf822011-11-01 14:28:34 +0530117/**
118 * pm8xxx_smpl_control - enables/disables SMPL detection
119 * @enable: 0 = shutdown PMIC on power loss, 1 = reset PMIC on power loss
120 *
121 * This function enables or disables the Sudden Momentary Power Loss detection
122 * module. If SMPL detection is enabled, then when a sufficiently long power
123 * loss event occurs, the PMIC will automatically reset itself. If SMPL
124 * detection is disabled, then the PMIC will shutdown when power loss occurs.
125 *
126 * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
127 */
128int pm8xxx_smpl_control(int enable);
129
130/**
131 * pm8xxx_smpl_set_delay - sets the SMPL detection time delay
132 * @delay: enum value corresponding to delay time
133 *
134 * This function sets the time delay of the SMPL detection module. If power
135 * is reapplied within this interval, then the PMIC reset automatically. The
136 * SMPL detection module must be enabled for this delay time to take effect.
137 *
138 * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
139 */
140int pm8xxx_smpl_set_delay(enum pm8xxx_smpl_delay delay);
141
Anirudh Ghayala23c1ca2011-11-01 14:36:24 +0530142/**
143 * pm8xxx_watchdog_reset_control - enables/disables watchdog reset detection
144 * @enable: 0 = shutdown when PS_HOLD goes low, 1 = reset when PS_HOLD goes low
145 *
146 * This function enables or disables the PMIC watchdog reset detection feature.
147 * If watchdog reset detection is enabled, then the PMIC will reset itself
148 * when PS_HOLD goes low. If it is not enabled, then the PMIC will shutdown
149 * when PS_HOLD goes low.
150 *
151 * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
152 */
153int pm8xxx_watchdog_reset_control(int enable);
154
Anirudh Ghayala4262a32011-11-10 00:02:18 +0530155/**
156 * pm8xxx_hard_reset_config - Allows different reset configurations
157 *
158 * config = DISABLE_HARD_RESET to disable hard reset
159 * = SHUTDOWN_ON_HARD_RESET to turn off the system on hard reset
160 * = RESTART_ON_HARD_RESET to restart the system on hard reset
161 *
162 * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
163 */
164int pm8xxx_hard_reset_config(enum pm8xxx_pon_config config);
165
Anirudh Ghayal51e947f2011-11-01 14:49:45 +0530166/**
167 * pm8xxx_stay_on - enables stay_on feature
168 *
169 * PMIC stay-on feature allows PMIC to ignore MSM PS_HOLD=low
170 * signal so that some special functions like debugging could be
171 * performed.
172 *
173 * This feature should not be used in any product release.
174 *
175 * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
176 */
177int pm8xxx_stay_on(void);
178
David Collins47242722012-01-20 11:34:58 -0800179/**
180 * pm8xxx_preload_dVdd - preload the dVdd regulator during off state.
181 *
182 * This can help to reduce fluctuations in the dVdd voltage during startup
183 * at the cost of additional off state current draw.
184 *
185 * This API should only be called if dVdd startup issues are suspected.
186 *
187 * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
188 */
189int pm8xxx_preload_dVdd(void);
190
Willie Ruan5db1f242012-01-30 22:08:04 -0800191/**
192 * pm8xxx_usb_id_pullup - Control a pullup for USB ID
193 *
194 * @enable: enable (1) or disable (0) the pullup
195 *
196 * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
197 */
198int pm8xxx_usb_id_pullup(int enable);
199
Amy Maloche4c994c92012-02-15 09:56:15 -0800200/**
201 * pm8xxx_aux_clk_control - Control an auxiliary clock
202 * @clk_id: ID of clock to be programmed, registers of XO_CNTRL2
203 * @divider: divisor to use when configuring desired clock
204 * @enable: enable (1) the designated clock with the supplied division,
205 * or disable (0) the designated clock
206 *
207 * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
208 */
209int pm8xxx_aux_clk_control(enum pm8xxx_aux_clk_id clk_id,
210 enum pm8xxx_aux_clk_div divider,
211 bool enable);
212
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700213#else
214
215static inline int pm8xxx_reset_pwr_off(int reset)
216{
217 return -ENODEV;
218}
Anirudh Ghayal5213eb82011-10-24 14:44:58 +0530219static inline int
220pm8xxx_uart_gpio_mux_ctrl(enum pm8xxx_uart_path_sel uart_path_sel)
221{
222 return -ENODEV;
223}
Anirudh Ghayal7b382292011-11-01 14:08:34 +0530224static inline int
225pm8xxx_coincell_chg_config(struct pm8xxx_coincell_chg *chg_config)
226{
227 return -ENODEV;
228}
Anirudh Ghayalbfbaf822011-11-01 14:28:34 +0530229static inline int pm8xxx_smpl_set_delay(enum pm8xxx_smpl_delay delay)
230{
231 return -ENODEV;
232}
233static inline int pm8xxx_smpl_control(int enable)
234{
235 return -ENODEV;
236}
Anirudh Ghayala23c1ca2011-11-01 14:36:24 +0530237static inline int pm8xxx_watchdog_reset_control(int enable)
238{
239 return -ENODEV;
240}
Anirudh Ghayala4262a32011-11-10 00:02:18 +0530241static inline int pm8xxx_hard_reset_config(enum pm8xxx_pon_config config)
242{
243 return -ENODEV;
244}
Anirudh Ghayal51e947f2011-11-01 14:49:45 +0530245static inline int pm8xxx_stay_on(void)
246{
247 return -ENODEV;
248}
David Collins47242722012-01-20 11:34:58 -0800249static inline int pm8xxx_preload_dVdd(void)
250{
251 return -ENODEV;
252}
Willie Ruan5db1f242012-01-30 22:08:04 -0800253static inline int pm8xxx_usb_id_pullup(int enable)
254{
255 return -ENODEV;
256}
Amy Maloche4c994c92012-02-15 09:56:15 -0800257static inline int pm8xxx_aux_clk_control(enum pm8xxx_aux_clk_id clk_id,
258 enum pm8xxx_aux_clk_div divider, bool enable)
259{
260 return -ENODEV;
261}
262
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700263#endif
264
265#endif