xref: /openbmc/u-boot/include/palmas.h (revision f9727161)
1 /*
2  * (C) Copyright 2012-2013
3  * Texas Instruments, <www.ti.com>
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 #ifndef PALMAS_H
8 #define PALMAS_H
9 
10 #include <common.h>
11 #include <i2c.h>
12 
13 /* I2C chip addresses, TW6035/37 */
14 #define TWL603X_CHIP_P1		0x48	/* Page 1 */
15 #define TWL603X_CHIP_P2		0x49	/* Page 2 */
16 #define TWL603X_CHIP_P3		0x4a	/* Page 3 */
17 
18 /* TPS659038/39 */
19 #define TPS65903X_CHIP_P1	0x58	/* Page 1 */
20 
21 /* Page 1 registers (0x1XY translates to page 1, reg addr 0xXY): */
22 
23 /* LDO1 control/voltage */
24 #define LDO1_CTRL		0x50
25 #define LDO1_VOLTAGE		0x51
26 
27 /* LDO9 control/voltage */
28 #define LDO9_CTRL		0x60
29 #define LDO9_VOLTAGE		0x61
30 
31 /* LDOUSB control/voltage */
32 #define LDOUSB_CTRL		0x64
33 #define LDOUSB_VOLTAGE		0x65
34 
35 /* Control of 32 kHz audio clock */
36 #define CLK32KGAUDIO_CTRL	0xd5
37 
38 /* SYSEN2_CTRL for VCC_3v3_AUX supply on the sEVM */
39 #define SYSEN2_CTRL		0xd9
40 
41 /*
42  * Bit field definitions for LDOx_CTRL, SYSENx_CTRL
43  * and some other xxx_CTRL resources:
44  */
45 #define LDO9_BYP_EN		(1 << 6)	/* LDO9 only! */
46 #define RSC_STAT_ON		(1 << 4)	/* RO status bit! */
47 #define RSC_MODE_SLEEP		(1 << 2)
48 #define RSC_MODE_ACTIVE		(1 << 0)
49 
50 /* Some LDO voltage values */
51 #define LDO_VOLT_OFF		0
52 #define LDO_VOLT_1V8		0x13
53 #define LDO_VOLT_3V0		0x2b
54 #define LDO_VOLT_3V3		0x31
55 /* Request bypass, LDO9 only */
56 #define LDO9_BYPASS		0x3f
57 
58 /* SMPS7_CTRL */
59 #define SMPS7_CTRL		0x30
60 
61 /* SMPS9_CTRL */
62 #define SMPS9_CTRL		0x38
63 #define SMPS9_VOLTAGE		0x3b
64 
65 /* Bit field definitions for SMPSx_CTRL */
66 #define SMPS_MODE_ACT_AUTO	1
67 #define SMPS_MODE_ACT_ECO	2
68 #define SMPS_MODE_ACT_FPWM	3
69 #define SMPS_MODE_SLP_AUTO	(1 << 2)
70 #define SMPS_MODE_SLP_ECO	(2 << 2)
71 #define SMPS_MODE_SLP_FPWM	(3 << 2)
72 
73 /*
74  * Some popular SMPS voltages, all with RANGE=1; note
75  * that RANGE cannot be changed on the fly
76  */
77 #define SMPS_VOLT_OFF		0
78 #define SMPS_VOLT_1V2		0x90
79 #define SMPS_VOLT_1V8		0xae
80 #define SMPS_VOLT_2V1		0xbd
81 #define SMPS_VOLT_3V0		0xea
82 #define SMPS_VOLT_3V3		0xf9
83 
84 /* Backup Battery & VRTC Control */
85 #define BB_VRTC_CTRL		0xa8
86 /* Bit definitions for BB_VRTC_CTRL */
87 #define VRTC_EN_SLP		(1 << 6)
88 #define VRTC_EN_OFF		(1 << 5)
89 #define VRTC_PWEN		(1 << 4)
90 #define BB_LOW_ICHRG		(1 << 3)
91 #define BB_HIGH_ICHRG		(0 << 3)
92 #define BB_VSEL_3V0		(0 << 1)
93 #define BB_VSEL_2V5		(1 << 1)
94 #define BB_VSEL_3V15		(2 << 1)
95 #define BB_VSEL_VBAT		(3 << 1)
96 #define BB_CHRG_EN		(1 << 0)
97 
98 /*
99  * Functions to read and write from TPS659038/TWL6035/TWL6037
100  * or other Palmas family of TI PMICs
101  */
102 static inline int palmas_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
103 {
104 	return i2c_write(chip_no, reg, 1, &val, 1);
105 }
106 
107 static inline int palmas_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
108 {
109 	return i2c_read(chip_no, reg, 1, val, 1);
110 }
111 
112 void palmas_init_settings(void);
113 int palmas_mmc1_poweron_ldo(void);
114 int twl603x_mmc1_set_ldo9(u8 vsel);
115 int twl603x_audio_power(u8 on);
116 int twl603x_enable_bb_charge(u8 bb_fields);
117 
118 #endif /* PALMAS_H */
119