99#include "hal/common.h"
1010#include "tools.h"
1111
12- // TODO: /proc/nvt_info/nvt_pinmux/chip_id
13-
1412static unsigned char sony_addrs [] = {0x34 , 0 };
1513static unsigned char ssens_addrs [] = {0x60 , 0 };
1614static unsigned char omni_addrs [] = {0x6c , 0 };
@@ -24,14 +22,49 @@ static sensor_addr_t novatek_possible_i2c_addrs[] = {
2422 {SENSOR_GALAXYCORE , gc_addrs }, {SENSOR_TECHPOINT , tp_addrs },
2523 {0 , NULL }};
2624
25+ static bool nvt_get_chip_id () {
26+ uint16_t reg ;
27+ unsigned int chip_id = 0 ;
28+ char buf [8 ];
29+ char * endptr ;
30+
31+ if (line_from_file ("/proc/nvt_info/nvt_pinmux/chip_id" , "(.+)" , buf ,
32+ sizeof (buf ))) {
33+
34+ reg = (uint16_t )strtol (buf , & endptr , 16 );
35+ switch (reg ) {
36+ case 0x5021 :
37+ strcpy (chip_name , "NT98562" );
38+ return true;
39+ case 0x7021 :
40+ strcpy (chip_name , "NT98566" );
41+ return true;
42+ case 0x8B20 :
43+ strcpy (chip_name , "NT98332G" );
44+ return true;
45+ }
46+ }
47+
48+ // if (mem_reg(IOADDR_TOP_REG_BASE + TOP_VERSION_REG_OFS, (uint32_t *)®,
49+ // OP_READ)) {
50+ // chip_id = (reg >> 16) & 0xFFFF;
51+ // }
52+ // printf("reg %x\n", chip_id);
53+ return false;
54+ }
55+
2756bool novatek_detect_cpu (char * chip_name ) {
2857 char buf [256 ];
2958
59+ if (nvt_get_chip_id ())
60+ return true;
61+
3062 if (!line_from_file ("/proc/device-tree/model" , "Novatek ([A-Z]+[0-9]+)" ,
3163 buf , sizeof (buf )))
3264 return false;
3365
3466 strcpy (chip_name , buf );
67+
3568 return true;
3669}
3770
@@ -82,36 +115,3 @@ void novatek_setup_hal() {
82115 hal_totalmem = novatek_totalmem ;
83116#endif
84117}
85-
86- enum CHIP_ID {
87- CHIP_NA51055 = 0x4821 , // NT98525, 128Kb L2, 5M@30
88- // NT98528, 256Kb L2, 4K@30
89- CHIP_NA51084 = 0x5021 ,
90- CHIP_NA51089 = 0x7021 , // NT98562, 64Mb internal RAM
91- // NT98566, 128Mb internal RAM
92- CHIP_NA51090 = 0xBC21
93- };
94-
95- #define TOP_VERSION_REG_OFS 0xF0
96-
97- /* na51000, na51089, na51068, na51000, na51090, na51055 */
98- #define IOADDR_GLOBAL_BASE (0xF0000000)
99- /* na51090 */
100- //#define IOADDR_GLOBAL_BASE (0x2F0000000)
101-
102- /* na51000, na51089, na51000, na51090, na51090, na51055 */
103- #define IOADDR_TOP_REG_BASE (IOADDR_GLOBAL_BASE + 0x00010000)
104- /* na51068 */
105- //#define IOADDR_TOP_REG_BASE (IOADDR_GLOBAL_BASE + 0x0E030000)
106-
107- static uint32_t nvt_get_chip_id () {
108- uint32_t reg ;
109- unsigned int chip_id = 0 ;
110-
111- if (mem_reg (IOADDR_TOP_REG_BASE + TOP_VERSION_REG_OFS , (uint32_t * )& reg ,
112- OP_READ )) {
113- chip_id = (reg >> 16 ) & 0xFFFF ;
114- }
115-
116- return chip_id ;
117- }
0 commit comments