* [PATCH v4 0/3] nvmem: add support for the MediaTek mt6323 PMIC
@ 2026-09-11 6:32 Roman Vivchar via B4 Relay
2026-09-11 6:32 ` [PATCH v4 1/3] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE Roman Vivchar via B4 Relay
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-09-11 6:32 UTC (permalink / raw)
To: Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Srinivas Kandagatla, Roman Vivchar
Cc: Andy Shevchenko, linux-pm, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, Ben Grisdale, Conor Dooley
This series adds support for the EFUSE 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.
[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 v4:
- Rebase onto nvmem/for-next (8f596c13b6b7 ("dt-bindings: nvmem: qfprom: Add compatible for Qualcomm Maili"))
- Drop device-id/of.h header (Andy)
- Mediatek -> MediaTek in Kconfig
- Link to v3: https://patch.msgid.link/20260713-mt6323-nvmem-v3-0-205c39267a24@protonmail.com
Changes in v3:
- Rebase onto next-20260708
- EFUSE driver: Replace 'mod_devicetable.h' with explicit 'device-id/of.h'
- Drop MFD patch since it's applied
- Link to v2: https://patch.msgid.link/20260617-mt6323-nvmem-v2-0-4f30e36aa0f4@protonmail.com
Changes in v2:
- EFUSE driver: Sort variables in the mt6323_efuse_read (Andy)
- Link to v1: https://patch.msgid.link/20260611-mt6323-nvmem-v1-0-b5e1b9ce51f2@protonmail.com
Changes after split:
- EFUSE driver:
- Remove 'linux/errno.h' header (Andy)
- Remove explicit cast to u16 in the 'mt6323_efuse_read' (Andy)
- Reword comment in the 'mt6323_efuse_read'
- Capitalize MediaTek in the module description
- Link to a previous series: https://patch.msgid.link/20260512-mt6323-v2-0-3efcba579e88@protonmail.com
---
Roman Vivchar (3):
dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE
nvmem: add mt6323 PMIC EFUSE driver
ARM: dts: mediatek: mt6323: add EFUSE support
.../devicetree/bindings/mfd/mediatek,mt6397.yaml | 21 ++++++
MAINTAINERS | 5 ++
arch/arm/boot/dts/mediatek/mt6323.dtsi | 4 ++
drivers/nvmem/Kconfig | 11 +++
drivers/nvmem/Makefile | 2 +
drivers/nvmem/mt6323-efuse.c | 84 ++++++++++++++++++++++
6 files changed, 127 insertions(+)
---
base-commit: 8f596c13b6b7fa9fa35091273c37f9b6e3fc2d0f
change-id: 20260611-mt6323-nvmem-0c54a0f2fa9f
Best regards,
--
Roman Vivchar <rva333@protonmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v4 1/3] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE 2026-09-11 6:32 [PATCH v4 0/3] nvmem: add support for the MediaTek mt6323 PMIC Roman Vivchar via B4 Relay @ 2026-09-11 6:32 ` Roman Vivchar via B4 Relay 2026-09-11 6:41 ` sashiko-bot 2026-09-11 6:33 ` [PATCH v4 2/3] nvmem: add mt6323 PMIC EFUSE driver Roman Vivchar via B4 Relay 2026-09-11 6:33 ` [PATCH v4 3/3] ARM: dts: mediatek: mt6323: add EFUSE support Roman Vivchar via B4 Relay 2 siblings, 1 reply; 7+ messages in thread From: Roman Vivchar via B4 Relay @ 2026-09-11 6:32 UTC (permalink / raw) To: Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno, Srinivas Kandagatla, Roman Vivchar Cc: Andy Shevchenko, linux-pm, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, Ben Grisdale, Conor Dooley From: Roman Vivchar <rva333@protonmail.com> The MediaTek mt6323 PMIC includes an EFUSE used for storing calibration data. Add the devicetree binding documentation for the MediaTek mt6323 EFUSE. Reviewed-by: Rob Herring (Arm) <robh@kernel.org> Acked-by: Conor Dooley <conor.dooley@microchip.com> Signed-off-by: Roman Vivchar <rva333@protonmail.com> --- .../devicetree/bindings/mfd/mediatek,mt6397.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml b/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml index 3cbc0dc12c31..d2de227ae7a6 100644 --- a/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +++ b/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml @@ -159,6 +159,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 @@ -307,6 +324,10 @@ examples: interrupt-controller; #interrupt-cells = <2>; + efuse { + compatible = "mediatek,mt6323-efuse"; + }; + leds { compatible = "mediatek,mt6323-led"; #address-cells = <1>; -- 2.55.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v4 1/3] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE 2026-09-11 6:32 ` [PATCH v4 1/3] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE Roman Vivchar via B4 Relay @ 2026-09-11 6:41 ` sashiko-bot 0 siblings, 0 replies; 7+ messages in thread From: sashiko-bot @ 2026-09-11 6:41 UTC (permalink / raw) To: Roman Vivchar; +Cc: devicetree, robh, conor+dt Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The `efuse` object sets `unevaluatedProperties: false` but omits a `$ref` to the base NVMEM schema, preventing the use of standard NVMEM properties. -- commit 564a77c7b7cc8f4b6a33fd5c7430ae49a1709346 Author: Roman Vivchar <rva333@protonmail.com> dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE The MediaTek mt6323 PMIC includes an EFUSE used for storing calibration data. This commit adds the corresponding devicetree binding documentation. > diff --git a/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml b/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml > index 3cbc0dc12c319..d2de227ae7a6d 100644 > --- a/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml > +++ b/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml > @@ -159,6 +159,23 @@ properties: > required: > - compatible > > + efuse: > + type: object > + unevaluatedProperties: false [Severity: Low] Does this efuse object also need a $ref: /schemas/nvmem/nvmem.yaml# included? Because unevaluatedProperties is set to false in properties.efuse without a reference to the base nvmem schema, could this cause a schema validation regression? It appears any device tree attempting to use standard nvmem properties (such as read-only, wp-gpios, or #address-cells and #size-cells for static cells) in the efuse node will incorrectly fail schema validation. > + description: > + The efuse is responsible for storing calibration data, such as thermal > + sensor calibration. -- Sashiko AI review · https://sashiko.dev/#/patchset/20260911-mt6323-nvmem-v4-0-626dd17531dc@protonmail.com?part=1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 2/3] nvmem: add mt6323 PMIC EFUSE driver 2026-09-11 6:32 [PATCH v4 0/3] nvmem: add support for the MediaTek mt6323 PMIC Roman Vivchar via B4 Relay 2026-09-11 6:32 ` [PATCH v4 1/3] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE Roman Vivchar via B4 Relay @ 2026-09-11 6:33 ` Roman Vivchar via B4 Relay 2026-09-11 6:51 ` sashiko-bot 2026-09-14 22:08 ` Srinivas Kandagatla 2026-09-11 6:33 ` [PATCH v4 3/3] ARM: dts: mediatek: mt6323: add EFUSE support Roman Vivchar via B4 Relay 2 siblings, 2 replies; 7+ messages in thread From: Roman Vivchar via B4 Relay @ 2026-09-11 6:33 UTC (permalink / raw) To: Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno, Srinivas Kandagatla, Roman Vivchar Cc: Andy Shevchenko, linux-pm, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, Ben Grisdale From: Roman Vivchar <rva333@protonmail.com> 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. Tested-by: Ben Grisdale <bengris32@protonmail.ch> # Amazon Echo Dot (2nd Generation) Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Roman Vivchar <rva333@protonmail.com> --- MAINTAINERS | 5 +++ drivers/nvmem/Kconfig | 11 ++++++ drivers/nvmem/Makefile | 2 ++ drivers/nvmem/mt6323-efuse.c | 84 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 3a19da74d00c..6ec0ed61260c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16718,6 +16718,11 @@ S: Maintained F: drivers/iio/adc/mt6323-auxadc.c F: include/dt-bindings/iio/adc/mediatek,mt6323-auxadc.h +MEDIATEK MT6323 PMIC NVMEM DRIVER +M: Roman Vivchar <rva333@protonmail.com> +S: Maintained +F: drivers/nvmem/mt6323-efuse.c + MEDIATEK MT6735 CLOCK & RESET DRIVERS M: Yassine Oudjana <y.oudjana@protonmail.com> L: linux-clk@vger.kernel.org diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index c36c2a4c2a0b..5115c46beb97 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -328,6 +328,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 diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index 2bbfb9ff1885..626936e4dfdd 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -55,6 +55,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 diff --git a/drivers/nvmem/mt6323-efuse.c b/drivers/nvmem/mt6323-efuse.c new file mode 100644 index 000000000000..6f6f1cdc2f38 --- /dev/null +++ b/drivers/nvmem/mt6323-efuse.c @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2026 Roman Vivchar <rva333@protonmail.com> + */ + +#include <linux/err.h> +#include <linux/module.h> +#include <linux/nvmem-provider.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> +#include <linux/types.h> + +#include <linux/mfd/mt6323/registers.h> + +#define MT6323_EFUSE_DOUT_BASE MT6323_EFUSE_DOUT_0_15 +#define MT6323_EFUSE_SIZE 24 + +static int mt6323_efuse_read(void *context, unsigned int offset, void *val, + size_t bytes) +{ + struct regmap *map = context; + u16 *buf = val; + u32 tmp; + int ret; + + /* + * A manual loop using regmap_read is required because PWRAP is not + * a continuous MMIO space, but rather a FSM that doesn't implement the + * 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++ = tmp; + } + + return 0; +} + +static int mt6323_efuse_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct nvmem_config config = { + .name = "mt6323-efuse", + .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); + if (!regmap) + return dev_err_probe(dev, -ENODEV, "failed to get regmap\n"); + + config.dev = dev; + config.priv = regmap; + + nvmem = devm_nvmem_register(dev, &config); + return PTR_ERR_OR_ZERO(nvmem); +} + +static const struct of_device_id mt6323_efuse_of_match[] = { + { .compatible = "mediatek,mt6323-efuse" }, + { } +}; +MODULE_DEVICE_TABLE(of, mt6323_efuse_of_match); + +static struct platform_driver mt6323_efuse_driver = { + .probe = mt6323_efuse_probe, + .driver = { + .name = "mt6323-efuse", + .of_match_table = mt6323_efuse_of_match, + }, +}; +module_platform_driver(mt6323_efuse_driver); + +MODULE_DESCRIPTION("MediaTek MT6323 PMIC EFUSE driver"); +MODULE_LICENSE("GPL"); -- 2.55.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v4 2/3] nvmem: add mt6323 PMIC EFUSE driver 2026-09-11 6:33 ` [PATCH v4 2/3] nvmem: add mt6323 PMIC EFUSE driver Roman Vivchar via B4 Relay @ 2026-09-11 6:51 ` sashiko-bot 2026-09-14 22:08 ` Srinivas Kandagatla 1 sibling, 0 replies; 7+ messages in thread From: sashiko-bot @ 2026-09-11 6:51 UTC (permalink / raw) To: Roman Vivchar; +Cc: robh, conor+dt, devicetree Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] NULL pointer dereference when accessing `dev->parent->parent` to retrieve the regmap. -- commit 9cacac916b33064bc7243868fd8890da0759dff1 Author: Roman Vivchar <rva333@protonmail.com> nvmem: add mt6323 PMIC EFUSE driver 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. > diff --git a/drivers/nvmem/mt6323-efuse.c b/drivers/nvmem/mt6323-efuse.c > new file mode 100644 > index 0000000000000..6f6f1cdc2f388 > --- /dev/null > +++ b/drivers/nvmem/mt6323-efuse.c [ ... ] > @@ -0,0 +1,84 @@ [ ... ] > +static int mt6323_efuse_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct nvmem_config config = { > + .name = "mt6323-efuse", > + .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); [Severity: High] Does this code safely handle cases where the device hierarchy is shallower than expected? If the device is instantiated without a grandparent (for example, via a malformed device tree overlay or manually created via sysfs), dev->parent will point to the platform_bus, and dev->parent->parent will be NULL. Passing NULL to dev_get_regmap() forwards it to devres_find(), which then dereferences the NULL pointer when attempting to take the device's resource lock. Additionally, if dev->parent itself is ever NULL, evaluating dev->parent->parent will crash before the function call even occurs. > + if (!regmap) > + return dev_err_probe(dev, -ENODEV, "failed to get regmap\n"); > + > + config.dev = dev; > + config.priv = regmap; > + > + nvmem = devm_nvmem_register(dev, &config); > + return PTR_ERR_OR_ZERO(nvmem); > +} -- Sashiko AI review · https://sashiko.dev/#/patchset/20260911-mt6323-nvmem-v4-0-626dd17531dc@protonmail.com?part=2 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 2/3] nvmem: add mt6323 PMIC EFUSE driver 2026-09-11 6:33 ` [PATCH v4 2/3] nvmem: add mt6323 PMIC EFUSE driver Roman Vivchar via B4 Relay 2026-09-11 6:51 ` sashiko-bot @ 2026-09-14 22:08 ` Srinivas Kandagatla 1 sibling, 0 replies; 7+ messages in thread From: Srinivas Kandagatla @ 2026-09-14 22:08 UTC (permalink / raw) To: rva333, Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno, Srinivas Kandagatla Cc: Andy Shevchenko, linux-pm, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, Ben Grisdale On 9/11/26 7:33 AM, Roman Vivchar via B4 Relay wrote: > From: Roman Vivchar <rva333@protonmail.com> > > 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. > > Tested-by: Ben Grisdale <bengris32@protonmail.ch> # Amazon Echo Dot (2nd Generation) > Reviewed-by: Andy Shevchenko <andy@kernel.org> > Signed-off-by: Roman Vivchar <rva333@protonmail.com> > --- > MAINTAINERS | 5 +++ > drivers/nvmem/Kconfig | 11 ++++++ > drivers/nvmem/Makefile | 2 ++ > drivers/nvmem/mt6323-efuse.c | 84 ++++++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 102 insertions(+) > > diff --git a/MAINTAINERS b/MAINTAINERS > index 3a19da74d00c..6ec0ed61260c 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -16718,6 +16718,11 @@ S: Maintained > F: drivers/iio/adc/mt6323-auxadc.c > F: include/dt-bindings/iio/adc/mediatek,mt6323-auxadc.h > > +MEDIATEK MT6323 PMIC NVMEM DRIVER > +M: Roman Vivchar <rva333@protonmail.com> > +S: Maintained > +F: drivers/nvmem/mt6323-efuse.c placement is in wrong order, same in make file too. > + > MEDIATEK MT6735 CLOCK & RESET DRIVERS > M: Yassine Oudjana <y.oudjana@protonmail.com> > L: linux-clk@vger.kernel.org > diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig > index c36c2a4c2a0b..5115c46beb97 100644 > --- a/drivers/nvmem/Kconfig > +++ b/drivers/nvmem/Kconfig > @@ -328,6 +328,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 > diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile > index 2bbfb9ff1885..626936e4dfdd 100644 > --- a/drivers/nvmem/Makefile > +++ b/drivers/nvmem/Makefile > @@ -55,6 +55,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 > diff --git a/drivers/nvmem/mt6323-efuse.c b/drivers/nvmem/mt6323-efuse.c > new file mode 100644 > index 000000000000..6f6f1cdc2f38 > --- /dev/null > +++ b/drivers/nvmem/mt6323-efuse.c > @@ -0,0 +1,84 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Copyright (c) 2026 Roman Vivchar <rva333@protonmail.com> > + */ > + > +#include <linux/err.h> > +#include <linux/module.h> > +#include <linux/nvmem-provider.h> > +#include <linux/platform_device.h> > +#include <linux/regmap.h> > +#include <linux/types.h> > + > +#include <linux/mfd/mt6323/registers.h> > + > +#define MT6323_EFUSE_DOUT_BASE MT6323_EFUSE_DOUT_0_15 > +#define MT6323_EFUSE_SIZE 24 > + > +static int mt6323_efuse_read(void *context, unsigned int offset, void *val, > + size_t bytes) > +{ > + struct regmap *map = context; > + u16 *buf = val; > + u32 tmp; > + int ret; > + > + /* > + * A manual loop using regmap_read is required because PWRAP is not > + * a continuous MMIO space, but rather a FSM that doesn't implement the > + * 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++ = tmp; > + } > + > + return 0; > +} > + > +static int mt6323_efuse_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct nvmem_config config = { > + .name = "mt6323-efuse", > + .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); > + if (!regmap) > + return dev_err_probe(dev, -ENODEV, "failed to get regmap\n"); can we be more consistent here, how about struct mt6397_chip *mt6323 = dev_get_drvdata(pdev->dev.parent); and use mt6323->regmap like how mt6323_regulators driver does it. > + > + config.dev = dev; > + config.priv = regmap; > + > + nvmem = devm_nvmem_register(dev, &config); > + return PTR_ERR_OR_ZERO(nvmem); > +} > + > +static const struct of_device_id mt6323_efuse_of_match[] = { > + { .compatible = "mediatek,mt6323-efuse" }, > + { } > +}; > +MODULE_DEVICE_TABLE(of, mt6323_efuse_of_match); > + > +static struct platform_driver mt6323_efuse_driver = { > + .probe = mt6323_efuse_probe, > + .driver = { > + .name = "mt6323-efuse", > + .of_match_table = mt6323_efuse_of_match, > + }, > +}; > +module_platform_driver(mt6323_efuse_driver); > + > +MODULE_DESCRIPTION("MediaTek MT6323 PMIC EFUSE driver"); > +MODULE_LICENSE("GPL"); > ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 3/3] ARM: dts: mediatek: mt6323: add EFUSE support 2026-09-11 6:32 [PATCH v4 0/3] nvmem: add support for the MediaTek mt6323 PMIC Roman Vivchar via B4 Relay 2026-09-11 6:32 ` [PATCH v4 1/3] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE Roman Vivchar via B4 Relay 2026-09-11 6:33 ` [PATCH v4 2/3] nvmem: add mt6323 PMIC EFUSE driver Roman Vivchar via B4 Relay @ 2026-09-11 6:33 ` Roman Vivchar via B4 Relay 2 siblings, 0 replies; 7+ messages in thread From: Roman Vivchar via B4 Relay @ 2026-09-11 6:33 UTC (permalink / raw) To: Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno, Srinivas Kandagatla, Roman Vivchar Cc: Andy Shevchenko, linux-pm, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, Ben Grisdale From: Roman Vivchar <rva333@protonmail.com> Add the devicetree node for the mt6323 efuse. 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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/mediatek/mt6323.dtsi b/arch/arm/boot/dts/mediatek/mt6323.dtsi index c070f4b0936c..c2d08d29cee7 100644 --- a/arch/arm/boot/dts/mediatek/mt6323.dtsi +++ b/arch/arm/boot/dts/mediatek/mt6323.dtsi @@ -19,6 +19,10 @@ mt6323_adc: adc { #io-channel-cells = <1>; }; + efuse { + compatible = "mediatek,mt6323-efuse"; + }; + mt6323_leds: leds { compatible = "mediatek,mt6323-led"; #address-cells = <1>; -- 2.55.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-09-14 22:08 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-09-11 6:32 [PATCH v4 0/3] nvmem: add support for the MediaTek mt6323 PMIC Roman Vivchar via B4 Relay 2026-09-11 6:32 ` [PATCH v4 1/3] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE Roman Vivchar via B4 Relay 2026-09-11 6:41 ` sashiko-bot 2026-09-11 6:33 ` [PATCH v4 2/3] nvmem: add mt6323 PMIC EFUSE driver Roman Vivchar via B4 Relay 2026-09-11 6:51 ` sashiko-bot 2026-09-14 22:08 ` Srinivas Kandagatla 2026-09-11 6:33 ` [PATCH v4 3/3] ARM: dts: mediatek: mt6323: add EFUSE support 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; as well as URLs for NNTP newsgroup(s).