]> git.ipfire.org Git - people/ms/u-boot.git/blame - include/twl6030.h
NAND: Fix integer overflow in ONFI detection of chips >= 4GiB
[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
B
35/* Slave Address 0x48 */
36#define VUSB_CFG_STATE 0xA2
37
38#define MISC1 0xE4
39#define VAC_MEAS (1 << 2)
40#define VBAT_MEAS (1 << 1)
41#define BB_MEAS (1 << 0)
42
43#define MISC2 0xE5
44
45/* Slave Address 0x49 */
46
516799f6
SS
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
64
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
3e664f6d
B
91/* CHARGERUSB_CTRL1 */
92#define SUSPEND_BOOT (1 << 7)
93#define OPA_MODE (1 << 6)
94#define HZ_MODE (1 << 5)
95#define TERM (1 << 4)
516799f6
SS
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)
3e664f6d 100#define CHARGERUSB_CTRL2_VITERM_400 (7 << 5)
516799f6
SS
101/* CONTROLLER_CTRL1 */
102#define CONTROLLER_CTRL1_EN_CHARGER (1 << 4)
103#define CONTROLLER_CTRL1_SEL_CHARGER (1 << 3)
3e664f6d
B
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)
516799f6 109
3e664f6d
B
110#define FG_REG_10 0xCA
111#define FG_REG_11 0xCB
112
113#define TOGGLE1 0x90
114#define FGS (1 << 5)
115#define FGR (1 << 4)
116#define GPADCS (1 << 1)
117#define GPADCR (1 << 0)
118
119#define CTRL_P2 0x34
120#define CTRL_P2_SP2 (1 << 2)
121#define CTRL_P2_EOCP2 (1 << 1)
122#define CTRL_P2_BUSY (1 << 0)
123
124#define GPCH0_LSB 0x57
125#define GPCH0_MSB 0x58
516799f6
SS
126
127void twl6030_init_battery_charging(void);
128void twl6030_usb_device_settings(void);
3e664f6d
B
129void twl6030_start_usb_charging(void);
130void twl6030_stop_usb_charging(void);
131int twl6030_get_battery_voltage(void);
132int twl6030_get_battery_current(void);