]> git.ipfire.org Git - people/ms/u-boot.git/blame - include/twl6030.h
Merge branch 'hs@denx.de' of git://git.denx.de/u-boot-staging
[people/ms/u-boot.git] / include / twl6030.h
CommitLineData
516799f6
SS
1/*
2 * (C) Copyright 2010
3 * Texas Instruments, <www.ti.com>
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
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.
12 *
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.
17 *
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,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <i2c.h>
26
27/* I2C chip addresses */
28#define TWL6030_CHIP_PM 0x48
29
30#define TWL6030_CHIP_USB 0x49
31#define TWL6030_CHIP_ADC 0x49
32#define TWL6030_CHIP_CHARGER 0x49
33#define TWL6030_CHIP_PWM 0x49
34
3e664f6d 35/* Slave Address 0x48 */
14fa2dd0
B
36#define VMMC_CFG_STATE 0x9A
37#define VMMC_CFG_VOLTATE 0x9B
3e664f6d
B
38#define VUSB_CFG_STATE 0xA2
39
40#define MISC1 0xE4
41#define VAC_MEAS (1 << 2)
42#define VBAT_MEAS (1 << 1)
43#define BB_MEAS (1 << 0)
44
45#define MISC2 0xE5
46
47/* Slave Address 0x49 */
48
516799f6
SS
49/* Battery CHARGER REGISTERS */
50#define CONTROLLER_INT_MASK 0xE0
51#define CONTROLLER_CTRL1 0xE1
52#define CONTROLLER_WDG 0xE2
53#define CONTROLLER_STAT1 0xE3
54#define CHARGERUSB_INT_STATUS 0xE4
55#define CHARGERUSB_INT_MASK 0xE5
56#define CHARGERUSB_STATUS_INT1 0xE6
57#define CHARGERUSB_STATUS_INT2 0xE7
58#define CHARGERUSB_CTRL1 0xE8
59#define CHARGERUSB_CTRL2 0xE9
60#define CHARGERUSB_CTRL3 0xEA
61#define CHARGERUSB_STAT1 0xEB
62#define CHARGERUSB_VOREG 0xEC
63#define CHARGERUSB_VICHRG 0xED
64#define CHARGERUSB_CINLIMIT 0xEE
65#define CHARGERUSB_CTRLLIMIT1 0xEF
66
67/* CHARGERUSB_VICHRG */
68#define CHARGERUSB_VICHRG_500 0x4
69#define CHARGERUSB_VICHRG_1500 0xE
70/* CHARGERUSB_CINLIMIT */
71#define CHARGERUSB_CIN_LIMIT_100 0x1
72#define CHARGERUSB_CIN_LIMIT_300 0x5
73#define CHARGERUSB_CIN_LIMIT_500 0x9
74#define CHARGERUSB_CIN_LIMIT_NONE 0xF
75/* CONTROLLER_INT_MASK */
76#define MVAC_FAULT (1 << 6)
77#define MAC_EOC (1 << 5)
78#define MBAT_REMOVED (1 << 4)
79#define MFAULT_WDG (1 << 3)
80#define MBAT_TEMP (1 << 2)
81#define MVBUS_DET (1 << 1)
82#define MVAC_DET (1 << 0)
83/* CHARGERUSB_INT_MASK */
84#define MASK_MCURRENT_TERM (1 << 3)
85#define MASK_MCHARGERUSB_STAT (1 << 2)
86#define MASK_MCHARGERUSB_THMREG (1 << 1)
87#define MASK_MCHARGERUSB_FAULT (1 << 0)
88/* CHARGERUSB_VOREG */
89#define CHARGERUSB_VOREG_3P52 0x01
90#define CHARGERUSB_VOREG_4P0 0x19
91#define CHARGERUSB_VOREG_4P2 0x23
92#define CHARGERUSB_VOREG_4P76 0x3F
3e664f6d
B
93/* CHARGERUSB_CTRL1 */
94#define SUSPEND_BOOT (1 << 7)
95#define OPA_MODE (1 << 6)
96#define HZ_MODE (1 << 5)
97#define TERM (1 << 4)
516799f6
SS
98/* CHARGERUSB_CTRL2 */
99#define CHARGERUSB_CTRL2_VITERM_50 (0 << 5)
100#define CHARGERUSB_CTRL2_VITERM_100 (1 << 5)
101#define CHARGERUSB_CTRL2_VITERM_150 (2 << 5)
3e664f6d 102#define CHARGERUSB_CTRL2_VITERM_400 (7 << 5)
516799f6
SS
103/* CONTROLLER_CTRL1 */
104#define CONTROLLER_CTRL1_EN_CHARGER (1 << 4)
105#define CONTROLLER_CTRL1_SEL_CHARGER (1 << 3)
3e664f6d
B
106/* CONTROLLER_STAT1 */
107#define CHRG_EXTCHRG_STATZ (1 << 7)
108#define CHRG_DET_N (1 << 5)
109#define VAC_DET (1 << 3)
110#define VBUS_DET (1 << 2)
516799f6 111
3e664f6d
B
112#define FG_REG_10 0xCA
113#define FG_REG_11 0xCB
114
115#define TOGGLE1 0x90
116#define FGS (1 << 5)
117#define FGR (1 << 4)
118#define GPADCS (1 << 1)
119#define GPADCR (1 << 0)
120
121#define CTRL_P2 0x34
122#define CTRL_P2_SP2 (1 << 2)
123#define CTRL_P2_EOCP2 (1 << 1)
124#define CTRL_P2_BUSY (1 << 0)
125
126#define GPCH0_LSB 0x57
127#define GPCH0_MSB 0x58
516799f6
SS
128
129void twl6030_init_battery_charging(void);
130void twl6030_usb_device_settings(void);
3e664f6d
B
131void twl6030_start_usb_charging(void);
132void twl6030_stop_usb_charging(void);
133int twl6030_get_battery_voltage(void);
134int twl6030_get_battery_current(void);
14fa2dd0 135void twl6030_power_mmc_init(void);