summaryrefslogtreecommitdiff
path: root/firmware/export/axp192-defs.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export/axp192-defs.h')
-rw-r--r--firmware/export/axp192-defs.h308
1 files changed, 308 insertions, 0 deletions
diff --git a/firmware/export/axp192-defs.h b/firmware/export/axp192-defs.h
new file mode 100644
index 0000000000..13b465351b
--- /dev/null
+++ b/firmware/export/axp192-defs.h
@@ -0,0 +1,308 @@
1/* Internal header for axp192 driver - not for general inclusion */
2
3#ifndef DEFREG
4# define DEFREG(...)
5#endif
6#ifndef DEFFLD
7# define DEFFLD(...)
8#endif
9
10#define DEFBIT(regname, fldname, bitpos, ...) \
11 DEFFLD(regname, fldname, bitpos, bitpos, __VA_ARGS__)
12
13DEFREG(PWRSTS, 0x00)
14DEFREG(CHGSTS, 0x01)
15DEFREG(CHIPID, 0x03)
16DEFREG(VBUSSTS, 0x04)
17DEFREG(DATA0, 0x06)
18DEFREG(DATA1, 0x07)
19DEFREG(DATA2, 0x08)
20DEFREG(DATA3, 0x09)
21DEFREG(DATA4, 0x0a)
22DEFREG(DATA5, 0x0b)
23DEFREG(PWRCTL1, 0x10)
24DEFREG(PWRCTL2, 0x12)
25DEFREG(DCDC2VOLT, 0x23)
26DEFREG(DCDC2RAMP, 0x25)
27DEFREG(DCDC1VOLT, 0x26)
28DEFREG(DCDC3VOLT, 0x27)
29DEFREG(LDO2LDO3VOLT, 0x28)
30DEFREG(VBUSIPSOUT, 0x30)
31DEFREG(VOFF, 0x31)
32DEFREG(PWROFF, 0x32)
33DEFREG(CHGCTL1, 0x33)
34DEFREG(CHGCTL2, 0x34)
35DEFREG(BKPCHGCTL, 0x35)
36DEFREG(PEKPARAM, 0x36)
37DEFREG(DCDCFREQ, 0x37)
38DEFREG(VLTFCHG, 0x38)
39DEFREG(VHTFCHG, 0x39)
40DEFREG(APSLOW1, 0x3a)
41DEFREG(APSLOW2, 0x3b)
42DEFREG(VLTFDCHG, 0x3c)
43DEFREG(VHTFDCHG, 0x3d)
44DEFREG(IRQEN1, 0x40)
45DEFREG(IRQEN2, 0x41)
46DEFREG(IRQEN3, 0x42)
47DEFREG(IRQEN4, 0x43)
48DEFREG(IRQSTS1, 0x44)
49DEFREG(IRQSTS2, 0x45)
50DEFREG(IRQSTS3, 0x46)
51DEFREG(IRQSTS4, 0x47)
52DEFREG(IRQEN5, 0x4a)
53DEFREG(IRQSTS5, 0x4d)
54DEFREG(DCDCMODE, 0x80)
55DEFREG(ADCEN1, 0x82)
56DEFREG(ADCEN2, 0x83)
57DEFREG(ADCCTL, 0x84)
58DEFREG(ADCRANGE, 0x85)
59DEFREG(TIMERCTL, 0x8a)
60DEFREG(VBUSSRP, 0x8b)
61DEFREG(OTPOWEROFF, 0x8f)
62DEFREG(GPIO0FUNC, 0x90)
63DEFREG(GPIO0LDO, 0x91)
64DEFREG(GPIO1FUNC, 0x92)
65DEFREG(GPIO2FUNC, 0x93)
66DEFREG(GPIOLEVEL1, 0x94)
67DEFREG(GPIO3GPIO4FUNC, 0x95)
68DEFREG(GPIOLEVEL2, 0x96)
69DEFREG(GPIOPULL, 0x97)
70DEFREG(PWM1X, 0x98)
71DEFREG(PWM1Y1, 0x99)
72DEFREG(PWM1Y2, 0x9a)
73DEFREG(PWM2X, 0x9b)
74DEFREG(PWM2Y1, 0x9c)
75DEFREG(PWM2Y2, 0x9d)
76DEFREG(NRSTO, 0x9e)
77DEFREG(CC_CTL, 0xb8)
78
79DEFBIT(PWRSTS, ACIN_PRESENT, 7)
80DEFBIT(PWRSTS, ACIN_VALID, 6)
81DEFBIT(PWRSTS, VBUS_PRESENT, 5)
82DEFBIT(PWRSTS, VBUS_VALID, 4)
83DEFBIT(PWRSTS, VBUS_VHOLD, 3)
84DEFBIT(PWRSTS, BATT_CURR_DIR, 2)
85DEFBIT(PWRSTS, PCB_SHORTED, 1)
86DEFBIT(PWRSTS, BOOT_TRIG, 0)
87
88DEFBIT(VBUSSTS, VALID, 2)
89DEFBIT(VBUSSTS, SESS_AB_VALID, 1)
90DEFBIT(VBUSSTS, SESS_END, 0)
91
92DEFBIT(CHGSTS, OVER_TEMP, 7)
93DEFBIT(CHGSTS, CHARGING, 6)
94DEFBIT(CHGSTS, BATT_PRESENT, 5)
95DEFBIT(CHGSTS, BATT_ERROR, 3)
96DEFBIT(CHGSTS, LOW_CHARGE, 2)
97
98/* NOTE: These two bits are mirrored in the upper nibble of PWRCTL2.
99 * Modifications through one register will immediately reflect in the
100 * other register. */
101DEFBIT(PWRCTL1, EXTEN_SW, 2)
102DEFBIT(PWRCTL1, DCDC2_SW, 0)
103
104DEFBIT(PWRCTL2, EXTEN_SW, 6)
105DEFBIT(PWRCTL2, DCDC2_SW, 4)
106DEFBIT(PWRCTL2, LDO3_SW, 3)
107DEFBIT(PWRCTL2, LDO2_SW, 2)
108DEFBIT(PWRCTL2, DCDC3_SW, 1)
109DEFBIT(PWRCTL2, DCDC1_SW, 0)
110
111DEFFLD(DCDC2VOLT, VALUE, 5, 0)
112
113DEFBIT(DCDC2RAMP, ENABLE, 2)
114DEFBIT(DCDC2RAMP, SLOPE, 0)
115
116DEFFLD(DCDC1VOLT, VALUE, 6, 0)
117DEFFLD(DCDC3VOLT, VALUE, 6, 0)
118
119DEFFLD(LDO2LDO3VOLT, LDO2_VALUE, 7, 4)
120DEFFLD(LDO2LDO3VOLT, LDO3_VALUE, 3, 0)
121
122DEFBIT(VBUSIPSOUT, ACCESS, 7)
123DEFBIT(VBUSIPSOUT, VHOLD_LIM, 6)
124DEFFLD(VBUSIPSOUT, VHOLD_LEV, 5, 3)
125DEFBIT(VBUSIPSOUT, VBUS_LIM, 1)
126DEFBIT(VBUSIPSOUT, LIM_100mA, 0)
127
128DEFFLD(VOFF, VALUE, 3, 0)
129
130DEFBIT(PWROFF, SHUTDOWN, 7)
131DEFBIT(PWROFF, MON_EN, 6)
132DEFFLD(PWROFF, LEDFUNC, 5, 4)
133DEFBIT(PWROFF, LEDCTL, 3)
134DEFBIT(PWROFF, DELAY, 1, 0)
135
136DEFBIT(CHGCTL1, CHARGE_EN, 7)
137DEFFLD(CHGCTL1, CHARGE_TGT, 6, 5)
138DEFBIT(CHGCTL1, CHARGE_ENDCURR, 4)
139DEFFLD(CHGCTL1, CHARGE_CURRENT, 3, 0)
140
141DEFFLD(CHGCTL2, PRECHARGE_OT, 7, 6)
142DEFFLD(CHGCTL2, EACCESS_CURRENT, 5, 3)
143DEFBIT(CHGCTL2, EACCESS_CHG_EN, 2)
144DEFFLD(CHGCTL2, CONST_CURR_OT, 1, 0)
145
146DEFBIT(BKPCHGCTL, ENABLE, 7)
147DEFFLD(BKPCHGCTL, TGT_VOLTAGE, 6, 5)
148DEFFLD(BKPCHGCTL, CHARGE_CURRENT, 1, 0)
149
150DEFFLD(PEKPARAM, POWER_ON_TIME, 7, 6)
151DEFFLD(PEKPARAM, LONG_TIME, 5, 4)
152DEFBIT(PEKPARAM, POWEROFF_EN, 3)
153DEFBIT(PEKPARAM, PWROK_DELAY, 2)
154DEFFLD(PEKPARAM, POWEROFF_TIME, 1, 0)
155
156DEFFLD(DCDCFREQ, VALUE, 3, 0)
157DEFFLD(VLTFCHG, VALUE, 7, 0)
158DEFFLD(VHTFCHG, VALUE, 7, 0)
159DEFFLD(APSLOW1, VALUE, 7, 0)
160DEFFLD(APSLOW2, VALUE, 7, 0)
161DEFFLD(VLTFDCHG, VALUE, 7, 0)
162DEFFLD(VHTFDCHG, VALUE, 7, 0)
163
164DEFBIT(IRQEN1, ACIN_OVER_VOLTAGE, 7)
165DEFBIT(IRQEN1, ACIN_INSERT, 6)
166DEFBIT(IRQEN1, ACIN_REMOVE, 5)
167DEFBIT(IRQEN1, VBUS_OVER_VOLTAGE, 4)
168DEFBIT(IRQEN1, VBUS_INSERT, 3)
169DEFBIT(IRQEN1, VBUS_REMOVE, 2)
170DEFBIT(IRQEN1, VBUS_BELOW_VHOLD, 1)
171DEFBIT(IRQEN2, BATTERY_INSERT, 7)
172DEFBIT(IRQEN2, BATTERY_REMOVE, 6)
173DEFBIT(IRQEN2, BATTERY_ERROR, 5)
174DEFBIT(IRQEN2, BATTERY_ERROR_CLR, 4)
175DEFBIT(IRQEN2, CHARGING_STARTED, 3)
176DEFBIT(IRQEN2, CHARGING_COMPLETE, 2)
177DEFBIT(IRQEN2, BATTERY_OVER_TEMP, 1)
178DEFBIT(IRQEN2, BATTERY_UNDER_TEMP, 0)
179DEFBIT(IRQEN3, INTERNAL_OVER_TEMP, 7)
180DEFBIT(IRQEN3, LOW_CHARGE_CURRENT, 6)
181DEFBIT(IRQEN3, DCDC1_UNDER_VOLT, 5)
182DEFBIT(IRQEN3, DCDC2_UNDER_VOLT, 4)
183DEFBIT(IRQEN3, DCDC3_UNDER_VOLT, 3)
184DEFBIT(IRQEN3, SHORT_PRESS, 1)
185DEFBIT(IRQEN3, LONG_PRESS, 0)
186DEFBIT(IRQEN4, POWER_ON_N_OE, 7)
187DEFBIT(IRQEN4, POWER_OFF_N_OE, 6)
188DEFBIT(IRQEN4, VBUS_VALID, 5)
189DEFBIT(IRQEN4, VBUS_INVALID, 4)
190DEFBIT(IRQEN4, VBUS_SESS_AB, 3)
191DEFBIT(IRQEN4, VBUS_SESS_END, 2)
192DEFBIT(IRQEN4, APS_UNDER_VOLT, 0)
193
194DEFBIT(IRQSTS1, ACIN_OVER_VOLTAGE, 7)
195DEFBIT(IRQSTS1, ACIN_INSERT, 6)
196DEFBIT(IRQSTS1, ACIN_REMOVE, 5)
197DEFBIT(IRQSTS1, VBUS_OVER_VOLTAGE, 4)
198DEFBIT(IRQSTS1, VBUS_INSERT, 3)
199DEFBIT(IRQSTS1, VBUS_REMOVE, 2)
200DEFBIT(IRQSTS1, VBUS_BELOW_VHOLD, 1)
201DEFBIT(IRQSTS2, BATTERY_INSERT, 7)
202DEFBIT(IRQSTS2, BATTERY_REMOVE, 6)
203DEFBIT(IRQSTS2, BATTERY_ERROR, 5)
204DEFBIT(IRQSTS2, BATTERY_ERROR_CLR, 4)
205DEFBIT(IRQSTS2, CHARGING_STARTED, 3)
206DEFBIT(IRQSTS2, CHARGING_STOPPED, 2)
207DEFBIT(IRQSTS2, BATTERY_OVER_TEMP, 1)
208DEFBIT(IRQSTS2, BATTERY_UNDER_TEMP, 0)
209DEFBIT(IRQSTS3, INTERNAL_OVER_TEMP, 7)
210DEFBIT(IRQSTS3, LOW_CHARGE_CURRENT, 6)
211DEFBIT(IRQSTS3, DCDC1_UNDER_VOLT, 5)
212DEFBIT(IRQSTS3, DCDC2_UNDER_VOLT, 4)
213DEFBIT(IRQSTS3, DCDC3_UNDER_VOLT, 3)
214DEFBIT(IRQSTS3, SHORT_PRESS, 1)
215DEFBIT(IRQSTS3, LONG_PRESS, 0)
216DEFBIT(IRQSTS4, POWER_ON_N_OE, 7)
217DEFBIT(IRQSTS4, POWER_OFF_N_OE, 6)
218DEFBIT(IRQSTS4, VBUS_VALID, 5)
219DEFBIT(IRQSTS4, VBUS_INVALID, 4)
220DEFBIT(IRQSTS4, VBUS_SESS_AB, 3)
221DEFBIT(IRQSTS4, VBUS_SESS_END, 2)
222DEFBIT(IRQSTS4, APS_UNDER_VOLT, 0)
223
224/* NOTE: IRQEN5 and IRQSTS5 are only listed on the Chinese datasheet. */
225DEFBIT(IRQEN5, TIME_OUT, 7)
226DEFBIT(IRQEN5, GPIO2_CHANGE, 2)
227DEFBIT(IRQEN5, GPIO1_CHANGE, 1)
228DEFBIT(IRQEN5, GPIO0_CHANGE, 0)
229
230DEFBIT(IRQSTS5, TIME_OUT, 7)
231DEFBIT(IRQSTS5, GPIO2_CHANGE, 2)
232DEFBIT(IRQSTS5, GPIO1_CHANGE, 1)
233DEFBIT(IRQSTS5, GPIO0_CHANGE, 0)
234
235DEFFLD(DCDCMODE, VALUE, 3, 1)
236
237DEFBIT(ADCEN1, BATTERY_VOLTAGE, 7)
238DEFBIT(ADCEN1, BATTERY_CURRENT, 6)
239DEFBIT(ADCEN1, ACIN_VOLTAGE, 5)
240DEFBIT(ADCEN1, ACIN_CURRENT, 4)
241DEFBIT(ADCEN1, VBUS_VOLTAGE, 3)
242DEFBIT(ADCEN1, VBUS_CURRENT, 2)
243DEFBIT(ADCEN1, APS_VOLTAGE, 1)
244DEFBIT(ADCEN1, TS_PIN, 0)
245
246DEFBIT(ADCEN2, INTERNAL_TEMP, 7)
247DEFBIT(ADCEN2, GPIO0, 3)
248DEFBIT(ADCEN2, GPIO1, 2)
249DEFBIT(ADCEN2, GPIO2, 1)
250DEFBIT(ADCEN2, GPIO3, 0)
251
252DEFFLD(ADCCTL, SAMPLE_RATE, 7, 6)
253DEFFLD(ADCCTL, TS_OUT_CURR, 5, 4)
254DEFBIT(ADCCTL, TS_FUNCTION, 2)
255DEFFLD(ADCCTL, TS_OUT_MODE, 1, 0)
256
257DEFBIT(ADCRANGE, GPIO3HIGH, 3)
258DEFBIT(ADCRANGE, GPIO2HIGH, 2)
259DEFBIT(ADCRANGE, GPIO1HIGH, 1)
260DEFBIT(ADCRANGE, GPIO0HIGH, 0)
261
262DEFBIT(TIMERCTL, TIMEOUT, 7)
263DEFFLD(TIMERCTL, DURATION, 6, 0)
264
265DEFFLD(VBUSSRP, VBUSVALID_VOLTAGE, 5, 4)
266DEFBIT(VBUSSRP, VBUSVALID_MONITOR, 3)
267DEFBIT(VBUSSRP, VBUS_SESS_MONITOR, 2)
268DEFBIT(VBUSSRP, VBUS_DCHG_RESISTOR, 1)
269DEFBIT(VBUSSRP, VBUS_CHG_RESISTOR, 0)
270
271DEFBIT(OTPOWEROFF, ENABLE, 2)
272
273DEFFLD(GPIO0FUNC, VALUE, 2, 0)
274DEFFLD(GPIO0LDO, VALUE, 7, 4)
275DEFFLD(GPIO1FUNC, VALUE, 2, 0)
276DEFFLD(GPIO2FUNC, VALUE, 2, 0)
277
278DEFBIT(GPIOLEVEL1, IN2, 6)
279DEFBIT(GPIOLEVEL1, IN1, 5)
280DEFBIT(GPIOLEVEL1, IN0, 4)
281DEFBIT(GPIOLEVEL1, OUT2, 2)
282DEFBIT(GPIOLEVEL1, OUT1, 1)
283DEFBIT(GPIOLEVEL1, OUT0, 0)
284
285DEFFLD(GPIO3GPIO4FUNC, FUNC3, 3, 2)
286DEFFLD(GPIO3GPIO4FUNC, FUNC4, 1, 0)
287
288DEFBIT(GPIOLEVEL2, IN4, 5)
289DEFBIT(GPIOLEVEL2, IN3, 4)
290DEFBIT(GPIOLEVEL2, OUT4, 1)
291DEFBIT(GPIOLEVEL2, OUT3, 0)
292
293DEFBIT(GPIOPULL, PULL2, 2)
294DEFBIT(GPIOPULL, PULL1, 1)
295DEFBIT(GPIOPULL, PULL0, 0)
296
297DEFBIT(NRSTO, FUNC, 7)
298DEFBIT(NRSTO, GPIO_DIR, 6)
299DEFBIT(NRSTO, GPIO_OUT, 5)
300DEFBIT(NRSTO, GPIO_IN, 4)
301
302DEFBIT(CC_CTL, OPEN, 7)
303DEFBIT(CC_CTL, PAUSE, 6)
304DEFBIT(CC_CTL, CLEAR, 5)
305
306#undef DEFBIT
307#undef DEFFLD
308#undef DEFREG