f6435611580b39f3ae5851cd12294dec3ef9524a
[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 #define tps80031_rails(_name) "tps80031_"#_name
36
37 enum {
38         TPS80031_ID_VIO,
39         TPS80031_ID_SMPS1,
40         TPS80031_ID_SMPS2,
41         TPS80031_ID_SMPS3,
42         TPS80031_ID_SMPS4,
43         TPS80031_ID_VANA,
44         TPS80031_ID_LDO1,
45         TPS80031_ID_LDO2,
46         TPS80031_ID_LDO3,
47         TPS80031_ID_LDO4,
48         TPS80031_ID_LDO5,
49         TPS80031_ID_LDO6,
50         TPS80031_ID_LDO7,
51         TPS80031_ID_LDOLN,
52         TPS80031_ID_LDOUSB,
53         TPS80031_ID_VBUS,
54 };
55
56 enum {
57         TPS80031_INT_PWRON,
58         TPS80031_INT_RPWRON,
59         TPS80031_INT_SYS_VLOW,
60         TPS80031_INT_RTC_ALARM,
61         TPS80031_INT_RTC_PERIOD,
62         TPS80031_INT_HOT_DIE,
63         TPS80031_INT_VXX_SHORT,
64         TPS80031_INT_SPDURATION,
65         TPS80031_INT_WATCHDOG,
66         TPS80031_INT_BAT,
67         TPS80031_INT_SIM,
68         TPS80031_INT_MMC,
69         TPS80031_INT_RES,
70         TPS80031_INT_GPADC_RT,
71         TPS80031_INT_GPADC_SW2_EOC,
72         TPS80031_INT_CC_AUTOCAL,
73         TPS80031_INT_ID_WKUP,
74         TPS80031_INT_VBUSS_WKUP,
75         TPS80031_INT_ID,
76         TPS80031_INT_VBUS,
77         TPS80031_INT_CHRG_CTRL,
78         TPS80031_INT_EXT_CHRG,
79         TPS80031_INT_INT_CHRG,
80         TPS80031_INT_RES2,
81         TPS80031_INT_BAT_TEMP_OVRANGE,
82         TPS80031_INT_BAT_REMOVED,
83         TPS80031_INT_VBUS_DET,
84         TPS80031_INT_VAC_DET,
85         TPS80031_INT_FAULT_WDG,
86         TPS80031_INT_LINCH_GATED,
87
88         /* Last interrupt id to get the end number */
89         TPS80031_INT_END,
90 };
91
92 enum {
93         SLAVE_ID0 = 0,
94         SLAVE_ID1 = 1,
95         SLAVE_ID2 = 2,
96         SLAVE_ID3 = 3,
97 };
98
99 enum {
100         I2C_ID0_ADDR = 0x12,
101         I2C_ID1_ADDR = 0x48,
102         I2C_ID2_ADDR = 0x49,
103         I2C_ID3_ADDR = 0x4A,
104 };
105
106 struct tps80031_subdev_info {
107         int             id;
108         const char      *name;
109         void            *platform_data;
110 };
111
112 struct tps80031_rtc_platform_data {
113         int irq;
114         struct rtc_time time;
115 };
116
117 struct tps80031_32kclock_plat_data {
118         unsigned en_clk32kao:1;
119         unsigned en_clk32kg:1;
120         unsigned en_clk32kaudio:1;
121 };
122
123 struct tps80031_platform_data {
124         int num_subdevs;
125         struct tps80031_subdev_info *subdevs;
126         int gpio_base;
127         int irq_base;
128         struct tps80031_32kclock_plat_data *clk32k_pdata;
129 };
130
131 /*
132  * NOTE: the functions below are not intended for use outside
133  * of the TPS80031 sub-device drivers
134  */
135 extern int tps80031_write(struct device *dev, int sid, int reg, uint8_t val);
136 extern int tps80031_writes(struct device *dev, int sid, int reg, int len,
137                                 uint8_t *val);
138 extern int tps80031_read(struct device *dev, int sid, int reg, uint8_t *val);
139 extern int tps80031_reads(struct device *dev, int sid, int reg, int len,
140                                 uint8_t *val);
141 extern int tps80031_set_bits(struct device *dev, int sid, int reg,
142                                 uint8_t bit_mask);
143 extern int tps80031_clr_bits(struct device *dev, int sid, int reg,
144                                 uint8_t bit_mask);
145 extern int tps80031_update(struct device *dev, int sid, int reg, uint8_t val,
146                            uint8_t mask);
147 extern int tps80031_force_update(struct device *dev, int sid, int reg,
148                                  uint8_t val, uint8_t mask);
149 extern int tps80031_power_off(void);
150
151 extern unsigned long tps80031_get_chip_info(struct device *dev);
152
153 #endif /*__LINUX_MFD_TPS80031_H */