add AUXADC, EFUSE and thermal drivers for the MediaTek mt6323 PMIC
Subsystems (9)
Roman Vivchar
maintainerv2 cover add AUXADC, EFUSE and thermal drivers for the MediaTek mt6323 PMIC
This series adds support for AUXADC, EFUSE and thermal drivers for the MediaTek mt6323 PMIC
Usually vendor downstream kernels for devices with mt6323 include various useful drivers like AUXADC, thermal, fuel gauge etc. Bring it to the upstream kernel by rewriting some drivers from 3.18 vendor tree.
Currently dt-bindings limit some values like ADC channel count and names to what mt6323 has, but the drivers were designed in a way to support other PMICs like mt6358 (which has very similar thermal logic).
Tested on the MediaTek mt6572 and mt8163 SoCs, both paired with mt6323.
---
Changes in v2:
- dt-bindings:
- Drop Tested-by tags (Krzysztof)
- AUXADC: drop mt6323 standalone binding and merge into mt6359 (Krzysztof)
- EFUSE: drop mt6323 standalone binding and merge into mt6397 (Krzysztof)
- Thermal: drop iio-channel-names, nvmem-cells description, unused label (Rob)
- Thermal: Merge into mt6397 mfd
- AUXADC driver:
- Fix formatting for macro, OF table, etc (Andy, Jonathan)
- Drop dev field from the mt6323_auxadc struct (Andy)
- Use dt-bindings constants for channels instead of raw numbers
- Simplify mt6323_auxadc_check_if_stuck implemenetation with iopoll (Andy)
- Drop untested audio channel support (Andy, Jonathan)
- Replace check for chan->address with chan->channel to avoid confusion (Jonathan)
- Replace scoped_guard with guard in mt6323_auxadc_read_raw (Andy)
- Replace mutex_init with devm helper in probe (Andy)
- EFUSE driver:
- Add comments about read function (Andy)
- Use sizeof() (Andy)
- Thermal driver:
- Rename to mtk_pmic_thermal for proper module name
- Add module name to Kconfig
- Use bitfield.h APIs for efuse extraction (Andy)
- Drop nvmem cell name for consistency with devicetree bindings
- Replace raw numbers with constants (Andy)
- Add comments to read function, remove redundant parentheses (Andy)
- Add comments to precalc function, simplify it for readability (Andy)
- Reorder struct fields (Andy)
- Drop cali_val field, since per-PMIC functions are used
- Use __free for nvmem_cell_read cleanup (Andy)
- Maintainers:
- Split patch into 3 for different subsystems (Krzysztof)
- Downgrade to "Odd fixes"
- Note: Signing key has been changed since v1. Sorry for inconvenience
- Link to v1: https://patch.msgid.link/[email protected]
---
Roman Vivchar (16):
dt-bindings: iio: adc: mt6359: generalize description for mt63xx series
dt-bindings: iio: adc: mt6359: add mt6323 PMIC AUXADC
dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE
dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC thermal
iio: adc: mediatek: add mt6323 PMIC AUXADC driver
nvmem: add mt6323 PMIC EFUSE driver
thermal: mediatek: add PMIC thermal support
mfd: mt6397-core: add mt6323 AUXADC support
mfd: mt6397-core: add mt6323 EFUSE support
mfd: mt6397-core: add mt6323 thermal support
ARM: dts: mediatek: mt6323: add AUXADC support
ARM: dts: mediatek: mt6323: add EFUSE support
ARM: dts: mediatek: mt6323: add thermal support
MAINTAINERS: add MediaTek mt6323 PMIC AUXADC driver maintainer
MAINTAINERS: add MediaTek mt6323 PMIC EFUSE driver maintainer
MAINTAINERS: add MediaTek mt6323 PMIC thermal driver maintainer
.../bindings/iio/adc/mediatek,mt6359-auxadc.yaml | 3 +- .../devicetree/bindings/mfd/mediatek,mt6397.yaml | 65 +++++ MAINTAINERS | 15 + arch/arm/boot/dts/mediatek/mt6323.dtsi | 40 +++ drivers/iio/adc/Kconfig | 11 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mt6323-auxadc.c | 319 +++++++++++++++++++++ drivers/mfd/mt6397-core.c | 9 + drivers/nvmem/Kconfig | 11 + drivers/nvmem/Makefile | 2 + drivers/nvmem/mt6323-efuse.c | 86 ++++++ drivers/thermal/mediatek/Kconfig | 12 + drivers/thermal/mediatek/Makefile | 1 + drivers/thermal/mediatek/mtk_pmic_thermal.c | 316 ++++++++++++++++++++ .../dt-bindings/iio/adc/mediatek,mt6323-auxadc.h | 24 ++ 15 files changed, 914 insertions(+), 1 deletion(-)
---
base-commit: 028ef9c96e96197026887c0f092424679298aae8
change-id: 20260502-mt6323-94e1f2d2abb3
Best regards,
Signature · 1 line
Roman Vivchar <[email protected]>
Roman Vivchar
maintainerPATCH v2 1/16 dt-bindings: iio: adc: mt6359: generalize description for mt63xx series
Update binding title to the MT63xx, since the list of compatibles already includes mt6363 and mt6373 which don't belong to the mt6350 family.
--- Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml +1 -1
@@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/iio/adc/mediatek,mt6359-auxadc.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: MediaTek MT6350 series PMIC AUXADC +title: MediaTek MT63xx series PMIC AUXADC maintainers: - AngeloGioacchino Del Regno <[email protected]>
Signature · 1 line
2.54.0
Jonathan Cameron
maintainerRe: [PATCH v2 01/16] dt-bindings: iio: adc: mt6359: generalize description for mt63xx series
Quoted 4 lines · On Tue, 12 May 2026 08:18:15 +0300 Roman Vivchar via B4 Relay…
From: Roman Vivchar <[email protected]>
Update binding title to the MT63xx, since the list of compatibles already includes mt6363 and mt6373 which don't belong to the mt6350 family.
Hi Roman,
Wild cards have a nasty habit of going wrong. I'd prefer to see language like: MT6359 and similar PMIC AUXADC
It is less important here than in many other places because the file has an explicit list soon after this, but none the less we've been bitten by this too often to think manufacturers won't throw a completely non compatible part in the middle of a wild card covered range.
Quoted 20 lines
Signed-off-by Roman Vivchar <[email protected]>--- Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml +1
-1@@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/iio/adc/mediatek,mt6359-auxadc.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: MediaTek MT6350 series PMIC AUXADC +title: MediaTek MT63xx series PMIC AUXADC maintainers: - AngeloGioacchino Del Regno <[email protected]>
Roman Vivchar
maintainerRe: [PATCH v2 01/16] dt-bindings: iio: adc: mt6359: generalize description for mt63xx series
Quoted 11 lines · Jonathan Cameron
Quoted 4 lines · On Tue, 12 May 2026 08:18:15 +0300 Roman Vivchar via B4 Relay…
From: Roman Vivchar <[email protected]>
Update binding title to the MT63xx, since the list of compatibles already includes mt6363 and mt6373 which don't belong to the mt6350 family.
Hi Roman,
Wild cards have a nasty habit of going wrong. I'd prefer to see language like: MT6359 and similar PMIC AUXADC
Hi Jonathan,
I agree that it would be better to specify the exact PMIC models, however 'similar' wording might be a bit misleading here. As far as I know, the mt6363 and mt6373 use SPMI, while mt635x (and older models, like most of the mt63xx series) use PWRAP (a custom SPI-based protocol). The mt6323 has an older AUXADC revision which is not compatible with the mt635x driver.
Would you prefer more explicit list like 'MT6323, MT6350 series, MT6363 and MT6373 PMIC AUXADC'? It's a bit mess because some mt63xx (like mt6333) are sub-PMICs and use I2C instead of PWRAP.
Quoted 6 lines
It is less important here than in many other places because the file has an explicit list soon after this, but none the less we've been bitten by this too often to think manufacturers won't throw a completely non compatible part in the middle of a wild card covered range.
Best regards,
Roman
Jonathan Cameron
maintainerRe: [PATCH v2 01/16] dt-bindings: iio: adc: mt6359: generalize description for mt63xx series
Quoted 23 lines · On Tue, 12 May 2026 13:55:26 +0000 Roman Vivchar <[email protected]> wrote:
Quoted 11 lines · Jonathan Cameron
Quoted 4 lines · On Tue, 12 May 2026 08:18:15 +0300 Roman Vivchar via B4 Relay…
From: Roman Vivchar <[email protected]>
Update binding title to the MT63xx, since the list of compatibles already includes mt6363 and mt6373 which don't belong to the mt6350 family.
Hi Roman,
Wild cards have a nasty habit of going wrong. I'd prefer to see language like: MT6359 and similar PMIC AUXADC
Hi Jonathan,
I agree that it would be better to specify the exact PMIC models, however 'similar' wording might be a bit misleading here. As far as I know, the mt6363 and mt6373 use SPMI, while mt635x (and older models, like most of the mt63xx series) use PWRAP (a custom SPI-based protocol). The mt6323 has an older AUXADC revision which is not compatible with the mt635x driver.
Quoted 3 lines
Would you prefer more explicit list like 'MT6323, MT6350 series, MT6363 and MT6373 PMIC AUXADC'? It's a bit mess because some mt63xx (like mt6333) are sub-PMICs and use I2C instead of PWRAP.
Complete lists don't work because sooner or later they become too long for a title (though they should be there elsewhere in the dt-binding!)
Perhaps something around: mt6359 and similar SoC ADCs including those accessed via ....
Quoted 10 lines
Quoted 7 lines
It is less important here than in many other places because the file has an explicit list soon after this, but none the less we've been bitten by this too often to think manufacturers won't throw a completely non compatible part in the middle of a wild card covered range.
Best regards,
Roman
Re: [PATCH v2 01/16] dt-bindings: iio: adc: mt6359: generalize description for mt63xx series
In reply to Roman VivcharQuoted 13 lines · Roman Vivchar
Update binding title to the MT63xx, since the list of compatibles already includes mt6363 and mt6373 which don't belong to the mt6350 family.
Signed-off-by Roman Vivchar <[email protected]>--- Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml +0
-0
Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml line 7
Quoted 5 lines
Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml +1
-1@@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/iio/adc/mediatek,mt6359-auxadc.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: MediaTek MT6350 series PMIC AUXADC +title: MediaTek MT63xx series PMIC AUXADC
Honestly that's close to churn... Do it while adding new compatibles.
Best regards,
Krzysztof
Roman Vivchar
maintainerPATCH v2 2/16 dt-bindings: iio: adc: mt6359: add mt6323 PMIC AUXADC
In reply to Roman VivcharThe MediaTek mt6323 PMIC includes an AUXADC used for battery voltage, temperature, and other internal measurements.
Add the devicetree binding documentation and the associated header file defining the ADC channel constants.
--- .../bindings/iio/adc/mediatek,mt6359-auxadc.yaml | 1 + .../dt-bindings/iio/adc/mediatek,mt6323-auxadc.h | 24 ++++++++++++++++++++++ 2 files changed, 25 insertions(+)
Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml +1 -0
@@ -19,6 +19,7 @@ description: properties: compatible: enum: + - mediatek,mt6323-auxadc - mediatek,mt6357-auxadc - mediatek,mt6358-auxadc - mediatek,mt6359-auxadc
include/dt-bindings/iio/adc/mediatek,mt6323-auxadc.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ + +#ifndef _DT_BINDINGS_MEDIATEK_MT6323_AUXADC_H +#define _DT_BINDINGS_MEDIATEK_MT6323_AUXADC_H + +#define MT6323_AUXADC_BATON2 0 +#define MT6323_AUXADC_CH6 1 +#define MT6323_AUXADC_BAT_TEMP 2 +#define MT6323_AUXADC_CHIP_TEMP 3 +#define MT6323_AUXADC_VCDT 4 +#define MT6323_AUXADC_BATON1 5 +#define MT6323_AUXADC_ISENSE 6 +#define MT6323_AUXADC_BATSNS 7 +#define MT6323_AUXADC_ACCDET 8 +#define MT6323_AUXADC_AUDIO0 9 +#define MT6323_AUXADC_AUDIO1 10 +#define MT6323_AUXADC_AUDIO2 11 +#define MT6323_AUXADC_AUDIO3 12 +#define MT6323_AUXADC_AUDIO4 13 +#define MT6323_AUXADC_AUDIO5 14 +#define MT6323_AUXADC_AUDIO6 15 +#define MT6323_AUXADC_AUDIO7 16 + +#endif
Signature · 1 line
2.54.0
Re: [PATCH v2 02/16] dt-bindings: iio: adc: mt6359: add mt6323 PMIC AUXADC
Quoted 11 lines · Roman Vivchar
The MediaTek mt6323 PMIC includes an AUXADC used for battery voltage, temperature, and other internal measurements.
Add the devicetree binding documentation and the associated header file defining the ADC channel constants.
Signed-off-by Roman Vivchar <[email protected]>--- .../bindings/iio/adc/mediatek,mt6359-auxadc.yaml | 1 + .../dt-bindings/iio/adc/mediatek,mt6323-auxadc.h | 24 ++++++++++++++++++++++ 2 files changed, 25 insertions(+)
Best regards,
Krzysztof
Roman Vivchar
maintainerPATCH v2 3/16 dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE
In reply to Roman VivcharThe MediaTek mt6323 PMIC includes an EFUSE used for storing calibration data.
Add the devicetree binding documentation for the MediaTek mt6323 EFUSE.
--- .../devicetree/bindings/mfd/mediatek,mt6397.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +21 -0
@@ -145,6 +145,23 @@ properties: required: - compatible + efuse: + type: object + unevaluatedProperties: false + description: + The efuse is responsible for storing calibration data, such as thermal + sensor calibration. + + properties: + compatible: + const: mediatek,mt6323-efuse + + nvmem-layout: + $ref: /schemas/nvmem/layouts/nvmem-layout.yaml# + + required: + - compatible + leds: type: object additionalProperties: false
@@ -243,6 +260,10 @@ examples: interrupt-controller; #interrupt-cells = <2>; + efuse { + compatible = "mediatek,mt6323-efuse"; + }; + leds { compatible = "mediatek,mt6323-led"; #address-cells = <1>;
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v2 03/16] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Missing reference to core NVMEM schema (`$ref: /schemas/nvmem/nvmem.yaml#`) in the `efuse` node…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing reference to core NVMEM schema ($ref: /schemas/nvmem/nvmem.yaml#) in the efuse node definition. --
commit ce0eef2651d566e649c71112862db7f2d4dc1545
Author: Roman Vivchar <[email protected]>
dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE
This commit adds the device tree binding documentation for the MediaTek mt6323 EFUSE, which is used to store calibration data on the mt6323 PMIC.
Quoted 3 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +0
-0
[ ... ]
Quoted 7 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +3
-0@@ -145,6 +145,23 @@ properties: required: - compatible + efuse: + type: object + unevaluatedProperties: false
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml properties: · line 160
Quoted 10 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +10
-0+ description: + The efuse is responsible for storing calibration data, such as thermal + sensor calibration. + + properties: + compatible: + const: mediatek,mt6323-efuse + + nvmem-layout: + $ref: /schemas/nvmem/layouts/nvmem-layout.yaml#
Should this node include a reference to the core nvmem schema?
Because the node sets unevaluatedProperties: false without referencing /schemas/nvmem/nvmem.yaml#, would dtbs_check incorrectly reject standard nvmem properties like read-only or wp-gpios?
Additionally, if the core nvmem schema is referenced, does the explicit reference to nvmem-layout.yaml become redundant?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v2 03/16] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE
In reply to Roman VivcharQuoted 10 lines · Roman Vivchar
The MediaTek mt6323 PMIC includes an EFUSE used for storing calibration data.
Add the devicetree binding documentation for the MediaTek mt6323 EFUSE.
Signed-off-by Roman Vivchar <[email protected]>--- .../devicetree/bindings/mfd/mediatek,mt6397.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
Roman Vivchar
maintainerPATCH v2 4/16 dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC thermal
In reply to Roman VivcharThe MediaTek mt6323 PMIC temperature can be read using AUXADC channel.
Add the devicetree binding documentation for the MediaTek mt6323 thermal.
While mt6323 exposes only a single thermal sensor, newer PMICs like mt6358 provide more than one sensor. Therefore define #thermal-sensor-cells as 1 to avoid breaking devicetree ABI in the future.
--- .../devicetree/bindings/mfd/mediatek,mt6397.yaml | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+)
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +44 -0
@@ -242,6 +242,31 @@ properties: description: Pin controller + thermal: + type: object + unevaluatedProperties: false + description: + PMIC thermal monitoring + + properties: + compatible: + const: mediatek,mt6323-thermal + + io-channels: + description: + IIO channel for the AUXADC to read raw data from. + maxItems: 1 + + nvmem-cells: + maxItems: 1 + + "#thermal-sensor-cells": + const: 1 + required: + - compatible + - io-channels + - "#thermal-sensor-cells" + required: - compatible - regulators
@@ -250,6 +275,7 @@ additionalProperties: false examples: - | + #include <dt-bindings/iio/adc/mediatek,mt6323-auxadc.h> #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/leds/common.h>
@@ -262,6 +288,16 @@ examples: efuse { compatible = "mediatek,mt6323-efuse"; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + mt6323_thermal_calibration_data: thermal-data@14 { + reg = <0x14 0x4>; + }; + }; }; leds {
@@ -511,6 +547,14 @@ examples: rtc { compatible = "mediatek,mt6323-rtc"; }; + + thermal { + compatible = "mediatek,mt6323-thermal"; + nvmem-cells = <&mt6323_thermal_calibration_data>; + + io-channels = <&mt6323_adc MT6323_AUXADC_CHIP_TEMP>; + #thermal-sensor-cells = <1>; + }; }; - |
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v2 04/16] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC thermal
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] The `#thermal-sensor-cells` property is constrained to 1, but the MT6323 hardware only possesses…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The #thermal-sensor-cells property is constrained to 1, but the MT6323 hardware only possesses a single thermal sensor, violating DT ABI design principles.
- [Low] The device tree example is missing the adc node and its corresponding mt6323_adc label, which is referenced by the new thermal node. --
commit 5d14cb32b8298f2c8dd1f6c1a6921b9e3942bf24
Author: Roman Vivchar <[email protected]>
dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC thermal
This commit adds devicetree binding documentation for the MediaTek mt6323 thermal monitoring hardware, which reads temperature via an AUXADC channel. It configures #thermal-sensor-cells to 1 and includes a thermal node in the example block.
Quoted 3 lines
While mt6323 exposes only a single thermal sensor, newer PMICs like mt6358 provide more than one sensor. Therefore define #thermal-sensor-cells as 1 to avoid breaking devicetree ABI in the future.
Since the mt6323 hardware only possesses a single thermal sensor, shouldn't #thermal-sensor-cells be constrained to 0?
Future hardware variants like the mt6358 will use different compatible strings, which can then define their own #thermal-sensor-cells: const: 1 constraint without affecting the mt6323 ABI.
Setting it to 1 here forces a dummy cell argument on single-sensor mt6323 devices, misrepresenting the actual hardware.
Quoted 4 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +0
-0
[ ... ]
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml examples: · line 555
Quoted 10 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +6
-0@@ -511,6 +547,14 @@ examples: rtc { compatible = "mediatek,mt6323-rtc"; }; + + thermal { + compatible = "mediatek,mt6323-thermal"; + nvmem-cells = <&mt6323_thermal_calibration_data>; + + io-channels = <&mt6323_adc MT6323_AUXADC_CHIP_TEMP>;
Does the mt6323_adc label exist in this example?
Looking through the example block, the adc sub-node and its corresponding mt6323_adc label do not seem to be defined. Will this cause dtc to fail with a reference to non-existent node or label error during dt_binding_check?
Quoted 3 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +2
-0+ #thermal-sensor-cells = <1>; + }; };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Rob Herring
maintainerRe: [PATCH v2 04/16] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC thermal
Quoted 22 lines · On Wed, May 13, 2026 at 05:00:07AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The#thermal-sensor-cellsproperty is constrained to 1, but the MT6323 hardware only possesses a single thermal sensor, violating DT ABI design principles.
- [Low] The device tree example is missing theadcnode and its correspondingmt6323_adclabel, which is referenced by the newthermalnode. --commit
5d14cb32b8298f2c8dd1f6c1a6921b9e3942bf24
Author: Roman Vivchar <[email protected]>dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC thermal
This commit adds devicetree binding documentation for the MediaTek mt6323 thermal monitoring hardware, which reads temperature via an AUXADC channel. It configures #thermal-sensor-cells to 1 and includes a thermal node in the example block.
Quoted 3 lines
While mt6323 exposes only a single thermal sensor, newer PMICs like mt6358 provide more than one sensor. Therefore define #thermal-sensor-cells as 1 to avoid breaking devicetree ABI in the future.
Since the mt6323 hardware only possesses a single thermal sensor, shouldn't #thermal-sensor-cells be constrained to 0?
Quoted 6 lines
Future hardware variants like the mt6358 will use different compatible strings, which can then define their own #thermal-sensor-cells: const: 1 constraint without affecting the mt6323 ABI.
Setting it to 1 here forces a dummy cell argument on single-sensor mt6323 devices, misrepresenting the actual hardware.
No, that's fine.
Quoted 19 lines
Quoted 5 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +0
-0[ ... ]
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml examples: · line 555
Quoted 10 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +6
-0@@ -511,6 +547,14 @@ examples: rtc { compatible = "mediatek,mt6323-rtc"; }; + + thermal { + compatible = "mediatek,mt6323-thermal"; + nvmem-cells = <&mt6323_thermal_calibration_data>; + + io-channels = <&mt6323_adc MT6323_AUXADC_CHIP_TEMP>;Does the
mt6323_adclabel exist in this example?
Quoted 3 lines
Looking through the example block, the adc sub-node and its corresponding
mt6323_adclabel do not seem to be defined. Will this cause dtc to fail with a reference to non-existent node or label error duringdt_binding_check?
Annoyingly, sashiko seems to consistently get this comment wrong.
Rob
Re: [PATCH v2 04/16] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC thermal
In reply to Roman VivcharQuoted 4 lines · Roman Vivchar
The MediaTek mt6323 PMIC temperature can be read using AUXADC channel.
Add the devicetree binding documentation for the MediaTek mt6323 thermal.
Quoted 9 lines
While mt6323 exposes only a single thermal sensor, newer PMICs like mt6358 provide more than one sensor. Therefore define #thermal-sensor-cells as 1 to avoid breaking devicetree ABI in the future.
Signed-off-by Roman Vivchar <[email protected]>--- .../devicetree/bindings/mfd/mediatek,mt6397.yaml | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+)
Roman Vivchar
maintainerPATCH v2 5/16 iio: adc: mediatek: add mt6323 PMIC AUXADC driver
In reply to Roman VivcharThe mt6323 AUXADC is a 15-bit ADC used for system monitoring. This driver provides support for reading various channels including battery and charger voltages, battery and chip temperature, current sensing and accessory detection.
Add a driver for the AUXADC found in the MediaTek mt6323 PMIC.
--- drivers/iio/adc/Kconfig | 11 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mt6323-auxadc.c | 319 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 331 insertions(+)
drivers/iio/adc/Kconfig +11 -0
@@ -1137,6 +1137,17 @@ config MCP3911 This driver can also be built as a module. If so, the module will be called mcp3911. +config MEDIATEK_MT6323_AUXADC + tristate "MediaTek MT6323 PMIC AUXADC driver" + depends on MFD_MT6397 + help + Say yes here to enable support for MediaTek MT6323 PMIC Auxiliary ADC. + This driver provides multiple channels for system monitoring, + such as battery voltage, PMIC temperature, and others. + + This driver can also be built as a module. If so, the module will be + called mt6323-auxadc. + config MEDIATEK_MT6359_AUXADC tristate "MediaTek MT6359 PMIC AUXADC driver" depends on MFD_MT6397
drivers/iio/adc/Makefile +1 -0
@@ -99,6 +99,7 @@ obj-$(CONFIG_MCP320X) += mcp320x.o obj-$(CONFIG_MCP3422) += mcp3422.o obj-$(CONFIG_MCP3564) += mcp3564.o obj-$(CONFIG_MCP3911) += mcp3911.o +obj-$(CONFIG_MEDIATEK_MT6323_AUXADC) += mt6323-auxadc.o obj-$(CONFIG_MEDIATEK_MT6359_AUXADC) += mt6359-auxadc.o obj-$(CONFIG_MEDIATEK_MT6360_ADC) += mt6360-adc.o obj-$(CONFIG_MEDIATEK_MT6370_ADC) += mt6370-adc.o
drivers/iio/adc/mt6323-auxadc.c new file +319 -0
319 lines not on this page · raw message
Signature · 1 line
2.54.0
Re: [PATCH v2 05/16] iio: adc: mediatek: add mt6323 PMIC AUXADC driver
Quoted 7 lines · On Tue, May 12, 2026 at 8:21 AM Roman Vivchar via B4 Relay…
The mt6323 AUXADC is a 15-bit ADC used for system monitoring. This driver provides support for reading various channels including battery and charger voltages, battery and chip temperature, current sensing and accessory detection.
Add a driver for the AUXADC found in the MediaTek mt6323 PMIC.
...
drivers/iio/adc/mt6323-auxadc.c line 20
Quoted 13 lines
drivers/iio/adc/mt6323-auxadc.c new file +13
-0+#include <linux/array_size.h> +#include <linux/bitfield.h> +#include <linux/bits.h> +#include <linux/cleanup.h> +#include <linux/delay.h> +#include <linux/iio/iio.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regmap.h> +#include <linux/stringify.h>
+ time.h // USEC_PER_MSEC
Quoted 1 line
+#include <
linux/types.h>
...
drivers/iio/adc/mt6323-auxadc.c line 36
Quoted 4 lines
drivers/iio/adc/mt6323-auxadc.c new file +4
-0+#define AUXADC_TRIM_CH2 (3 << 10) +#define AUXADC_TRIM_CH4 (3 << 8) +#define AUXADC_TRIM_CH5 (3 << 4) +#define AUXADC_TRIM_CH6 (3 << 2)
Without a comment it's hard to say if these are like masks or actual values. Can you clarify that in the comment on top of these four?
Quoted 1 line
+#define
VOLTAGE_FULL_RANGE1800
Are there any units? Are they millivolts or is it just some scale?
...
drivers/iio/adc/mt6323-auxadc.c line 70
Quoted 9 lines
drivers/iio/adc/mt6323-auxadc.c new file +9
-0+#define MTK_PMIC_IIO_CHAN (_name, _idx, _ch_type) \ +{ \ + .type = _ch_type, \ + .indexed = 1, \ + .channel = _idx, \ + .address = _idx, \ + .datasheet_name = __stringify(_name), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE) \
Keep the trailing comma as this is not a terminator.
Quoted 1 line
+}
...
Quoted 9 lines
+/**
+ * structmt6323_auxadc- Main driver structure
+ * @regmap: Regmap from PWRAP
+ * @lock: Mutex to serialize AUXADC reading vs configuration
+ *
+ * The MediaTek MT6323 (as well as lot of other PMICs) have the following hierarchy:
+ * PMIC AUXADC <- PMIC MFD <- SoC PWRAP (wrapper for PWRAP FSM)
+ *
+ * Therefore, PWRAP regmap should be get usingdev->parent->parent.
get --> obtained
Quoted 1 line
+ */
...
Quoted 6 lines
drivers/iio/adc/mt6323-auxadc.c new file +6
-0+static int mt6323_auxadc_prepare_channel (struct mt6323_auxadc *auxadc) +{ +struct regmap *map = auxadc->regmap; +u32 val; +int ret; +
drivers/iio/adc/mt6323-auxadc.c line 141
Quoted 10 lines
drivers/iio/adc/mt6323-auxadc.c new file +10
-0+ ret =regmap_read (map,MT6323_AUXADC_CON19 , &val); +if (ret) +return ret; + +/* The ADC is idle */ +if (!(val &AUXADC_DECI_GDLY_MASK )) +return 0 ; + + ret =regmap_read_poll_timeout (map,MT6323_AUXADC_ADC19 , val, + !(val &AUXADC_ADC19_BUSY_MASK ),10 ,500 );
It's better to have a logical split
ret = regmap_read_poll_timeout(map, MT6323_AUXADC_ADC19,
val, !(val & AUXADC_ADC19_BUSY_MASK),
10, 500);Quoted 6 lines
drivers/iio/adc/mt6323-auxadc.c new file +6
-0+if (ret) +return ret; + +return regmap_clear_bits (map,MT6323_AUXADC_CON19 , +AUXADC_DECI_GDLY_MASK ); +}
...
drivers/iio/adc/mt6323-auxadc.c line 173
Quoted 8 lines
drivers/iio/adc/mt6323-auxadc.c new file +8
-0+static int mt6323_auxadc_read (struct mt6323_auxadc *auxadc, +const struct iio_chan_spec *chan,int *out) +{ +struct regmap *map = auxadc->regmap; +u32 val, reg =mt6323_auxadc_channel_to_reg (chan->address); +int ret; + + ret = regmap_read_poll_timeout(map, reg, val, (val & AUXADC_RDY_MASK),
Parentheses are not needed in this case. But I'm fine with it here as it probably makes it easier to get the idea.
drivers/iio/adc/mt6323-auxadc.c line 185
Quoted 12 lines
drivers/iio/adc/mt6323-auxadc.c new file +12
-0+ 1 * USEC_PER_MSEC, 100 * USEC_PER_MSEC); +if (ret) +return ret; + + *out =FIELD_GET (AUXADC_DATA_MASK , val); + +return 0 ; +} + +static int mt6323_auxadc_read_raw (struct iio_dev *indio_dev, +const struct iio_chan_spec *chan,int *val, +int *val2,long mask)
Logical split
static int mt6323_auxadc_read_raw(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, int *val, int *val2, long mask)
drivers/iio/adc/mt6323-auxadc.c line 188
Quoted 3 lines
drivers/iio/adc/mt6323-auxadc.c new file +3
-0+{ +struct mt6323_auxadc *auxadc =iio_priv (indio_dev); +int ret, mult =1 ;
Decouple assignment and definition. These types of assignments are hard to maintain and might lead to subtle mistakes in the future.
drivers/iio/adc/mt6323-auxadc.c line 198
Quoted 9 lines
drivers/iio/adc/mt6323-auxadc.c new file +9
-0+if (mask ==IIO_CHAN_INFO_RAW ) { +guard (mutex)(&auxadc->lock); + ret =mt6323_auxadc_prepare_channel (auxadc); +if (ret) +return ret; + + ret =mt6323_auxadc_request (auxadc, chan->address); +if (ret) +return ret;
Please, add a comment with the reference to a datasheet (ideally) explaining this sleep.
drivers/iio/adc/mt6323-auxadc.c line 206
Quoted 7 lines
drivers/iio/adc/mt6323-auxadc.c new file +7
-0+fsleep (300 ); + + ret =mt6323_auxadc_read (auxadc, chan, val); +if (ret) +return ret; +return IIO_VAL_INT ; + }else if (mask ==IIO_CHAN_INFO_SCALE ) {
Redundant 'else'
drivers/iio/adc/mt6323-auxadc.c line 215
Quoted 10 lines
drivers/iio/adc/mt6323-auxadc.c new file +9
-0+if (chan->channel ==MT6323_AUXADC_ISENSE || + chan->channel ==MT6323_AUXADC_BATSNS ) + mult =4 ; + + *val = mult *VOLTAGE_FULL_RANGE ; + *val2 =AUXADC_PRECISE ; + +return IIO_VAL_FRACTIONAL ; + }else
Ditto, and it's the wrong style. Read the Coding Style documentation to clarify this.
Quoted 2 lines
(quoted diff) +2
-0+ return -EINVAL; +}
...
drivers/iio/adc/mt6323-auxadc.c line 284
Quoted 3 lines
drivers/iio/adc/mt6323-auxadc.c new file +3
-0+ ret =devm_mutex_init (dev, &auxadc->lock); +if (ret) +return dev_err_probe (dev, ret,"failed to initialize mutex\n" );
Unneeded error message. Most likely it's -ENOMEM, which will be ignored by dev_err_probe() anyway.
...
drivers/iio/adc/mt6323-auxadc.c line 298
Quoted 3 lines
drivers/iio/adc/mt6323-auxadc.c new file +3
-0+ ret =devm_iio_device_register (dev, iio); +if (ret) +return dev_err_probe (dev, ret,"failed to register iio device\n" );
If you don't see the device, it's failed to register, do we need this message?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerRe: [PATCH v2 05/16] iio: adc: mediatek: add mt6323 PMIC AUXADC driver
In reply to Roman VivcharQuoted 11 lines · On Tue, 12 May 2026 08:18:19 +0300 Roman Vivchar via B4 Relay…
From: Roman Vivchar <[email protected]>
The mt6323 AUXADC is a 15-bit ADC used for system monitoring. This driver provides support for reading various channels including battery and charger voltages, battery and chip temperature, current sensing and accessory detection.
Add a driver for the AUXADC found in the MediaTek mt6323 PMIC.
Hi Roman
Various comments inline - mostly naming related.
Jonathan
Quoted 44 lines
drivers/iio/adc/mt6323-auxadc.c new file +38
-0@@ -0,0 +1,319 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2026 Roman Vivchar <[email protected]> +* +* Based on drivers/iio/adc/mt6359-auxadc.c +*/ + +#include <linux/array_size.h> +#include <linux/bitfield.h> +#include <linux/bits.h> +#include <linux/cleanup.h> +#include <linux/delay.h> +#include <linux/iio/iio.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regmap.h> +#include <linux/stringify.h> +#include <linux/types.h> + +#include <linux/mfd/mt6397/core.h> +#include <linux/mfd/mt6323/registers.h> + +#include <dt-bindings/iio/adc/mediatek,mt6323-auxadc.h> + +#define AUXADC_RSTB_SEL BIT(7) +#define AUXADC_RSTB_SW BIT(5) + +#define AUXADC_CTL_CK BIT(5) + +#define AUXADC_TRIM_CH2 (3 << 10) +#define AUXADC_TRIM_CH4 (3 << 8) +#define AUXADC_TRIM_CH5 (3 << 4) +#define AUXADC_TRIM_CH6 (3 << 2) + +#define AUXADC_VREF18_ENB_MD BIT(15)
drivers/iio/adc/mt6323-auxadc.c line 48
Quoted 10 lines
drivers/iio/adc/mt6323-auxadc.c new file +10
-0+#define AUXADC_MD_STATUS BIT(0) + +#define AUXADC_GPS_STATUS BIT(1) + +#define AUXADC_VREF18_SELB BIT(1) +#define AUXADC_DECI_GDLY_SEL BIT(0) + +#define AUXADC_VBUF_EN BIT(4) + +#define AUXADC_DECI_GDLY_MASK GENMASK(15, 14)
Why you can it is much better to clearly associate a field mask definition with which register it is in. Lets us quickly spot if there is a missmatch.
#define AUXADC_CON19_DECI_GDLY_MASK for example.
THough DECI_GDLY isn't exactly easy to understand as abbreviations go!
drivers/iio/adc/mt6323-auxadc.c line 59
Quoted 11 lines
drivers/iio/adc/mt6323-auxadc.c new file +11
-0+#define AUXADC_ADC19_BUSY_MASK GENMASK(15, 1) +#define AUXADC_RDY_MASK BIT(15) +#define AUXADC_DATA_MASK GENMASK(14, 0) + +#define AUXADC_OSR_MASK GENMASK(12, 10) +#define AUXADC_DEFAULT_OSR 3 + +#define AUXADC_LOW_CHANNEL_MASK GENMASK(9, 0) +#define AUXADC_AUDIO_CHANNEL_MASK GENMASK(8, 0) + +#define VOLTAGE_FULL_RANGE 1800
Probably better to have this inline - however if you do keep it prefix t he define VOLTAGE_FULL_RANGE sounds too generic!
drivers/iio/adc/mt6323-auxadc.c line 60
Quoted 1 line
drivers/iio/adc/mt6323-auxadc.c new file +1
-0+#define AUXADC_PRECISE 32768
I'd put that inline. Little benefit it in having it up here...
drivers/iio/adc/mt6323-auxadc.c line 67
Quoted 7 lines
drivers/iio/adc/mt6323-auxadc.c new file +7
-0+ +#define MTK_PMIC_IIO_CHAN (_name, _idx, _ch_type) \ +{ \ + .type = _ch_type, \ + .indexed = 1, \ + .channel = _idx, \ + .address = _idx, \
Why put an index in address? Seems to me that complicates things vs putting the relevant register address in there.
Quoted 27 lines
drivers/iio/adc/mt6323-auxadc.c new file +27
-0+ .datasheet_name = __stringify(_name), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE) \ +} + +static const struct iio_chan_spec mt6323_auxadc_channels[] = { +MTK_PMIC_IIO_CHAN (baton2,MT6323_AUXADC_BATON2 ,IIO_VOLTAGE ), +MTK_PMIC_IIO_CHAN (ch6,MT6323_AUXADC_CH6 ,IIO_VOLTAGE ), +MTK_PMIC_IIO_CHAN (bat_temp,MT6323_AUXADC_BAT_TEMP ,IIO_TEMP ), +MTK_PMIC_IIO_CHAN (chip_temp,MT6323_AUXADC_CHIP_TEMP ,IIO_TEMP ), +MTK_PMIC_IIO_CHAN (vcdt,MT6323_AUXADC_VCDT ,IIO_VOLTAGE ), +MTK_PMIC_IIO_CHAN (baton1,MT6323_AUXADC_BATON1 ,IIO_VOLTAGE ), +MTK_PMIC_IIO_CHAN (isense,MT6323_AUXADC_ISENSE ,IIO_VOLTAGE ), +MTK_PMIC_IIO_CHAN (batsns,MT6323_AUXADC_BATSNS ,IIO_VOLTAGE ), +MTK_PMIC_IIO_CHAN (accdet,MT6323_AUXADC_ACCDET ,IIO_VOLTAGE ), +}; + +/** +* struct mt6323_auxadc - Main driver structure +* @regmap: Regmap from PWRAP +* @lock: Mutex to serialize AUXADC reading vs configuration +* +* The MediaTek MT6323 (as well as lot of other PMICs) have the following hierarchy: +* PMIC AUXADC <- PMIC MFD <- SoC PWRAP (wrapper for PWRAP FSM) +* +* Therefore, PWRAP regmap should be get using dev->parent->parent. +*/
drivers/iio/adc/mt6323-auxadc.c line 104
Quoted 10 lines
drivers/iio/adc/mt6323-auxadc.c new file +10
-0+struct mt6323_auxadc { +struct regmap *regmap; +struct mutex lock; +}; + +static u32 mt6323_auxadc_channel_to_reg (unsigned long channel) +{ +switch (channel) { +case MT6323_AUXADC_BATON2 : +return MT6323_AUXADC_ADC6 ;
You should put these in chan->address perhaps to avoid need for a separate lookup function.
Quoted 18 lines
drivers/iio/adc/mt6323-auxadc.c new file +18
-0+case MT6323_AUXADC_CH6 : +return MT6323_AUXADC_ADC11 ; +case MT6323_AUXADC_BAT_TEMP : +return MT6323_AUXADC_ADC5 ; +case MT6323_AUXADC_CHIP_TEMP : +return MT6323_AUXADC_ADC4 ; +case MT6323_AUXADC_VCDT : +return MT6323_AUXADC_ADC2 ; +case MT6323_AUXADC_BATON1 : +return MT6323_AUXADC_ADC3 ; +case MT6323_AUXADC_ISENSE : +return MT6323_AUXADC_ADC1 ; +case MT6323_AUXADC_BATSNS : +return MT6323_AUXADC_ADC0 ; +case MT6323_AUXADC_ACCDET : +return MT6323_AUXADC_ADC7 ; +default : +return MT6323_AUXADC_ADC17 ;
drivers/iio/adc/mt6323-auxadc.c line 155
Quoted 10 lines
drivers/iio/adc/mt6323-auxadc.c new file +9
-0+ } +} +static int mt6323_auxadc_request (struct mt6323_auxadc *auxadc, +unsigned long channel) +{ +struct regmap *map = auxadc->regmap; +int ret; + + ret =regmap_set_bits (map,MT6323_AUXADC_CON11 ,AUXADC_VBUF_EN );
As above. I'd like that field name to include which register it is in. That makes it easier to spot mismatches.
Quoted 5 lines
drivers/iio/adc/mt6323-auxadc.c new file +5
-0+if (ret) +return ret; + + ret =regmap_clear_bits (map,MT6323_AUXADC_CON22 ,BIT (channel)); +if (ret)
drivers/iio/adc/mt6323-auxadc.c line 170
Quoted 10 lines
drivers/iio/adc/mt6323-auxadc.c new file +10
-0+return ret; + +return regmap_set_bits (map,MT6323_AUXADC_CON22 ,BIT (channel)); +} + +static int mt6323_auxadc_read (struct mt6323_auxadc *auxadc, +const struct iio_chan_spec *chan,int *out) +{ +struct regmap *map = auxadc->regmap; +u32 val, reg =mt6323_auxadc_channel_to_reg (chan->address);
Don't mix elements that assign with ones that don't. Doesn't make for easy to read code.
Quoted 26 lines
drivers/iio/adc/mt6323-auxadc.c new file +26
-0+int ret; + + ret =regmap_read_poll_timeout (map, reg, val, (val &AUXADC_RDY_MASK ), +1 *USEC_PER_MSEC ,100 *USEC_PER_MSEC ); +if (ret) +return ret; + + *out =FIELD_GET (AUXADC_DATA_MASK , val); + +return 0 ; +} + +static int mt6323_auxadc_read_raw (struct iio_dev *indio_dev, +const struct iio_chan_spec *chan,int *val, +int *val2,long mask) +{ +struct mt6323_auxadc *auxadc =iio_priv (indio_dev); +int ret, mult =1 ; + +if (mask ==IIO_CHAN_INFO_RAW ) { +guard (mutex)(&auxadc->lock); + ret =mt6323_auxadc_prepare_channel (auxadc); +if (ret) +return ret; + + ret =mt6323_auxadc_request (auxadc, chan->address);
drivers/iio/adc/mt6323-auxadc.c line 206
Quoted 10 lines
drivers/iio/adc/mt6323-auxadc.c new file +10
-0+if (ret) +return ret; + +fsleep (300 ); + + ret =mt6323_auxadc_read (auxadc, chan, val); +if (ret) +return ret; +return IIO_VAL_INT ; + }else if (mask ==IIO_CHAN_INFO_SCALE ) {
Andy covered not having the else etc already I think. A switch might work better though.
drivers/iio/adc/mt6323-auxadc.c line 212
Quoted 6 lines
drivers/iio/adc/mt6323-auxadc.c new file +6
-0+if (chan->channel ==MT6323_AUXADC_ISENSE || + chan->channel ==MT6323_AUXADC_BATSNS ) + mult =4 ; + + *val = mult *VOLTAGE_FULL_RANGE ; + *val2 =AUXADC_PRECISE ;
IIO_VAL_FRACTIONAL_LOG2 probably more appropriate here (which would be more obvious with the values down here.
Quoted 13 lines
drivers/iio/adc/mt6323-auxadc.c new file +13
-0+ +return IIO_VAL_FRACTIONAL ; + }else +return -EINVAL ; +} + +static int mt6323_auxadc_init (struct mt6323_auxadc *auxadc) +{ +struct regmap *map = auxadc->regmap; +int ret; + + ret =regmap_set_bits (map,MT6323_STRUP_CON10 , +AUXADC_RSTB_SW |AUXADC_RSTB_SEL );
drivers/iio/adc/mt6323-auxadc.c line 235
Quoted 10 lines
drivers/iio/adc/mt6323-auxadc.c new file +10
-0+if (ret) +return ret; + + ret =regmap_set_bits (map,MT6323_TOP_CKPDN2 ,AUXADC_CTL_CK ); +if (ret) +return ret; + + ret =regmap_set_bits (map,MT6323_AUXADC_CON10 , +AUXADC_TRIM_CH2 |AUXADC_TRIM_CH4 | +AUXADC_TRIM_CH5 |AUXADC_TRIM_CH6 );
ret = regmap_set_bits(map, MT6323_AUXADC_CON10, AUXADC_TRIM_CH2 | AUXADC_TRIM_CH4 | AUXADC_TRIM_CH5 | AUXADC_TRIM_CH6);
is fine.
Quoted 11 lines
drivers/iio/adc/mt6323-auxadc.c new file +11
-0+if (ret) +return ret; + + ret =regmap_set_bits (map,MT6323_AUXADC_CON27 , +AUXADC_VREF18_ENB_MD |AUXADC_MD_STATUS ); +if (ret) +return ret; + + ret =regmap_set_bits (map,MT6323_AUXADC_CON19 ,AUXADC_GPS_STATUS ); +if (ret) +return ret;
drivers/iio/adc/mt6323-auxadc.c line 256
Quoted 10 lines
drivers/iio/adc/mt6323-auxadc.c new file +10
-0+ + ret =regmap_set_bits (map,MT6323_AUXADC_CON26 , +AUXADC_VREF18_SELB |AUXADC_DECI_GDLY_SEL ); +if (ret) +return ret; + + ret =regmap_update_bits (map,MT6323_AUXADC_CON9 ,AUXADC_OSR_MASK , +FIELD_PREP (AUXADC_OSR_MASK , +AUXADC_DEFAULT_OSR )); +return ret;
Might as well do
return regmap_update_bits()
Quoted 1 line
+}
Roman Vivchar
maintainerRe: [PATCH v2 05/16] iio: adc: mediatek: add mt6323 PMIC AUXADC driver
Quoted 2 lines · Jonathan Cameron
On Tue, 12 May 2026 08:18:19 +0300
Roman Vivchar via B4 Relay <[email protected]> wrote:
...
Quoted 6 lines
Quoted 1 line
+#define
VOLTAGE_FULL_RANGE1800Probably better to have this inline - however if you do keep it prefix t he define
VOLTAGE_FULL_RANGEsounds too generic!Quoted 1 line
+#define
AUXADC_PRECISE32768I'd put that inline. Little benefit it in having it up here...
There was a mention about magic values in the v1 for the thermal patch [1]. Andy, would it be better to use an inline style or a #define here? If the former, I'll rename the first constant to something like AUXADC_VOLTAGE_FULL_RANGE.
[1]: https://lore.kernel.org/linux-mediatek/[email protected]/
Best regards,
Roman
Re: [PATCH v2 05/16] iio: adc: mediatek: add mt6323 PMIC AUXADC driver
Quoted 3 lines · Roman Vivchar
Quoted 2 lines · Jonathan Cameron
On Tue, 12 May 2026 08:18:19 +0300
Roman Vivchar via B4 Relay <[email protected]> wrote:
...
Quoted 11 lines
Quoted 6 lines
Quoted 1 line
+#define
VOLTAGE_FULL_RANGE1800Probably better to have this inline - however if you do keep it prefix t he define
VOLTAGE_FULL_RANGEsounds too generic!Quoted 1 line
+#define
AUXADC_PRECISE32768I'd put that inline. Little benefit it in having it up here...
There was a mention about magic values in the v1 for the thermal patch [1]. Andy, would it be better to use an inline style or a #define here? If the former, I'll rename the first constant to something like
AUXADC_VOLTAGE_FULL_RANGE.
If you use it inline, add a comment to explain the magic. It will be a good compromise.
Quoted 1 line
[1]: https://lore.kernel.org/linux-mediatek/[email protected]/
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerRe: [PATCH v2 05/16] iio: adc: mediatek: add mt6323 PMIC AUXADC driver
In reply to Roman VivcharQuoted 11 lines · On Tue, 12 May 2026 14:34:55 +0000 Roman Vivchar <[email protected]> wrote:
Quoted 2 lines · Jonathan Cameron
On Tue, 12 May 2026 08:18:19 +0300
Roman Vivchar via B4 Relay <[email protected]> wrote:...
Quoted 4 lines
Quoted 1 line
+#define
VOLTAGE_FULL_RANGE1800Probably better to have this inline - however if you do keep it prefix t he define
VOLTAGE_FULL_RANGEsounds too generic!
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
+#define
AUXADC_PRECISE32768I'd put that inline. Little benefit it in having it up here...
There was a mention about magic values in the v1 for the thermal patch [1]. Andy, would it be better to use an inline style or a #define here? If the former, I'll rename the first constant to something like
AUXADC_VOLTAGE_FULL_RANGE.
FWIW that isn't a magic value - it's 2**resolution and the one is a voltage in mV. Those aren't normally the ones people care about defines for - those apply when they are weird and wonderful things not related directly to physical quantities.
Jonathan
Quoted 5 lines
[1]: https://lore.kernel.org/linux-mediatek/[email protected]/
Best regards,
Roman
[email protected]
AI reviewRe: [PATCH v2 05/16] iio: adc: mediatek: add mt6323 PMIC AUXADC driver
In reply to Roman VivcharThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Hardware initialization uses inverted logic, powering down the ADC clock and disabling its voltage…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Hardware initialization uses inverted logic, powering down the ADC clock and disabling its voltage reference. --
commit a9bbb1136cb8fc7a5d965b8e9d48f405b0c7b4fa
Author: Roman Vivchar <[email protected]>
iio: adc: mediatek: add mt6323 PMIC AUXADC driver
This commit adds a new driver for the 15-bit AUXADC found in the MediaTek mt6323 PMIC. It provides support for reading channels like battery voltage, temperatures, and accessory detection.
Quoted 5 lines
drivers/iio/adc/mt6323-auxadc.c new file +0
-0
[ ... ]
drivers/iio/adc/mt6323-auxadc.c line 229
Quoted 11 lines
drivers/iio/adc/mt6323-auxadc.c new file +11
-0+static int mt6323_auxadc_init (struct mt6323_auxadc *auxadc) +{ +struct regmap *map = auxadc->regmap; +int ret; + + ret =regmap_set_bits (map,MT6323_STRUP_CON10 , +AUXADC_RSTB_SW |AUXADC_RSTB_SEL ); +if (ret) +return ret; + + ret =regmap_set_bits (map,MT6323_TOP_CKPDN2 ,AUXADC_CTL_CK );
Is it intentional to set AUXADC_CTL_CK here? In MediaTek PMICs, CKPDN typically stands for Clock Power Down, meaning a value of 1 powers off the clock. Should this use regmap_clear_bits() instead to enable the ADC clock?
drivers/iio/adc/mt6323-auxadc.c line 240
Quoted 11 lines
drivers/iio/adc/mt6323-auxadc.c new file +11
-0+if (ret) +return ret; + + ret =regmap_set_bits (map,MT6323_AUXADC_CON10 , +AUXADC_TRIM_CH2 |AUXADC_TRIM_CH4 | +AUXADC_TRIM_CH5 |AUXADC_TRIM_CH6 ); +if (ret) +return ret; + + ret =regmap_set_bits (map,MT6323_AUXADC_CON27 , +AUXADC_VREF18_ENB_MD |AUXADC_MD_STATUS );
Does setting AUXADC_VREF18_ENB_MD disable the 1.8V analog voltage reference?
The _ENB suffix usually indicates an active-low enable signal. If setting this bit to 1 disables the reference voltage, it might leave the hardware functionally offline.
Could regmap_clear_bits() be the correct operation for the active-low enable bar signal?
Quoted 2 lines
drivers/iio/adc/mt6323-auxadc.c new file +2
-0+if (ret) +return ret;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Roman Vivchar
maintainerPATCH v2 6/16 nvmem: add mt6323 PMIC EFUSE driver
In reply to Roman VivcharAdd support for the EFUSE controller found in the Mediatek MT6323 PMIC. The MT6323 EFUSE stores 24 bytes of hardware-related data, such as thermal sensor calibration values.
--- drivers/nvmem/Kconfig | 11 ++++++ drivers/nvmem/Makefile | 2 ++ drivers/nvmem/mt6323-efuse.c | 86 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+)
drivers/nvmem/Kconfig +11 -0
@@ -227,6 +227,17 @@ config NVMEM_MTK_EFUSE This driver can also be built as a module. If so, the module will be called efuse-mtk. +config NVMEM_MT6323_EFUSE + tristate "Mediatek MT6323 PMIC EFUSE support" + depends on ARCH_MEDIATEK || COMPILE_TEST + depends on MFD_MT6397 + help + This is a driver to access hardware related data like sensor + calibration, etc. + + This driver can also be built as a module. If so, the module + will be called efuse-mt6323. + config NVMEM_MXS_OCOTP tristate "Freescale MXS On-Chip OTP Memory Support" depends on ARCH_MXS || COMPILE_TEST
drivers/nvmem/Makefile +2 -0
@@ -48,6 +48,8 @@ obj-$(CONFIG_NVMEM_MICROCHIP_OTPC) += nvmem-microchip-otpc.o nvmem-microchip-otpc-y := microchip-otpc.o obj-$(CONFIG_NVMEM_MTK_EFUSE) += nvmem_mtk-efuse.o nvmem_mtk-efuse-y := mtk-efuse.o +obj-$(CONFIG_NVMEM_MT6323_EFUSE) += nvmem_mt6323-efuse.o +nvmem_mt6323-efuse-y := mt6323-efuse.o obj-$(CONFIG_NVMEM_MXS_OCOTP) += nvmem-mxs-ocotp.o nvmem-mxs-ocotp-y := mxs-ocotp.o obj-$(CONFIG_NVMEM_NINTENDO_OTP) += nvmem-nintendo-otp.o
drivers/nvmem/mt6323-efuse.c new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.54.0
Re: [PATCH v2 06/16] nvmem: add mt6323 PMIC EFUSE driver
Quoted 4 lines · On Tue, May 12, 2026 at 8:21 AM Roman Vivchar via B4 Relay…
Add support for the EFUSE controller found in the Mediatek MT6323 PMIC. The MT6323 EFUSE stores 24 bytes of hardware-related data, such as thermal sensor calibration values.
...
drivers/nvmem/mt6323-efuse.c line 7
Quoted 3 lines
drivers/nvmem/mt6323-efuse.c new file +2
-0+#include <linux/err.h> +#include <linux/errno.h>
Doesn't seem to be used as err.h implies asm/errno.h that provides basic error codes.
Quoted 6 lines
drivers/nvmem/mt6323-efuse.c new file +6
-0+#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/nvmem-provider.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> +#include <linux/types.h>
...
Quoted 10 lines
drivers/nvmem/mt6323-efuse.c new file +10
-0+static int mt6323_efuse_read (void *context,unsigned int offset,void *val, +size_t bytes) +{ +struct regmap *map = context; +u32 tmp; +u16 *buf = val; +int ret; + +/* +* Manual regmap_read with loop is needed, because PWRAP is not
drivers/nvmem/mt6323-efuse.c line 39
Quoted 10 lines
drivers/nvmem/mt6323-efuse.c new file +9
-0+* a continuous MMIO space, but rather FSM which doesn't implement +* necessary read callback for the regmap_read_raw and regmap_read_bulk +* functions. +*/ +for (size_t i =0 ; i < bytes; i +=sizeof (*buf)) { + ret =regmap_read (map,MT6323_EFUSE_DOUT_BASE + offset + i, &tmp); +if (ret) +return ret; + *buf++ = (u16 )tmp;
Why explicit casting?
Quoted 4 lines
drivers/nvmem/mt6323-efuse.c new file +4
-0+ } + +return 0 ; +}
Signature · 2 lines
With Best Regards, Andy Shevchenko
[email protected]
AI reviewRe: [PATCH v2 06/16] nvmem: add mt6323 PMIC EFUSE driver
In reply to Roman VivcharThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] Unsafe device topology assumption leads to a NULL pointer dereference and kernel panic. - [Medium]…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Unsafe device topology assumption leads to a NULL pointer dereference and kernel panic.
- [Medium] Direct 16-bit assignments to the output buffer cause endianness corruption and potential unaligned memory access.
- [Low] Kconfig help text documents an incorrect module name.
--
commit 4bbd96ffdcf57f8479b893cecdcd10f45fef30fa
Author: Roman Vivchar <[email protected]>
nvmem: add mt6323 PMIC EFUSE driver
This commit adds support for the EFUSE controller found in the Mediatek MT6323 PMIC. It registers an nvmem device to provide access to 24 bytes of hardware-related data, such as thermal sensor calibration values.
Quoted 4 lines
drivers/nvmem/Kconfig +0
-0
[ ... ]
Quoted 4 lines
drivers/nvmem/Kconfig +0
-0@@ -227,6 +227,17 @@ config NVMEM_MTK_EFUSE This driver can also be built as a module. If so, the module will be called efuse-mtk.
drivers/nvmem/Kconfig config NVMEM_MTK_EFUSE · line 239
Quoted 10 lines
drivers/nvmem/Kconfig +10
-0+config NVMEM_MT6323_EFUSE + tristate "Mediatek MT6323 PMIC EFUSE support" + depends on ARCH_MEDIATEK || COMPILE_TEST + depends on MFD_MT6397 + help + This is a driver to access hardware related data like sensor + calibration, etc. + + This driver can also be built as a module. If so, the module + will be called efuse-mt6323.
This isn't a bug, but the help text says the module will be called efuse-mt6323, while the Makefile specifies the build target as nvmem_mt6323-efuse.o.
[ ... ]
Quoted 6 lines
drivers/nvmem/mt6323-efuse.c new file +0
-0@@ -0,0 +1,86 @@
[ ... ]
Quoted 10 lines
drivers/nvmem/mt6323-efuse.c new file +10
-0+static int mt6323_efuse_read (void *context,unsigned int offset,void *val, +size_t bytes) +{ +struct regmap *map = context; +u32 tmp; +u16 *buf = val; +int ret; + +/* +* Manual regmap_read with loop is needed, because PWRAP is not
drivers/nvmem/mt6323-efuse.c line 39
Quoted 10 lines
drivers/nvmem/mt6323-efuse.c new file +10
-0+* a continuous MMIO space, but rather FSM which doesn't implement +* necessary read callback for the regmap_read_raw and regmap_read_bulk +* functions. +*/ +for (size_t i =0 ; i < bytes; i +=sizeof (*buf)) { + ret =regmap_read (map,MT6323_EFUSE_DOUT_BASE + offset + i, &tmp); +if (ret) +return ret; + + *buf++ = (u16 )tmp;
Does this assignment cause alignment faults or endianness corruption?
The val pointer passed by the NVMEM API is a generic void pointer. Casting it to a u16 pointer and dereferencing it directly can trigger alignment faults on architectures that do not support unaligned memory access.
Additionally, this writes the data in the CPU's native byte order, which results in swapped bytes on big-endian architectures compared to little-endian architectures. Downstream consumers might expect a consistent data layout.
Could this use put_unaligned_le16() instead to ensure safe memory access and consistent byte ordering?
Quoted 10 lines
drivers/nvmem/mt6323-efuse.c new file +10
-0+ } + +return 0 ; +} + +static int mt6323_efuse_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct nvmem_config config = { + .name ="mt6323-efuse" ,
drivers/nvmem/mt6323-efuse.c line 59
Quoted 10 lines
drivers/nvmem/mt6323-efuse.c new file +10
-0+ .stride = 2, + .word_size = 2, + .size = MT6323_EFUSE_SIZE, + .reg_read = mt6323_efuse_read, + }; +struct nvmem_device *nvmem; +struct regmap *regmap; + +/* efuse -> mfd -> pwrap */ + regmap =dev_get_regmap (dev->parent->parent,NULL );
Can dev->parent->parent evaluate to NULL and cause a NULL pointer dereference here?
The driver registers an of_match_table, meaning it can be instantiated directly from a Device Tree node. If a malformed or overlay Device Tree places the node at the root level instead of within the expected PMIC/MFD hierarchy, the device is instantiated by the top-level platform bus.
In that case, dev->parent is the platform bus, which has no parent, so dev->parent->parent would be NULL. Passing a NULL device pointer to dev_get_regmap() will cause an immediate NULL pointer dereference when devres_find() attempts to acquire the lock.
Would it be safer to verify the existence of the expected parent hierarchy before dereferencing it?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Roman Vivchar
maintainerPATCH v2 7/16 thermal: mediatek: add PMIC thermal support
In reply to Roman VivcharAdd a new driver to support thermal monitoring on MediaTek PMICs.
The driver retrieves calibration data from EFUSE, calculates the temperature using a linear interpolation, and registers the device with the thermal framework.
Initial support is added for the mt6323 PMIC.
--- drivers/thermal/mediatek/Kconfig | 12 ++ drivers/thermal/mediatek/Makefile | 1 + drivers/thermal/mediatek/mtk_pmic_thermal.c | 316 ++++++++++++++++++++++++++++ 3 files changed, 329 insertions(+)
drivers/thermal/mediatek/Kconfig +12 -0
@@ -34,4 +34,16 @@ config MTK_LVTS_THERMAL_DEBUGFS help Enable this option to debug the internals of the device driver. +config MTK_PMIC_THERMAL + tristate "AUXADC temperature sensor driver for MediaTek PMICs" + depends on MFD_MT6397 + help + Enable this option if you want to get PMIC temperature + information for MediaTek platforms. + This driver configures thermal controllers to collect + temperature via AUXADC interface. + + This driver can also be built as a module. If so, the module will be + called mtk_pmic_thermal. + endif
drivers/thermal/mediatek/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_MTK_SOC_THERMAL) += auxadc_thermal.o obj-$(CONFIG_MTK_LVTS_THERMAL) += lvts_thermal.o +obj-$(CONFIG_MTK_PMIC_THERMAL) += mtk_pmic_thermal.o
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +316 -0
316 lines not on this page · raw message
Signature · 1 line
2.54.0
Re: [PATCH v2 07/16] thermal: mediatek: add PMIC thermal support
Quoted 8 lines · On Tue, May 12, 2026 at 8:21 AM Roman Vivchar via B4 Relay…
Add a new driver to support thermal monitoring on MediaTek PMICs.
The driver retrieves calibration data from EFUSE, calculates the temperature using a linear interpolation, and registers the device with the thermal framework.
Initial support is added for the mt6323 PMIC.
...
+ array_size.h
drivers/thermal/mediatek/mtk_pmic_thermal.c line 13
Quoted 7 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +6
-0+#include <linux/bitfield.h> +#include <linux/bits.h> +#include <linux/cleanup.h> +#include <linux/err.h> +#include <linux/iio/consumer.h> +#include <linux/kernel.h>
No way the driver(s) nowadays use this header. Please, drop it and add the ones that are really in use (there are missing ones).
drivers/thermal/mediatek/mtk_pmic_thermal.c line 19
Quoted 7 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +6
-0+#include <linux/module.h> +#include <linux/nvmem-consumer.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regmap.h> +#include <linux/slab.h>
Is it used?
Quoted 1 line
+#include <
linux/thermal.h>
Missing types.h
Quoted 1 line
+#include <
linux/units.h>
...
drivers/thermal/mediatek/mtk_pmic_thermal.c line 45
Quoted 2 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +2
-0+#define MT6323_ADC_VOLTAGE_RANGE 1800 +#define MT6323_ADC_RESOLUTION 32768
These two ring a bell with the first code patch. Are they the same? Can they be deduplicated?
...
drivers/thermal/mediatek/mtk_pmic_thermal.c line 95
Quoted 2 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +2
-0+ ret =iio_read_channel_processed (sensor->adc_channel, &raw); +if (ret <0 ) {
Do we need that ' < 0' part? What is the meaning of positive returned value (if any) and why do we ignore that? Same question to all similar checks in the whole series.
Quoted 4 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +4
-0+dev_err (sensor->mt->dev,"failed to read iio channel: %d\n" , + ret); +return ret; + }
...
drivers/thermal/mediatek/mtk_pmic_thermal.c line 130
Quoted 3 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +3
-0+/* +* Temperature coefficient. The o_slope is a trim value applied to +* the base calibration
Respect English grammar and punctuation. Here is the period missing.
Quoted 1 line
+ */
...
drivers/thermal/mediatek/mtk_pmic_thermal.c line 155
Quoted 6 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +6
-0+static int mtk_pmic_thermal_extract_efuse_mt6323 (struct mtk_pmic_thermal *mt, +u16 *buf) +{ +u32 reg; +s32 vts, degc_cali, o_slope, o_slope_sign, id; +int ret;
Better to keep reversed xmas tree order.
Quoted 2 lines
(quoted diff) +2
-0+ return 0; +}
...
drivers/thermal/mediatek/mtk_pmic_thermal.c line 198
Quoted 5 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +4
-0+static int mtk_pmic_thermal_get_calib_data (struct device *dev, +struct mtk_pmic_thermal *mt) +{ + void *buf __free(kfree) = NULL;
This is a discouraged way of defining variables with __free(). See below.
drivers/thermal/mediatek/mtk_pmic_thermal.c line 207
Quoted 9 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +8
-0+struct nvmem_cell *cell; +size_t len; +int ret; + + cell =nvmem_cell_get (dev,NULL ); +if (IS_ERR (cell)) +return PTR_ERR (cell); + buf =nvmem_cell_read (cell, &len);
Should be rather here
void *buf __free(kfree) = nvmem_cell_read(cell, &len);
drivers/thermal/mediatek/mtk_pmic_thermal.c line 218
Quoted 11 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +11
-0+nvmem_cell_put (cell); + +if (IS_ERR (buf)) { + ret =PTR_ERR (buf); + buf =NULL ; +return ret; + } + +if (len <2 *sizeof (u16)) { +dev_err (dev,"invalid calibration data length\n" ); +return -EINVAL ;
return dev_err_probe(...);
Quoted 18 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +18
-0+ } + + ret = mt->data->extract_efuse (mt, buf); +if (ret) { +dev_info (dev,"device not calibrated, using default values\n" ); + mt->data->precalc (mt,MT6323_DEFAULT_VTS , +MT6323_DEFAULT_DEGC_CALI , +MT6323_DEFAULT_SLOPE , +MT6323_DEFAULT_SLOPE_SIGN ); + } + +return 0 ; +} + +static int mtk_pmic_thermal_init_sensor (struct mtk_pmic_thermal *mt,int id) +{ +struct mtk_pmic_sensor *sensor = &mt->sensors[id]; +struct device *dev = mt->dev;
drivers/thermal/mediatek/mtk_pmic_thermal.c line 245
Quoted 10 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +9
-0+ + sensor->id = id; + sensor->mt = mt; + +if (mt->data->num_sensors >1 ) + sensor->adc_channel =devm_iio_channel_get (dev, mt->data->sensors[id]); +else + sensor->adc_channel =devm_iio_channel_get (dev,NULL ); +
Unneeded blank line as the above and below are coupled semantically.
Quoted 13 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +13
-0+if (IS_ERR (sensor->adc_channel)) +return dev_err_probe (dev,PTR_ERR (sensor->adc_channel), +"failed to get channel %s\n" , + mt->data->sensors[id]); + + sensor->tzdev =devm_thermal_of_zone_register (dev, id, sensor, + &mtk_pmic_thermal_ops); +if (IS_ERR (sensor->tzdev)) +return dev_err_probe (dev,PTR_ERR (sensor->tzdev), +"failed to register thermal zone %d\n" , id); + +return 0 ; +}
...
drivers/thermal/mediatek/mtk_pmic_thermal.c line 302
Quoted 4 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +4
-0+static const struct of_device_id mtk_pmic_thermal_of_match[] = { + { .compatible ="mediatek,mt6323-thermal" , + .data = &mt6323_thermal_data }, + {/* sentinel */ },
No comma for the terminator entry.
Quoted 1 line
+};
Signature · 2 lines
With Best Regards, Andy Shevchenko
Roman Vivchar
maintainerRe: [PATCH v2 07/16] thermal: mediatek: add PMIC thermal support
Quoted 2 lines · Andy Shevchenko
On Tue, May 12, 2026 at 8:21 AM Roman Vivchar via B4 Relay <[email protected]> wrote:
...
Quoted 4 lines
Quoted 1 line
+#include <
linux/kernel.h>No way the driver(s) nowadays use this header. Please, drop it and add the ones that are really in use (there are missing ones).
Is there a tool or script that can check for IWYU? For example, the u32 and s32 types are defined in the asm-generic/int-ll64.h, which is not used by any device driver. Instead, types.h should be used. It's difficult to guess which header to use for a given type/function.
I've tried include-what-you-use [1], but it gives bad results like "add #include <asm-generic/int-ll64.h> // for u32".
Quoted 9 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c line 19
Quoted 7 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +6
-0+#include <linux/module.h> +#include <linux/nvmem-consumer.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regmap.h> +#include <linux/slab.h> Is it used?
Yes, without slab.h the __free would complain about missing __free_kfree, which is DEFINE_FREE(kfree, void *, if (!IS_ERR_OR_NULL(_T)) kfree(_T)).
...
Quoted 5 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c line 45
Quoted 2 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +2
-0+#define MT6323_ADC_VOLTAGE_RANGE 1800 +#define MT6323_ADC_RESOLUTION 32768These two ring a bell with the first code patch. Are they the same? Can they be deduplicated?
They can, but I doubt it's worth creating a header just for 2 constants. It would look too small compared to the other headers in the include/linux/iio/adc.
1: https://github.com/include-what-you-use/include-what-you-use
Best regards,
Roman
Re: [PATCH v2 07/16] thermal: mediatek: add PMIC thermal support
Quoted 3 lines · Roman Vivchar
Quoted 2 lines · Andy Shevchenko
On Tue, May 12, 2026 at 8:21 AM Roman Vivchar via B4 Relay <[email protected]> wrote:
...
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
+#include <
linux/kernel.h>No way the driver(s) nowadays use this header. Please, drop it and add the ones that are really in use (there are missing ones).
Is there a tool or script that can check for IWYU?
The iwyu tool with customised configuration is the closest what we have (but quite far from ideal), you can read this thread [2].
Quoted 4 lines
For example,
the u32 and s32 types are defined in theasm-generic/int-ll64.h, which is not used by any device driver. Instead,types.hshould be used. It's difficult to guess which header to use for a given type/function.
I know. I got this knowledge because:
- I do a lot of reviews and patches and gathered it from the experience
- I am the one who reshuffled *some* of the headers
Quoted 2 lines
I've tried include-what-you-use [1], but it gives bad results like "add #include <
asm-generic/int-ll64.h> // for u32".
See above.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +5
-0+#include <linux/module.h> +#include <linux/nvmem-consumer.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regmap.h>
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
+#include <
linux/slab.h>Is it used?
Yes, without
slab.hthe__freewould complain about missing__free_kfree, which isDEFINE_FREE(kfree, void *, if (!IS_ERR_OR_NULL(_T)) kfree(_T)).
Ah, indeed. I forgot that this is not the part of cleanup.h.
...
Quoted 1 line
1: https://github.com/include-what-you-use/include-what-you-use
[2]: https://lore.kernel.org/all/[email protected]/
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerRe: [PATCH v2 07/16] thermal: mediatek: add PMIC thermal support
Quoted 9 lines · On Tue, 12 May 2026 14:02:50 +0300 Andy Shevchenko…
Quoted 3 lines · Roman Vivchar
Quoted 2 lines · Andy Shevchenko
On Tue, May 12, 2026 at 8:21 AM Roman Vivchar via B4 Relay <[email protected]> wrote:
...
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
+#include <
linux/kernel.h>
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
No way the driver(s) nowadays use this header. Please, drop it and add the ones that are really in use (there are missing ones).
Is there a tool or script that can check for IWYU?
The
iwyutool with customised configuration is the closest what we have (but quite far from ideal), you can read this thread [2].
For what it is worth the various AI tools don't do badly if you ask them and Sasiko often comments on this now (running on all of linux-iio) This series is pending though - might be done tomorrow:
https://sashiko.dev/#/patchset/20260512-mt6323-v2-0-3efcba579e88%40protonmail.com
Quoted 35 lines
Quoted 5 lines
For example,
the u32 and s32 types are defined in theasm-generic/int-ll64.h, which is not used by any device driver. Instead,types.hshould be used. It's difficult to guess which header to use for a given type/function.I know. I got this knowledge because:
- I do a lot of reviews and patches and gathered it from the experience
- I am the one who reshuffled *some* of the headersQuoted 2 lines
I've tried include-what-you-use [1], but it gives bad results like "add #include <
asm-generic/int-ll64.h> // for u32".See above.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +5
-0+#include <linux/module.h> +#include <linux/nvmem-consumer.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regmap.h> Quoted 6 lines
Quoted 3 lines
Quoted 1 line
+#include <
linux/slab.h>Is it used?
Yes, without
slab.hthe__freewould complain about missing__free_kfree, which isDEFINE_FREE(kfree, void *, if (!IS_ERR_OR_NULL(_T)) kfree(_T)).Ah, indeed. I forgot that this is not the part of
cleanup.h....
Quoted 1 line
1: https://github.com/include-what-you-use/include-what-you-use
[email protected]
AI reviewRe: [PATCH v2 07/16] thermal: mediatek: add PMIC thermal support
In reply to Roman VivcharThank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider: - [High] Incorrect error handling logic prevents the use of default calibration values and masks fatal…
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
- [High] Incorrect error handling logic prevents the use of default calibration values and masks fatal hardware errors.
- [High] MT6323_TEMP_MAX is capped at 50°C, causing valid high temperatures to be discarded and breaking thermal mitigation.
- [High] Signed integer overflow in temperature calculation results in wildly negative temperatures under load.
- [High] Missing NULL check for the result of device_get_match_data() leads to a potential kernel panic on probe.
- [High] Missing Kconfig dependencies on the IIO subsystem.
- [Medium] NVMEM byte stream is incorrectly cast directly to a u16 array, causing Big Endian read failures. --
commit 7a6cbdb919c201e8e0890350ae5a7b867cecd588
Author: Roman Vivchar <[email protected]>
thermal: mediatek: add PMIC thermal support
Add a new driver to support thermal monitoring on MediaTek PMICs, which retrieves calibration data from EFUSE and registers with the thermal framework.
drivers/thermal/mediatek/Kconfig config MTK_LVTS_THERMAL_DEBUGFS · line 39
Quoted 11 lines
drivers/thermal/mediatek/Kconfig +3
-0@@ -34,4 +34,16 @@ config MTK_LVTS_THERMAL_DEBUGFS help Enable this option to debug the internals of the device driver. +config MTK_PMIC_THERMAL + tristate "AUXADC temperature sensor driver for MediaTek PMICs" + depends on MFD_MT6397
Should this also depend on IIO?
If the thermal driver is compiled as built-in (CONFIG_MTK_PMIC_THERMAL=y) while IIO is compiled as a module (CONFIG_IIO=m), could the kernel build fail during linking with unresolved symbols?
Quoted 2 lines
drivers/thermal/mediatek/Kconfig +2
-0+ help + Enable this option if you want to get PMIC temperature
[ ... ]
Quoted 6 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +0
-0@@ -0,0 +1,316 @@
[ ... ]
drivers/thermal/mediatek/mtk_pmic_thermal.c line 28
Quoted 4 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +4
-0+#define MAX_SENSORS 1 + +#define MT6323_TEMP_MIN (-20 * MILLIDEGREE_PER_DEGREE) +#define MT6323_TEMP_MAX (50 * MILLIDEGREE_PER_DEGREE)
Is 50 degrees Celsius the intended maximum limit for MT6323_TEMP_MAX?
PMICs routinely operate well above 50 degrees under normal load, and thermal mitigation trip points are typically set above 105 degrees.
Could this cap cause the driver to return -EINVAL for valid high temperatures, effectively hiding overheating from the thermal subsystem?
[ ... ]
Quoted 9 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +9
-0+static int mtk_pmic_read_temp (struct thermal_zone_device *tz,int *temperature) +{ +struct mtk_pmic_sensor *sensor =thermal_zone_device_priv (tz); +int ret, raw, temp; + + ret =iio_read_channel_processed (sensor->adc_channel, &raw); +if (ret <0 ) { +dev_err (sensor->mt->dev,"failed to read iio channel: %d\n" , + ret);
drivers/thermal/mediatek/mtk_pmic_thermal.c line 107
Quoted 10 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +10
-0+return ret; + } + +/* +* slope1 * V +* t = Intercept + ---------- +* slope2 +*/ + temp = sensor->mt->t_intercept + + (sensor->mt->t_slope1 * raw) / sensor->mt->t_slope2;
Can the multiplication of mt->t_slope1 and raw overflow the signed 32-bit integer here?
mt->t_slope1 is initialized to 100,000, and raw comes from an AUXADC with a resolution up to 32,767. Any raw value exceeding 21,474 will cause the multiplication to exceed 2,147,483,647.
Would it be better to use a 64-bit cast, such as div_s64(), to avoid returning wrapped negative temperatures when the device is under load?
Quoted 7 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +7
-0+ +if (!mtk_pmic_thermal_temp_is_valid (temp)) +return -EINVAL ; + + *temperature = temp; +return 0 ; +}
[ ... ]
drivers/thermal/mediatek/mtk_pmic_thermal.c line 157
Quoted 8 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +8
-0+static int mtk_pmic_thermal_extract_efuse_mt6323 (struct mtk_pmic_thermal *mt, +u16 *buf) +{ +u32 reg; +s32 vts, degc_cali, o_slope, o_slope_sign, id; +int ret; + +if (!FIELD_GET (CALIB_BUF0_ADC_CALI_EN_MASK , buf[0 ]))
Does buf need to be parsed with endian-safe helpers?
Since nvmem_cell_read() returns an opaque byte stream buffer, treating it directly as a u16 array relies on the CPU byte order. On a big-endian kernel, could this swap the bytes within each 16-bit word and corrupt the calibration data?
Quoted 3 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +3
-0+return -EINVAL ; + +/* Voltage offset */
[ ... ]
drivers/thermal/mediatek/mtk_pmic_thermal.c line 205
Quoted 11 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +11
-0+static int mtk_pmic_thermal_get_calib_data (struct device *dev, +struct mtk_pmic_thermal *mt) +{ + void *buf __free(kfree) = NULL; +struct nvmem_cell *cell; +size_t len; +int ret; + + cell =nvmem_cell_get (dev,NULL ); +if (IS_ERR (cell)) +return PTR_ERR (cell);
Does returning here bypass the fallback logic for uncalibrated devices?
If nvmem_cell_get() returns -ENOENT because the nvmem-cells property is legitimately missing from the device tree, the probe is aborted before applying the default calibration values.
Quoted 8 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +8
-0+ + buf =nvmem_cell_read (cell, &len); +nvmem_cell_put (cell); + +if (IS_ERR (buf)) { + ret =PTR_ERR (buf); + buf =NULL ; +return ret;
drivers/thermal/mediatek/mtk_pmic_thermal.c line 223
Quoted 10 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +10
-0+ } + +if (len <2 *sizeof (u16)) { +dev_err (dev,"invalid calibration data length\n" ); +return -EINVAL ; + } + + ret = mt->data->extract_efuse (mt, buf); +if (ret) { +dev_info (dev,"device not calibrated, using default values\n" );
Conversely, if extract_efuse() encounters a hardware communication error or an invalid chip ID, will this incorrectly mask the hardware error as "device not calibrated"?
This might cause the driver to register the thermal zone using default values on unresponsive hardware.
Quoted 8 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +8
-0+ mt->data->precalc (mt,MT6323_DEFAULT_VTS , +MT6323_DEFAULT_DEGC_CALI , +MT6323_DEFAULT_SLOPE , +MT6323_DEFAULT_SLOPE_SIGN ); + } + +return 0 ; +}
[ ... ]
Quoted 6 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +6
-0+static int mtk_pmic_thermal_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct mtk_pmic_thermal *mt; +int ret; +
drivers/thermal/mediatek/mtk_pmic_thermal.c line 275
Quoted 10 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +10
-0+ mt =devm_kzalloc (dev,sizeof (*mt),GFP_KERNEL ); +if (!mt) +return -ENOMEM ; + + mt->regmap =dev_get_regmap (dev->parent->parent,NULL ); +if (!mt->regmap) +return dev_err_probe (dev, -ENODEV ,"failed to get regmap" ); + + mt->dev = dev; + mt->data =device_get_match_data (dev);
Should mt->data be checked for NULL?
If the driver is bound to the MFD cell purely by platform name (e.g., if the MFD core does not pass an of_node to the cell), device_get_match_data() will return NULL.
drivers/thermal/mediatek/mtk_pmic_thermal.c line 277
Quoted 2 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +2
-0+ + ret =mtk_pmic_thermal_get_calib_data (dev, mt);
If mt->data is NULL, calling mtk_pmic_thermal_get_calib_data() will dereference a NULL pointer when it attempts to call mt->data->extract_efuse(mt, buf).
Quoted 4 lines
drivers/thermal/mediatek/mtk_pmic_thermal.c new file +4
-0+if (ret) +return ret; + +for (int i =0 ; i < mt->data->num_sensors; i++) {
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
Roman Vivchar
maintainerPATCH v2 8/16 mfd: mt6397-core: add mt6323 AUXADC support
In reply to Roman VivcharThe mt6323 PMIC includes an AUXADC. Register the AUXADC in the mt6323 devices array to allow the corresponding driver to probe using compatible string.
--- drivers/mfd/mt6397-core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mfd/mt6397-core.c +3 -0
@@ -125,6 +125,9 @@ static const struct resource mt6323_pwrc_resources[] = {static const struct mfd_cell mt6323_devs[] = { { + .name ="mt6323-auxadc" , + .of_compatible ="mediatek,mt6323-auxadc" , + }, { .name ="mt6323-rtc" , .num_resources =ARRAY_SIZE (mt6323_rtc_resources), .resources = mt6323_rtc_resources,
Signature · 1 line
2.54.0
Roman Vivchar
maintainerPATCH v2 9/16 mfd: mt6397-core: add mt6323 EFUSE support
In reply to Roman VivcharThe mt6323 PMIC includes an EFUSE. Register the EFUSE in the mt6323 devices array to allow the corresponding driver to probe using compatible string.
--- drivers/mfd/mt6397-core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mfd/mt6397-core.c +3 -0
@@ -127,6 +127,9 @@ static const struct mfd_cell mt6323_devs[] = { { .name = "mt6323-auxadc", .of_compatible = "mediatek,mt6323-auxadc", + }, { + .name = "mt6323-efuse", + .of_compatible = "mediatek,mt6323-efuse", }, { .name = "mt6323-rtc", .num_resources = ARRAY_SIZE(mt6323_rtc_resources),
Signature · 1 line
2.54.0
Roman Vivchar
maintainerPATCH v2 10/16 mfd: mt6397-core: add mt6323 thermal support
In reply to Roman VivcharThe mt6323 PMIC temperature can be measured using AUXADC channel. Register the thermal in the mt6323 devices array to allow the corresponding driver to probe using compatible string.
--- drivers/mfd/mt6397-core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mfd/mt6397-core.c +3 -0
@@ -151,6 +151,9 @@ static const struct mfd_cell mt6323_devs[] = { .num_resources = ARRAY_SIZE(mt6323_pwrc_resources), .resources = mt6323_pwrc_resources, .of_compatible = "mediatek,mt6323-pwrc" + }, { + .name = "mt6323-thermal", + .of_compatible = "mediatek,mt6323-thermal", }, };
Signature · 1 line
2.54.0
Re: [PATCH v2 10/16] mfd: mt6397-core: add mt6323 thermal support
Quoted 4 lines · On Tue, May 12, 2026 at 8:21 AM Roman Vivchar via B4 Relay…
The mt6323 PMIC temperature can be measured using AUXADC channel. Register the thermal in the mt6323 devices array to allow the corresponding driver to probe using compatible string.
Wouldn't it be better to interleave these MFD patches to enable each driver just immediately after the driver provided? However, in previous review somebody ( IIRC it was Krzysztof) asked how dependent are they and it has something to do with the device tree bindings. Take into account that one as well.
Signature · 2 lines
With Best Regards, Andy Shevchenko
[email protected]
AI reviewRe: [PATCH v2 10/16] mfd: mt6397-core: add mt6323 thermal support
In reply to Roman VivcharThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] The `mtk_pmic_thermal` driver causes a kernel panic (NULL pointer dereference) if instantiated…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The mtk_pmic_thermal driver causes a kernel panic (NULL pointer dereference) if instantiated with a malformed device tree that lacks the expected parent hierarchy.
- [High] The mtk_pmic_thermal driver aborts probing if the optional nvmem-cells device tree property is missing, breaking support for uncalibrated operation and violating its DT binding. --
commit 3e8b78507795872b5938fe1527d98ac0e8b204df
Author: Roman Vivchar <[email protected]>
mfd: mt6397-core: add mt6323 thermal support
The mt6323 PMIC temperature can be measured using AUXADC channel. Register the thermal in the mt6323 devices array to allow the corresponding driver to probe using compatible string.
drivers/mfd/mt6397-core.c static const struct mfd_cell mt6323_devs[] = { · line 156
Quoted 11 lines
drivers/mfd/mt6397-core.c +3
-0@@ -151,6 +151,9 @@ static const struct mfd_cell mt6323_devs[] = { .num_resources = ARRAY_SIZE(mt6323_pwrc_resources), .resources = mt6323_pwrc_resources, .of_compatible ="mediatek,mt6323-pwrc" + }, { + .name = "mt6323-thermal", + .of_compatible = "mediatek,mt6323-thermal",
Does the mtk_pmic_thermal driver gracefully handle missing device tree properties when instantiated here?
Looking at mtk_pmic_thermal_get_calib_data():
drivers/thermal/mediatek/mtk_pmic_thermal.c:mtk_pmic_thermal_get_calib_data() {
...
cell = nvmem_cell_get(dev, NULL);
if (IS_ERR(cell))
return PTR_ERR(cell);
...
}If the optional nvmem-cells property is missing, nvmem_cell_get() returns an error. This causes the driver to unconditionally abort probing, which prevents it from reaching its intended default calibration fallback.
Can this also cause a kernel panic if instantiated with a device tree that lacks the expected parent hierarchy?
Looking at mtk_pmic_thermal_probe():
drivers/thermal/mediatek/mtk_pmic_thermal.c:mtk_pmic_thermal_probe() {
...
mt->regmap = dev_get_regmap(dev->parent->parent, NULL);
if (!mt->regmap)
return dev_err_probe(dev, -ENODEV, "failed to get regmap");
...
}If the thermal device is instantiated from a top-level node rather than as an MFD child, dev->parent points to the platform_bus device. Because platform_bus.parent is NULL, dev->parent->parent resolves to NULL. Passing this NULL pointer to dev_get_regmap() triggers a panic when the core attempts to acquire the devres_lock spinlock.
Quoted 2 lines
drivers/mfd/mt6397-core.c +0
-0}, };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
Roman Vivchar
maintainerPATCH v2 11/16 ARM: dts: mediatek: mt6323: add AUXADC support
In reply to Roman VivcharAdd the devicetree node for the mt6323 AUXADC.
--- arch/arm/boot/dts/mediatek/mt6323.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm/boot/dts/mediatek/mt6323.dtsi +5 -0
@@ -14,6 +14,11 @@ pmic: mt6323 { interrupt-controller; #interrupt-cells = <2>; + mt6323_adc: adc { + compatible = "mediatek,mt6323-auxadc"; + #io-channel-cells = <1>; + }; + mt6323_leds: leds { compatible = "mediatek,mt6323-led"; #address-cells = <1>;
Signature · 1 line
2.54.0
Roman Vivchar
maintainerPATCH v2 12/16 ARM: dts: mediatek: mt6323: add EFUSE support
In reply to Roman VivcharAdd the efuse node for the mt6323 efuse.
--- arch/arm/boot/dts/mediatek/mt6323.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/mediatek/mt6323.dtsi +4 -0
@@ -19,6 +19,10 @@ mt6323_adc: adc { #io-channel-cells = <1>; }; + mt6323_efuse: efuse { + compatible = "mediatek,mt6323-efuse"; + }; + mt6323_leds: leds { compatible = "mediatek,mt6323-led"; #address-cells = <1>;
Signature · 1 line
2.54.0
Roman Vivchar
maintainerPATCH v2 13/16 ARM: dts: mediatek: mt6323: add thermal support
In reply to Roman VivcharAdd the devicetree node for the mt6323 thermal.
--- arch/arm/boot/dts/mediatek/mt6323.dtsi | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
arch/arm/boot/dts/mediatek/mt6323.dtsi +31 -0
@@ -6,6 +6,8 @@ * */ +#include <dt-bindings/iio/adc/mediatek,mt6323-auxadc.h> + &pwrap { pmic: mt6323 { compatible = "mediatek,mt6323";
@@ -21,6 +23,16 @@ mt6323_adc: adc { mt6323_efuse: efuse { compatible = "mediatek,mt6323-efuse"; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + mt6323_thermal_calibration_data: thermal-data@14 { + reg = <0x14 0x4>; + }; + }; }; mt6323_leds: leds {
@@ -274,5 +286,24 @@ power-controller { rtc { compatible = "mediatek,mt6323-rtc"; }; + + mt6323_thermal: thermal { + compatible = "mediatek,mt6323-thermal"; + nvmem-cells = <&mt6323_thermal_calibration_data>; + + io-channels = <&mt6323_adc MT6323_AUXADC_CHIP_TEMP>; + #thermal-sensor-cells = <1>; + }; + }; +}; + +/ { + thermal-zones { + pmic_vts_thermal { + polling-delay-passive = <1000>; + polling-delay = <1000>; + + thermal-sensors = <&mt6323_thermal 0>; + }; }; };
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v2 13/16] ARM: dts: mediatek: mt6323: add thermal support
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The thermal zone node name `pmic_vts_thermal` contains underscores, which violates the DT schema…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The thermal zone node name pmic_vts_thermal contains underscores, which violates the DT schema validation rules for thermal zones. --
commit b08a96e273f3be780a8e1efc4286fbc9434906b8
Author: Roman Vivchar <[email protected]>
ARM: dts: mediatek: mt6323: add thermal support
Add the devicetree node for the mt6323 thermal.
Quoted 4 lines
arch/arm/boot/dts/mediatek/mt6323.dtsi +0
-0
[ ... ]
Quoted 8 lines
arch/arm/boot/dts/mediatek/mt6323.dtsi +4
-0@@ -274,5 +286,24 @@ power-controller { rtc { compatible = "mediatek,mt6323-rtc"; }; + + mt6323_thermal: thermal { + compatible = "mediatek,mt6323-thermal"; + nvmem-cells = <&mt6323_thermal_calibration_data>;
arch/arm/boot/dts/mediatek/mt6323.dtsi power-controller { · line 302
Quoted 10 lines
arch/arm/boot/dts/mediatek/mt6323.dtsi +10
-0+ + io-channels = <&mt6323_adc MT6323_AUXADC_CHIP_TEMP>; + #thermal-sensor-cells = <1>; + }; + }; +}; + +/ { + thermal-zones { + pmic_vts_thermal {
Does this node name violate the device tree schema validation rules?
According to the thermal zone bindings, child nodes of thermal-zones must match the regular expression ^[a-zA-Z][a-zA-Z0-9\-]{1,10}-thermal$. Because this name contains underscores and ends with _thermal instead of -thermal, it will fail validation.
Should this be renamed to use hyphens, such as pmic-vts-thermal?
Quoted 7 lines
arch/arm/boot/dts/mediatek/mt6323.dtsi +5
-0+ polling-delay-passive = <1000>; + polling-delay = <1000>; + + thermal-sensors = <&mt6323_thermal 0>; + }; }; };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=13
Roman Vivchar
maintainerPATCH v2 14/16 MAINTAINERS: add MediaTek mt6323 PMIC AUXADC driver maintainer
In reply to Roman VivcharAdd myself as MediaTek mt6323 AUXADC driver maintainer.
--- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)
MAINTAINERS +5 -0
@@ -16337,6 +16337,11 @@ S: Orphan F: Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml F: drivers/mtd/nand/raw/mtk_* +MEDIATEK PMIC AUXADC DRIVER +M: Roman Vivchar <[email protected]> +S: Odd Fixes +F: drivers/iio/adc/mt6323-auxadc.c + MEDIATEK PMIC LED DRIVER M: Sen Chu <[email protected]> M: Sean Wang <[email protected]>
Signature · 1 line
2.54.0
Jonathan Cameron
maintainerRe: [PATCH v2 14/16] MAINTAINERS: add MediaTek mt6323 PMIC AUXADC driver maintainer
Quoted 14 lines · On Tue, 12 May 2026 08:18:28 +0300 Roman Vivchar via B4 Relay…
From: Roman Vivchar <[email protected]>
Add myself as MediaTek mt6323 AUXADC driver maintainer.
Signed-off-by Roman Vivchar <[email protected]>--- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)MAINTAINERS +0
-0
MAINTAINERS S: Orphan · line 16340
Quoted 4 lines
MAINTAINERS +1
-0@@ -16337,6 +16337,11 @@ S: Orphan F: Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml F: drivers/mtd/nand/raw/mtk_* +MEDIATEK PMIC AUXADC DRIVER
Given this is one of quite a few Mediatek PMIC drivers, you either need to be more specific in that title or offer to handle them all.
Quoted 8 lines
MAINTAINERS +4
-0+M: Roman Vivchar <[email protected]> +S: Odd Fixes +F: drivers/iio/adc/mt6323-auxadc.c + MEDIATEK PMIC LED DRIVER M: Sen Chu <[email protected]> M: Sean Wang <[email protected]>
Roman Vivchar
maintainerPATCH v2 15/16 MAINTAINERS: add MediaTek mt6323 PMIC EFUSE driver maintainer
In reply to Roman VivcharAdd myself as MediaTek mt6323 EFUSE driver maintainer.
--- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)
MAINTAINERS +5 -0
@@ -16342,6 +16342,11 @@ M: Roman Vivchar <[email protected]> S: Odd Fixes F: drivers/iio/adc/mt6323-auxadc.c +MEDIATEK PMIC EFUSE DRIVER +M: Roman Vivchar <[email protected]> +S: Odd Fixes +F: drivers/nvmem/mt6323-efuse.c + MEDIATEK PMIC LED DRIVER M: Sen Chu <[email protected]> M: Sean Wang <[email protected]>
Signature · 1 line
2.54.0
Re: [PATCH v2 15/16] MAINTAINERS: add MediaTek mt6323 PMIC EFUSE driver maintainer
Quoted 12 lines · Roman Vivchar
Add myself as MediaTek mt6323 EFUSE driver maintainer.
Signed-off-by Roman Vivchar <[email protected]>--- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)MAINTAINERS +0
-0
MAINTAINERS M: Roman Vivchar <[email protected]> · line 16348
Quoted 7 lines
MAINTAINERS +4
-0@@ -16342,6 +16342,11 @@ M: Roman Vivchar <[email protected]> S: Odd Fixes F: drivers/iio/adc/mt6323-auxadc.c +MEDIATEK PMIC EFUSE DRIVER +M: Roman Vivchar <[email protected]> +S: Odd Fixes +F: drivers/nvmem/mt6323-efuse.c
I don't understand why this cannot be one maintainer entry. Really, these are just single drivers.
Quoted 8 lines
MAINTAINERS +1
-0+ MEDIATEK PMIC LED DRIVER M: Sen Chu <[email protected]> M: Sean Wang <[email protected]>Signature · 2 lines
-- 2.54.0
Re: [PATCH v2 15/16] MAINTAINERS: add MediaTek mt6323 PMIC EFUSE driver maintainer
Quoted 16 lines · Krzysztof Kozlowski
Quoted 15 lines · Roman Vivchar
Add myself as MediaTek mt6323 EFUSE driver maintainer.
Signed-off-by Roman Vivchar <[email protected]>--- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)MAINTAINERS +0
-0@@ -16342,6 +16342,11 @@ M: Roman Vivchar <[email protected]> S: Odd Fixes F: drivers/iio/adc/mt6323-auxadc.c
Quoted 7 lines
MAINTAINERS M: Roman Vivchar <[email protected]> · line 16348
Quoted 4 lines
MAINTAINERS +4
-0+MEDIATEK PMIC EFUSE DRIVER +M: Roman Vivchar <[email protected]> +S: Odd Fixes +F: drivers/nvmem/mt6323-efuse.cI don't understand why this cannot be one maintainer entry. Really, these are just single drivers.
Heh, and now I see my comment on v1 which you did not implement.
SQUASHED. Please see git rebase and the meaning of squash.
Best regards,
Krzysztof
Roman Vivchar
maintainerPATCH v2 16/16 MAINTAINERS: add MediaTek mt6323 PMIC thermal driver maintainer
In reply to Roman VivcharAdd myself as MediaTek mt6323 thermal driver maintainer.
--- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)
MAINTAINERS +5 -0
@@ -16355,6 +16355,11 @@ S: Maintained F: Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml F: drivers/leds/leds-mt6323.c +MEDIATEK PMIC THERMAL DRIVER +M: Roman Vivchar <[email protected]> +S: Odd Fixes +F: drivers/thermal/mediatek/mtk_pmic_thermal.c + MEDIATEK RANDOM NUMBER GENERATOR SUPPORT M: Sean Wang <[email protected]> S: Maintained
Signature · 1 line
2.54.0
Re: [PATCH v2 16/16] MAINTAINERS: add MediaTek mt6323 PMIC thermal driver maintainer
Quoted 12 lines · Roman Vivchar
Add myself as MediaTek mt6323 thermal driver maintainer.
Signed-off-by Roman Vivchar <[email protected]>--- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)MAINTAINERS +0
-0
MAINTAINERS S: Maintained · line 16360
Quoted 6 lines
MAINTAINERS +3
-0@@ -16355,6 +16355,11 @@ S: Maintained F: Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml F: drivers/leds/leds-mt6323.c +MEDIATEK PMIC THERMAL DRIVER +M: Roman Vivchar <[email protected]> +S: Odd Fixes
Odd Fixes means driver is half-abandonded, so please explain in the commit msg why you add yourself as maintainer but not really committed. Such entry makes more sense for subsystems, but if individual driver has odd-fixes stage, shouldn't we just remove this maintainer entry? If so, why adding it in the first place?
MAINTAINERS S: Maintained · line 16361
Quoted 1 line
MAINTAINERS +1
-0+F: drivers/thermal/mediatek/mtk_pmic_thermal.c
Best regards,
Krzysztof
Roman Vivchar
maintainerRe: [PATCH v2 16/16] MAINTAINERS: add MediaTek mt6323 PMIC thermal driver maintainer
Hi Krzysztof,
Quoted 1 line · Krzysztof Kozlowski
On Tue, May 12, 2026 at 08:18:30AM +0300, Roman Vivchar wrote:
...
Quoted 10 lines
MAINTAINERS S: Maintained · line 16360
Quoted 4 lines
MAINTAINERS +3
-0+MEDIATEK PMIC THERMAL DRIVER +M: Roman Vivchar <[email protected]> +S: Odd FixesOdd Fixes means driver is half-abandonded, so please explain in the commit msg why you add yourself as maintainer but not really committed. Such entry makes more sense for subsystems, but if individual driver has odd-fixes stage, shouldn't we just remove this maintainer entry? If so, why adding it in the first place?
That is a fair point. As an individual contributor, I'm hesitant to use "Maintained" indefinitely, but I understand that "Odd Fixes" for a new driver is not the best idea either.
If no one else can take it, I'll change the status to "Maintained" for v3, but I want to see if there's a more sustainable long-term home for the drivers first.
Angelo, Matthias:
Since the patch series is about MediaTek PMIC drivers, would you be open for taking drivers under "ARM/Mediatek SoC support" entry? Or is there someone at MediaTek who might be interested in this?
Best regards,
Roman