xref: /openbmc/u-boot/include/power/max8997_pmic.h (revision 713cb680)
1 /*
2  *  Copyright (C) 2011 Samsung Electronics
3  *  Lukasz Majewski <l.majewski@samsung.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 #ifndef __MAX8997_PMIC_H_
25 #define __MAX8997_PMIC_H_
26 
27 /* MAX 8997 registers */
28 enum {
29 	MAX8997_REG_PMIC_ID0	= 0x00,
30 	MAX8997_REG_PMIC_ID1	= 0x01,
31 	MAX8997_REG_INTSRC	= 0x02,
32 	MAX8997_REG_INT1	= 0x03,
33 	MAX8997_REG_INT2	= 0x04,
34 	MAX8997_REG_INT3	= 0x05,
35 	MAX8997_REG_INT4	= 0x06,
36 
37 	MAX8997_REG_INT1MSK	= 0x08,
38 	MAX8997_REG_INT2MSK	= 0x09,
39 	MAX8997_REG_INT3MSK	= 0x0a,
40 	MAX8997_REG_INT4MSK	= 0x0b,
41 
42 	MAX8997_REG_STATUS1	= 0x0d,
43 	MAX8997_REG_STATUS2	= 0x0e,
44 	MAX8997_REG_STATUS3	= 0x0f,
45 	MAX8997_REG_STATUS4	= 0x10,
46 
47 	MAX8997_REG_MAINCON1	= 0x13,
48 	MAX8997_REG_MAINCON2	= 0x14,
49 	MAX8997_REG_BUCKRAMP	= 0x15,
50 
51 	MAX8997_REG_BUCK1CTRL	= 0x18,
52 	MAX8997_REG_BUCK1DVS1	= 0x19,
53 	MAX8997_REG_BUCK1DVS2	= 0x1a,
54 	MAX8997_REG_BUCK1DVS3	= 0x1b,
55 	MAX8997_REG_BUCK1DVS4	= 0x1c,
56 	MAX8997_REG_BUCK1DVS5	= 0x1d,
57 	MAX8997_REG_BUCK1DVS6	= 0x1e,
58 	MAX8997_REG_BUCK1DVS7	= 0x1f,
59 	MAX8997_REG_BUCK1DVS8	= 0x20,
60 	MAX8997_REG_BUCK2CTRL	= 0x21,
61 	MAX8997_REG_BUCK2DVS1	= 0x22,
62 	MAX8997_REG_BUCK2DVS2	= 0x23,
63 	MAX8997_REG_BUCK2DVS3	= 0x24,
64 	MAX8997_REG_BUCK2DVS4	= 0x25,
65 	MAX8997_REG_BUCK2DVS5	= 0x26,
66 	MAX8997_REG_BUCK2DVS6	= 0x27,
67 	MAX8997_REG_BUCK2DVS7	= 0x28,
68 	MAX8997_REG_BUCK2DVS8	= 0x29,
69 	MAX8997_REG_BUCK3CTRL	= 0x2a,
70 	MAX8997_REG_BUCK3DVS	= 0x2b,
71 	MAX8997_REG_BUCK4CTRL	= 0x2c,
72 	MAX8997_REG_BUCK4DVS	= 0x2d,
73 	MAX8997_REG_BUCK5CTRL	= 0x2e,
74 	MAX8997_REG_BUCK5DVS1	= 0x2f,
75 	MAX8997_REG_BUCK5DVS2	= 0x30,
76 	MAX8997_REG_BUCK5DVS3	= 0x31,
77 	MAX8997_REG_BUCK5DVS4	= 0x32,
78 	MAX8997_REG_BUCK5DVS5	= 0x33,
79 	MAX8997_REG_BUCK5DVS6	= 0x34,
80 	MAX8997_REG_BUCK5DVS7	= 0x35,
81 	MAX8997_REG_BUCK5DVS8	= 0x36,
82 	MAX8997_REG_BUCK6CTRL	= 0x37,
83 	MAX8997_REG_BUCK6BPSKIPCTRL	= 0x38,
84 	MAX8997_REG_BUCK7CTRL	= 0x39,
85 	MAX8997_REG_BUCK7DVS	= 0x3a,
86 	MAX8997_REG_LDO1CTRL	= 0x3b,
87 	MAX8997_REG_LDO2CTRL	= 0x3c,
88 	MAX8997_REG_LDO3CTRL	= 0x3d,
89 	MAX8997_REG_LDO4CTRL	= 0x3e,
90 	MAX8997_REG_LDO5CTRL	= 0x3f,
91 	MAX8997_REG_LDO6CTRL	= 0x40,
92 	MAX8997_REG_LDO7CTRL	= 0x41,
93 	MAX8997_REG_LDO8CTRL	= 0x42,
94 	MAX8997_REG_LDO9CTRL	= 0x43,
95 	MAX8997_REG_LDO10CTRL	= 0x44,
96 	MAX8997_REG_LDO11CTRL	= 0x45,
97 	MAX8997_REG_LDO12CTRL	= 0x46,
98 	MAX8997_REG_LDO13CTRL	= 0x47,
99 	MAX8997_REG_LDO14CTRL	= 0x48,
100 	MAX8997_REG_LDO15CTRL	= 0x49,
101 	MAX8997_REG_LDO16CTRL	= 0x4a,
102 	MAX8997_REG_LDO17CTRL	= 0x4b,
103 	MAX8997_REG_LDO18CTRL	= 0x4c,
104 	MAX8997_REG_LDO21CTRL	= 0x4d,
105 
106 	MAX8997_REG_MBCCTRL1	= 0x50,
107 	MAX8997_REG_MBCCTRL2	= 0x51,
108 	MAX8997_REG_MBCCTRL3	= 0x52,
109 	MAX8997_REG_MBCCTRL4	= 0x53,
110 	MAX8997_REG_MBCCTRL5	= 0x54,
111 	MAX8997_REG_MBCCTRL6	= 0x55,
112 	MAX8997_REG_OTPCGHCVS	= 0x56,
113 
114 	MAX8997_REG_SAFEOUTCTRL = 0x5a,
115 
116 	MAX8997_REG_LBCNFG1	= 0x5e,
117 	MAX8997_REG_LBCNFG2	= 0x5f,
118 	MAX8997_REG_BBCCTRL	= 0x60,
119 
120 	MAX8997_REG_FLASH1_CUR	= 0x63, /* 0x63 ~ 0x6e for FLASH */
121 	MAX8997_REG_FLASH2_CUR	= 0x64,
122 	MAX8997_REG_MOVIE_CUR	= 0x65,
123 	MAX8997_REG_GSMB_CUR	= 0x66,
124 	MAX8997_REG_BOOST_CNTL	= 0x67,
125 	MAX8997_REG_LEN_CNTL	= 0x68,
126 	MAX8997_REG_FLASH_CNTL	= 0x69,
127 	MAX8997_REG_WDT_CNTL	= 0x6a,
128 	MAX8997_REG_MAXFLASH1	= 0x6b,
129 	MAX8997_REG_MAXFLASH2	= 0x6c,
130 	MAX8997_REG_FLASHSTATUS	= 0x6d,
131 	MAX8997_REG_FLASHSTATUSMASK	= 0x6e,
132 
133 	MAX8997_REG_GPIOCNTL1	= 0x70,
134 	MAX8997_REG_GPIOCNTL2	= 0x71,
135 	MAX8997_REG_GPIOCNTL3	= 0x72,
136 	MAX8997_REG_GPIOCNTL4	= 0x73,
137 	MAX8997_REG_GPIOCNTL5	= 0x74,
138 	MAX8997_REG_GPIOCNTL6	= 0x75,
139 	MAX8997_REG_GPIOCNTL7	= 0x76,
140 	MAX8997_REG_GPIOCNTL8	= 0x77,
141 	MAX8997_REG_GPIOCNTL9	= 0x78,
142 	MAX8997_REG_GPIOCNTL10	= 0x79,
143 	MAX8997_REG_GPIOCNTL11	= 0x7a,
144 	MAX8997_REG_GPIOCNTL12	= 0x7b,
145 
146 	MAX8997_REG_LDO1CONFIG	= 0x80,
147 	MAX8997_REG_LDO2CONFIG	= 0x81,
148 	MAX8997_REG_LDO3CONFIG	= 0x82,
149 	MAX8997_REG_LDO4CONFIG	= 0x83,
150 	MAX8997_REG_LDO5CONFIG	= 0x84,
151 	MAX8997_REG_LDO6CONFIG	= 0x85,
152 	MAX8997_REG_LDO7CONFIG	= 0x86,
153 	MAX8997_REG_LDO8CONFIG	= 0x87,
154 	MAX8997_REG_LDO9CONFIG	= 0x88,
155 	MAX8997_REG_LDO10CONFIG	= 0x89,
156 	MAX8997_REG_LDO11CONFIG	= 0x8a,
157 	MAX8997_REG_LDO12CONFIG	= 0x8b,
158 	MAX8997_REG_LDO13CONFIG	= 0x8c,
159 	MAX8997_REG_LDO14CONFIG	= 0x8d,
160 	MAX8997_REG_LDO15CONFIG	= 0x8e,
161 	MAX8997_REG_LDO16CONFIG	= 0x8f,
162 	MAX8997_REG_LDO17CONFIG	= 0x90,
163 	MAX8997_REG_LDO18CONFIG	= 0x91,
164 	MAX8997_REG_LDO21CONFIG	= 0x92,
165 
166 	MAX8997_REG_DVSOKTIMER1	= 0x97,
167 	MAX8997_REG_DVSOKTIMER2	= 0x98,
168 	MAX8997_REG_DVSOKTIMER4	= 0x99,
169 	MAX8997_REG_DVSOKTIMER5	= 0x9a,
170 
171 	PMIC_NUM_OF_REGS = 0x9b,
172 };
173 
174 #define ACTDISSAFEO1 (1 << 4)
175 #define ACTDISSAFEO2 (1 << 5)
176 #define ENSAFEOUT1 (1 << 6)
177 #define ENSAFEOUT2 (1 << 7)
178 
179 #define ENBUCK (1 << 0)
180 #define ACTIVE_DISCHARGE (1 << 3)
181 #define GNSLCT (1 << 2)
182 #define LDO_ADE (1 << 1)
183 #define SAFEOUT_4_85V 0x00
184 #define SAFEOUT_4_90V 0x01
185 #define SAFEOUT_4_95V 0x02
186 #define SAFEOUT_3_30V 0x03
187 
188 /* Charger */
189 enum {CHARGER_ENABLE, CHARGER_DISABLE};
190 #define DETBAT                  (1 << 2)
191 #define MBCICHFCSET             (1 << 4)
192 #define MBCHOSTEN               (1 << 6)
193 #define VCHGR_FC                (1 << 7)
194 
195 #define CHARGER_MIN_CURRENT 200
196 #define CHARGER_MAX_CURRENT 950
197 #define CHARGER_CURRENT_RESOLUTION 50
198 
199 #define MAX8997_I2C_ADDR        (0xCC >> 1)
200 #define MAX8997_RTC_ADDR	(0x0C >> 1)
201 #define MAX8997_MUIC_ADDR	(0x4A >> 1)
202 #define MAX8997_FG_ADDR	(0x6C >> 1)
203 
204 enum {
205 	LDO_OFF = 0,
206 	LDO_ON = 1,
207 
208 	DIS_LDO = (0x00 << 6),
209 	EN_LDO = (0x3 << 6),
210 };
211 
212 #define MAX8997_LDO_MAX_VAL 0x3F
213 unsigned char max8997_reg_ldo(int uV);
214 #endif /* __MAX8997_PMIC_H_ */
215