* [PATCH v2 0/4] AUXADC driver for the MediaTek mt6323 PMIC
@ 2026-06-09 13:31 Roman Vivchar via B4 Relay
2026-06-09 13:31 ` [PATCH v2 1/4] dt-bindings: iio: adc: mediatek,mt6359-auxadc: add mt6323 PMIC AUXADC Roman Vivchar via B4 Relay
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-06-09 13:31 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Lee Jones
Cc: linux-iio, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Ben Grisdale, Roman Vivchar
This series adds support for the 15-bit AUXADC hardware block found on
the MediaTek mt6323 PMIC.
The previous version of the series for all AUXADC, EFUSE and thermal
drivers was split after Krzysztof's comment [1].
Tested on the MediaTek mt6572 and mt8163 SoCs (Ben), both paired with a
mt6323.
The other parts (EFUSE and thermal) will probably be sent this week.
[1]: https://lore.kernel.org/linux-mediatek/20260504-mt6323-v1-0-799b58b355ff@protonmail.com/T/#med30fad67a090be35f549231336b2dec295233f6
Tested-by: Ben Grisdale <bengris32@protonmail.ch> # Amazon Echo Dot (2nd Generation)
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Changes in v2:
- AUXADC driver:
- Drop channel type from the MTK_PMIC_IIO_CHAN macro (Nuno)
- Drop kerneldoc for the mt6323_auxadc struct (Nuno)
- Add channel release to save power (Sashiko, Jonathan)
- Drop 'reg' variable in the mt6323_auxadc_read (Jonathan)
- Sort variables in the mt6323_auxadc_probe (Jonathan)
- Maintainers:
- Drop linux-mediatek list (Andy)
- Split between dt-bindings and driver to avoid missing file (Nuno)
- Link to v1: https://patch.msgid.link/20260602-mt6323-adc-v1-0-68ec737508ee@protonmail.com
Changes after split:
- dt-bindings: Change 'MT63xx' to 'MT6350 series and similar' (Jonathan)
- AUXADC driver:
- Add missing headers (Andy)
- Fix AUXADC_TRIM_CH* values (Andy)
- Rename masks to include their register name (Jonathan)
- Fix formatting (Andy, Jonathan)
- Replace channel address with actual register value (Jonathan), align the table
- Replace IIO_TEMP with IIO_VOLTAGE, since the actual output is still mV, not mC
- Rename constants to match their registers (Jonathan)
- Remove 'if/else if/else' in the mt6323_auxadc_read_raw (Andy)
- Add comments for fsleep, ADC range and resolution (Andy, Jonathan)
- Remove useless error messages (Andy)
- Maintainers:
- Explicitly include mt6323 in the name (Jonathan)
- Squash with AUXADC driver commit (Krzysztof)
- Set status back to 'Maintained'
- Link to a previous series: https://patch.msgid.link/20260512-mt6323-v2-0-3efcba579e88@protonmail.com
---
Roman Vivchar (4):
dt-bindings: iio: adc: mediatek,mt6359-auxadc: add mt6323 PMIC AUXADC
iio: adc: mt6323-auxadc: add mt6323 PMIC AUXADC driver
mfd: mt6397-core: add mt6323 AUXADC support
ARM: dts: mediatek: mt6323: add AUXADC support
.../bindings/iio/adc/mediatek,mt6359-auxadc.yaml | 3 +-
MAINTAINERS | 7 +
arch/arm/boot/dts/mediatek/mt6323.dtsi | 5 +
drivers/iio/adc/Kconfig | 11 +
drivers/iio/adc/Makefile | 1 +
drivers/iio/adc/mt6323-auxadc.c | 305 +++++++++++++++++++++
drivers/mfd/mt6397-core.c | 3 +
.../dt-bindings/iio/adc/mediatek,mt6323-auxadc.h | 24 ++
8 files changed, 358 insertions(+), 1 deletion(-)
---
base-commit: 028ef9c96e96197026887c0f092424679298aae8
change-id: 20260525-mt6323-adc-3befce36cbf2
Best regards,
--
Roman Vivchar <rva333@protonmail.com>
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH v2 1/4] dt-bindings: iio: adc: mediatek,mt6359-auxadc: add mt6323 PMIC AUXADC 2026-06-09 13:31 [PATCH v2 0/4] AUXADC driver for the MediaTek mt6323 PMIC Roman Vivchar via B4 Relay @ 2026-06-09 13:31 ` Roman Vivchar via B4 Relay 2026-06-09 16:01 ` Conor Dooley 2026-06-09 13:31 ` [PATCH v2 2/4] iio: adc: mt6323-auxadc: add mt6323 PMIC AUXADC driver Roman Vivchar via B4 Relay ` (2 subsequent siblings) 3 siblings, 1 reply; 11+ messages in thread From: Roman Vivchar via B4 Relay @ 2026-06-09 13:31 UTC (permalink / raw) To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno, Lee Jones Cc: linux-iio, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, Ben Grisdale, Roman Vivchar From: Roman Vivchar <rva333@protonmail.com> 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. Also change the description to 'MT6350 series and similar' because the binding already includes more than mt635x series PMICs. Finally, add the MAINTAINERS entry for the header with ADC constants. Signed-off-by: Roman Vivchar <rva333@protonmail.com> --- .../bindings/iio/adc/mediatek,mt6359-auxadc.yaml | 3 ++- MAINTAINERS | 6 ++++++ .../dt-bindings/iio/adc/mediatek,mt6323-auxadc.h | 24 ++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml b/Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml index 5d4ab701f51a..852eb7336a5a 100644 --- a/Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml @@ -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 MT6350 series and similar PMIC AUXADC maintainers: - AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> @@ -19,6 +19,7 @@ description: properties: compatible: enum: + - mediatek,mt6323-auxadc - mediatek,mt6357-auxadc - mediatek,mt6358-auxadc - mediatek,mt6359-auxadc diff --git a/MAINTAINERS b/MAINTAINERS index d1cc0e12fe1f..2551c8cd9e9d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16256,6 +16256,12 @@ S: Maintained F: Documentation/devicetree/bindings/mmc/mtk-sd.yaml F: drivers/mmc/host/mtk-sd.c +MEDIATEK MT6323 PMIC AUXADC DRIVER +M: Roman Vivchar <rva333@protonmail.com> +L: linux-iio@vger.kernel.org +S: Maintained +F: include/dt-bindings/iio/adc/mediatek,mt6323-auxadc.h + MEDIATEK MT6735 CLOCK & RESET DRIVERS M: Yassine Oudjana <y.oudjana@protonmail.com> L: linux-clk@vger.kernel.org diff --git a/include/dt-bindings/iio/adc/mediatek,mt6323-auxadc.h b/include/dt-bindings/iio/adc/mediatek,mt6323-auxadc.h new file mode 100644 index 000000000000..6ee9a9ecffc1 --- /dev/null +++ b/include/dt-bindings/iio/adc/mediatek,mt6323-auxadc.h @@ -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 -- 2.54.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/4] dt-bindings: iio: adc: mediatek,mt6359-auxadc: add mt6323 PMIC AUXADC 2026-06-09 13:31 ` [PATCH v2 1/4] dt-bindings: iio: adc: mediatek,mt6359-auxadc: add mt6323 PMIC AUXADC Roman Vivchar via B4 Relay @ 2026-06-09 16:01 ` Conor Dooley 2026-06-09 17:29 ` Roman Vivchar 0 siblings, 1 reply; 11+ messages in thread From: Conor Dooley @ 2026-06-09 16:01 UTC (permalink / raw) To: rva333 Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno, Lee Jones, linux-iio, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, Ben Grisdale [-- Attachment #1: Type: text/plain, Size: 3739 bytes --] On Tue, Jun 09, 2026 at 04:31:58PM +0300, Roman Vivchar via B4 Relay wrote: > From: Roman Vivchar <rva333@protonmail.com> > > 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. > > Also change the description to 'MT6350 series and similar' because > the binding already includes more than mt635x series PMICs. > > Finally, add the MAINTAINERS entry for the header with ADC constants. > > Signed-off-by: Roman Vivchar <rva333@protonmail.com> > --- > .../bindings/iio/adc/mediatek,mt6359-auxadc.yaml | 3 ++- > MAINTAINERS | 6 ++++++ > .../dt-bindings/iio/adc/mediatek,mt6323-auxadc.h | 24 ++++++++++++++++++++++ > 3 files changed, 32 insertions(+), 1 deletion(-) > > diff --git a/Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml b/Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml > index 5d4ab701f51a..852eb7336a5a 100644 > --- a/Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml > +++ b/Documentation/devicetree/bindings/iio/adc/mediatek,mt6359-auxadc.yaml > @@ -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 MT6350 series and similar PMIC AUXADC > > maintainers: > - AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> > @@ -19,6 +19,7 @@ description: > properties: > compatible: > enum: > + - mediatek,mt6323-auxadc Commit message needs to explain why a fallback is not suitable. pw-bot: changes-requested > - mediatek,mt6357-auxadc > - mediatek,mt6358-auxadc > - mediatek,mt6359-auxadc > diff --git a/MAINTAINERS b/MAINTAINERS > index d1cc0e12fe1f..2551c8cd9e9d 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -16256,6 +16256,12 @@ S: Maintained > F: Documentation/devicetree/bindings/mmc/mtk-sd.yaml > F: drivers/mmc/host/mtk-sd.c > > +MEDIATEK MT6323 PMIC AUXADC DRIVER > +M: Roman Vivchar <rva333@protonmail.com> > +L: linux-iio@vger.kernel.org > +S: Maintained > +F: include/dt-bindings/iio/adc/mediatek,mt6323-auxadc.h Why is the binding not being included here? Cheers, Conor. > + > MEDIATEK MT6735 CLOCK & RESET DRIVERS > M: Yassine Oudjana <y.oudjana@protonmail.com> > L: linux-clk@vger.kernel.org > diff --git a/include/dt-bindings/iio/adc/mediatek,mt6323-auxadc.h b/include/dt-bindings/iio/adc/mediatek,mt6323-auxadc.h > new file mode 100644 > index 000000000000..6ee9a9ecffc1 > --- /dev/null > +++ b/include/dt-bindings/iio/adc/mediatek,mt6323-auxadc.h > @@ -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 > > -- > 2.54.0 > > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/4] dt-bindings: iio: adc: mediatek,mt6359-auxadc: add mt6323 PMIC AUXADC 2026-06-09 16:01 ` Conor Dooley @ 2026-06-09 17:29 ` Roman Vivchar 0 siblings, 0 replies; 11+ messages in thread From: Roman Vivchar @ 2026-06-09 17:29 UTC (permalink / raw) To: Conor Dooley Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno, Lee Jones, linux-iio, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, Ben Grisdale Hi Conor, On Tuesday, June 9th, 2026 at 7:01 PM, Conor Dooley <conor@kernel.org> wrote: > On Tue, Jun 09, 2026 at 04:31:58PM +0300, Roman Vivchar via B4 Relay wrote: > > properties: > > compatible: > > enum: > > + - mediatek,mt6323-auxadc > > Commit message needs to explain why a fallback is not suitable. > pw-bot: changes-requested Ack. > > > - mediatek,mt6357-auxadc > > - mediatek,mt6358-auxadc > > - mediatek,mt6359-auxadc > > diff --git a/MAINTAINERS b/MAINTAINERS > > index d1cc0e12fe1f..2551c8cd9e9d 100644 > > --- a/MAINTAINERS > > +++ b/MAINTAINERS > > @@ -16256,6 +16256,12 @@ S: Maintained > > F: Documentation/devicetree/bindings/mmc/mtk-sd.yaml > > F: drivers/mmc/host/mtk-sd.c > > > > +MEDIATEK MT6323 PMIC AUXADC DRIVER > > +M: Roman Vivchar <rva333@protonmail.com> > > +L: linux-iio@vger.kernel.org > > +S: Maintained > > +F: include/dt-bindings/iio/adc/mediatek,mt6323-auxadc.h > > Why is the binding not being included here? > The binding is shared across multiple PMIC ADCs and maintained by Angelo. Since I'm only familiar with mt6323 and not others like mt6358, I decided to not include it in the mt6323 entry. Best regards, Roman ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/4] iio: adc: mt6323-auxadc: add mt6323 PMIC AUXADC driver 2026-06-09 13:31 [PATCH v2 0/4] AUXADC driver for the MediaTek mt6323 PMIC Roman Vivchar via B4 Relay 2026-06-09 13:31 ` [PATCH v2 1/4] dt-bindings: iio: adc: mediatek,mt6359-auxadc: add mt6323 PMIC AUXADC Roman Vivchar via B4 Relay @ 2026-06-09 13:31 ` Roman Vivchar via B4 Relay 2026-06-09 13:44 ` sashiko-bot 2026-06-09 18:30 ` Andy Shevchenko 2026-06-09 13:32 ` [PATCH v2 3/4] mfd: mt6397-core: add mt6323 AUXADC support Roman Vivchar via B4 Relay 2026-06-09 13:32 ` [PATCH v2 4/4] ARM: dts: mediatek: mt6323: add " Roman Vivchar via B4 Relay 3 siblings, 2 replies; 11+ messages in thread From: Roman Vivchar via B4 Relay @ 2026-06-09 13:31 UTC (permalink / raw) To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno, Lee Jones Cc: linux-iio, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, Ben Grisdale, Roman Vivchar From: Roman Vivchar <rva333@protonmail.com> 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. Tested-by: Ben Grisdale <bengris32@protonmail.ch> # Amazon Echo Dot (2nd Generation) Signed-off-by: Roman Vivchar <rva333@protonmail.com> --- MAINTAINERS | 1 + drivers/iio/adc/Kconfig | 11 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mt6323-auxadc.c | 305 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 318 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 2551c8cd9e9d..fb40128451dd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16260,6 +16260,7 @@ MEDIATEK MT6323 PMIC AUXADC DRIVER M: Roman Vivchar <rva333@protonmail.com> L: linux-iio@vger.kernel.org S: Maintained +F: drivers/iio/adc/mt6323-auxadc.c F: include/dt-bindings/iio/adc/mediatek,mt6323-auxadc.h MEDIATEK MT6735 CLOCK & RESET DRIVERS diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 60038ae8dfc4..a03614b46041 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -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 diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index c76550415ff1..58161750d6e3 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -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 diff --git a/drivers/iio/adc/mt6323-auxadc.c b/drivers/iio/adc/mt6323-auxadc.c new file mode 100644 index 000000000000..f2cef989d3ce --- /dev/null +++ b/drivers/iio/adc/mt6323-auxadc.c @@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2026 Roman Vivchar <rva333@protonmail.com> + * + * 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/regmap.h> +#include <linux/stringify.h> +#include <linux/time.h> +#include <linux/types.h> + +#include <linux/mfd/mt6323/registers.h> + +#include <dt-bindings/iio/adc/mediatek,mt6323-auxadc.h> + +#define AUXADC_STRUP_CON10_RSTB_SEL BIT(7) +#define AUXADC_STRUP_CON10_RSTB_SW BIT(5) + +#define AUXADC_TOP_CKPDN2_CTL_CK BIT(5) + +#define AUXADC_TRIM_CH2_MASK GENMASK(11, 10) +#define AUXADC_TRIM_CH4_MASK GENMASK(9, 8) +#define AUXADC_TRIM_CH5_MASK GENMASK(5, 4) +#define AUXADC_TRIM_CH6_MASK GENMASK(3, 2) + +#define AUXADC_CON27_VREF18_ENB_MD BIT(15) +#define AUXADC_CON27_MD_STATUS BIT(0) + +#define AUXADC_CON19_GPS_STATUS BIT(1) + +#define AUXADC_CON26_VREF18_SELB BIT(1) +#define AUXADC_CON26_DECI_GDLY_SEL BIT(0) + +#define AUXADC_CON11_VBUF_EN BIT(4) + +#define AUXADC_CON19_DECI_GDLY_MASK GENMASK(15, 14) +#define AUXADC_ADC19_BUSY_MASK GENMASK(15, 1) +#define AUXADC_READY_MASK BIT(15) +#define AUXADC_DATA_MASK GENMASK(14, 0) + +#define AUXADC_CON9_OSR_MASK GENMASK(12, 10) +#define AUXADC_DEFAULT_OSR 3 + +#define MTK_PMIC_IIO_CHAN(_name, _chan, _addr) \ +{ \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .channel = _chan, \ + .address = _addr, \ + .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, MT6323_AUXADC_ADC6), + MTK_PMIC_IIO_CHAN(ch6, MT6323_AUXADC_CH6, MT6323_AUXADC_ADC11), + MTK_PMIC_IIO_CHAN(bat_temp, MT6323_AUXADC_BAT_TEMP, MT6323_AUXADC_ADC5), + MTK_PMIC_IIO_CHAN(chip_temp, MT6323_AUXADC_CHIP_TEMP, MT6323_AUXADC_ADC4), + MTK_PMIC_IIO_CHAN(vcdt, MT6323_AUXADC_VCDT, MT6323_AUXADC_ADC2), + MTK_PMIC_IIO_CHAN(baton1, MT6323_AUXADC_BATON1, MT6323_AUXADC_ADC3), + MTK_PMIC_IIO_CHAN(isense, MT6323_AUXADC_ISENSE, MT6323_AUXADC_ADC1), + MTK_PMIC_IIO_CHAN(batsns, MT6323_AUXADC_BATSNS, MT6323_AUXADC_ADC0), + MTK_PMIC_IIO_CHAN(accdet, MT6323_AUXADC_ACCDET, MT6323_AUXADC_ADC7), +}; + +/* + * The MediaTek MT6323 (as well as a lot of other PMICs) has the following hierarchy: + * PMIC AUXADC <- PMIC MFD <- SoC PWRAP (wrapper for PWRAP FSM) + * + * Therefore, PWRAP regmap should be obtained using dev->parent->parent. + */ +struct mt6323_auxadc { + struct regmap *regmap; + struct mutex lock; +}; + +static int mt6323_auxadc_prepare_channel(struct mt6323_auxadc *auxadc) +{ + struct regmap *map = auxadc->regmap; + u32 val; + int ret; + + ret = regmap_read(map, MT6323_AUXADC_CON19, &val); + if (ret) + return ret; + + /* The ADC is idle. */ + if (!(val & AUXADC_CON19_DECI_GDLY_MASK)) + return 0; + + ret = regmap_read_poll_timeout(map, MT6323_AUXADC_ADC19, val, + !(val & AUXADC_ADC19_BUSY_MASK), + 10, 500); + if (ret) + return ret; + + return regmap_clear_bits(map, MT6323_AUXADC_CON19, + AUXADC_CON19_DECI_GDLY_MASK); +} + +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_CON11_VBUF_EN); + if (ret) + return ret; + + return regmap_set_bits(map, MT6323_AUXADC_CON22, BIT(channel)); +} + +static int mt6323_auxadc_release(struct mt6323_auxadc *auxadc, + unsigned long channel) +{ + struct regmap *map = auxadc->regmap; + int ret; + + ret = regmap_clear_bits(map, MT6323_AUXADC_CON22, BIT(channel)); + if (ret) + return ret; + + return regmap_clear_bits(map, MT6323_AUXADC_CON11, AUXADC_CON11_VBUF_EN); +} + +static int mt6323_auxadc_read(struct mt6323_auxadc *auxadc, + const struct iio_chan_spec *chan, int *out) +{ + struct regmap *map = auxadc->regmap; + u32 val; + int ret; + + ret = regmap_read_poll_timeout(map, chan->address, val, (val & AUXADC_READY_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; + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + if (chan->channel == MT6323_AUXADC_ISENSE || + chan->channel == MT6323_AUXADC_BATSNS) + mult = 4; + else + mult = 1; + + /* 1800mV full range with 15-bit resolution. */ + *val = mult * 1800; + *val2 = 15; + + return IIO_VAL_FRACTIONAL_LOG2; + case IIO_CHAN_INFO_RAW: + scoped_guard(mutex, &auxadc->lock) { + ret = mt6323_auxadc_prepare_channel(auxadc); + if (ret) + return ret; + + ret = mt6323_auxadc_request(auxadc, chan->channel); + if (ret) + return ret; + + /* Hardware limitation: the AUXADC needs a delay to become ready. */ + fsleep(300); + + ret = mt6323_auxadc_read(auxadc, chan, val); + + if (mt6323_auxadc_release(auxadc, chan->channel)) + dev_err(&indio_dev->dev, + "failed to release channel %d\n", chan->channel); + + if (ret) + return ret; + } + return IIO_VAL_INT; + default: + 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_STRUP_CON10_RSTB_SW | + AUXADC_STRUP_CON10_RSTB_SEL); + if (ret) + return ret; + + ret = regmap_set_bits(map, MT6323_TOP_CKPDN2, AUXADC_TOP_CKPDN2_CTL_CK); + if (ret) + return ret; + + ret = regmap_update_bits(map, MT6323_AUXADC_CON10, + AUXADC_TRIM_CH2_MASK | AUXADC_TRIM_CH4_MASK | + AUXADC_TRIM_CH5_MASK | AUXADC_TRIM_CH6_MASK, + FIELD_PREP(AUXADC_TRIM_CH2_MASK, 1) | + FIELD_PREP(AUXADC_TRIM_CH4_MASK, 1) | + FIELD_PREP(AUXADC_TRIM_CH5_MASK, 1) | + FIELD_PREP(AUXADC_TRIM_CH6_MASK, 1)); + if (ret) + return ret; + + ret = regmap_set_bits(map, MT6323_AUXADC_CON27, + AUXADC_CON27_VREF18_ENB_MD | + AUXADC_CON27_MD_STATUS); + if (ret) + return ret; + + ret = regmap_set_bits(map, MT6323_AUXADC_CON19, AUXADC_CON19_GPS_STATUS); + if (ret) + return ret; + + ret = regmap_set_bits(map, MT6323_AUXADC_CON26, + AUXADC_CON26_VREF18_SELB | + AUXADC_CON26_DECI_GDLY_SEL); + if (ret) + return ret; + + return regmap_update_bits(map, MT6323_AUXADC_CON9, AUXADC_CON9_OSR_MASK, + FIELD_PREP(AUXADC_CON9_OSR_MASK, AUXADC_DEFAULT_OSR)); +} + +static const struct iio_info mt6323_auxadc_iio_info = { + .read_raw = mt6323_auxadc_read_raw, +}; + +static int mt6323_auxadc_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct mt6323_auxadc *auxadc; + struct regmap *regmap; + struct iio_dev *iio; + int ret; + + regmap = dev_get_regmap(dev->parent->parent, NULL); + if (!regmap) + return dev_err_probe(dev, -ENODEV, "failed to get regmap\n"); + + iio = devm_iio_device_alloc(dev, sizeof(*auxadc)); + if (!iio) + return -ENOMEM; + + auxadc = iio_priv(iio); + auxadc->regmap = regmap; + + ret = devm_mutex_init(dev, &auxadc->lock); + if (ret) + return ret; + + ret = mt6323_auxadc_init(auxadc); + if (ret) + return dev_err_probe(dev, ret, "failed to initialize auxadc\n"); + + iio->name = "mt6323-auxadc"; + iio->info = &mt6323_auxadc_iio_info; + iio->modes = INDIO_DIRECT_MODE; + iio->channels = mt6323_auxadc_channels; + iio->num_channels = ARRAY_SIZE(mt6323_auxadc_channels); + + return devm_iio_device_register(dev, iio); +} + +static const struct of_device_id mt6323_auxadc_of_match[] = { + { .compatible = "mediatek,mt6323-auxadc" }, + { } +}; +MODULE_DEVICE_TABLE(of, mt6323_auxadc_of_match); + +static struct platform_driver mt6323_auxadc_driver = { + .driver = { + .name = "mt6323-auxadc", + .of_match_table = mt6323_auxadc_of_match, + }, + .probe = mt6323_auxadc_probe, +}; +module_platform_driver(mt6323_auxadc_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("MediaTek MT6323 PMIC AUXADC Driver"); -- 2.54.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/4] iio: adc: mt6323-auxadc: add mt6323 PMIC AUXADC driver 2026-06-09 13:31 ` [PATCH v2 2/4] iio: adc: mt6323-auxadc: add mt6323 PMIC AUXADC driver Roman Vivchar via B4 Relay @ 2026-06-09 13:44 ` sashiko-bot 2026-06-09 18:30 ` Andy Shevchenko 1 sibling, 0 replies; 11+ messages in thread From: sashiko-bot @ 2026-06-09 13:44 UTC (permalink / raw) To: Roman Vivchar via B4 Relay; +Cc: devicetree, conor+dt, robh Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] The probe function unconditionally dereferences `dev->parent` and `dev->parent->parent`, which will cause a kernel panic if the parent device is NULL. - [High] The driver incorrectly uses the logical device tree channel index instead of the physical ADC channel index when setting the hardware request bitmask. - [Medium] The AUXADC voltage buffer (`VBUF`) is left permanently enabled on error paths, leading to a resource/power leak. - [Medium] Incorrect IIO channel types are hardcoded as `IIO_VOLTAGE` for temperature and current channels, violating IIO ABI. -- commit 5d793b85b8942cff4538a9fd7c909fd225402286 Author: Roman Vivchar <rva333@protonmail.com> iio: adc: mt6323-auxadc: add mt6323 PMIC AUXADC driver 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. Tested-by: Ben Grisdale <bengris32@protonmail.ch> # Amazon Echo Dot (2nd Generation) Signed-off-by: Roman Vivchar <rva333@protonmail.com> [ ... ] > diff --git a/drivers/iio/adc/mt6323-auxadc.c b/drivers/iio/adc/mt6323-auxadc.c > new file mode 100644 > index 0000000000000..f2cef989d3ce7 > --- /dev/null > +++ b/drivers/iio/adc/mt6323-auxadc.c [ ... ] > +#define AUXADC_DEFAULT_OSR 3 > + > +#define MTK_PMIC_IIO_CHAN(_name, _chan, _addr) \ > +{ \ > + .type = IIO_VOLTAGE, \ [Severity: Medium] Does hardcoding IIO_VOLTAGE here break the IIO ABI for temperature and current channels? It looks like bat_temp, chip_temp, and isense will be exported as in_voltage_*_raw instead of IIO_TEMP and IIO_CURRENT. > + .indexed = 1, \ > + .channel = _chan, \ [ ... ] > +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_CON11_VBUF_EN); > + if (ret) > + return ret; > + > + return regmap_set_bits(map, MT6323_AUXADC_CON22, BIT(channel)); [Severity: High] Does BIT(channel) request the correct physical hardware channel here? The channel parameter receives chan->channel, which is a logical sequential index (e.g., MT6323_AUXADC_BATON2 = 0), but the hardware request register appears to expect bits corresponding to the physical ADC channels. For instance, setting BIT(0) for BATON2 would request ADC0 from the hardware, but the driver will later poll the ADC6 data register. [Severity: Medium] If regmap_set_bits() fails to set MT6323_AUXADC_CON22, does this leave the AUXADC voltage buffer (VBUF) permanently enabled? Since the caller aborts on error without calling mt6323_auxadc_release(), the AUXADC_CON11_VBUF_EN bit is never cleared. > +} > + > +static int mt6323_auxadc_release(struct mt6323_auxadc *auxadc, > + unsigned long channel) > +{ > + struct regmap *map = auxadc->regmap; > + int ret; > + > + ret = regmap_clear_bits(map, MT6323_AUXADC_CON22, BIT(channel)); > + if (ret) > + return ret; [Severity: Medium] If clearing MT6323_AUXADC_CON22 fails here, does it skip disabling the voltage buffer? Returning early would leave AUXADC_CON11_VBUF_EN enabled. > + > + return regmap_clear_bits(map, MT6323_AUXADC_CON11, AUXADC_CON11_VBUF_EN); > +} [ ... ] > +static int mt6323_auxadc_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct mt6323_auxadc *auxadc; > + struct regmap *regmap; > + struct iio_dev *iio; > + int ret; > + > + regmap = dev_get_regmap(dev->parent->parent, NULL); [Severity: High] Can this cause a null pointer dereference if the driver is probed directly from a device tree node without an MFD parent? Because the driver defines an of_match_table, it could be instantiated where dev->parent is null. Even if dev->parent is valid but dev->parent->parent is null, passing null to dev_get_regmap() will cause a kernel panic when it attempts to lock devres. > + if (!regmap) > + return dev_err_probe(dev, -ENODEV, "failed to get regmap\n"); > + -- Sashiko AI review · https://sashiko.dev/#/patchset/20260609-mt6323-adc-v2-0-aa93a22309f9@protonmail.com?part=2 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/4] iio: adc: mt6323-auxadc: add mt6323 PMIC AUXADC driver 2026-06-09 13:31 ` [PATCH v2 2/4] iio: adc: mt6323-auxadc: add mt6323 PMIC AUXADC driver Roman Vivchar via B4 Relay 2026-06-09 13:44 ` sashiko-bot @ 2026-06-09 18:30 ` Andy Shevchenko 2026-06-09 19:15 ` Roman Vivchar 1 sibling, 1 reply; 11+ messages in thread From: Andy Shevchenko @ 2026-06-09 18:30 UTC (permalink / raw) To: rva333 Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno, Lee Jones, linux-iio, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, Ben Grisdale On Tue, Jun 09, 2026 at 04:31:59PM +0300, Roman Vivchar via B4 Relay wrote: > 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. Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> A few nit-picks, most important from which is the scoped_guard() versus guard()() use. ... > +static int mt6323_auxadc_prepare_channel(struct mt6323_auxadc *auxadc) > +{ > + struct regmap *map = auxadc->regmap; > + u32 val; > + int ret; > + > + ret = regmap_read(map, MT6323_AUXADC_CON19, &val); > + if (ret) > + return ret; > + > + /* The ADC is idle. */ > + if (!(val & AUXADC_CON19_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 split on logical boundaries: ret = regmap_read_poll_timeout(map, MT6323_AUXADC_ADC19, val, !(val & AUXADC_ADC19_BUSY_MASK), 10, 500); > + if (ret) > + return ret; > + > + return regmap_clear_bits(map, MT6323_AUXADC_CON19, > + AUXADC_CON19_DECI_GDLY_MASK); > +} ... > +static int mt6323_auxadc_read(struct mt6323_auxadc *auxadc, > + const struct iio_chan_spec *chan, int *out) > +{ > + struct regmap *map = auxadc->regmap; > + u32 val; > + int ret; > + > + ret = regmap_read_poll_timeout(map, chan->address, val, (val & AUXADC_READY_MASK), > + 1 * USEC_PER_MSEC, 100 * USEC_PER_MSEC); Perhaps ret = regmap_read_poll_timeout(map, chan->address, val, (val & AUXADC_READY_MASK), 1 * USEC_PER_MSEC, 100 * USEC_PER_MSEC); (see above why). > + if (ret) > + return ret; > + > + *out = FIELD_GET(AUXADC_DATA_MASK, val); > + > + return 0; > +} ... > + case IIO_CHAN_INFO_RAW: > + scoped_guard(mutex, &auxadc->lock) { I'm wondering why we haven't moved to guard()() here case IIO_CHAN_INFO_RAW: { guard(mutex)(&auxadc->lock); > + ret = mt6323_auxadc_prepare_channel(auxadc); > + if (ret) > + return ret; > + > + ret = mt6323_auxadc_request(auxadc, chan->channel); > + if (ret) > + return ret; > + > + /* Hardware limitation: the AUXADC needs a delay to become ready. */ > + fsleep(300); > + > + ret = mt6323_auxadc_read(auxadc, chan, val); > + > + if (mt6323_auxadc_release(auxadc, chan->channel)) > + dev_err(&indio_dev->dev, > + "failed to release channel %d\n", chan->channel); > + > + if (ret) > + return ret; > + } > + return IIO_VAL_INT; -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/4] iio: adc: mt6323-auxadc: add mt6323 PMIC AUXADC driver 2026-06-09 18:30 ` Andy Shevchenko @ 2026-06-09 19:15 ` Roman Vivchar 0 siblings, 0 replies; 11+ messages in thread From: Roman Vivchar @ 2026-06-09 19:15 UTC (permalink / raw) To: Andy Shevchenko Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno, Lee Jones, linux-iio, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, Ben Grisdale Hi Andy, On Tuesday, June 9th, 2026 at 9:30 PM, Andy Shevchenko <andriy.shevchenko@intel.com> wrote: > On Tue, Jun 09, 2026 at 04:31:59PM +0300, Roman Vivchar via B4 Relay wrote: > ... > > > + ret = regmap_read_poll_timeout(map, MT6323_AUXADC_ADC19, val, > > + !(val & AUXADC_ADC19_BUSY_MASK), > > + 10, 500); > > It's better to split on logical boundaries: > > ret = regmap_read_poll_timeout(map, MT6323_AUXADC_ADC19, > val, !(val & AUXADC_ADC19_BUSY_MASK), > 10, 500); > Agreed. ... > > > + case IIO_CHAN_INFO_RAW: > > + scoped_guard(mutex, &auxadc->lock) { > > I'm wondering why we haven't moved to guard()() here The compiler would complain about 'cannot jump from switch statement' due to default case. Best regards, Roman ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 3/4] mfd: mt6397-core: add mt6323 AUXADC support 2026-06-09 13:31 [PATCH v2 0/4] AUXADC driver for the MediaTek mt6323 PMIC Roman Vivchar via B4 Relay 2026-06-09 13:31 ` [PATCH v2 1/4] dt-bindings: iio: adc: mediatek,mt6359-auxadc: add mt6323 PMIC AUXADC Roman Vivchar via B4 Relay 2026-06-09 13:31 ` [PATCH v2 2/4] iio: adc: mt6323-auxadc: add mt6323 PMIC AUXADC driver Roman Vivchar via B4 Relay @ 2026-06-09 13:32 ` Roman Vivchar via B4 Relay 2026-06-09 13:43 ` sashiko-bot 2026-06-09 13:32 ` [PATCH v2 4/4] ARM: dts: mediatek: mt6323: add " Roman Vivchar via B4 Relay 3 siblings, 1 reply; 11+ messages in thread From: Roman Vivchar via B4 Relay @ 2026-06-09 13:32 UTC (permalink / raw) To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno, Lee Jones Cc: linux-iio, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, Ben Grisdale, Roman Vivchar From: Roman Vivchar <rva333@protonmail.com> The mt6323 PMIC includes an AUXADC. Register the AUXADC in the mt6323 devices array to allow the corresponding driver to probe using compatible string. Tested-by: Ben Grisdale <bengris32@protonmail.ch> # Amazon Echo Dot (2nd Generation) Signed-off-by: Roman Vivchar <rva333@protonmail.com> --- drivers/mfd/mt6397-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c index 3e58d0764c7e..013b0857fb54 100644 --- a/drivers/mfd/mt6397-core.c +++ b/drivers/mfd/mt6397-core.c @@ -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, -- 2.54.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/4] mfd: mt6397-core: add mt6323 AUXADC support 2026-06-09 13:32 ` [PATCH v2 3/4] mfd: mt6397-core: add mt6323 AUXADC support Roman Vivchar via B4 Relay @ 2026-06-09 13:43 ` sashiko-bot 0 siblings, 0 replies; 11+ messages in thread From: sashiko-bot @ 2026-06-09 13:43 UTC (permalink / raw) To: Roman Vivchar via B4 Relay; +Cc: robh, devicetree, conor+dt Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Setting the clock power down bit disables the AUXADC clock instead of enabling it. -- commit bab9fefa6ba4c56ff9360f203a97d192c15f6cd1 Author: Roman Vivchar <rva333@protonmail.com> mfd: mt6397-core: add mt6323 AUXADC support The mt6323 PMIC includes an AUXADC. Register the AUXADC in the mt6323 devices array to allow the corresponding driver to probe using compatible string. > diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c > index 3e58d0764c7e0..013b0857fb548 100644 > --- a/drivers/mfd/mt6397-core.c > +++ b/drivers/mfd/mt6397-core.c > @@ -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", [Severity: High] Does enabling this device expose an issue in the mt6323-auxadc driver's clock initialization? Looking at mt6323_auxadc_init() in drivers/iio/adc/mt6323-auxadc.c, it writes a 1 to the power down register bit: ret = regmap_set_bits(map, MT6323_TOP_CKPDN2, AUXADC_TOP_CKPDN2_CTL_CK); if (ret) return ret; Since CKPDN registers in MediaTek PMICs are Clock Power Down registers, setting a bit to 1 explicitly disables the clock, while clearing it to 0 powers it up. Because the AUXADC clock is explicitly disabled here and never turned back on, will ADC read requests in mt6323_auxadc_read_raw() fail or time out waiting for AUXADC_READY_MASK? If the entire driver is functionally broken due to this, could it subsequently break dependent features like battery management and thermal protection? > + }, { > .name = "mt6323-rtc", > .num_resources = ARRAY_SIZE(mt6323_rtc_resources), > .resources = mt6323_rtc_resources, -- Sashiko AI review · https://sashiko.dev/#/patchset/20260609-mt6323-adc-v2-0-aa93a22309f9@protonmail.com?part=3 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 4/4] ARM: dts: mediatek: mt6323: add AUXADC support 2026-06-09 13:31 [PATCH v2 0/4] AUXADC driver for the MediaTek mt6323 PMIC Roman Vivchar via B4 Relay ` (2 preceding siblings ...) 2026-06-09 13:32 ` [PATCH v2 3/4] mfd: mt6397-core: add mt6323 AUXADC support Roman Vivchar via B4 Relay @ 2026-06-09 13:32 ` Roman Vivchar via B4 Relay 3 siblings, 0 replies; 11+ messages in thread From: Roman Vivchar via B4 Relay @ 2026-06-09 13:32 UTC (permalink / raw) To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno, Lee Jones Cc: linux-iio, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, Ben Grisdale, Roman Vivchar From: Roman Vivchar <rva333@protonmail.com> Add the devicetree node for the mt6323 AUXADC. Tested-by: Ben Grisdale <bengris32@protonmail.ch> # Amazon Echo Dot (2nd Generation) Signed-off-by: Roman Vivchar <rva333@protonmail.com> --- arch/arm/boot/dts/mediatek/mt6323.dtsi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/boot/dts/mediatek/mt6323.dtsi b/arch/arm/boot/dts/mediatek/mt6323.dtsi index c230c865116d..c070f4b0936c 100644 --- a/arch/arm/boot/dts/mediatek/mt6323.dtsi +++ b/arch/arm/boot/dts/mediatek/mt6323.dtsi @@ -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>; -- 2.54.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-06-09 19:15 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-06-09 13:31 [PATCH v2 0/4] AUXADC driver for the MediaTek mt6323 PMIC Roman Vivchar via B4 Relay 2026-06-09 13:31 ` [PATCH v2 1/4] dt-bindings: iio: adc: mediatek,mt6359-auxadc: add mt6323 PMIC AUXADC Roman Vivchar via B4 Relay 2026-06-09 16:01 ` Conor Dooley 2026-06-09 17:29 ` Roman Vivchar 2026-06-09 13:31 ` [PATCH v2 2/4] iio: adc: mt6323-auxadc: add mt6323 PMIC AUXADC driver Roman Vivchar via B4 Relay 2026-06-09 13:44 ` sashiko-bot 2026-06-09 18:30 ` Andy Shevchenko 2026-06-09 19:15 ` Roman Vivchar 2026-06-09 13:32 ` [PATCH v2 3/4] mfd: mt6397-core: add mt6323 AUXADC support Roman Vivchar via B4 Relay 2026-06-09 13:43 ` sashiko-bot 2026-06-09 13:32 ` [PATCH v2 4/4] ARM: dts: mediatek: mt6323: add " Roman Vivchar via B4 Relay
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox