2 * rk808.h for Rockchip RK808
4 * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
6 * Author: Chris Zhong <zyw@rock-chips.com>
7 * Author: Zhang Qing <zhangqing@rock-chips.com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms and conditions of the GNU General Public License,
11 * version 2, as published by the Free Software Foundation.
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 #ifndef __LINUX_REGULATOR_rk808_H
20 #define __LINUX_REGULATOR_rk808_H
22 #include <linux/regulator/machine.h>
23 #include <linux/regmap.h>
26 * rk808 Global Register Map.
29 #define RK808_DCDC1 0 /* (0+RK808_START) */
30 #define RK808_LDO1 4 /* (4+RK808_START) */
31 #define RK808_NUM_REGULATORS 14
67 #define RK808_SECONDS_REG 0x00
68 #define RK808_MINUTES_REG 0x01
69 #define RK808_HOURS_REG 0x02
70 #define RK808_DAYS_REG 0x03
71 #define RK808_MONTHS_REG 0x04
72 #define RK808_YEARS_REG 0x05
73 #define RK808_WEEKS_REG 0x06
74 #define RK808_ALARM_SECONDS_REG 0x08
75 #define RK808_ALARM_MINUTES_REG 0x09
76 #define RK808_ALARM_HOURS_REG 0x0a
77 #define RK808_ALARM_DAYS_REG 0x0b
78 #define RK808_ALARM_MONTHS_REG 0x0c
79 #define RK808_ALARM_YEARS_REG 0x0d
80 #define RK808_RTC_CTRL_REG 0x10
81 #define RK808_RTC_STATUS_REG 0x11
82 #define RK808_RTC_INT_REG 0x12
83 #define RK808_RTC_COMP_LSB_REG 0x13
84 #define RK808_RTC_COMP_MSB_REG 0x14
85 #define RK808_CLK32OUT_REG 0x20
86 #define RK808_VB_MON_REG 0x21
87 #define RK808_THERMAL_REG 0x22
88 #define RK808_DCDC_EN_REG 0x23
89 #define RK808_LDO_EN_REG 0x24
90 #define RK808_SLEEP_SET_OFF_REG1 0x25
91 #define RK808_SLEEP_SET_OFF_REG2 0x26
92 #define RK808_DCDC_UV_STS_REG 0x27
93 #define RK808_DCDC_UV_ACT_REG 0x28
94 #define RK808_LDO_UV_STS_REG 0x29
95 #define RK808_LDO_UV_ACT_REG 0x2a
96 #define RK808_DCDC_PG_REG 0x2b
97 #define RK808_LDO_PG_REG 0x2c
98 #define RK808_VOUT_MON_TDB_REG 0x2d
99 #define RK808_BUCK1_CONFIG_REG 0x2e
100 #define RK808_BUCK1_ON_VSEL_REG 0x2f
101 #define RK808_BUCK1_SLP_VSEL_REG 0x30
102 #define RK808_BUCK1_DVS_VSEL_REG 0x31
103 #define RK808_BUCK2_CONFIG_REG 0x32
104 #define RK808_BUCK2_ON_VSEL_REG 0x33
105 #define RK808_BUCK2_SLP_VSEL_REG 0x34
106 #define RK808_BUCK2_DVS_VSEL_REG 0x35
107 #define RK808_BUCK3_CONFIG_REG 0x36
108 #define RK808_BUCK4_CONFIG_REG 0x37
109 #define RK808_BUCK4_ON_VSEL_REG 0x38
110 #define RK808_BUCK4_SLP_VSEL_REG 0x39
111 #define RK808_BOOST_CONFIG_REG 0x3a
112 #define RK808_LDO1_ON_VSEL_REG 0x3b
113 #define RK808_LDO1_SLP_VSEL_REG 0x3c
114 #define RK808_LDO2_ON_VSEL_REG 0x3d
115 #define RK808_LDO2_SLP_VSEL_REG 0x3e
116 #define RK808_LDO3_ON_VSEL_REG 0x3f
117 #define RK808_LDO3_SLP_VSEL_REG 0x40
118 #define RK808_LDO4_ON_VSEL_REG 0x41
119 #define RK808_LDO4_SLP_VSEL_REG 0x42
120 #define RK808_LDO5_ON_VSEL_REG 0x43
121 #define RK808_LDO5_SLP_VSEL_REG 0x44
122 #define RK808_LDO6_ON_VSEL_REG 0x45
123 #define RK808_LDO6_SLP_VSEL_REG 0x46
124 #define RK808_LDO7_ON_VSEL_REG 0x47
125 #define RK808_LDO7_SLP_VSEL_REG 0x48
126 #define RK808_LDO8_ON_VSEL_REG 0x49
127 #define RK808_LDO8_SLP_VSEL_REG 0x4a
128 #define RK808_DEVCTRL_REG 0x4b
129 #define RK808_INT_STS_REG1 0x4c
130 #define RK808_INT_STS_MSK_REG1 0x4d
131 #define RK808_INT_STS_REG2 0x4e
132 #define RK808_INT_STS_MSK_REG2 0x4f
133 #define RK808_IO_POL_REG 0x50
135 #define RK818_VB_MON_REG 0x21
136 #define RK818_THERMAL_REG 0x22
137 #define RK818_DCDC_EN_REG 0x23
138 #define RK818_LDO_EN_REG 0x24
139 #define RK818_SLEEP_SET_OFF_REG1 0x25
140 #define RK818_SLEEP_SET_OFF_REG2 0x26
141 #define RK818_DCDC_UV_STS_REG 0x27
142 #define RK818_DCDC_UV_ACT_REG 0x28
143 #define RK818_LDO_UV_STS_REG 0x29
144 #define RK818_LDO_UV_ACT_REG 0x2a
145 #define RK818_DCDC_PG_REG 0x2b
146 #define RK818_LDO_PG_REG 0x2c
147 #define RK818_VOUT_MON_TDB_REG 0x2d
148 #define RK818_BUCK1_CONFIG_REG 0x2e
149 #define RK818_BUCK1_ON_VSEL_REG 0x2f
150 #define RK818_BUCK1_SLP_VSEL_REG 0x30
151 #define RK818_BUCK2_CONFIG_REG 0x32
152 #define RK818_BUCK2_ON_VSEL_REG 0x33
153 #define RK818_BUCK2_SLP_VSEL_REG 0x34
154 #define RK818_BUCK3_CONFIG_REG 0x36
155 #define RK818_BUCK4_CONFIG_REG 0x37
156 #define RK818_BUCK4_ON_VSEL_REG 0x38
157 #define RK818_BUCK4_SLP_VSEL_REG 0x39
158 #define RK818_BOOST_CONFIG_REG 0x3a
159 #define RK818_LDO1_ON_VSEL_REG 0x3b
160 #define RK818_LDO1_SLP_VSEL_REG 0x3c
161 #define RK818_LDO2_ON_VSEL_REG 0x3d
162 #define RK818_LDO2_SLP_VSEL_REG 0x3e
163 #define RK818_LDO3_ON_VSEL_REG 0x3f
164 #define RK818_LDO3_SLP_VSEL_REG 0x40
165 #define RK818_LDO4_ON_VSEL_REG 0x41
166 #define RK818_LDO4_SLP_VSEL_REG 0x42
167 #define RK818_LDO5_ON_VSEL_REG 0x43
168 #define RK818_LDO5_SLP_VSEL_REG 0x44
169 #define RK818_LDO6_ON_VSEL_REG 0x45
170 #define RK818_LDO6_SLP_VSEL_REG 0x46
171 #define RK818_LDO7_ON_VSEL_REG 0x47
172 #define RK818_LDO7_SLP_VSEL_REG 0x48
173 #define RK818_LDO8_ON_VSEL_REG 0x49
174 #define RK818_LDO8_SLP_VSEL_REG 0x4a
175 #define RK818_DEVCTRL_REG 0x4b
176 #define RK818_INT_STS_REG1 0X4c
177 #define RK818_INT_STS_MSK_REG1 0X4d
178 #define RK818_INT_STS_REG2 0X4e
179 #define RK818_INT_STS_MSK_REG2 0X4f
180 #define RK818_IO_POL_REG 0X50
181 #define RK818_OTP_VDD_EN_REG 0x51
182 #define RK818_H5V_EN_REG 0x52
183 #define RK818_SLEEP_SET_OFF_REG3 0x53
184 #define RK818_BOOST_LDO9_ON_VSEL_REG 0x54
185 #define RK818_BOOST_LDO9_SLP_VSEL_REG 0x55
186 #define RK818_BOOST_CTRL_REG 0x56
187 #define RK818_DCDC_ILMAX_REG 0x90
188 #define RK818_CHRG_COMP_REG 0x9a
189 #define RK818_SUP_STS_REG 0xa0
190 #define RK818_USB_CTRL_REG 0xa1
192 #define RK818_SAVE_DATA19 0xF2
193 #define RK818_NUM_REGULATORS 14
195 /* IRQ Definitions */
196 #define RK808_IRQ_VOUT_LO 0
197 #define RK808_IRQ_VB_LO 1
198 #define RK808_IRQ_PWRON 2
199 #define RK808_IRQ_PWRON_LP 3
200 #define RK808_IRQ_HOTDIE 4
201 #define RK808_IRQ_RTC_ALARM 5
202 #define RK808_IRQ_RTC_PERIOD 6
203 #define RK808_IRQ_PLUG_IN_INT 7
204 #define RK808_IRQ_PLUG_OUT_INT 8
205 #define RK808_NUM_IRQ 9
207 #define RK808_IRQ_VOUT_LO_MSK BIT(0)
208 #define RK808_IRQ_VB_LO_MSK BIT(1)
209 #define RK808_IRQ_PWRON_MSK BIT(2)
210 #define RK808_IRQ_PWRON_LP_MSK BIT(3)
211 #define RK808_IRQ_HOTDIE_MSK BIT(4)
212 #define RK808_IRQ_RTC_ALARM_MSK BIT(5)
213 #define RK808_IRQ_RTC_PERIOD_MSK BIT(6)
214 #define RK808_IRQ_PLUG_IN_INT_MSK BIT(0)
215 #define RK808_IRQ_PLUG_OUT_INT_MSK BIT(1)
217 #define RK808_VBAT_LOW_2V8 0x00
218 #define RK808_VBAT_LOW_2V9 0x01
219 #define RK808_VBAT_LOW_3V0 0x02
220 #define RK808_VBAT_LOW_3V1 0x03
221 #define RK808_VBAT_LOW_3V2 0x04
222 #define RK808_VBAT_LOW_3V3 0x05
223 #define RK808_VBAT_LOW_3V4 0x06
224 #define RK808_VBAT_LOW_3V5 0x07
225 #define VBAT_LOW_VOL_MASK (0x07 << 0)
226 #define EN_VABT_LOW_SHUT_DOWN (0x00 << 4)
227 #define EN_VBAT_LOW_IRQ (0x1 << 4)
228 #define VBAT_LOW_ACT_MASK (0x1 << 4)
230 #define BUCK_ILMIN_MASK (7 << 0)
231 #define BOOST_ILMIN_MASK (7 << 0)
232 #define BUCK1_RATE_MASK (3 << 3)
233 #define BUCK2_RATE_MASK (3 << 3)
234 #define MASK_ALL 0xff
236 #define BUCK_UV_ACT_MASK 0x0f
237 #define BUCK_UV_ACT_DISABLE 0
239 #define SWITCH2_EN BIT(6)
240 #define SWITCH1_EN BIT(5)
241 #define DEV_OFF_RST BIT(3)
243 #define VB_LO_ACT BIT(4)
244 #define VB_LO_SEL_3500MV (7 << 0)
246 #define VOUT_LO_INT BIT(0)
247 #define CLK32KOUT2_EN BIT(0)
248 #define H5V_EN_MASK BIT(0)
249 #define H5V_EN_ENABLE BIT(0)
250 #define REF_RDY_CTRL_MASK BIT(1)
251 #define REF_RDY_CTRL_ENABLE BIT(1)
253 /*RK818_DCDC_EN_REG*/
254 #define BUCK1_EN_MASK BIT(0)
255 #define BUCK2_EN_MASK BIT(1)
256 #define BUCK3_EN_MASK BIT(2)
257 #define BUCK4_EN_MASK BIT(3)
258 #define BOOST_EN_MASK BIT(4)
259 #define LDO9_EN_MASK BIT(5)
260 #define SWITCH_EN_MASK BIT(6)
261 #define OTG_EN_MASK BIT(7)
263 #define BUCK1_EN_ENABLE BIT(0)
264 #define BUCK2_EN_ENABLE BIT(1)
265 #define BUCK3_EN_ENABLE BIT(2)
266 #define BUCK4_EN_ENABLE BIT(3)
267 #define BOOST_EN_ENABLE BIT(4)
268 #define LDO9_EN_ENABLE BIT(5)
269 #define SWITCH_EN_ENABLE BIT(6)
270 #define OTG_EN_ENABLE BIT(7)
272 /* IRQ Definitions */
273 #define RK818_IRQ_VOUT_LO 0
274 #define RK818_IRQ_VB_LO 1
275 #define RK818_IRQ_PWRON 2
276 #define RK818_IRQ_PWRON_LP 3
277 #define RK818_IRQ_HOTDIE 4
278 #define RK818_IRQ_RTC_ALARM 5
279 #define RK818_IRQ_RTC_PERIOD 6
280 #define RK818_IRQ_USB_OV 7
281 #define RK818_IRQ_PLUG_IN 8
282 #define RK818_IRQ_PLUG_OUT 9
283 #define RK818_IRQ_CHG_OK 10
284 #define RK818_IRQ_CHG_TE 11
285 #define RK818_IRQ_CHG_TS1 12
286 #define RK818_IRQ_TS2 13
287 #define RK818_IRQ_CHG_CVTLIM 14
288 #define RK818_IRQ_DISCHG_ILIM 15
290 #define BUCK1_SLP_SET_MASK BIT(0)
291 #define BUCK2_SLP_SET_MASK BIT(1)
292 #define BUCK3_SLP_SET_MASK BIT(2)
293 #define BUCK4_SLP_SET_MASK BIT(3)
294 #define BOOST_SLP_SET_MASK BIT(4)
295 #define LDO9_SLP_SET_MASK BIT(5)
296 #define SWITCH_SLP_SET_MASK BIT(6)
297 #define OTG_SLP_SET_MASK BIT(7)
299 #define BUCK1_SLP_SET_OFF BIT(0)
300 #define BUCK2_SLP_SET_OFF BIT(1)
301 #define BUCK3_SLP_SET_OFF BIT(2)
302 #define BUCK4_SLP_SET_OFF BIT(3)
303 #define BOOST_SLP_SET_OFF BIT(4)
304 #define LDO9_SLP_SET_OFF BIT(5)
305 #define SWITCH_SLP_SET_OFF BIT(6)
306 #define OTG_SLP_SET_OFF BIT(7)
308 #define BUCK1_SLP_SET_ON BIT(0)
309 #define BUCK2_SLP_SET_ON BIT(1)
310 #define BUCK3_SLP_SET_ON BIT(2)
311 #define BUCK4_SLP_SET_ON BIT(3)
312 #define BOOST_SLP_SET_ON BIT(4)
313 #define LDO9_SLP_SET_ON BIT(5)
314 #define SWITCH_SLP_SET_ON BIT(6)
315 #define OTG_SLP_SET_ON BIT(7)
317 #define VOUT_LO_MASK BIT(0)
318 #define VB_LO_MASK BIT(1)
319 #define PWRON_MASK BIT(2)
320 #define PWRON_LP_MASK BIT(3)
321 #define HOTDIE_MASK BIT(4)
322 #define RTC_ALARM_MASK BIT(5)
323 #define RTC_PERIOD_MASK BIT(6)
324 #define USB_OV_MASK BIT(7)
326 #define VOUT_LO_DISABLE BIT(0)
327 #define VB_LO_DISABLE BIT(1)
328 #define PWRON_DISABLE BIT(2)
329 #define PWRON_LP_DISABLE BIT(3)
330 #define HOTDIE_DISABLE BIT(4)
331 #define RTC_ALARM_DISABLE BIT(5)
332 #define RTC_PERIOD_DISABLE BIT(6)
333 #define USB_OV_INT_DISABLE BIT(7)
335 #define VOUT_LO_ENABLE (0 << 0)
336 #define VB_LO_ENABLE (0 << 1)
337 #define PWRON_ENABLE (0 << 2)
338 #define PWRON_LP_ENABLE (0 << 3)
339 #define HOTDIE_ENABLE (0 << 4)
340 #define RTC_ALARM_ENABLE (0 << 5)
341 #define RTC_PERIOD_ENABLE (0 << 6)
342 #define USB_OV_INT_ENABLE (0 << 7)
344 #define PLUG_IN_MASK BIT(0)
345 #define PLUG_OUT_MASK BIT(1)
346 #define CHGOK_MASK BIT(2)
347 #define CHGTE_MASK BIT(3)
348 #define CHGTS1_MASK BIT(4)
349 #define TS2_MASK BIT(5)
350 #define CHG_CVTLIM_MASK BIT(6)
351 #define DISCHG_ILIM_MASK BIT(7)
353 #define PLUG_IN_DISABLE BIT(0)
354 #define PLUG_OUT_DISABLE BIT(1)
355 #define CHGOK_DISABLE BIT(2)
356 #define CHGTE_DISABLE BIT(3)
357 #define CHGTS1_DISABLE BIT(4)
358 #define TS2_DISABLE BIT(5)
359 #define CHG_CVTLIM_DISABLE BIT(6)
360 #define DISCHG_ILIM_DISABLE BIT(7)
362 #define PLUG_IN_ENABLE BIT(0)
363 #define PLUG_OUT_ENABLE BIT(1)
364 #define CHGOK_ENABLE BIT(2)
365 #define CHGTE_ENABLE BIT(3)
366 #define CHGTS1_ENABLE BIT(4)
367 #define TS2_ENABLE BIT(5)
368 #define CHG_CVTLIM_ENABLE BIT(6)
369 #define DISCHG_ILIM_ENABLE BIT(7)
394 struct i2c_client *i2c;
395 struct regmap_irq_chip_data *irq_data;
396 struct regmap *regmap;
398 #endif /* __LINUX_REGULATOR_rk808_H */