1 /* linux/i2c/tps65910.h
3 * TPS65910 Power Management Device Definitions.
5 * Based on include/linux/i2c/twl.h
7 * Copyright (C) 2010 Mistral Solutions Pvt Ltd <www.mistralsolutions.com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
20 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
30 #ifndef __LINUX_I2C_TPS65910_H
31 #define __LINUX_I2C_TPS65910_H
33 #define TPS65910_NUM_SLAVES 1
34 /* I2C Slave Address 7-bit */
35 #define TPS65910_I2C_ID0 0x2D /* general-purpose */
36 #define TPS65910_I2C_ID1 0x12 /* Smart Reflex */
38 /* TPS65910 to host IRQ */
39 #define TPS65910_HOST_IRQ RK29_PIN4_PD3
41 /* TPS65910 MAX GPIOs */
42 #define TPS65910_GPIO_MAX 1
45 * ----------------------------------------------------------------------------
46 * Registers, all 8 bits
47 * ----------------------------------------------------------------------------
49 #define TPS65910_REG_SECONDS 0x00
50 #define TPS65910_REG_MINUTES 0x01
51 #define TPS65910_REG_HOURS 0x02
52 #define TPS65910_REG_DAYS 0x03
53 #define TPS65910_REG_MONTHS 0x04
54 #define TPS65910_REG_YEARS 0x05
55 #define TPS65910_REG_WEEKS 0x06
56 #define TPS65910_REG_ALARM_SECONDS 0x08
57 #define TPS65910_REG_ALARM_MINUTES 0x09
58 #define TPS65910_REG_ALARM_HOURS 0x0A
59 #define TPS65910_REG_ALARM_DAYS 0x0B
60 #define TPS65910_REG_ALARM_MONTHS 0x0C
61 #define TPS65910_REG_ALARM_YEARS 0x0D
63 #define TPS65910_REG_RTC_CTRL 0x10
64 #define TPS65910_REG_RTC_STATUS 0x11
65 #define TPS65910_REG_RTC_INTERRUPTS 0x12
66 #define TPS65910_REG_RTC_COMP_LSB 0x13
67 #define TPS65910_REG_RTC_COMP_MSB 0x14
68 #define TPS65910_REG_RTC_RES_PROG 0x15
69 #define TPS65910_REG_RTC_RESET_STATUS 0x16
70 #define TPS65910_REG_BCK1 0x17
71 #define TPS65910_REG_BCK2 0x18
72 #define TPS65910_REG_BCK3 0x19
73 #define TPS65910_REG_BCK4 0x1A
74 #define TPS65910_REG_BCK5 0x1B
75 #define TPS65910_REG_PUADEN 0x1C
76 #define TPS65910_REG_REF 0x1D
77 #define TPS65910_REG_VRTC 0x1E
79 #define TPS65910_REG_VIO 0x20
80 #define TPS65910_REG_VDD1 0x21
81 #define TPS65910_REG_VDD1_OP 0x22
82 #define TPS65910_REG_VDD1_SR 0x23
83 #define TPS65910_REG_VDD2 0x24
84 #define TPS65910_REG_VDD2_OP 0x25
85 #define TPS65910_REG_VDD2_SR 0x26
86 #define TPS65910_REG_VDD3 0x27
88 #define TPS65910_REG_VDIG1 0x30
89 #define TPS65910_REG_VDIG2 0x31
90 #define TPS65910_REG_VAUX1 0x32
91 #define TPS65910_REG_VAUX2 0x33
92 #define TPS65910_REG_VAUX33 0x34
93 #define TPS65910_REG_VMMC 0x35
94 #define TPS65910_REG_VPLL 0x36
95 #define TPS65910_REG_VDAC 0x37
96 #define TPS65910_REG_THERM 0x38
97 #define TPS65910_REG_BBCH 0x39
99 #define TPS65910_REG_DCDCCTRL 0x3E
100 #define TPS65910_REG_DEVCTRL 0x3F
101 #define TPS65910_REG_DEVCTRL2 0x40
102 #define TPS65910_REG_SLEEP_KEEP_LDO_ON 0x41
103 #define TPS65910_REG_SLEEP_KEEP_RES_ON 0x42
104 #define TPS65910_REG_SLEEP_SET_LDO_OFF 0x43
105 #define TPS65910_REG_SLEEP_SET_RES_OFF 0x44
106 #define TPS65910_REG_EN1_LDO_ASS 0x45
107 #define TPS65910_REG_EN1_SMPS_ASS 0x46
108 #define TPS65910_REG_EN2_LDO_ASS 0x47
109 #define TPS65910_REG_EN2_SMPS_ASS 0x48
110 #define TPS65910_REG_EN3_LDO_ASS 0x49
111 #define TPS65910_REG_SPARE 0x4A
113 #define TPS65910_REG_INT_STS 0x50
114 #define TPS65910_REG_INT_MSK 0x51
115 #define TPS65910_REG_INT_STS2 0x52
116 #define TPS65910_REG_INT_MSK2 0x53
117 #define TPS65910_REG_INT_STS3 0x54
118 #define TPS65910_REG_INT_MSK3 0x55
120 #define TPS65910_REG_GPIO0 0x60
122 #define TPS65910_REG_JTAGVERNUM 0x80
124 /* TPS65910 GPIO Specific flags */
125 #define TPS65910_GPIO_INT_FALLING 0
126 #define TPS65910_GPIO_INT_RISING 1
128 #define TPS65910_DEBOUNCE_91_5_MS 0
129 #define TPS65910_DEBOUNCE_150_MS 1
131 #define TPS65910_GPIO_PUDIS (1 << 3)
132 #define TPS65910_GPIO_CFG_OUTPUT (1 << 2)
136 /* TPS65910 Interrupt events */
139 #define TPS65910_RTC_ALARM_IT 0x80
140 #define TPS65910_RTC_PERIOD_IT 0x40
143 #define TPS65910_HOT_DIE_IT 0x20
144 #define TPS65910_PWRHOLD_IT 0x10
145 #define TPS65910_PWRON_LP_IT 0x08
146 #define TPS65910_PWRON_IT 0x04
147 #define TPS65910_VMBHI_IT 0x02
148 #define TPS65910_VMBGCH_IT 0x01
151 #define TPS65910_GPIO_F_IT 0x02
152 #define TPS65910_GPIO_R_IT 0x01
155 #define TPS65910_VRTC_OFFMASK (1<<3)
157 /* Back-up battery charger control */
158 #define TPS65910_BBCHEN 0x01
160 /* Back-up battery charger voltage */
161 #define TPS65910_BBSEL_3P0 0x00
162 #define TPS65910_BBSEL_2P52 0x02
163 #define TPS65910_BBSEL_3P15 0x04
164 #define TPS65910_BBSEL_VBAT 0x06
166 /* DEVCTRL_REG flags */
167 #define TPS65910_RTC_PWDNN 0x40
168 #define TPS65910_CK32K_CTRL 0x20
169 #define TPS65910_SR_CTL_I2C_SEL 0x10
170 #define TPS65910_DEV_OFF_RST 0x08
171 #define TPS65910_DEV_ON 0x04
172 #define TPS65910_DEV_SLP 0x02
173 #define TPS65910_DEV_OFF 0x01
175 /* DEVCTRL2_REG flags */
176 #define TPS65910_DEV2_TSLOT_LENGTH 0x30
177 #define TPS65910_DEV2_SLEEPSIG_POL 0x08
178 #define TPS65910_DEV2_PWON_LP_OFF 0x04
179 #define TPS65910_DEV2_PWON_LP_RST 0x02
180 #define TPS65910_DEV2_IT_POL 0x01
182 /* TPS65910 SMPS/LDO's */
183 #define TPS65910_VIO 0
184 #define TPS65910_VDD1 1
185 #define TPS65910_VDD2 2
186 #define TPS65910_VDD3 3
188 #define TPS65910_VDIG1 4
189 #define TPS65910_VDIG2 5
190 #define TPS65910_VAUX33 6
191 #define TPS65910_VMMC 7
192 #define TPS65910_VAUX1 8
193 #define TPS65910_VAUX2 9
194 #define TPS65910_VDAC 10
195 #define TPS65910_VPLL 11
197 #define TPS65910_VRTC 12
199 /* Number of step-down/up converters available */
200 #define TPS65910_NUM_DCDC 4
202 /* Number of LDO voltage regulators available */
203 #define TPS65910_NUM_LDO 9
205 /* Number of total regulators available */
206 #define TPS65910_NUM_REGULATOR (TPS65910_NUM_DCDC + TPS65910_NUM_LDO)
209 /* Regulator Supply state */
210 #define SUPPLY_STATE_FLAG 0x03
212 #define TPS65910_REG_OFF_00 0x00
213 #define TPS65910_REG_OFF_10 0x02
214 /* OHP - on High Power */
215 #define TPS65910_REG_OHP 0x01
216 /* OLP - on Low Power */
217 #define TPS65910_REG_OLP 0x03
219 #define TPS65910_MAX_IRQS 10
220 #define TPS65910_VMBDCH_IRQ 0
221 #define TPS65910_VMBHI_IRQ 1
222 #define TPS65910_PWRON_IRQ 2
223 #define TPS65910_PWRON_LP_IRQ 3
224 #define TPS65910_PWRHOLD_IRQ 4
225 #define TPS65910_HOTDIE_IRQ 5
226 #define TPS65910_RTC_ALARM_IRQ 6
227 #define TPS65910_RTC_PERIOD_IRQ 7
228 #define TPS65910_GPIO0_R_IRQ 8
229 #define TPS65910_GPIO0_F_IRQ 9
231 /* TPS65910 has 1 GPIO */
232 struct tps65910_gpio {
235 u8 gpio_config; /* Input or output */
236 u8 gpio_val; /* Output value */
237 int (*gpio_setup)(struct tps65910_gpio *pdata);
238 int (*gpio_taredown)(struct tps65910_gpio *pdata);
241 struct tps65910_platform_data {
243 unsigned irq_num; /* TPS65910 to Host IRQ Number */
244 struct tps65910_gpio *gpio;
246 /* plaform specific data to be initialised in board file */
247 struct regulator_init_data *vio;
248 struct regulator_init_data *vdd1;
249 struct regulator_init_data *vdd2;
250 struct regulator_init_data *vdd3;
251 struct regulator_init_data *vdig1;
252 struct regulator_init_data *vdig2;
253 struct regulator_init_data *vaux33;
254 struct regulator_init_data *vmmc;
255 struct regulator_init_data *vaux1;
256 struct regulator_init_data *vaux2;
257 struct regulator_init_data *vdac;
258 struct regulator_init_data *vpll;
260 void (*handlers[TPS65910_MAX_IRQS]) (void *data);
261 /* Configure TP65910 to board specific usage*/
262 int (*board_tps65910_config)(struct tps65910_platform_data *pdata);
265 int tps65910_enable_bbch(u8 voltage);
266 int tps65910_disable_bbch(void);
268 int tps65910_remove_irq_work(int irq);
269 int tps65910_add_irq_work(int irq, void (*handler)(void *data));
271 int tps65910_i2c_write_u8(u8 slave_addr, u8 val, u8 reg);
272 int tps65910_i2c_read_u8(u8 slave_addr, u8 *val, u8 reg);
274 #endif /* __LINUX_I2C_TPS65910_H */