2452282c3c772e19b3ede1090d9f7865ff7b929c
[pandora-kernel.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 /* IRQ information-need base */
56 #include <asm/arch/irqs.h>
57 /* TWL4030 interrupts */
58
59 #define TWL4030_MODIRQ_GPIO             (IH_TWL4030_BASE + 0)
60 #define TWL4030_MODIRQ_KEYPAD           (IH_TWL4030_BASE + 1)
61 #define TWL4030_MODIRQ_BCI              (IH_TWL4030_BASE + 2)
62 #define TWL4030_MODIRQ_MADC             (IH_TWL4030_BASE + 3)
63 #define TWL4030_MODIRQ_USB              (IH_TWL4030_BASE + 4)
64 #define TWL4030_MODIRQ_PWR              (IH_TWL4030_BASE + 5)
65
66 #define TWL4030_PWRIRQ_PWRBTN           (IH_TWL4030_PWRBASE + 0)
67 #define TWL4030_PWRIRQ_CHG_PRES         (IH_TWL4030_PWRBASE + 1)
68 #define TWL4030_PWRIRQ_USB_PRES         (IH_TWL4030_PWRBASE + 2)
69 #define TWL4030_PWRIRQ_RTC              (IH_TWL4030_PWRBASE + 3)
70 #define TWL4030_PWRIRQ_HOT_DIE          (IH_TWL4030_PWRBASE + 4)
71 #define TWL4030_PWRIRQ_PWROK_TIMEOUT    (IH_TWL4030_PWRBASE + 5)
72 #define TWL4030_PWRIRQ_MBCHG            (IH_TWL4030_PWRBASE + 6)
73 #define TWL4030_PWRIRQ_SC_DETECT        (IH_TWL4030_PWRBASE + 7)
74
75 /* Rest are unsued currently*/
76
77 /* Offsets to Power Registers */
78 #define TWL4030_VDAC_DEV_GRP            0x3B
79 #define TWL4030_VDAC_DEDICATED          0x3E
80 #define TWL4030_VAUX2_DEV_GRP           0x1B
81 #define TWL4030_VAUX2_DEDICATED         0x1E
82 #define TWL4030_VAUX3_DEV_GRP           0x1F
83 #define TWL4030_VAUX3_DEDICATED         0x22
84
85 /* TWL4030 GPIO interrupt definitions */
86
87 #define TWL4030_GPIO_MIN                0
88 #define TWL4030_GPIO_MAX                18
89 #define TWL4030_GPIO_MAX_CD             2
90 #define TWL4030_GPIO_IRQ_NO(n)          (IH_TWL4030_GPIO_BASE+n)
91 #define TWL4030_GPIO_IS_INPUT           1
92 #define TWL4030_GPIO_IS_OUTPUT          0
93 #define TWL4030_GPIO_IS_ENABLE          1
94 #define TWL4030_GPIO_IS_DISABLE         0
95 #define TWL4030_GPIO_PULL_UP            0
96 #define TWL4030_GPIO_PULL_DOWN          1
97 #define TWL4030_GPIO_PULL_NONE          2
98 #define TWL4030_GPIO_EDGE_NONE          0
99 #define TWL4030_GPIO_EDGE_RISING        1
100 #define TWL4030_GPIO_EDGE_FALLING       2
101
102 /* Functions to read and write from TWL4030 */
103
104 /*
105  * IMP NOTE:
106  * The base address of the module will be added by the triton driver
107  * It is the caller's responsibility to ensure sane values
108  */
109 int twl4030_i2c_write_u8(u8 mod_no, u8 val, u8 reg);
110 int twl4030_i2c_read_u8(u8 mod_no, u8 *val, u8 reg);
111
112  /*
113   * i2c_write: IMPORTANT - Allocate value num_bytes+1 and valid data starts at
114   *             Offset 1.
115   */
116 int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, u8 num_bytes);
117 int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, u8 num_bytes);
118
119 /*
120  * Exported TWL4030 GPIO APIs
121  */
122 int twl4030_get_gpio_datain(int gpio);
123 int twl4030_request_gpio(int gpio);
124 int twl4030_set_gpio_edge_ctrl(int gpio, int edge);
125 int twl4030_set_gpio_debounce(int gpio, int enable);
126 int twl4030_free_gpio(int gpio);
127
128 #endif /* End of __TWL4030_H */