summaryrefslogtreecommitdiff
path: root/firmware/export/mc13783.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export/mc13783.h')
-rw-r--r--firmware/export/mc13783.h90
1 files changed, 58 insertions, 32 deletions
diff --git a/firmware/export/mc13783.h b/firmware/export/mc13783.h
index 6ad34346df..d427830786 100644
--- a/firmware/export/mc13783.h
+++ b/firmware/export/mc13783.h
@@ -1256,9 +1256,6 @@ enum mc13783_regs_enum
1256#define MC13783_TC3PERIOD_POS (21) 1256#define MC13783_TC3PERIOD_POS (21)
1257#define MC13783_TC3TRIODE (0x1 << 23) 1257#define MC13783_TC3TRIODE (0x1 << 23)
1258 1258
1259/* For event enum values which are target-defined */
1260#include "mc13783-target.h"
1261
1262void mc13783_init(void); 1259void mc13783_init(void);
1263void mc13783_close(void); 1260void mc13783_close(void);
1264uint32_t mc13783_set(unsigned address, uint32_t bits); 1261uint32_t mc13783_set(unsigned address, uint32_t bits);
@@ -1296,7 +1293,7 @@ enum mc13783_int_ids
1296 MC13783_INT_ID_CHGSHORT = 9, 1293 MC13783_INT_ID_CHGSHORT = 9,
1297 MC13783_INT_ID_CCCV = 10, 1294 MC13783_INT_ID_CCCV = 10,
1298 MC13783_INT_ID_CHGCURR = 11, 1295 MC13783_INT_ID_CHGCURR = 11,
1299 MC13783_INT_ID_BPONI = 12, 1296 MC13783_INT_ID_BPON = 12,
1300 MC13783_INT_ID_LOBATL = 13, 1297 MC13783_INT_ID_LOBATL = 13,
1301 MC13783_INT_ID_LOBATH = 14, 1298 MC13783_INT_ID_LOBATH = 14,
1302 MC13783_INT_ID_UDP = 15, 1299 MC13783_INT_ID_UDP = 15,
@@ -1306,41 +1303,70 @@ enum mc13783_int_ids
1306 MC13783_INT_ID_CKDET = 22, 1303 MC13783_INT_ID_CKDET = 22,
1307 MC13783_INT_ID_UDM = 23, 1304 MC13783_INT_ID_UDM = 23,
1308 /* *STATUS1/MASK1/SENSE1 */ 1305 /* *STATUS1/MASK1/SENSE1 */
1309 MC13783_INT_ID_1HZ = 0 + 0x20, 1306 MC13783_INT_ID_1HZ = 0 + 32,
1310 MC13783_INT_ID_TODA = 1 + 0x20, 1307 MC13783_INT_ID_TODA = 1 + 32,
1311 MC13783_INT_ID_ONOFD1 = 3 + 0x20, /* ON1B */ 1308 MC13783_INT_ID_ONOFD1 = 3 + 32, /* ON1B */
1312 MC13783_INT_ID_ONOFD2 = 4 + 0x20, /* ON2B */ 1309 MC13783_INT_ID_ONOFD2 = 4 + 32, /* ON2B */
1313 MC13783_INT_ID_ONOFD3 = 5 + 0x20, /* ON3B */ 1310 MC13783_INT_ID_ONOFD3 = 5 + 32, /* ON3B */
1314 MC13783_INT_ID_SYSRST = 6 + 0x20, 1311 MC13783_INT_ID_SYSRST = 6 + 32,
1315 MC13783_INT_ID_RTCRST = 7 + 0x20, 1312 MC13783_INT_ID_RTCRST = 7 + 32,
1316 MC13783_INT_ID_PCI = 8 + 0x20, 1313 MC13783_INT_ID_PCI = 8 + 32,
1317 MC13783_INT_ID_WARM = 9 + 0x20, 1314 MC13783_INT_ID_WARM = 9 + 32,
1318 MC13783_INT_ID_MEMHLD = 10 + 0x20, 1315 MC13783_INT_ID_MEMHLD = 10 + 32,
1319 MC13783_INT_ID_PWRRDY = 11 + 0x20, 1316 MC13783_INT_ID_PWRRDY = 11 + 32,
1320 MC13783_INT_ID_THWARNL = 12 + 0x20, 1317 MC13783_INT_ID_THWARNL = 12 + 32,
1321 MC13783_INT_ID_THWARNH = 13 + 0x20, 1318 MC13783_INT_ID_THWARNH = 13 + 32,
1322 MC13783_INT_ID_CLK = 14 + 0x20, 1319 MC13783_INT_ID_CLK = 14 + 32,
1323 MC13783_INT_ID_SEMAF = 15 + 0x20, 1320 MC13783_INT_ID_SEMAF = 15 + 32,
1324 MC13783_INT_ID_MC2B = 17 + 0x20, 1321 MC13783_INT_ID_MC2B = 17 + 32,
1325 MC13783_INT_ID_HSDET = 18 + 0x20, 1322 MC13783_INT_ID_HSDET = 18 + 32,
1326 MC13783_INT_ID_HSL = 19 + 0x20, 1323 MC13783_INT_ID_HSL = 19 + 32,
1327 MC13783_INT_ID_ALSPTH = 20 + 0x20, 1324 MC13783_INT_ID_ALSPTH = 20 + 32,
1328 MC13783_INT_ID_AHSSHORT = 21 + 0x20, 1325 MC13783_INT_ID_AHSSHORT = 21 + 32,
1329}; 1326};
1330 1327
1331#define MC13783_INT_ID_SET_DIV (0x20) 1328#ifdef DEFINE_MC13783_VECTOR_TABLE
1332#define MC13783_INT_ID_NUM_MASK (0x1f)
1333 1329
1334struct mc13783_event 1330struct mc13783_event
1335{ 1331{
1336 enum mc13783_int_ids int_id : 8; 1332 uint32_t id : 8; /* MC13783_INT_ID_x */
1337 uint32_t sense : 24; 1333 uint32_t sense : 24; /* MC13783_xS */
1338 void (*callback)(void); 1334 void (*callback)(void); /* MC13783_EVENT_CB_x */
1339}; 1335};
1340 1336
1341void mc13783_enable_event(enum mc13783_event_ids id, bool enable); 1337/* Declares vector table. Order-implied priority */
1338#define MC13783_EVENT_VECTOR_TBL_START() \
1339 static FORCE_INLINE uintptr_t __mc13783_event_vector_tbl(int __what) \
1340 { \
1341 static const struct mc13783_event __tbl[] = {
1342
1343#define MC13783_EVENT_VECTOR(__name, __sense) \
1344 { .id = MC13783_INT_ID_##__name, \
1345 .sense = (__sense), \
1346 .callback = ({ void MC13783_EVENT_CB_##__name(void); \
1347 MC13783_EVENT_CB_##__name; }) },
1348
1349#define MC13783_EVENT_VECTOR_TBL_END() \
1350 }; \
1351 switch (__what) \
1352 { \
1353 default: return (uintptr_t)__tbl; \
1354 case 1: return (uintptr_t)ARRAYLEN(__tbl); \
1355 } \
1356 }
1357
1358#define mc13783_event_vector_tbl \
1359 ((const struct mc13783_event *)__mc13783_event_vector_tbl(0))
1360
1361#define mc13783_event_vector_tbl_len \
1362 ((unsigned int)__mc13783_event_vector_tbl(1))
1363
1364#endif /* DEFINE_MC13783_VECTOR_TABLE */
1365
1366void mc13783_enable_event(enum mc13783_int_ids id, bool enable);
1342 1367
1343/* Read the sense bit if one exists - valid only within event handlers */ 1368/* Read the sense bit(s) if configured - valid only within the respective
1344uint32_t mc13783_event_sense(enum mc13783_event_ids id); 1369 event handler */
1370uint32_t mc13783_event_sense(void);
1345 1371
1346#endif /* _MC13783_H_ */ 1372#endif /* _MC13783_H_ */