diff target-utils/libbase/abbdrv.c @ 499:44a1de4264d8

target-utils: added support for secret register page 2 of Iota ABB
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 25 May 2019 22:20:34 +0000
parents 74610c4f10f7
children a04a145098f1
line wrap: on
line diff
--- a/target-utils/libbase/abbdrv.c	Sat May 25 21:30:23 2019 +0000
+++ b/target-utils/libbase/abbdrv.c	Sat May 25 22:20:34 2019 +0000
@@ -24,8 +24,8 @@
 #include "types.h"
 #include "abbdefs.h"
 
-/* TWL3025 */
-#define REG_PAGE(n)	((n) >> 7)
+/* TWL3025, modified for page 2 support */
+#define REG_PAGE(n)	((n) >> 6)
 #define REG_ADDR(n)	((n) & 0x1f)
 
 #define TWL3025_DEV_IDX		0	/* On the SPI bus */
@@ -70,10 +70,18 @@
 /* Switch the register page of the TWL3025 */
 abb_select_page(page)
 {
-	if (page == 0)
+	switch (page) {
+	case 0:
 		abb_reg_write(PAGEREG, 1 << 0);
-	else
+		break;
+	case 1:
 		abb_reg_write(PAGEREG, 1 << 1);
+		break;
+	case 2:
+		/* not documented in datasheet, learned from TCS211 code */
+		abb_reg_write(PAGEREG, 1 << 4);
+		break;
+	}
 	abb_state_page = page;
 	return(0);
 }
@@ -97,6 +105,13 @@
 }
 
 void
+abb_unlock_page2()
+{
+	abb_reg_write(TAPCTRL, 0x01);
+	abb_reg_write(TAPREG,  0x1B);
+}
+
+void
 abb_power_off()
 {
 	abb_init();