Skip to content

novatek: read the die temperature on NA51055 and NA51084 too - #277

Merged
widgetii merged 1 commit into
masterfrom
novatek-temp-na51055-na51084
Nov 10, 2026
Merged

widgetii merged 1 commit into
masterfrom
novatek-temp-na51055-na51084

Conversation

@widgetii

Copy link
Copy Markdown
Member

Follow-up to #276, which reads the die temperature directly on NA51089 (NT98562/NT98566). The vendor SDK shows that NA51055 (NT9852x) and NA51084 (NT98528/NT98529) work the same way, so this installs the same reader for them.

Why the same code applies

na51089_linux_sdk_uclibc_v1.01.002 ships plat-na51055 alongside plat-na51089. The plat-na51055 platform covers both NA51055 and NA51084; top.h lists both IDs.

plat-na51055 (NA51055, NA51084) plat-na51089
CG / eFuse base (hardware.h) 0xF0020000 / 0xF0660000 same
ADC clock gate (*-clk.c, "f0260000.adc") CG_CLK_EN_REG1 bit 13 same
adc_reg.h (thermal average at +0x40 [24:16]) byte-identical
EFUSE_THERMAL_TRIM_DATA 0x105 0x105
otp_protected.o_shipped efuse_open/read/close same register sequence (decompiled)
efuse_readParamOps(0x105) row 6, first copy with bit 15 set and bit 14 clear same

The only difference is in nvt_adc's thermal_get_temp():

die slope default trim
NA51055 (0x4821) 1.3 °C/code 259 (DEFAULT_THERMAL_LEVEL)
NA51084 (0x5021), NA51089 1.319 °C/code 231 (DEFAULT_THERMAL_528_LEVEL, named for the NT98528, i.e. NA51084)

The reader chooses the slope and default by chip ID. A device-tree model of NA51055 or NA51084 now sets the ID the way NA51089 already does. NA51090, NA51103 and NA51023 keep the sysfs reader. The register macros lose their NA51089_ prefix.

Tested

  • novatek_test covers both formulas and defaults, the reader being installed for all three IDs, the device-tree names, and the three dies that keep sysfs. Breaking the slope choice, the default choice, NA51084's installation or NA51055's device-tree mapping each makes it fail.
  • NA51089 is unchanged. On the lab NT98566 + SC501AI (CI-toolchain arm32 build), ipcinfo --temp printed 68.25, which is code 257 with trim 228. The eFuse was left closed.
  • ipcinfo grows 180 bytes with IPCHW_VENDORS=all and 0 with none.

Not tested on NA51055 or NA51084 hardware. There is no such camera in the lab, so the table above is what the SDK says, not a measurement. If you have an NT9852x or NT98528/529, please post the output of:

ipctool --temp
devmem 0xf0260040; devmem 0xf0020074; devmem 0xf0260000
echo trim > /proc/nvt_otp_op/otp_trim; dmesg | tail -8   # if your kernel has it

#276's reader is not NA51089's alone. The SDK's kernel carries
plat-na51055, which serves both NA51055 and NA51084, next to
plat-na51089, and the two agree on everything it touches:

- the peripheral base, CG at +0x20000 and eFuse at +0x660000
  (hardware.h); the ADC's gate is CG_CLK_EN_REG1 bit 13 on both
  (na51055-clk.c and na51089-clk.c name "f0260000.adc" alike);
- adc_reg.h, byte for byte, so the thermal average is the same field;
- EFUSE_THERMAL_TRIM_DATA, 0x105 in both efuse_protected.h;
- the eFuse read. na51055/otp_protected.o_shipped is a different
  binary, but its efuse_open/efuse_read/efuse_close are the same
  register sequence as NA51089's, and its efuse_readParamOps maps 0x105
  to row 6 and takes the first of the two copies with bit 15 set and
  bit 14 clear, as NA51089's does.

What differs is nvt_adc's thermal_get_temp(): on NA51055 it is 1.3
degC per code with a default trim of 259 (DEFAULT_THERMAL_LEVEL); every
later die gets 1.319 and 231, a default the SDK names for the NT98528,
which is an NA51084.

So the reader is installed for all three IDs, with NA51055's slope and
default chosen by ID, and the register names lose their NA51089_ prefix.
A device-tree model of NA51055 or NA51084 now sets the ID as NA51089's
does. NA51090, NA51103 and NA51023 keep the sysfs reader.

There is no NA51055 or NA51084 camera here, so this is the SDK's word,
not a measurement. NA51089 is unchanged: lab NT98566, code 257 with
trim 228, 68.25 degC. ipcinfo grows 180 bytes (IPCHW_VENDORS=all).
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Read die temperature directly on NA51055 and NA51084

✨ Enhancement 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Extend direct die-temperature readings to NA51055 and NA51084 using shared ADC and eFuse hardware.
• Apply each die’s calibration formula while preserving sysfs fallback and other chips’ behavior.
• Test device-tree detection, reader selection, calibration defaults, and fallback paths.
Diagram

graph TD
  ID["Chip identity"] --> Setup["HAL setup"] --> Supported{"Supported die?"} -->|yes| Reader["Direct reader"] --> ADC["ADC sample"] --> Math["Die-specific math"]
  Reader --> Trim["eFuse trim"] --> Math
  Supported -->|no| Sysfs["Sysfs reader"]
  Reader -->|read fails| Sysfs
Loading
High-Level Assessment

Reuse the direct reader because the SDK indicates shared registers and eFuse behavior; select only the slope and default trim by die. Sysfs-only reading cannot cover kernels without the vendor ADC driver, while separate readers would duplicate the same hardware sequence. Hardware validation on NA51055 and NA51084 is still needed.

Files changed (2) +131 / -75

Enhancement (1) +58 / -45
novatek.cShare direct thermal reading across three Novatek dies +58/-45

Share direct thermal reading across three Novatek dies

• Maps NA51055 and NA51084 device-tree models to chip IDs and installs the direct reader for both alongside NA51089. Generalizes register names and selects NA51055’s distinct slope and default trim, retaining sysfs fallback on read failure.

src/hal/novatek.c

Tests (1) +73 / -30
novatek_test.cCover new die-specific temperature paths +73/-30

Cover new die-specific temperature paths

• Extends the modeled ADC and eFuse tests to verify NA51084 and NA51055 formulas, defaults, reader installation, and device-tree identification. Checks that NA51090, NA51103, and NA51023 do not receive the direct reader.

src/hal/novatek_test.c

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can move or hide resolved findings to focus on what still needs action

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@widgetii
widgetii merged commit c87ed47 into master Nov 10, 2026
5 checks passed
@widgetii
widgetii deleted the novatek-temp-na51055-na51084 branch November 10, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant