upload tizen1.0 source
[kernel/linux-2.6.36.git] / include / linux / mfd / max8997.h
1 /*
2  * max8997.h - Driver for the Maxim 8997/8966
3  *
4  *  Copyright (C) 2009-2010 Samsung Electrnoics
5  *  MyungJoo Ham <myungjoo.ham@samsung.com>
6  *
7  * This program is not provided / owned by Maxim Integrated Products.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  *
23  * This driver is based on max8998.h
24  */
25
26 #ifndef __LINUX_MFD_MAX8998_H
27 #define __LINUX_MFD_MAX8998_H
28
29 #include <linux/regulator/consumer.h>
30
31 /* MAX8997/8966 regulator IDs */
32 enum max8998_regulators {
33         MAX8997_LDO1 = 0,
34         MAX8997_LDO2,
35         MAX8997_LDO3,
36         MAX8997_LDO4,
37         MAX8997_LDO5,
38         MAX8997_LDO6,
39         MAX8997_LDO7,
40         MAX8997_LDO8,
41         MAX8997_LDO9,
42         MAX8997_LDO10,
43         MAX8997_LDO11,
44         MAX8997_LDO12,
45         MAX8997_LDO13,
46         MAX8997_LDO14,
47         MAX8997_LDO15,
48         MAX8997_LDO16,
49         MAX8997_LDO17,
50         MAX8997_LDO18,
51         MAX8997_LDO21,
52         MAX8997_BUCK1,
53         MAX8997_BUCK2,
54         MAX8997_BUCK3,
55         MAX8997_BUCK4,
56         MAX8997_BUCK5,
57         MAX8997_BUCK6,
58         MAX8997_BUCK7,
59         MAX8997_EN32KHZ_AP,
60         MAX8997_EN32KHZ_CP,
61         MAX8997_ENVICHG,
62         MAX8997_ESAFEOUT1,
63         MAX8997_ESAFEOUT2,
64         MAX8997_CHARGER_CV, /* control MBCCV of MBCCTRL3 */
65         MAX8997_CHARGER, /* charger current, MBCCTRL4 */
66         MAX8997_CHARGER_TOPOFF, /* MBCCTRL5 */
67         MAX8997_FLASH_CUR,
68         MAX8997_MOVIE_CUR,
69         MAX8997_TORCH_CUR,
70         MAX8997_REG_MAX,
71 };
72
73 enum max8997_irq {
74         MAX8997_PMICIRQ_PWRONR,
75         MAX8997_PMICIRQ_PWRONF,
76         MAX8997_PMICIRQ_PWRON1SEC,
77         MAX8997_PMICIRQ_JIGONR,
78         MAX8997_PMICIRQ_JIGONF,
79         MAX8997_PMICIRQ_LOWBAT2,
80         MAX8997_PMICIRQ_LOWBAT1,
81
82         MAX8997_PMICIRQ_JIGR,
83         MAX8997_PMICIRQ_JIGF,
84         MAX8997_PMICIRQ_MR,
85         MAX8997_PMICIRQ_DVS1OK,
86         MAX8997_PMICIRQ_DVS2OK,
87         MAX8997_PMICIRQ_DVS3OK,
88         MAX8997_PMICIRQ_DVS4OK,
89
90         MAX8997_PMICIRQ_CHGINS,
91         MAX8997_PMICIRQ_CHGRM,
92         MAX8997_PMICIRQ_DCINOVP,
93         MAX8997_PMICIRQ_TOPOFFR,
94         MAX8997_PMICIRQ_CHGRSTF,
95         MAX8997_PMICIRQ_MBCHGTMEXPD,
96
97         MAX8997_PMICIRQ_RTC60S,
98         MAX8997_PMICIRQ_RTCA1,
99         MAX8997_PMICIRQ_RTCA2,
100         MAX8997_PMICIRQ_SMPL_INT,
101         MAX8997_PMICIRQ_RTC1S,
102         MAX8997_PMICIRQ_WTSR,
103
104         MAX8997_MUICIRQ_ADCError,
105         MAX8997_MUICIRQ_ADCLow,
106         MAX8997_MUICIRQ_ADC,
107
108         MAX8997_MUICIRQ_VBVolt,
109         MAX8997_MUICIRQ_DBChg,
110         MAX8997_MUICIRQ_DCDTmr,
111         MAX8997_MUICIRQ_ChgDetRun,
112         MAX8997_MUICIRQ_ChgTyp,
113
114         MAX8997_MUICIRQ_OVP,
115
116         MAX8997_IRQ_NR,
117 };
118
119 struct max8997_regulator_data {
120         int id;
121         struct regulator_init_data *initdata;
122 };
123
124 struct max8997_power_data {
125         int             (*set_charger)(int);
126         int             (*topoff_cb) (void);
127         unsigned        batt_detect:1;
128         unsigned        topoff_threshold:2;
129         unsigned        fast_charge:3;  /* charge current */
130 };
131
132 enum {
133         MAX8997_MUIC_DETACHED = 0,
134         MAX8997_MUIC_ATTACHED
135 };
136
137 enum {
138         AP_USB_MODE = 0,
139         CP_USB_MODE,
140         AUDIO_MODE,
141 };
142
143 enum {
144         UART_PATH_CP = 0,
145         UART_PATH_AP,
146 };
147
148 typedef enum cable_type {
149         CABLE_TYPE_NONE = 0,
150         CABLE_TYPE_USB,
151         CABLE_TYPE_OTG,
152         CABLE_TYPE_TA,
153         CABLE_TYPE_DESKDOCK,
154         CABLE_TYPE_CARDOCK,
155         CABLE_TYPE_JIG_UART_OFF,
156         CABLE_TYPE_JIG_UART_OFF_VB,     /* VBUS enabled */
157         CABLE_TYPE_JIG_UART_ON,
158         CABLE_TYPE_JIG_USB_OFF,
159         CABLE_TYPE_JIG_USB_ON,
160         CABLE_TYPE_MHL,
161         CABLE_TYPE_MHL_VB,
162         CABLE_TYPE_UNKNOWN
163 } cable_type_t;
164
165
166 /*muic device platform data */
167 struct max8997_muic_platform_data {
168         void (*usb_power)(u8 on);
169         void (*usb_cb)(u8 attached);
170         int (*charger_cb)(cable_type_t cable_type);
171         void (*deskdock_cb) (bool attached);
172         void (*cardock_cb) (bool attached);
173         void (*mhl_cb) (int attached);
174         void (*init_cb) (void);
175         int (*set_safeout) (int path);
176         bool (*is_mhl_attached) (void);
177         int (*cfg_uart_gpio) (void);
178         void (*jig_uart_cb) (int path);
179         int (*host_notify_cb) (int enable);
180         int gpio_usb_sel;
181         int sw_path;
182         int uart_path;
183
184 };
185
186 /* haptic device platform data */
187 struct max8997_haptic_platform_data {
188         const char      *name;
189         int             pwm_timer;
190         void            (*control_power)(struct device *, int);
191 };
192
193 struct max8997_platform_data {
194         /* IRQ */
195         int irq_base;
196         int ono;
197         int wakeup;
198
199         /* ---- PMIC ---- */
200         struct max8997_regulator_data *regulators;
201         int num_regulators;
202
203         /*
204          * SET1~3 DVS GPIOs control Buck1, 2, and 5 simultaneously. Therefore,
205          * With buckx_gpiodvs enabled, the buckx cannot be controlled
206          * independently. To control buckx (of 1, 2, and 5) independently,
207          * disable buckx_gpiodvs and control with BUCKxDVS1 register.
208          *
209          * When buckx_gpiodvs and bucky_gpiodvs are both enabled, set_voltage
210          * on buckx will change the voltage of bucky at the same time.
211          *
212          */
213         bool ignore_gpiodvs_side_effect;
214         int buck125_gpios[3]; /* GPIO of [0]SET1, [1]SET2, [2]SET3 */
215         int buck125_default_idx; /* Default value of SET1, 2, 3 */
216         unsigned int buck1_voltage[8]; /* buckx_voltage in uV */
217         bool buck1_gpiodvs;
218         unsigned int buck2_voltage[8];
219         bool buck2_gpiodvs;
220         unsigned int buck5_voltage[8];
221         bool buck5_gpiodvs;
222
223         /* ---- MUIC ---- */
224         struct max8997_muic_platform_data *muic_pdata;
225
226         /* ---- HAPTIC ---- */
227         struct max8997_haptic_platform_data *haptic_pdata;
228
229         /* ---- RTC ---- */
230         bool delay; /* The MAX8997 RTC write delay is requred. */
231
232         /* ---- Charger control ---- */
233
234         /* 50 ~ 200mA by 10mA step */
235         int eoc_mA;
236         /*
237          * 0 ~ 50 in percent to current limit of regulaotr "CHARGER"
238          * if eoc_mA = 0. If eoc_mA > 0, this is ignored.
239          */
240         int eoc_ratio;
241         /*
242          * ADC read function for the ADC connected to VICHG
243          * This is not required: ignored if NULL */
244         int (*vichg_adc_get_uV)(void *);
245         /* Charge Restart Level is Constant in MAX8997 (150mV) */
246
247         /* Charge Full Timeout */
248         int timeout; /* 0 (no timeout), 5, 6, 7 hours */
249
250         /* ---- Flash ---- */
251         int flash_cntl_val;
252
253         /*
254          * Note that MAX8997 has a fuel gauge that is identical to MAX17042.
255          * However, it has a seperated I2C bus. Thus we do not include
256          * the fuel gauge in this mfd.
257          */
258 };
259
260 #endif /* __LINUX_MFD_MAX8998_H */