comparison 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
comparison
equal deleted inserted replaced
498:ca98f800bbf3 499:44a1de4264d8
22 */ 22 */
23 23
24 #include "types.h" 24 #include "types.h"
25 #include "abbdefs.h" 25 #include "abbdefs.h"
26 26
27 /* TWL3025 */ 27 /* TWL3025, modified for page 2 support */
28 #define REG_PAGE(n) ((n) >> 7) 28 #define REG_PAGE(n) ((n) >> 6)
29 #define REG_ADDR(n) ((n) & 0x1f) 29 #define REG_ADDR(n) ((n) & 0x1f)
30 30
31 #define TWL3025_DEV_IDX 0 /* On the SPI bus */ 31 #define TWL3025_DEV_IDX 0 /* On the SPI bus */
32 #define TWL3025_TSP_DEV_IDX 0 /* On the TSP bus */ 32 #define TWL3025_TSP_DEV_IDX 0 /* On the TSP bus */
33 33
68 } 68 }
69 69
70 /* Switch the register page of the TWL3025 */ 70 /* Switch the register page of the TWL3025 */
71 abb_select_page(page) 71 abb_select_page(page)
72 { 72 {
73 if (page == 0) 73 switch (page) {
74 case 0:
74 abb_reg_write(PAGEREG, 1 << 0); 75 abb_reg_write(PAGEREG, 1 << 0);
75 else 76 break;
77 case 1:
76 abb_reg_write(PAGEREG, 1 << 1); 78 abb_reg_write(PAGEREG, 1 << 1);
79 break;
80 case 2:
81 /* not documented in datasheet, learned from TCS211 code */
82 abb_reg_write(PAGEREG, 1 << 4);
83 break;
84 }
77 abb_state_page = page; 85 abb_state_page = page;
78 return(0); 86 return(0);
79 } 87 }
80 88
81 abb_init() 89 abb_init()
95 abb_state_initdone = 1; 103 abb_state_initdone = 1;
96 return(1); 104 return(1);
97 } 105 }
98 106
99 void 107 void
108 abb_unlock_page2()
109 {
110 abb_reg_write(TAPCTRL, 0x01);
111 abb_reg_write(TAPREG, 0x1B);
112 }
113
114 void
100 abb_power_off() 115 abb_power_off()
101 { 116 {
102 abb_init(); 117 abb_init();
103 serial_flush(); 118 serial_flush();
104 abb_reg_write(VRPCDEV, 0x01); 119 abb_reg_write(VRPCDEV, 0x01);