Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/chipid.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ static const manufacturers_t manufacturers[] = {
{"isvp", ingenic_detect_cpu, VENDOR_INGENIC, setup_hal_ingenic},
{"ingenic", ingenic_detect_cpu, VENDOR_INGENIC, setup_hal_ingenic},
#endif
#ifdef IPCHW_VENDOR_NOVATEK
/* NA51023 (NT96672, NT9851x): a MIPS 24KEc, "machine : Novatek ..." */
{"Novatek", novatek_detect_cpu, VENDOR_NOVATEK, novatek_setup_hal},
#endif
#endif
#ifdef __arm__
#ifdef IPCHW_VENDOR_SSTAR
Expand All @@ -74,7 +78,8 @@ static const manufacturers_t manufacturers[] = {
{NULL /* Generic */, anyka_detect_cpu, VENDOR_ANYKA, anyka_setup_hal},
#endif
#ifdef IPCHW_VENDOR_ROCKCHIP
{NULL /* Generic */, rockchip_detect_cpu, VENDOR_ROCKCHIP, rockchip_setup_hal},
{NULL /* Generic */, rockchip_detect_cpu, VENDOR_ROCKCHIP,
rockchip_setup_hal},
#endif
#ifdef IPCHW_VENDOR_XILINX
{"Xilinx", xilinx_detect_cpu, NULL, xilinx_setup_hal},
Expand Down
30 changes: 25 additions & 5 deletions src/hal/novatek.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,42 @@ static sensor_addr_t novatek_possible_i2c_addrs[] = {
static bool nvt_get_chip_id() {
char buf[8];

if (!line_from_file("/proc/nvt_info/nvt_pinmux/chip_id", "(.+)", buf,
sizeof(buf)))
return false;

/* The TOP block's chip-ID word, which is what tells the pad-mux table and
* the GPIO controller which SoC this is. Set for every ID the kernel hands
* over, named or not: a part with no table gets no table, which
* padmux_ops() says rather than guessing one. */
chip_generation = (uint16_t)strtol(buf, NULL, 16);
if (line_from_file("/proc/nvt_info/nvt_pinmux/chip_id", "(.+)", buf,
sizeof(buf))) {
chip_generation = (uint16_t)strtol(buf, NULL, 16);
} else {
#if defined(__mips__)
/* NA51023's 4.1 kernel predates nvt_pinmux. Its TOP block is
* NA51089's at 0xC0000000 instead of 0xF0000000, and the vendor
* firmware's drv_init() aborts unless TOP+0xF0 [31:16] is 0x6E19.
* Only that value is taken: this is a refinement, the device-tree
* model below still names the die on a kernel that withholds
* /dev/mem. */
uint32_t reg;
if (!mem_reg(0xC0010000 + TOP_VERSION_REG_OFS, &reg, OP_READ) ||
(reg >> 16) != CHIP_NA51023)
return false;
chip_generation = CHIP_NA51023;
#else
return false;
#endif
}

/* The ID names the die, not the part: NT98562 and NT98566 are both
* NA51089 and differ only in an eFuse package word whose decoding is not
* in the SDK, so the two read alike here. The dies with no name below
* (NA51055, NA51090) are named by the device tree. */
const char *name;
switch (chip_generation) {
case CHIP_NA51023:
/* One ID for the NT96672 dashcam part and the NT9851x camera parts;
* nothing in the BSP tells them apart, so the die is the name. */
name = "NA51023";
break;
case CHIP_NA51084:
/* u-boot's NA51084 code drives the "_528_" clock registers and allows
* 1200 MHz only on an NT98529, told apart by OTP. */
Expand Down
1 change: 1 addition & 0 deletions src/hal/novatek.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void novatek_setup_hal();
/* TOP + 0xF0 bits [31:16], also /proc/nvt_info/nvt_pinmux/chip_id. One ID
* per die; the parts cut from a die are told apart by eFuse/OTP words. */
enum CHIP_ID {
CHIP_NA51023 = 0x6E19, // NT96672, NT9851x: MIPS 24KEc, TOP at 0xC0010000
CHIP_NA51055 = 0x4821, // NT9852x: NT98520, NT98525
CHIP_NA51084 = 0x5021, // NT98528, NT98529 (the 1.2 GHz part, by OTP)
CHIP_NA51089 = 0x7021, // NT98562 (64 MB internal RAM),
Expand Down
Loading