3 * Texas Instruments, <www.ti.com>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 /* I2C chip addresses */
28 #define TWL6030_CHIP_PM 0x48
30 #define TWL6030_CHIP_USB 0x49
31 #define TWL6030_CHIP_ADC 0x49
32 #define TWL6030_CHIP_CHARGER 0x49
33 #define TWL6030_CHIP_PWM 0x49
35 /* Slave Address 0x48 */
36 #define VUSB_CFG_STATE 0xA2
39 #define VAC_MEAS (1 << 2)
40 #define VBAT_MEAS (1 << 1)
41 #define BB_MEAS (1 << 0)
45 /* Slave Address 0x49 */
47 /* Battery CHARGER REGISTERS */
48 #define CONTROLLER_INT_MASK 0xE0
49 #define CONTROLLER_CTRL1 0xE1
50 #define CONTROLLER_WDG 0xE2
51 #define CONTROLLER_STAT1 0xE3
52 #define CHARGERUSB_INT_STATUS 0xE4
53 #define CHARGERUSB_INT_MASK 0xE5
54 #define CHARGERUSB_STATUS_INT1 0xE6
55 #define CHARGERUSB_STATUS_INT2 0xE7
56 #define CHARGERUSB_CTRL1 0xE8
57 #define CHARGERUSB_CTRL2 0xE9
58 #define CHARGERUSB_CTRL3 0xEA
59 #define CHARGERUSB_STAT1 0xEB
60 #define CHARGERUSB_VOREG 0xEC
61 #define CHARGERUSB_VICHRG 0xED
62 #define CHARGERUSB_CINLIMIT 0xEE
63 #define CHARGERUSB_CTRLLIMIT1 0xEF
65 /* CHARGERUSB_VICHRG */
66 #define CHARGERUSB_VICHRG_500 0x4
67 #define CHARGERUSB_VICHRG_1500 0xE
68 /* CHARGERUSB_CINLIMIT */
69 #define CHARGERUSB_CIN_LIMIT_100 0x1
70 #define CHARGERUSB_CIN_LIMIT_300 0x5
71 #define CHARGERUSB_CIN_LIMIT_500 0x9
72 #define CHARGERUSB_CIN_LIMIT_NONE 0xF
73 /* CONTROLLER_INT_MASK */
74 #define MVAC_FAULT (1 << 6)
75 #define MAC_EOC (1 << 5)
76 #define MBAT_REMOVED (1 << 4)
77 #define MFAULT_WDG (1 << 3)
78 #define MBAT_TEMP (1 << 2)
79 #define MVBUS_DET (1 << 1)
80 #define MVAC_DET (1 << 0)
81 /* CHARGERUSB_INT_MASK */
82 #define MASK_MCURRENT_TERM (1 << 3)
83 #define MASK_MCHARGERUSB_STAT (1 << 2)
84 #define MASK_MCHARGERUSB_THMREG (1 << 1)
85 #define MASK_MCHARGERUSB_FAULT (1 << 0)
86 /* CHARGERUSB_VOREG */
87 #define CHARGERUSB_VOREG_3P52 0x01
88 #define CHARGERUSB_VOREG_4P0 0x19
89 #define CHARGERUSB_VOREG_4P2 0x23
90 #define CHARGERUSB_VOREG_4P76 0x3F
91 /* CHARGERUSB_CTRL1 */
92 #define SUSPEND_BOOT (1 << 7)
93 #define OPA_MODE (1 << 6)
94 #define HZ_MODE (1 << 5)
96 /* CHARGERUSB_CTRL2 */
97 #define CHARGERUSB_CTRL2_VITERM_50 (0 << 5)
98 #define CHARGERUSB_CTRL2_VITERM_100 (1 << 5)
99 #define CHARGERUSB_CTRL2_VITERM_150 (2 << 5)
100 #define CHARGERUSB_CTRL2_VITERM_400 (7 << 5)
101 /* CONTROLLER_CTRL1 */
102 #define CONTROLLER_CTRL1_EN_CHARGER (1 << 4)
103 #define CONTROLLER_CTRL1_SEL_CHARGER (1 << 3)
104 /* CONTROLLER_STAT1 */
105 #define CHRG_EXTCHRG_STATZ (1 << 7)
106 #define CHRG_DET_N (1 << 5)
107 #define VAC_DET (1 << 3)
108 #define VBUS_DET (1 << 2)
110 #define FG_REG_10 0xCA
111 #define FG_REG_11 0xCB
116 #define GPADCS (1 << 1)
117 #define GPADCR (1 << 0)
120 #define CTRL_P2_SP2 (1 << 2)
121 #define CTRL_P2_EOCP2 (1 << 1)
122 #define CTRL_P2_BUSY (1 << 0)
124 #define GPCH0_LSB 0x57
125 #define GPCH0_MSB 0x58
127 void twl6030_init_battery_charging(void);
128 void twl6030_usb_device_settings(void);
129 void twl6030_start_usb_charging(void);
130 void twl6030_stop_usb_charging(void);
131 int twl6030_get_battery_voltage(void);
132 int twl6030_get_battery_current(void);