]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/linux/i2c/twl4030.h
twl4030-gpio: pullup/pulldown init
[linux-2.6-omap-h63xx.git] / include / linux / i2c / twl4030.h
1 /*
2  * twl4030.h - header for TWL4030 PM and audio CODEC device
3  *
4  * Copyright (C) 2005-2006 Texas Instruments, Inc.
5  *
6  * Based on tlv320aic23.c:
7  * Copyright (c) by Kai Svahn <kai.svahn@nokia.com>
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  */
24
25 #ifndef __TWL4030_H_
26 #define __TWL4030_H_
27
28 /* USB ID */
29 #define TWL4030_MODULE_USB              0x00
30 /* AUD ID */
31 #define TWL4030_MODULE_AUDIO_VOICE      0x01
32 #define TWL4030_MODULE_GPIO             0x02
33 #define TWL4030_MODULE_INTBR            0x03
34 #define TWL4030_MODULE_PIH              0x04
35 #define TWL4030_MODULE_TEST             0x05
36 /* AUX ID */
37 #define TWL4030_MODULE_KEYPAD           0x06
38 #define TWL4030_MODULE_MADC             0x07
39 #define TWL4030_MODULE_INTERRUPTS       0x08
40 #define TWL4030_MODULE_LED              0x09
41 #define TWL4030_MODULE_MAIN_CHARGE      0x0A
42 #define TWL4030_MODULE_PRECHARGE        0x0B
43 #define TWL4030_MODULE_PWM0             0x0C
44 #define TWL4030_MODULE_PWM1             0x0D
45 #define TWL4030_MODULE_PWMA             0x0E
46 #define TWL4030_MODULE_PWMB             0x0F
47 /* POWER ID */
48 #define TWL4030_MODULE_BACKUP           0x10
49 #define TWL4030_MODULE_INT              0x11
50 #define TWL4030_MODULE_PM_MASTER        0x12
51 #define TWL4030_MODULE_PM_RECEIVER      0x13
52 #define TWL4030_MODULE_RTC              0x14
53 #define TWL4030_MODULE_SECURED_REG      0x15
54
55 struct twl4030_bci_platform_data {
56         int *battery_tmp_tbl;
57         unsigned int tblsize;
58 };
59
60 /* TWL4030_GPIO_MAX (18) GPIOs, with interrupts */
61 struct twl4030_gpio_platform_data {
62         int             gpio_base;
63         unsigned        irq_base, irq_end;
64
65         /* For gpio-N, bit (1 << N) in "pullups" is set if that pullup
66          * should be enabled.  Else, if that bit is set in "pulldowns",
67          * that pulldown is enabled.  Don't waste power by letting any
68          * digital inputs float...
69          */
70         u32             pullups;
71         u32             pulldowns;
72
73         int             (*setup)(struct device *dev,
74                                 unsigned gpio, unsigned ngpio);
75         int             (*teardown)(struct device *dev,
76                                 unsigned gpio, unsigned ngpio);
77 };
78
79 struct twl4030_madc_platform_data {
80         int             irq_line;
81 };
82
83 struct twl4030_keypad_data {
84         int rows;
85         int cols;
86         int *keymap;
87         int irq;
88         unsigned int keymapsize;
89         unsigned int rep:1;
90 };
91
92 enum twl4030_usb_mode {
93         T2_USB_MODE_ULPI = 1,
94         T2_USB_MODE_CEA2011_3PIN = 2,
95 };
96
97 struct twl4030_usb_data {
98         enum twl4030_usb_mode   usb_mode;
99 };
100
101 struct twl4030_platform_data {
102         unsigned                                irq_base, irq_end;
103         struct twl4030_bci_platform_data        *bci;
104         struct twl4030_gpio_platform_data       *gpio;
105         struct twl4030_madc_platform_data       *madc;
106         struct twl4030_keypad_data              *keypad;
107         struct twl4030_usb_data                 *usb;
108
109         /* REVISIT more to come ... _nothing_ should be hard-wired */
110 };
111
112 /*
113  * FIXME completely stop using TWL4030_IRQ_BASE ... instead, pass the
114  * IRQ data to subsidiary devices using platform device resources.
115  */
116
117 /* IRQ information-need base */
118 #include <mach/irqs.h>
119 /* TWL4030 interrupts */
120
121 /* #define TWL4030_MODIRQ_GPIO          (TWL4030_IRQ_BASE + 0) */
122 #define TWL4030_MODIRQ_KEYPAD           (TWL4030_IRQ_BASE + 1)
123 #define TWL4030_MODIRQ_BCI              (TWL4030_IRQ_BASE + 2)
124 #define TWL4030_MODIRQ_MADC             (TWL4030_IRQ_BASE + 3)
125 /* #define TWL4030_MODIRQ_USB           (TWL4030_IRQ_BASE + 4) */
126 #define TWL4030_MODIRQ_PWR              (TWL4030_IRQ_BASE + 5)
127
128 #define TWL4030_PWRIRQ_PWRBTN           (TWL4030_PWR_IRQ_BASE + 0)
129 #define TWL4030_PWRIRQ_CHG_PRES         (TWL4030_PWR_IRQ_BASE + 1)
130 #define TWL4030_PWRIRQ_USB_PRES         (TWL4030_PWR_IRQ_BASE + 2)
131 #define TWL4030_PWRIRQ_RTC              (TWL4030_PWR_IRQ_BASE + 3)
132 #define TWL4030_PWRIRQ_HOT_DIE          (TWL4030_PWR_IRQ_BASE + 4)
133 #define TWL4030_PWRIRQ_PWROK_TIMEOUT    (TWL4030_PWR_IRQ_BASE + 5)
134 #define TWL4030_PWRIRQ_MBCHG            (TWL4030_PWR_IRQ_BASE + 6)
135 #define TWL4030_PWRIRQ_SC_DETECT        (TWL4030_PWR_IRQ_BASE + 7)
136
137 /* Rest are unsued currently*/
138
139 /* Offsets to Power Registers */
140 #define TWL4030_VDAC_DEV_GRP            0x3B
141 #define TWL4030_VDAC_DEDICATED          0x3E
142 #define TWL4030_VAUX1_DEV_GRP           0x17
143 #define TWL4030_VAUX1_DEDICATED         0x1A
144 #define TWL4030_VAUX2_DEV_GRP           0x1B
145 #define TWL4030_VAUX2_DEDICATED         0x1E
146 #define TWL4030_VAUX3_DEV_GRP           0x1F
147 #define TWL4030_VAUX3_DEDICATED         0x22
148
149 /* TWL4030 GPIO interrupt definitions */
150
151 #define TWL4030_GPIO_MAX                18
152 #define TWL4030_GPIO_IRQ_NO(n)          (TWL4030_GPIO_IRQ_BASE + (n))
153 #define TWL4030_GPIO_IS_ENABLE          1
154 #define TWL4030_GPIO_PULL_UP            0
155 #define TWL4030_GPIO_PULL_DOWN          1
156
157 /* Functions to read and write from TWL4030 */
158
159 /*
160  * IMP NOTE:
161  * The base address of the module will be added by the triton driver
162  * It is the caller's responsibility to ensure sane values
163  */
164 int twl4030_i2c_write_u8(u8 mod_no, u8 val, u8 reg);
165 int twl4030_i2c_read_u8(u8 mod_no, u8 *val, u8 reg);
166
167  /*
168   * i2c_write: IMPORTANT - Allocate value num_bytes+1 and valid data starts at
169   *             Offset 1.
170   */
171 int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, u8 num_bytes);
172 int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, u8 num_bytes);
173
174 /*
175  * Exported TWL4030 GPIO APIs
176  *
177  * WARNING -- use standard GPIO and IRQ calls instead; these will vanish.
178  */
179 int twl4030_get_gpio_datain(int gpio);
180 int twl4030_request_gpio(int gpio);
181 int twl4030_set_gpio_debounce(int gpio, int enable);
182 int twl4030_free_gpio(int gpio);
183
184 #if defined(CONFIG_TWL4030_BCI_BATTERY) || \
185         defined(CONFIG_TWL4030_BCI_BATTERY_MODULE)
186         extern int twl4030charger_usb_en(int enable);
187 #else
188         static inline int twl4030charger_usb_en(int enable) { return 0; }
189 #endif
190
191 #endif /* End of __TWL4030_H */