1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Functions and registers to access AXP20X power management chip.
4  *
5  * Copyright (C) 2013, Carlo Caione <carlo@caione.org>
6  */
7 
8 #ifndef __LINUX_MFD_AXP20X_H
9 #define __LINUX_MFD_AXP20X_H
10 
11 #include <linux/regmap.h>
12 
13 enum axp20x_variants {
14 	AXP152_ID = 0,
15 	AXP202_ID,
16 	AXP209_ID,
17 	AXP221_ID,
18 	AXP223_ID,
19 	AXP288_ID,
20 	AXP803_ID,
21 	AXP806_ID,
22 	AXP809_ID,
23 	AXP813_ID,
24 	NR_AXP20X_VARIANTS,
25 };
26 
27 #define AXP20X_DATACACHE(m)		(0x04 + (m))
28 
29 /* Power supply */
30 #define AXP152_PWR_OP_MODE		0x01
31 #define AXP152_LDO3456_DC1234_CTRL	0x12
32 #define AXP152_ALDO_OP_MODE		0x13
33 #define AXP152_LDO0_CTRL		0x15
34 #define AXP152_DCDC2_V_OUT		0x23
35 #define AXP152_DCDC2_V_RAMP		0x25
36 #define AXP152_DCDC1_V_OUT		0x26
37 #define AXP152_DCDC3_V_OUT		0x27
38 #define AXP152_ALDO12_V_OUT		0x28
39 #define AXP152_DLDO1_V_OUT		0x29
40 #define AXP152_DLDO2_V_OUT		0x2a
41 #define AXP152_DCDC4_V_OUT		0x2b
42 #define AXP152_V_OFF			0x31
43 #define AXP152_OFF_CTRL			0x32
44 #define AXP152_PEK_KEY			0x36
45 #define AXP152_DCDC_FREQ		0x37
46 #define AXP152_DCDC_MODE		0x80
47 
48 #define AXP20X_PWR_INPUT_STATUS		0x00
49 #define AXP20X_PWR_OP_MODE		0x01
50 #define AXP20X_USB_OTG_STATUS		0x02
51 #define AXP20X_PWR_OUT_CTRL		0x12
52 #define AXP20X_DCDC2_V_OUT		0x23
53 #define AXP20X_DCDC2_LDO3_V_RAMP	0x25
54 #define AXP20X_DCDC3_V_OUT		0x27
55 #define AXP20X_LDO24_V_OUT		0x28
56 #define AXP20X_LDO3_V_OUT		0x29
57 #define AXP20X_VBUS_IPSOUT_MGMT		0x30
58 #define AXP20X_V_OFF			0x31
59 #define AXP20X_OFF_CTRL			0x32
60 #define AXP20X_CHRG_CTRL1		0x33
61 #define AXP20X_CHRG_CTRL2		0x34
62 #define AXP20X_CHRG_BAK_CTRL		0x35
63 #define AXP20X_PEK_KEY			0x36
64 #define AXP20X_DCDC_FREQ		0x37
65 #define AXP20X_V_LTF_CHRG		0x38
66 #define AXP20X_V_HTF_CHRG		0x39
67 #define AXP20X_APS_WARN_L1		0x3a
68 #define AXP20X_APS_WARN_L2		0x3b
69 #define AXP20X_V_LTF_DISCHRG		0x3c
70 #define AXP20X_V_HTF_DISCHRG		0x3d
71 
72 #define AXP22X_PWR_OUT_CTRL1		0x10
73 #define AXP22X_PWR_OUT_CTRL2		0x12
74 #define AXP22X_PWR_OUT_CTRL3		0x13
75 #define AXP22X_DLDO1_V_OUT		0x15
76 #define AXP22X_DLDO2_V_OUT		0x16
77 #define AXP22X_DLDO3_V_OUT		0x17
78 #define AXP22X_DLDO4_V_OUT		0x18
79 #define AXP22X_ELDO1_V_OUT		0x19
80 #define AXP22X_ELDO2_V_OUT		0x1a
81 #define AXP22X_ELDO3_V_OUT		0x1b
82 #define AXP22X_DC5LDO_V_OUT		0x1c
83 #define AXP22X_DCDC1_V_OUT		0x21
84 #define AXP22X_DCDC2_V_OUT		0x22
85 #define AXP22X_DCDC3_V_OUT		0x23
86 #define AXP22X_DCDC4_V_OUT		0x24
87 #define AXP22X_DCDC5_V_OUT		0x25
88 #define AXP22X_DCDC23_V_RAMP_CTRL	0x27
89 #define AXP22X_ALDO1_V_OUT		0x28
90 #define AXP22X_ALDO2_V_OUT		0x29
91 #define AXP22X_ALDO3_V_OUT		0x2a
92 #define AXP22X_CHRG_CTRL3		0x35
93 
94 #define AXP806_STARTUP_SRC		0x00
95 #define AXP806_CHIP_ID			0x03
96 #define AXP806_PWR_OUT_CTRL1		0x10
97 #define AXP806_PWR_OUT_CTRL2		0x11
98 #define AXP806_DCDCA_V_CTRL		0x12
99 #define AXP806_DCDCB_V_CTRL		0x13
100 #define AXP806_DCDCC_V_CTRL		0x14
101 #define AXP806_DCDCD_V_CTRL		0x15
102 #define AXP806_DCDCE_V_CTRL		0x16
103 #define AXP806_ALDO1_V_CTRL		0x17
104 #define AXP806_ALDO2_V_CTRL		0x18
105 #define AXP806_ALDO3_V_CTRL		0x19
106 #define AXP806_DCDC_MODE_CTRL1		0x1a
107 #define AXP806_DCDC_MODE_CTRL2		0x1b
108 #define AXP806_DCDC_FREQ_CTRL		0x1c
109 #define AXP806_BLDO1_V_CTRL		0x20
110 #define AXP806_BLDO2_V_CTRL		0x21
111 #define AXP806_BLDO3_V_CTRL		0x22
112 #define AXP806_BLDO4_V_CTRL		0x23
113 #define AXP806_CLDO1_V_CTRL		0x24
114 #define AXP806_CLDO2_V_CTRL		0x25
115 #define AXP806_CLDO3_V_CTRL		0x26
116 #define AXP806_VREF_TEMP_WARN_L		0xf3
117 #define AXP806_BUS_ADDR_EXT		0xfe
118 #define AXP806_REG_ADDR_EXT		0xff
119 
120 #define AXP803_POLYPHASE_CTRL		0x14
121 #define AXP803_FLDO1_V_OUT		0x1c
122 #define AXP803_FLDO2_V_OUT		0x1d
123 #define AXP803_DCDC1_V_OUT		0x20
124 #define AXP803_DCDC2_V_OUT		0x21
125 #define AXP803_DCDC3_V_OUT		0x22
126 #define AXP803_DCDC4_V_OUT		0x23
127 #define AXP803_DCDC5_V_OUT		0x24
128 #define AXP803_DCDC6_V_OUT		0x25
129 #define AXP803_DCDC_FREQ_CTRL		0x3b
130 
131 /* Other DCDC regulator control registers are the same as AXP803 */
132 #define AXP813_DCDC7_V_OUT		0x26
133 
134 /* Interrupt */
135 #define AXP152_IRQ1_EN			0x40
136 #define AXP152_IRQ2_EN			0x41
137 #define AXP152_IRQ3_EN			0x42
138 #define AXP152_IRQ1_STATE		0x48
139 #define AXP152_IRQ2_STATE		0x49
140 #define AXP152_IRQ3_STATE		0x4a
141 
142 #define AXP20X_IRQ1_EN			0x40
143 #define AXP20X_IRQ2_EN			0x41
144 #define AXP20X_IRQ3_EN			0x42
145 #define AXP20X_IRQ4_EN			0x43
146 #define AXP20X_IRQ5_EN			0x44
147 #define AXP20X_IRQ6_EN			0x45
148 #define AXP20X_IRQ1_STATE		0x48
149 #define AXP20X_IRQ2_STATE		0x49
150 #define AXP20X_IRQ3_STATE		0x4a
151 #define AXP20X_IRQ4_STATE		0x4b
152 #define AXP20X_IRQ5_STATE		0x4c
153 #define AXP20X_IRQ6_STATE		0x4d
154 
155 /* ADC */
156 #define AXP20X_ACIN_V_ADC_H		0x56
157 #define AXP20X_ACIN_V_ADC_L		0x57
158 #define AXP20X_ACIN_I_ADC_H		0x58
159 #define AXP20X_ACIN_I_ADC_L		0x59
160 #define AXP20X_VBUS_V_ADC_H		0x5a
161 #define AXP20X_VBUS_V_ADC_L		0x5b
162 #define AXP20X_VBUS_I_ADC_H		0x5c
163 #define AXP20X_VBUS_I_ADC_L		0x5d
164 #define AXP20X_TEMP_ADC_H		0x5e
165 #define AXP20X_TEMP_ADC_L		0x5f
166 #define AXP20X_TS_IN_H			0x62
167 #define AXP20X_TS_IN_L			0x63
168 #define AXP20X_GPIO0_V_ADC_H		0x64
169 #define AXP20X_GPIO0_V_ADC_L		0x65
170 #define AXP20X_GPIO1_V_ADC_H		0x66
171 #define AXP20X_GPIO1_V_ADC_L		0x67
172 #define AXP20X_PWR_BATT_H		0x70
173 #define AXP20X_PWR_BATT_M		0x71
174 #define AXP20X_PWR_BATT_L		0x72
175 #define AXP20X_BATT_V_H			0x78
176 #define AXP20X_BATT_V_L			0x79
177 #define AXP20X_BATT_CHRG_I_H		0x7a
178 #define AXP20X_BATT_CHRG_I_L		0x7b
179 #define AXP20X_BATT_DISCHRG_I_H		0x7c
180 #define AXP20X_BATT_DISCHRG_I_L		0x7d
181 #define AXP20X_IPSOUT_V_HIGH_H		0x7e
182 #define AXP20X_IPSOUT_V_HIGH_L		0x7f
183 
184 /* Power supply */
185 #define AXP20X_DCDC_MODE		0x80
186 #define AXP20X_ADC_EN1			0x82
187 #define AXP20X_ADC_EN2			0x83
188 #define AXP20X_ADC_RATE			0x84
189 #define AXP20X_GPIO10_IN_RANGE		0x85
190 #define AXP20X_GPIO1_ADC_IRQ_RIS	0x86
191 #define AXP20X_GPIO1_ADC_IRQ_FAL	0x87
192 #define AXP20X_TIMER_CTRL		0x8a
193 #define AXP20X_VBUS_MON			0x8b
194 #define AXP20X_OVER_TMP			0x8f
195 
196 #define AXP22X_PWREN_CTRL1		0x8c
197 #define AXP22X_PWREN_CTRL2		0x8d
198 
199 /* GPIO */
200 #define AXP152_GPIO0_CTRL		0x90
201 #define AXP152_GPIO1_CTRL		0x91
202 #define AXP152_GPIO2_CTRL		0x92
203 #define AXP152_GPIO3_CTRL		0x93
204 #define AXP152_LDOGPIO2_V_OUT		0x96
205 #define AXP152_GPIO_INPUT		0x97
206 #define AXP152_PWM0_FREQ_X		0x98
207 #define AXP152_PWM0_FREQ_Y		0x99
208 #define AXP152_PWM0_DUTY_CYCLE		0x9a
209 #define AXP152_PWM1_FREQ_X		0x9b
210 #define AXP152_PWM1_FREQ_Y		0x9c
211 #define AXP152_PWM1_DUTY_CYCLE		0x9d
212 
213 #define AXP20X_GPIO0_CTRL		0x90
214 #define AXP20X_LDO5_V_OUT		0x91
215 #define AXP20X_GPIO1_CTRL		0x92
216 #define AXP20X_GPIO2_CTRL		0x93
217 #define AXP20X_GPIO20_SS		0x94
218 #define AXP20X_GPIO3_CTRL		0x95
219 
220 #define AXP22X_LDO_IO0_V_OUT		0x91
221 #define AXP22X_LDO_IO1_V_OUT		0x93
222 #define AXP22X_GPIO_STATE		0x94
223 #define AXP22X_GPIO_PULL_DOWN		0x95
224 
225 /* Battery */
226 #define AXP20X_CHRG_CC_31_24		0xb0
227 #define AXP20X_CHRG_CC_23_16		0xb1
228 #define AXP20X_CHRG_CC_15_8		0xb2
229 #define AXP20X_CHRG_CC_7_0		0xb3
230 #define AXP20X_DISCHRG_CC_31_24		0xb4
231 #define AXP20X_DISCHRG_CC_23_16		0xb5
232 #define AXP20X_DISCHRG_CC_15_8		0xb6
233 #define AXP20X_DISCHRG_CC_7_0		0xb7
234 #define AXP20X_CC_CTRL			0xb8
235 #define AXP20X_FG_RES			0xb9
236 
237 /* OCV */
238 #define AXP20X_RDC_H			0xba
239 #define AXP20X_RDC_L			0xbb
240 #define AXP20X_OCV(m)			(0xc0 + (m))
241 #define AXP20X_OCV_MAX			0xf
242 
243 /* AXP22X specific registers */
244 #define AXP22X_PMIC_TEMP_H		0x56
245 #define AXP22X_PMIC_TEMP_L		0x57
246 #define AXP22X_TS_ADC_H			0x58
247 #define AXP22X_TS_ADC_L			0x59
248 #define AXP22X_BATLOW_THRES1		0xe6
249 
250 /* AXP288/AXP803 specific registers */
251 #define AXP288_POWER_REASON		0x02
252 #define AXP288_BC_GLOBAL		0x2c
253 #define AXP288_BC_VBUS_CNTL		0x2d
254 #define AXP288_BC_USB_STAT		0x2e
255 #define AXP288_BC_DET_STAT		0x2f
256 #define AXP288_PMIC_ADC_H               0x56
257 #define AXP288_PMIC_ADC_L               0x57
258 #define AXP288_TS_ADC_H			0x58
259 #define AXP288_TS_ADC_L			0x59
260 #define AXP288_GP_ADC_H			0x5a
261 #define AXP288_GP_ADC_L			0x5b
262 #define AXP288_ADC_TS_PIN_CTRL          0x84
263 #define AXP288_RT_BATT_V_H		0xa0
264 #define AXP288_RT_BATT_V_L		0xa1
265 
266 #define AXP813_ACIN_PATH_CTRL		0x3a
267 #define AXP813_ADC_RATE			0x85
268 
269 /* Fuel Gauge */
270 #define AXP288_FG_RDC1_REG          0xba
271 #define AXP288_FG_RDC0_REG          0xbb
272 #define AXP288_FG_OCVH_REG          0xbc
273 #define AXP288_FG_OCVL_REG          0xbd
274 #define AXP288_FG_OCV_CURVE_REG     0xc0
275 #define AXP288_FG_DES_CAP1_REG      0xe0
276 #define AXP288_FG_DES_CAP0_REG      0xe1
277 #define AXP288_FG_CC_MTR1_REG       0xe2
278 #define AXP288_FG_CC_MTR0_REG       0xe3
279 #define AXP288_FG_OCV_CAP_REG       0xe4
280 #define AXP288_FG_CC_CAP_REG        0xe5
281 #define AXP288_FG_LOW_CAP_REG       0xe6
282 #define AXP288_FG_TUNE0             0xe8
283 #define AXP288_FG_TUNE1             0xe9
284 #define AXP288_FG_TUNE2             0xea
285 #define AXP288_FG_TUNE3             0xeb
286 #define AXP288_FG_TUNE4             0xec
287 #define AXP288_FG_TUNE5             0xed
288 
289 /* Regulators IDs */
290 enum {
291 	AXP20X_LDO1 = 0,
292 	AXP20X_LDO2,
293 	AXP20X_LDO3,
294 	AXP20X_LDO4,
295 	AXP20X_LDO5,
296 	AXP20X_DCDC2,
297 	AXP20X_DCDC3,
298 	AXP20X_REG_ID_MAX,
299 };
300 
301 enum {
302 	AXP22X_DCDC1 = 0,
303 	AXP22X_DCDC2,
304 	AXP22X_DCDC3,
305 	AXP22X_DCDC4,
306 	AXP22X_DCDC5,
307 	AXP22X_DC1SW,
308 	AXP22X_DC5LDO,
309 	AXP22X_ALDO1,
310 	AXP22X_ALDO2,
311 	AXP22X_ALDO3,
312 	AXP22X_ELDO1,
313 	AXP22X_ELDO2,
314 	AXP22X_ELDO3,
315 	AXP22X_DLDO1,
316 	AXP22X_DLDO2,
317 	AXP22X_DLDO3,
318 	AXP22X_DLDO4,
319 	AXP22X_RTC_LDO,
320 	AXP22X_LDO_IO0,
321 	AXP22X_LDO_IO1,
322 	AXP22X_REG_ID_MAX,
323 };
324 
325 enum {
326 	AXP806_DCDCA = 0,
327 	AXP806_DCDCB,
328 	AXP806_DCDCC,
329 	AXP806_DCDCD,
330 	AXP806_DCDCE,
331 	AXP806_ALDO1,
332 	AXP806_ALDO2,
333 	AXP806_ALDO3,
334 	AXP806_BLDO1,
335 	AXP806_BLDO2,
336 	AXP806_BLDO3,
337 	AXP806_BLDO4,
338 	AXP806_CLDO1,
339 	AXP806_CLDO2,
340 	AXP806_CLDO3,
341 	AXP806_SW,
342 	AXP806_REG_ID_MAX,
343 };
344 
345 enum {
346 	AXP809_DCDC1 = 0,
347 	AXP809_DCDC2,
348 	AXP809_DCDC3,
349 	AXP809_DCDC4,
350 	AXP809_DCDC5,
351 	AXP809_DC1SW,
352 	AXP809_DC5LDO,
353 	AXP809_ALDO1,
354 	AXP809_ALDO2,
355 	AXP809_ALDO3,
356 	AXP809_ELDO1,
357 	AXP809_ELDO2,
358 	AXP809_ELDO3,
359 	AXP809_DLDO1,
360 	AXP809_DLDO2,
361 	AXP809_RTC_LDO,
362 	AXP809_LDO_IO0,
363 	AXP809_LDO_IO1,
364 	AXP809_SW,
365 	AXP809_REG_ID_MAX,
366 };
367 
368 enum {
369 	AXP803_DCDC1 = 0,
370 	AXP803_DCDC2,
371 	AXP803_DCDC3,
372 	AXP803_DCDC4,
373 	AXP803_DCDC5,
374 	AXP803_DCDC6,
375 	AXP803_DC1SW,
376 	AXP803_ALDO1,
377 	AXP803_ALDO2,
378 	AXP803_ALDO3,
379 	AXP803_DLDO1,
380 	AXP803_DLDO2,
381 	AXP803_DLDO3,
382 	AXP803_DLDO4,
383 	AXP803_ELDO1,
384 	AXP803_ELDO2,
385 	AXP803_ELDO3,
386 	AXP803_FLDO1,
387 	AXP803_FLDO2,
388 	AXP803_RTC_LDO,
389 	AXP803_LDO_IO0,
390 	AXP803_LDO_IO1,
391 	AXP803_REG_ID_MAX,
392 };
393 
394 enum {
395 	AXP813_DCDC1 = 0,
396 	AXP813_DCDC2,
397 	AXP813_DCDC3,
398 	AXP813_DCDC4,
399 	AXP813_DCDC5,
400 	AXP813_DCDC6,
401 	AXP813_DCDC7,
402 	AXP813_ALDO1,
403 	AXP813_ALDO2,
404 	AXP813_ALDO3,
405 	AXP813_DLDO1,
406 	AXP813_DLDO2,
407 	AXP813_DLDO3,
408 	AXP813_DLDO4,
409 	AXP813_ELDO1,
410 	AXP813_ELDO2,
411 	AXP813_ELDO3,
412 	AXP813_FLDO1,
413 	AXP813_FLDO2,
414 	AXP813_FLDO3,
415 	AXP813_RTC_LDO,
416 	AXP813_LDO_IO0,
417 	AXP813_LDO_IO1,
418 	AXP813_SW,
419 	AXP813_REG_ID_MAX,
420 };
421 
422 /* IRQs */
423 enum {
424 	AXP152_IRQ_LDO0IN_CONNECT = 1,
425 	AXP152_IRQ_LDO0IN_REMOVAL,
426 	AXP152_IRQ_ALDO0IN_CONNECT,
427 	AXP152_IRQ_ALDO0IN_REMOVAL,
428 	AXP152_IRQ_DCDC1_V_LOW,
429 	AXP152_IRQ_DCDC2_V_LOW,
430 	AXP152_IRQ_DCDC3_V_LOW,
431 	AXP152_IRQ_DCDC4_V_LOW,
432 	AXP152_IRQ_PEK_SHORT,
433 	AXP152_IRQ_PEK_LONG,
434 	AXP152_IRQ_TIMER,
435 	AXP152_IRQ_PEK_RIS_EDGE,
436 	AXP152_IRQ_PEK_FAL_EDGE,
437 	AXP152_IRQ_GPIO3_INPUT,
438 	AXP152_IRQ_GPIO2_INPUT,
439 	AXP152_IRQ_GPIO1_INPUT,
440 	AXP152_IRQ_GPIO0_INPUT,
441 };
442 
443 enum {
444 	AXP20X_IRQ_ACIN_OVER_V = 1,
445 	AXP20X_IRQ_ACIN_PLUGIN,
446 	AXP20X_IRQ_ACIN_REMOVAL,
447 	AXP20X_IRQ_VBUS_OVER_V,
448 	AXP20X_IRQ_VBUS_PLUGIN,
449 	AXP20X_IRQ_VBUS_REMOVAL,
450 	AXP20X_IRQ_VBUS_V_LOW,
451 	AXP20X_IRQ_BATT_PLUGIN,
452 	AXP20X_IRQ_BATT_REMOVAL,
453 	AXP20X_IRQ_BATT_ENT_ACT_MODE,
454 	AXP20X_IRQ_BATT_EXIT_ACT_MODE,
455 	AXP20X_IRQ_CHARG,
456 	AXP20X_IRQ_CHARG_DONE,
457 	AXP20X_IRQ_BATT_TEMP_HIGH,
458 	AXP20X_IRQ_BATT_TEMP_LOW,
459 	AXP20X_IRQ_DIE_TEMP_HIGH,
460 	AXP20X_IRQ_CHARG_I_LOW,
461 	AXP20X_IRQ_DCDC1_V_LONG,
462 	AXP20X_IRQ_DCDC2_V_LONG,
463 	AXP20X_IRQ_DCDC3_V_LONG,
464 	AXP20X_IRQ_PEK_SHORT = 22,
465 	AXP20X_IRQ_PEK_LONG,
466 	AXP20X_IRQ_N_OE_PWR_ON,
467 	AXP20X_IRQ_N_OE_PWR_OFF,
468 	AXP20X_IRQ_VBUS_VALID,
469 	AXP20X_IRQ_VBUS_NOT_VALID,
470 	AXP20X_IRQ_VBUS_SESS_VALID,
471 	AXP20X_IRQ_VBUS_SESS_END,
472 	AXP20X_IRQ_LOW_PWR_LVL1,
473 	AXP20X_IRQ_LOW_PWR_LVL2,
474 	AXP20X_IRQ_TIMER,
475 	AXP20X_IRQ_PEK_RIS_EDGE,
476 	AXP20X_IRQ_PEK_FAL_EDGE,
477 	AXP20X_IRQ_GPIO3_INPUT,
478 	AXP20X_IRQ_GPIO2_INPUT,
479 	AXP20X_IRQ_GPIO1_INPUT,
480 	AXP20X_IRQ_GPIO0_INPUT,
481 };
482 
483 enum axp22x_irqs {
484 	AXP22X_IRQ_ACIN_OVER_V = 1,
485 	AXP22X_IRQ_ACIN_PLUGIN,
486 	AXP22X_IRQ_ACIN_REMOVAL,
487 	AXP22X_IRQ_VBUS_OVER_V,
488 	AXP22X_IRQ_VBUS_PLUGIN,
489 	AXP22X_IRQ_VBUS_REMOVAL,
490 	AXP22X_IRQ_VBUS_V_LOW,
491 	AXP22X_IRQ_BATT_PLUGIN,
492 	AXP22X_IRQ_BATT_REMOVAL,
493 	AXP22X_IRQ_BATT_ENT_ACT_MODE,
494 	AXP22X_IRQ_BATT_EXIT_ACT_MODE,
495 	AXP22X_IRQ_CHARG,
496 	AXP22X_IRQ_CHARG_DONE,
497 	AXP22X_IRQ_BATT_TEMP_HIGH,
498 	AXP22X_IRQ_BATT_TEMP_LOW,
499 	AXP22X_IRQ_DIE_TEMP_HIGH,
500 	AXP22X_IRQ_PEK_SHORT,
501 	AXP22X_IRQ_PEK_LONG,
502 	AXP22X_IRQ_LOW_PWR_LVL1,
503 	AXP22X_IRQ_LOW_PWR_LVL2,
504 	AXP22X_IRQ_TIMER,
505 	AXP22X_IRQ_PEK_RIS_EDGE,
506 	AXP22X_IRQ_PEK_FAL_EDGE,
507 	AXP22X_IRQ_GPIO1_INPUT,
508 	AXP22X_IRQ_GPIO0_INPUT,
509 };
510 
511 enum axp288_irqs {
512 	AXP288_IRQ_VBUS_FALL     = 2,
513 	AXP288_IRQ_VBUS_RISE,
514 	AXP288_IRQ_OV,
515 	AXP288_IRQ_FALLING_ALT,
516 	AXP288_IRQ_RISING_ALT,
517 	AXP288_IRQ_OV_ALT,
518 	AXP288_IRQ_DONE          = 10,
519 	AXP288_IRQ_CHARGING,
520 	AXP288_IRQ_SAFE_QUIT,
521 	AXP288_IRQ_SAFE_ENTER,
522 	AXP288_IRQ_ABSENT,
523 	AXP288_IRQ_APPEND,
524 	AXP288_IRQ_QWBTU,
525 	AXP288_IRQ_WBTU,
526 	AXP288_IRQ_QWBTO,
527 	AXP288_IRQ_WBTO,
528 	AXP288_IRQ_QCBTU,
529 	AXP288_IRQ_CBTU,
530 	AXP288_IRQ_QCBTO,
531 	AXP288_IRQ_CBTO,
532 	AXP288_IRQ_WL2,
533 	AXP288_IRQ_WL1,
534 	AXP288_IRQ_GPADC,
535 	AXP288_IRQ_OT            = 31,
536 	AXP288_IRQ_GPIO0,
537 	AXP288_IRQ_GPIO1,
538 	AXP288_IRQ_POKO,
539 	AXP288_IRQ_POKL,
540 	AXP288_IRQ_POKS,
541 	AXP288_IRQ_POKN,
542 	AXP288_IRQ_POKP,
543 	AXP288_IRQ_TIMER,
544 	AXP288_IRQ_MV_CHNG,
545 	AXP288_IRQ_BC_USB_CHNG,
546 };
547 
548 enum axp803_irqs {
549 	AXP803_IRQ_ACIN_OVER_V = 1,
550 	AXP803_IRQ_ACIN_PLUGIN,
551 	AXP803_IRQ_ACIN_REMOVAL,
552 	AXP803_IRQ_VBUS_OVER_V,
553 	AXP803_IRQ_VBUS_PLUGIN,
554 	AXP803_IRQ_VBUS_REMOVAL,
555 	AXP803_IRQ_BATT_PLUGIN,
556 	AXP803_IRQ_BATT_REMOVAL,
557 	AXP803_IRQ_BATT_ENT_ACT_MODE,
558 	AXP803_IRQ_BATT_EXIT_ACT_MODE,
559 	AXP803_IRQ_CHARG,
560 	AXP803_IRQ_CHARG_DONE,
561 	AXP803_IRQ_BATT_CHG_TEMP_HIGH,
562 	AXP803_IRQ_BATT_CHG_TEMP_HIGH_END,
563 	AXP803_IRQ_BATT_CHG_TEMP_LOW,
564 	AXP803_IRQ_BATT_CHG_TEMP_LOW_END,
565 	AXP803_IRQ_BATT_ACT_TEMP_HIGH,
566 	AXP803_IRQ_BATT_ACT_TEMP_HIGH_END,
567 	AXP803_IRQ_BATT_ACT_TEMP_LOW,
568 	AXP803_IRQ_BATT_ACT_TEMP_LOW_END,
569 	AXP803_IRQ_DIE_TEMP_HIGH,
570 	AXP803_IRQ_GPADC,
571 	AXP803_IRQ_LOW_PWR_LVL1,
572 	AXP803_IRQ_LOW_PWR_LVL2,
573 	AXP803_IRQ_TIMER,
574 	AXP803_IRQ_PEK_RIS_EDGE,
575 	AXP803_IRQ_PEK_FAL_EDGE,
576 	AXP803_IRQ_PEK_SHORT,
577 	AXP803_IRQ_PEK_LONG,
578 	AXP803_IRQ_PEK_OVER_OFF,
579 	AXP803_IRQ_GPIO1_INPUT,
580 	AXP803_IRQ_GPIO0_INPUT,
581 	AXP803_IRQ_BC_USB_CHNG,
582 	AXP803_IRQ_MV_CHNG,
583 };
584 
585 enum axp806_irqs {
586 	AXP806_IRQ_DIE_TEMP_HIGH_LV1,
587 	AXP806_IRQ_DIE_TEMP_HIGH_LV2,
588 	AXP806_IRQ_DCDCA_V_LOW,
589 	AXP806_IRQ_DCDCB_V_LOW,
590 	AXP806_IRQ_DCDCC_V_LOW,
591 	AXP806_IRQ_DCDCD_V_LOW,
592 	AXP806_IRQ_DCDCE_V_LOW,
593 	AXP806_IRQ_POK_LONG,
594 	AXP806_IRQ_POK_SHORT,
595 	AXP806_IRQ_WAKEUP,
596 	AXP806_IRQ_POK_FALL,
597 	AXP806_IRQ_POK_RISE,
598 };
599 
600 enum axp809_irqs {
601 	AXP809_IRQ_ACIN_OVER_V = 1,
602 	AXP809_IRQ_ACIN_PLUGIN,
603 	AXP809_IRQ_ACIN_REMOVAL,
604 	AXP809_IRQ_VBUS_OVER_V,
605 	AXP809_IRQ_VBUS_PLUGIN,
606 	AXP809_IRQ_VBUS_REMOVAL,
607 	AXP809_IRQ_VBUS_V_LOW,
608 	AXP809_IRQ_BATT_PLUGIN,
609 	AXP809_IRQ_BATT_REMOVAL,
610 	AXP809_IRQ_BATT_ENT_ACT_MODE,
611 	AXP809_IRQ_BATT_EXIT_ACT_MODE,
612 	AXP809_IRQ_CHARG,
613 	AXP809_IRQ_CHARG_DONE,
614 	AXP809_IRQ_BATT_CHG_TEMP_HIGH,
615 	AXP809_IRQ_BATT_CHG_TEMP_HIGH_END,
616 	AXP809_IRQ_BATT_CHG_TEMP_LOW,
617 	AXP809_IRQ_BATT_CHG_TEMP_LOW_END,
618 	AXP809_IRQ_BATT_ACT_TEMP_HIGH,
619 	AXP809_IRQ_BATT_ACT_TEMP_HIGH_END,
620 	AXP809_IRQ_BATT_ACT_TEMP_LOW,
621 	AXP809_IRQ_BATT_ACT_TEMP_LOW_END,
622 	AXP809_IRQ_DIE_TEMP_HIGH,
623 	AXP809_IRQ_LOW_PWR_LVL1,
624 	AXP809_IRQ_LOW_PWR_LVL2,
625 	AXP809_IRQ_TIMER,
626 	AXP809_IRQ_PEK_RIS_EDGE,
627 	AXP809_IRQ_PEK_FAL_EDGE,
628 	AXP809_IRQ_PEK_SHORT,
629 	AXP809_IRQ_PEK_LONG,
630 	AXP809_IRQ_PEK_OVER_OFF,
631 	AXP809_IRQ_GPIO1_INPUT,
632 	AXP809_IRQ_GPIO0_INPUT,
633 };
634 
635 struct axp20x_dev {
636 	struct device			*dev;
637 	int				irq;
638 	unsigned long			irq_flags;
639 	struct regmap			*regmap;
640 	struct regmap_irq_chip_data	*regmap_irqc;
641 	long				variant;
642 	int                             nr_cells;
643 	const struct mfd_cell           *cells;
644 	const struct regmap_config	*regmap_cfg;
645 	const struct regmap_irq_chip	*regmap_irq_chip;
646 };
647 
648 /* generic helper function for reading 9-16 bit wide regs */
axp20x_read_variable_width(struct regmap * regmap,unsigned int reg,unsigned int width)649 static inline int axp20x_read_variable_width(struct regmap *regmap,
650 	unsigned int reg, unsigned int width)
651 {
652 	unsigned int reg_val, result;
653 	int err;
654 
655 	err = regmap_read(regmap, reg, &reg_val);
656 	if (err)
657 		return err;
658 
659 	result = reg_val << (width - 8);
660 
661 	err = regmap_read(regmap, reg + 1, &reg_val);
662 	if (err)
663 		return err;
664 
665 	result |= reg_val;
666 
667 	return result;
668 }
669 
670 /**
671  * axp20x_match_device(): Setup axp20x variant related fields
672  *
673  * @axp20x: axp20x device to setup (.dev field must be set)
674  * @dev: device associated with this axp20x device
675  *
676  * This lets the axp20x core configure the mfd cells and register maps
677  * for later use.
678  */
679 int axp20x_match_device(struct axp20x_dev *axp20x);
680 
681 /**
682  * axp20x_device_probe(): Probe a configured axp20x device
683  *
684  * @axp20x: axp20x device to probe (must be configured)
685  *
686  * This function lets the axp20x core register the axp20x mfd devices
687  * and irqchip. The axp20x device passed in must be fully configured
688  * with axp20x_match_device, its irq set, and regmap created.
689  */
690 int axp20x_device_probe(struct axp20x_dev *axp20x);
691 
692 /**
693  * axp20x_device_remove(): Remove a axp20x device
694  *
695  * @axp20x: axp20x device to remove
696  *
697  * This tells the axp20x core to remove the associated mfd devices
698  */
699 int axp20x_device_remove(struct axp20x_dev *axp20x);
700 
701 #endif /* __LINUX_MFD_AXP20X_H */
702