Skip to contentSkip to conversation

dt-bindings: iio: adc: st,stm32-adc: add temperature sensor calibration cells

PATCH New Gerard Marull-Paretas 2 participants 2 messages Dec 3

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 dt-bindings: iio: adc: st,stm32-adc: add temperature sensor calibration cells

The internal temperature sensor of the STM32H7, STM32MP13 and STM32MP15 ADCs is calibrated in the factory at two temperatures, and its calibration data (TS_CAL1 and TS_CAL2) is stored in a read-only area, along with the internal voltage reference calibration (VREFINT_CAL).

Only the vrefint calibration can be passed to an ADC today. Allow the two temperature sensor calibration points to be passed as nvmem cells as well, so the ADC the temperature sensor is connected to can convert its readings.

No Linux driver reads these cells yet: on the STM32MP1, the dedicated digital temperature sensor is used for thermal protection instead, and the STM32H7 device trees are deprecated. The binding is also used to describe these SoCs outside Linux, though: PebbleOS describes the STM32H747 with it and reads the temperature sensor through the ADC using these cells.

---
Changes in v2:
- Drop the stm32h743.dtsi patch, the STM32H7 device trees being deprecated
- Name the SoCs with the calibration rather than the ADC3 connection
- Add background on the users of the cells
- Link to v1: https://lore.kernel.org/r/[email protected]

 .../devicetree/bindings/iio/adc/st,stm32-adc.yaml      | 10 ++++++++++
 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/iio/adc/st,stm32-adc.yaml +10 -0
index c4c4575d3fa9..9fe41b89982e 100644
@@ -337,12 +337,22 @@ patternProperties:
         deprecated: true
 
       nvmem-cells:
+        minItems: 1
         items:
           - description: Phandle to the calibration vrefint data provided by otp
+          - description:
+              Temperature sensor calibration data at the first calibration
+              temperature (TS_CAL1)
+          - description:
+              Temperature sensor calibration data at the second calibration
+              temperature (TS_CAL2)
 
       nvmem-cell-names:
+        minItems: 1
         items:
           - const: vrefint
+          - const: ts-cal1
+          - const: ts-cal2
 
     patternProperties:
       "^channel@([0-9]|1[0-9])$":

base-commit: 8d7fe9885c62fc9a95bf55d9db244d9672a8aadc

Signature · 1 line
2.45.2
#1 lore raw
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Low] dt-bindings: iio: stm32-adc: nvmem-cells schema allows partial ts-cal1 - [Low] dt-bindings…

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Low] dt-bindings: iio: stm32-adc: nvmem-cells schema allows partial ts-cal1
- [Low] dt-bindings: st,stm32-adc: missing reserved label for internal temp channel
--

commit 4db5e46c3a856f2f8d4973c119c1d93502ec2b26
Author: Gerard Marull-Paretas <[email protected]>

dt-bindings: iio: adc: st,stm32-adc: add temperature sensor calibration cells

This commit extends the nvmem-cells and nvmem-cell-names properties in the STM32 ADC binding to accept ts-cal1 and ts-cal2 temperature sensor calibration cells alongside vrefint.

Quoted 14 lines
Documentation/devicetree/bindings/iio/adc/st,stm32-adc.yaml +4 -0
index c4c4575d3fa96..9fe41b89982e9 100644
@@ -337,12 +337,22 @@ patternProperties:
         deprecated: true
 
       nvmem-cells:
+        minItems: 1
         items:
           - description: Phandle to the calibration vrefint data provided by otp
+          - description:
+              Temperature sensor calibration data at the first calibration
+              temperature (TS_CAL1)

Documentation/devicetree/bindings/iio/adc/st,stm32-adc.yaml patternProperties: · line 355

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/st,stm32-adc.yaml +6 -0
+          - description:
+              Temperature sensor calibration data at the second calibration
+              temperature (TS_CAL2)
 
       nvmem-cell-names:
+        minItems: 1
         items:
           - const: vrefint
+          - const: ts-cal1
+          - const: ts-cal2

[Severity: Low]
Does setting minItems: 1 on a 3-entry positional items list accept an incomplete [vrefint, ts-cal1] pair without ts-cal2?

It also forces vrefint to index 0, rejecting an ADC node that provides only ts-cal1 and ts-cal2 (arch/arm/boot/dts/st/stm32f429.dtsi defines only ts_cal1 and ts_cal2 in its romem node). Using oneOf to allow vrefint alone, ts-cal1 and ts-cal2 together, or all three cells would handle both cases.

Documentation/devicetree/bindings/iio/adc/st,stm32-adc.yaml patternProperties: · line 358

Quoted 3 lines
Documentation/devicetree/bindings/iio/adc/st,stm32-adc.yaml +0 -0
     patternProperties:
       "^channel@([0-9]|1[0-9])$":

[Severity: Low]
Should this binding also define a reserved channel label for the internal temperature sensor?

Other internal ADC channels (vddcore, vddcpu, vddq_ddr, vrefint, and vbat) are identified by reserved label names under channel@N, which stm32_adc_populate_int_ch() in drivers/iio/adc/stm32-adc.c matches to bind their calibration cells.

Because compatible and reg do not uniquely identify the temperature sensor channel across STM32 SoCs, omitting a reserved label leaves the binding incomplete. In-tree STM32MP15 boards already diverge on ad-hoc names such as internal_temp and sense_temp.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1