mfd: tps80031: add option to enable internal pullup or pulldown
[linux-2.6.git] / include / linux / mfd / tps80031.h
1 /*
2  * include/linux/mfd/tps80031.c
3  *
4  * Core driver interface for TI TPS80031 PMIC
5  *
6  * Copyright (C) 2011 NVIDIA Corporation
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16  * more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21  *
22  */
23
24 #ifndef __LINUX_MFD_TPS80031_H
25 #define __LINUX_MFD_TPS80031_H
26
27 #include <linux/rtc.h>
28
29 /* Supported chips */
30 enum chips {
31         TPS80031 = 0x00000001,
32         TPS80032 = 0x00000002,
33 };
34
35 enum {
36         TPS80031_INT_PWRON,
37         TPS80031_INT_RPWRON,
38         TPS80031_INT_SYS_VLOW,
39         TPS80031_INT_RTC_ALARM,
40         TPS80031_INT_RTC_PERIOD,
41         TPS80031_INT_HOT_DIE,
42         TPS80031_INT_VXX_SHORT,
43         TPS80031_INT_SPDURATION,
44         TPS80031_INT_WATCHDOG,
45         TPS80031_INT_BAT,
46         TPS80031_INT_SIM,
47         TPS80031_INT_MMC,
48         TPS80031_INT_RES,
49         TPS80031_INT_GPADC_RT,
50         TPS80031_INT_GPADC_SW2_EOC,
51         TPS80031_INT_CC_AUTOCAL,
52         TPS80031_INT_ID_WKUP,
53         TPS80031_INT_VBUSS_WKUP,
54         TPS80031_INT_ID,
55         TPS80031_INT_VBUS,
56         TPS80031_INT_CHRG_CTRL,
57         TPS80031_INT_EXT_CHRG,
58         TPS80031_INT_INT_CHRG,
59         TPS80031_INT_RES2,
60         TPS80031_INT_BAT_TEMP_OVRANGE,
61         TPS80031_INT_BAT_REMOVED,
62         TPS80031_INT_VBUS_DET,
63         TPS80031_INT_VAC_DET,
64         TPS80031_INT_FAULT_WDG,
65         TPS80031_INT_LINCH_GATED,
66
67         /* Last interrupt id to get the end number */
68         TPS80031_INT_NR,
69 };
70
71 enum adc_channel {
72         BATTERY_TYPE                    = 0,  /* External ADC */
73         BATTERY_TEMPERATURE             = 1,  /* External ADC */
74         AUDIO_ACCESSORY                 = 2,  /* External ADC */
75         TEMPERATURE_EXTERNAL_DIODE      = 3,  /* External ADC */
76         TEMPERATURE_MEASUREMENT         = 4,  /* External ADC */
77         GENERAL_PURPOSE_1               = 5,  /* External ADC */
78         GENERAL_PURPOSE_2               = 6,  /* External ADC */
79         SYSTEM_SUPPLY                   = 7,  /* Internal ADC */
80         BACKUP_BATTERY                  = 8,  /* Internal ADC */
81         EXTERNAL_CHARGER_INPUT          = 9,  /* Internal ADC */
82         VBUS                            = 10, /* Internal ADC */
83         VBUS_DCDC_OUTPUT_CURRENT        = 11, /* Internal ADC */
84         DIE_TEMPERATURE_1               = 12, /* Internal ADC */
85         DIE_TEMPERATURE_2               = 13, /* Internal ADC */
86         USB_ID_LINE                     = 14, /* Internal ADC */
87         TEST_NETWORK_1                  = 15, /* Internal ADC */
88         TEST_NETWORK_2                  = 16, /* Internal ADC */
89         BATTERY_CHARGING_CURRENT        = 17, /* Internal ADC */
90         BATTERY_VOLTAGE                 = 18, /* Internal ADC */
91 };
92
93 enum TPS80031_GPIO {
94         TPS80031_GPIO_REGEN1,
95         TPS80031_GPIO_REGEN2,
96         TPS80031_GPIO_SYSEN,
97
98         /* Last entry */
99         TPS80031_GPIO_NR,
100 };
101
102 enum TPS80031_CLOCK32K {
103         TPS80031_CLOCK32K_AO,
104         TPS80031_CLOCK32K_G,
105         TPS80031_CLOCK32K_AUDIO,
106
107         /* Last entry */
108         TPS80031_CLOCK32K_NR,
109 };
110
111 enum {
112         SLAVE_ID0 = 0,
113         SLAVE_ID1 = 1,
114         SLAVE_ID2 = 2,
115         SLAVE_ID3 = 3,
116 };
117
118 enum {
119         I2C_ID0_ADDR = 0x12,
120         I2C_ID1_ADDR = 0x48,
121         I2C_ID2_ADDR = 0x49,
122         I2C_ID3_ADDR = 0x4A,
123 };
124
125 /* External controls requests */
126 enum tps80031_ext_control {
127         PWR_REQ_INPUT_NONE      = 0x00000000,
128         PWR_REQ_INPUT_PREQ1     = 0x00000001,
129         PWR_REQ_INPUT_PREQ2     = 0x00000002,
130         PWR_REQ_INPUT_PREQ3     = 0x00000004,
131         PWR_OFF_ON_SLEEP        = 0x00000008,
132         PWR_ON_ON_SLEEP         = 0x00000010,
133 };
134
135 enum tps80031_pupd_pins {
136         TPS80031_PREQ1 = 0,
137         TPS80031_PREQ2A,
138         TPS80031_PREQ2B,
139         TPS80031_PREQ2C,
140         TPS80031_PREQ3,
141         TPS80031_NRES_WARM,
142         TPS80031_PWM_FORCE,
143         TPS80031_CHRG_EXT_CHRG_STATZ,
144         TPS80031_SIM,
145         TPS80031_MMC,
146         TPS80031_GPADC_START,
147         TPS80031_DVSI2C_SCL,
148         TPS80031_DVSI2C_SDA,
149         TPS80031_CTLI2C_SCL,
150         TPS80031_CTLI2C_SDA,
151 };
152
153 enum tps80031_pupd_settings {
154         TPS80031_PUPD_NORMAL,
155         TPS80031_PUPD_PULLDOWN,
156         TPS80031_PUPD_PULLUP,
157 };
158
159 struct tps80031_subdev_info {
160         int             id;
161         const char      *name;
162         void            *platform_data;
163 };
164
165 struct tps80031_rtc_platform_data {
166         int irq;
167         struct rtc_time time;
168 };
169
170 struct tps80031_clk32k_init_data {
171         int clk32k_nr;
172         bool enable;
173         unsigned long ext_ctrl_flag;
174 };
175
176 struct tps80031_gpio_init_data {
177         int gpio_nr;
178         unsigned long ext_ctrl_flag;
179 };
180
181 struct tps80031_pupd_init_data {
182         int input_pin;
183         int setting;
184 };
185
186 struct tps80031_platform_data {
187         int num_subdevs;
188         struct tps80031_subdev_info *subdevs;
189         int gpio_base;
190         int irq_base;
191         struct tps80031_32kclock_plat_data *clk32k_pdata;
192         struct tps80031_gpio_init_data *gpio_init_data;
193         int gpio_init_data_size;
194         struct tps80031_clk32k_init_data *clk32k_init_data;
195         int clk32k_init_data_size;
196         bool use_power_off;
197         struct tps80031_pupd_init_data *pupd_init_data;
198         int pupd_init_data_size;
199 };
200
201 struct tps80031_bg_platform_data {
202         int irq_base;
203         int battery_present;
204 };
205
206 /*
207  * NOTE: the functions below are not intended for use outside
208  * of the TPS80031 sub-device drivers
209  */
210 extern int tps80031_write(struct device *dev, int sid, int reg, uint8_t val);
211 extern int tps80031_writes(struct device *dev, int sid, int reg, int len,
212                                 uint8_t *val);
213 extern int tps80031_read(struct device *dev, int sid, int reg, uint8_t *val);
214 extern int tps80031_reads(struct device *dev, int sid, int reg, int len,
215                                 uint8_t *val);
216 extern int tps80031_set_bits(struct device *dev, int sid, int reg,
217                                 uint8_t bit_mask);
218 extern int tps80031_clr_bits(struct device *dev, int sid, int reg,
219                                 uint8_t bit_mask);
220 extern int tps80031_update(struct device *dev, int sid, int reg, uint8_t val,
221                            uint8_t mask);
222 extern int tps80031_force_update(struct device *dev, int sid, int reg,
223                                  uint8_t val, uint8_t mask);
224 extern int tps80031_ext_power_req_config(struct device *dev,
225                 unsigned long ext_ctrl_flag, int preq_bit,
226                 int state_reg_add, int trans_reg_add);
227
228 extern unsigned long tps80031_get_chip_info(struct device *dev);
229
230 extern int tps80031_gpadc_conversion(int channle_no);
231
232 extern int tps80031_get_pmu_version(struct device *dev);
233
234 #endif /*__LINUX_MFD_TPS80031_H */