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,
24 #ifdef CONFIG_TWL6030_POWER
28 /* Functions to read and write from TWL6030 */
29 static inline int twl6030_i2c_write_u8(u8 chip_no, u8 val, u8 reg)
31 return i2c_write(chip_no, reg, 1, &val, 1);
34 static inline int twl6030_i2c_read_u8(u8 chip_no, u8 *val, u8 reg)
36 return i2c_read(chip_no, reg, 1, val, 1);
39 void twl6030_start_usb_charging(void)
41 twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, CHARGERUSB_VICHRG_1500,
43 twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, CHARGERUSB_CIN_LIMIT_NONE,
45 twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, MBAT_TEMP,
47 twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, MASK_MCHARGERUSB_THMREG,
49 twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, CHARGERUSB_VOREG_4P0,
51 twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, CHARGERUSB_CTRL2_VITERM_100,
53 /* Enable USB charging */
54 twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, CONTROLLER_CTRL1_EN_CHARGER,
59 void twl6030_init_battery_charging(void)
61 twl6030_start_usb_charging();
65 void twl6030_usb_device_settings()
69 /* Select APP Group and set state to ON */
70 twl6030_i2c_write_u8(TWL6030_CHIP_PM, 0x21, VUSB_CFG_STATE);
72 twl6030_i2c_read_u8(TWL6030_CHIP_PM, &data, MISC2);
75 /* Select the input supply for VBUS regulator */
76 twl6030_i2c_write_u8(TWL6030_CHIP_PM, data, MISC2);