changeset 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 ca98f800bbf3
children a04a145098f1
files target-utils/buzplayer/cmdtab.c target-utils/c139explore/cmdtab.c target-utils/calversion/cmdtab.c target-utils/flash-boot-test/cmdtab.c target-utils/include/abbdefs.h target-utils/libbase/abbdrv.c target-utils/libcommon/abbcmd.c target-utils/loadagent/cmdtab.c target-utils/pirexplore/cmdtab.c target-utils/simtest/cmdtab.c
diffstat 10 files changed, 38 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/target-utils/buzplayer/cmdtab.c	Sat May 25 21:30:23 2019 +0000
+++ b/target-utils/buzplayer/cmdtab.c	Sat May 25 22:20:34 2019 +0000
@@ -15,6 +15,7 @@
 
 extern void abb_init();
 extern void abb_power_off();
+extern void abb_unlock_page2();
 
 extern void melody_init();
 extern void melody_entry();
@@ -25,6 +26,7 @@
 	{"I", melody_init},
 	{"P", melody_play},
 	{"abbinit", abb_init},
+	{"abbpage2", abb_unlock_page2},
 	{"abbr", cmd_abbr},
 	{"abbw", cmd_abbw},
 	{"baud", cmd_baud_switch},
--- a/target-utils/c139explore/cmdtab.c	Sat May 25 21:30:23 2019 +0000
+++ b/target-utils/c139explore/cmdtab.c	Sat May 25 22:20:34 2019 +0000
@@ -25,10 +25,12 @@
 
 extern void abb_init();
 extern void abb_power_off();
+extern void abb_unlock_page2();
 extern void cmd_memdump_human();
 
 const struct cmdtab cmdtab[] = {
 	{"abbinit", abb_init},
+	{"abbpage2", abb_unlock_page2},
 	{"abbr", cmd_abbr},
 	{"abbw", cmd_abbw},
 	{"buz", cmd_buz},
--- a/target-utils/calversion/cmdtab.c	Sat May 25 21:30:23 2019 +0000
+++ b/target-utils/calversion/cmdtab.c	Sat May 25 22:20:34 2019 +0000
@@ -14,9 +14,11 @@
 
 extern void abb_init();
 extern void abb_power_off();
+extern void abb_unlock_page2();
 
 const struct cmdtab cmdtab[] = {
 	{"abbinit", abb_init},
+	{"abbpage2", abb_unlock_page2},
 	{"abbr", cmd_abbr},
 	{"abbw", cmd_abbw},
 	{"dump", cmd_memdump_human},
--- a/target-utils/flash-boot-test/cmdtab.c	Sat May 25 21:30:23 2019 +0000
+++ b/target-utils/flash-boot-test/cmdtab.c	Sat May 25 22:20:34 2019 +0000
@@ -19,9 +19,11 @@
 
 extern void abb_init();
 extern void abb_power_off();
+extern void abb_unlock_page2();
 
 const struct cmdtab cmdtab[] = {
 	{"abbinit", abb_init},
+	{"abbpage2", abb_unlock_page2},
 	{"abbr", cmd_abbr},
 	{"abbw", cmd_abbw},
 	{"dump", cmd_memdump_human},
--- a/target-utils/include/abbdefs.h	Sat May 25 21:30:23 2019 +0000
+++ b/target-utils/include/abbdefs.h	Sat May 25 22:20:34 2019 +0000
@@ -1,15 +1,16 @@
-/* lifted from OsmocomBB */
+/* lifted from OsmocomBB, then modified for page 2 support */
 
 #ifndef _TWL3025_H
 #define _TWL3025_H
 
-#define PAGE(n)		(n << 7)
+#define PAGE(n)		(n << 6)
 enum twl3025_reg {
 	VRPCCFG		= PAGE(1) | 30,
 	VRPCDEV		= PAGE(0) | 30,
 	VRPCMSK		= PAGE(1) | 31,
 	VRPCMSKABB	= PAGE(1) | 29,
 	VRPCSTS		= PAGE(0) | 31,
+	VRPCAUX		= PAGE(2) | 30,	/* secret undocumented register! */
 	/* Monitoring ADC Registers */
 	MADCTRL		= PAGE(0) | 13,
 	MADCSTAT	= PAGE(0) | 24,
--- 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();
--- a/target-utils/libcommon/abbcmd.c	Sat May 25 21:30:23 2019 +0000
+++ b/target-utils/libcommon/abbcmd.c	Sat May 25 22:20:34 2019 +0000
@@ -23,7 +23,7 @@
 		return;
 	pg = strtoul(argv[0], 0, 0);
 	reg = strtoul(argv[1], 0, 0);
-	if (pg > 1 || reg > 31) {
+	if (pg > 2 || reg > 31) {
 		printf("ERROR: argument(s) out of range\n");
 		return;
 	}
@@ -44,7 +44,7 @@
 	pg = strtoul(argv[0], 0, 0);
 	reg = strtoul(argv[1], 0, 0);
 	val = strtoul(argv[2], 0, 16);
-	if (pg > 1 || reg > 31 || val > 0x3FF) {
+	if (pg > 2 || reg > 31 || val > 0x3FF) {
 		printf("ERROR: argument(s) out of range\n");
 		return;
 	}
--- a/target-utils/loadagent/cmdtab.c	Sat May 25 21:30:23 2019 +0000
+++ b/target-utils/loadagent/cmdtab.c	Sat May 25 22:20:34 2019 +0000
@@ -24,6 +24,7 @@
 
 extern void abb_init();
 extern void abb_power_off();
+extern void abb_unlock_page2();
 
 const struct cmdtab cmdtab[] = {
 	{"AMFB", cmd_AMFB},
@@ -33,6 +34,7 @@
 	{"INFW", cmd_INFW},
 	{"ML", cmd_memload},
 	{"abbinit", abb_init},
+	{"abbpage2", abb_unlock_page2},
 	{"abbr", cmd_abbr},
 	{"abbw", cmd_abbw},
 	{"baud", cmd_baud_switch},
--- a/target-utils/pirexplore/cmdtab.c	Sat May 25 21:30:23 2019 +0000
+++ b/target-utils/pirexplore/cmdtab.c	Sat May 25 22:20:34 2019 +0000
@@ -26,11 +26,13 @@
 
 extern void abb_init();
 extern void abb_power_off();
+extern void abb_unlock_page2();
 extern void cmd_memdump_human();
 extern void tiffs_init();
 
 const struct cmdtab cmdtab[] = {
 	{"abbinit", abb_init},
+	{"abbpage2", abb_unlock_page2},
 	{"abbr", cmd_abbr},
 	{"abbw", cmd_abbw},
 	{"baud", cmd_baud_switch},
--- a/target-utils/simtest/cmdtab.c	Sat May 25 21:30:23 2019 +0000
+++ b/target-utils/simtest/cmdtab.c	Sat May 25 22:20:34 2019 +0000
@@ -18,9 +18,11 @@
 
 extern void abb_init();
 extern void abb_power_off();
+extern void abb_unlock_page2();
 
 const struct cmdtab cmdtab[] = {
 	{"abbinit", abb_init},
+	{"abbpage2", abb_unlock_page2},
 	{"abbr", cmd_abbr},
 	{"abbw", cmd_abbw},
 	{"dump", cmd_memdump_human},