* [PATCH v2 0/3] nvmem: mtk-efuse: mt6572 support
@ 2026-07-24 11:07 ` Roman Vivchar
0 siblings, 0 replies; 11+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-07-24 11:07 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Andrew-CT Chen, Lala Lin
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
This patch series adds MediaTek mt6572 efuse support. Unlike newer SoCs,
its efuse controller doesn't work properly with 8-bit reads, leading to
invalid data with current mtk-efuse driver implementation.
This behavior can be observed with devmem (0x10009174 and 0x10009178 are
thermal calibration cells):
~ # devmem 0x10009174 32
0x00CDD4CD
~ # devmem 0x10009178 32
0x0F76865D
~ # devmem 0x10009174 8
0xCD
~ # devmem 0x10009175 8
0x00
~ # devmem 0x10009176 8
0x00
~ # devmem 0x10009177 8
0x00
~ # devmem 0x10009178 8
0x5D
~ # devmem 0x10009179 8
0x00
~ # devmem 0x1000917a 8
0x00
~ # devmem 0x1000917b 8
0x00
Patch 1 adds dt-bindings compatible for the mt6572,
Patch 2 adds platform data option to use aligned 32-bit reads instead
of plain readb().
Patch 3 adds platform data for mt6572 SoC.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Changes in v2:
- dt-bindings: make mediatek,mt6572-efuse standalone compatible
- Driver: add 'mtk_reg_read_aligned' helper instead of modifying 'mtk_reg_read'
- Link to v1: https://patch.msgid.link/20260715-6572-nvmem-v1-0-9c13be99d077@protonmail.com
---
Roman Vivchar (3):
dt-bindings: nvmem: mediatek: efuse: add mt6572
nvmem: mtk-efuse: add support for 32-bit aligned reads
nvmem: mtk-efuse: add mt6572 support
.../devicetree/bindings/nvmem/mediatek,efuse.yaml | 5 ++-
drivers/nvmem/mtk-efuse.c | 41 +++++++++++++++++++++-
2 files changed, 44 insertions(+), 2 deletions(-)
---
base-commit: 8cd9520d35a6c38db6567e97dd93b1f11f185dc6
change-id: 20260710-6572-nvmem-eb98c7a73351
Best regards,
--
Roman Vivchar <rva333@protonmail.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 0/3] nvmem: mtk-efuse: mt6572 support
@ 2026-07-24 11:07 ` Roman Vivchar
0 siblings, 0 replies; 11+ messages in thread
From: Roman Vivchar @ 2026-07-24 11:07 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Andrew-CT Chen, Lala Lin
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
This patch series adds MediaTek mt6572 efuse support. Unlike newer SoCs,
its efuse controller doesn't work properly with 8-bit reads, leading to
invalid data with current mtk-efuse driver implementation.
This behavior can be observed with devmem (0x10009174 and 0x10009178 are
thermal calibration cells):
~ # devmem 0x10009174 32
0x00CDD4CD
~ # devmem 0x10009178 32
0x0F76865D
~ # devmem 0x10009174 8
0xCD
~ # devmem 0x10009175 8
0x00
~ # devmem 0x10009176 8
0x00
~ # devmem 0x10009177 8
0x00
~ # devmem 0x10009178 8
0x5D
~ # devmem 0x10009179 8
0x00
~ # devmem 0x1000917a 8
0x00
~ # devmem 0x1000917b 8
0x00
Patch 1 adds dt-bindings compatible for the mt6572,
Patch 2 adds platform data option to use aligned 32-bit reads instead
of plain readb().
Patch 3 adds platform data for mt6572 SoC.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Changes in v2:
- dt-bindings: make mediatek,mt6572-efuse standalone compatible
- Driver: add 'mtk_reg_read_aligned' helper instead of modifying 'mtk_reg_read'
- Link to v1: https://patch.msgid.link/20260715-6572-nvmem-v1-0-9c13be99d077@protonmail.com
---
Roman Vivchar (3):
dt-bindings: nvmem: mediatek: efuse: add mt6572
nvmem: mtk-efuse: add support for 32-bit aligned reads
nvmem: mtk-efuse: add mt6572 support
.../devicetree/bindings/nvmem/mediatek,efuse.yaml | 5 ++-
drivers/nvmem/mtk-efuse.c | 41 +++++++++++++++++++++-
2 files changed, 44 insertions(+), 2 deletions(-)
---
base-commit: 8cd9520d35a6c38db6567e97dd93b1f11f185dc6
change-id: 20260710-6572-nvmem-eb98c7a73351
Best regards,
--
Roman Vivchar <rva333@protonmail.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 1/3] dt-bindings: nvmem: mediatek: efuse: add mt6572
2026-07-24 11:07 ` Roman Vivchar
@ 2026-07-24 11:07 ` Roman Vivchar
-1 siblings, 0 replies; 11+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-07-24 11:07 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Andrew-CT Chen, Lala Lin
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
From: Roman Vivchar <rva333@protonmail.com>
Add a compatible string for the mt6572 SoC efuse controller.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
index f9323b3ecfc8..e10947164941 100644
--- a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
+++ b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
@@ -24,13 +24,16 @@ properties:
compatible:
oneOf:
+ - enum:
+ - mediatek,mt6572-efuse
+ - mediatek,mt8186-efuse
+
- items:
- enum:
- mediatek,mt8188-efuse
- mediatek,mt8189-efuse
- mediatek,mt8196-efuse
- const: mediatek,mt8186-efuse
- - const: mediatek,mt8186-efuse
- items:
- enum:
--
2.54.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 1/3] dt-bindings: nvmem: mediatek: efuse: add mt6572
@ 2026-07-24 11:07 ` Roman Vivchar
0 siblings, 0 replies; 11+ messages in thread
From: Roman Vivchar @ 2026-07-24 11:07 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Andrew-CT Chen, Lala Lin
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
Add a compatible string for the mt6572 SoC efuse controller.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
index f9323b3ecfc8..e10947164941 100644
--- a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
+++ b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
@@ -24,13 +24,16 @@ properties:
compatible:
oneOf:
+ - enum:
+ - mediatek,mt6572-efuse
+ - mediatek,mt8186-efuse
+
- items:
- enum:
- mediatek,mt8188-efuse
- mediatek,mt8189-efuse
- mediatek,mt8196-efuse
- const: mediatek,mt8186-efuse
- - const: mediatek,mt8186-efuse
- items:
- enum:
--
2.54.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] nvmem: mtk-efuse: add support for 32-bit aligned reads
2026-07-24 11:07 ` Roman Vivchar
@ 2026-07-24 11:07 ` Roman Vivchar
-1 siblings, 0 replies; 11+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-07-24 11:07 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Andrew-CT Chen, Lala Lin
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
From: Roman Vivchar <rva333@protonmail.com>
Some MediaTek SoCs, such as mt6572, don't support 8-bit reads, leading
to zeroes or garbage data. 32-bit aligned reads must be used instead.
Introduce a 'mtk_reg_read_aligned' helper to enforce 32-bit aligned
register access. All reads will be performed by reading 4-byte words
and masking them.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
drivers/nvmem/mtk-efuse.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
index af953e1d9230..178b9d85f813 100644
--- a/drivers/nvmem/mtk-efuse.c
+++ b/drivers/nvmem/mtk-efuse.c
@@ -4,6 +4,7 @@
* Author: Andrew-CT Chen <andrew-ct.chen@mediatek.com>
*/
+#include <linux/align.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
@@ -14,12 +15,37 @@
struct mtk_efuse_pdata {
bool uses_post_processing;
+ bool needs_aligned_read;
};
struct mtk_efuse_priv {
void __iomem *base;
};
+static int mtk_reg_read_aligned(void *context,
+ unsigned int reg, void *_val, size_t bytes)
+{
+ struct mtk_efuse_priv *priv = context;
+ u8 *val = _val;
+ u32 i, pos, shift, val32;
+
+ for (i = 0; i < bytes; i++, val++) {
+ pos = reg + i;
+
+ /*
+ * Read on 32-bit word boundary or if it's the first
+ * iteration
+ */
+ if (i == 0 || IS_ALIGNED(pos, 4))
+ val32 = readl(priv->base + (pos & ~3));
+
+ shift = (pos & 3) * 8;
+ *val = (val32 >> shift) & 0xff;
+ }
+
+ return 0;
+}
+
static int mtk_reg_read(void *context,
unsigned int reg, void *_val, size_t bytes)
{
@@ -82,7 +108,12 @@ static int mtk_efuse_probe(struct platform_device *pdev)
econfig.add_legacy_fixed_of_cells = true;
econfig.stride = 1;
econfig.word_size = 1;
- econfig.reg_read = mtk_reg_read;
+
+ if (pdata->needs_aligned_read)
+ econfig.reg_read = mtk_reg_read_aligned;
+ else
+ econfig.reg_read = mtk_reg_read;
+
econfig.size = resource_size(res);
econfig.priv = priv;
econfig.dev = dev;
@@ -103,10 +134,12 @@ static int mtk_efuse_probe(struct platform_device *pdev)
static const struct mtk_efuse_pdata mtk_mt8186_efuse_pdata = {
.uses_post_processing = true,
+ .needs_aligned_read = false,
};
static const struct mtk_efuse_pdata mtk_efuse_pdata = {
.uses_post_processing = false,
+ .needs_aligned_read = false,
};
static const struct of_device_id mtk_efuse_of_match[] = {
--
2.54.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] nvmem: mtk-efuse: add support for 32-bit aligned reads
@ 2026-07-24 11:07 ` Roman Vivchar
0 siblings, 0 replies; 11+ messages in thread
From: Roman Vivchar @ 2026-07-24 11:07 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Andrew-CT Chen, Lala Lin
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
Some MediaTek SoCs, such as mt6572, don't support 8-bit reads, leading
to zeroes or garbage data. 32-bit aligned reads must be used instead.
Introduce a 'mtk_reg_read_aligned' helper to enforce 32-bit aligned
register access. All reads will be performed by reading 4-byte words
and masking them.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
drivers/nvmem/mtk-efuse.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
index af953e1d9230..178b9d85f813 100644
--- a/drivers/nvmem/mtk-efuse.c
+++ b/drivers/nvmem/mtk-efuse.c
@@ -4,6 +4,7 @@
* Author: Andrew-CT Chen <andrew-ct.chen@mediatek.com>
*/
+#include <linux/align.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
@@ -14,12 +15,37 @@
struct mtk_efuse_pdata {
bool uses_post_processing;
+ bool needs_aligned_read;
};
struct mtk_efuse_priv {
void __iomem *base;
};
+static int mtk_reg_read_aligned(void *context,
+ unsigned int reg, void *_val, size_t bytes)
+{
+ struct mtk_efuse_priv *priv = context;
+ u8 *val = _val;
+ u32 i, pos, shift, val32;
+
+ for (i = 0; i < bytes; i++, val++) {
+ pos = reg + i;
+
+ /*
+ * Read on 32-bit word boundary or if it's the first
+ * iteration
+ */
+ if (i == 0 || IS_ALIGNED(pos, 4))
+ val32 = readl(priv->base + (pos & ~3));
+
+ shift = (pos & 3) * 8;
+ *val = (val32 >> shift) & 0xff;
+ }
+
+ return 0;
+}
+
static int mtk_reg_read(void *context,
unsigned int reg, void *_val, size_t bytes)
{
@@ -82,7 +108,12 @@ static int mtk_efuse_probe(struct platform_device *pdev)
econfig.add_legacy_fixed_of_cells = true;
econfig.stride = 1;
econfig.word_size = 1;
- econfig.reg_read = mtk_reg_read;
+
+ if (pdata->needs_aligned_read)
+ econfig.reg_read = mtk_reg_read_aligned;
+ else
+ econfig.reg_read = mtk_reg_read;
+
econfig.size = resource_size(res);
econfig.priv = priv;
econfig.dev = dev;
@@ -103,10 +134,12 @@ static int mtk_efuse_probe(struct platform_device *pdev)
static const struct mtk_efuse_pdata mtk_mt8186_efuse_pdata = {
.uses_post_processing = true,
+ .needs_aligned_read = false,
};
static const struct mtk_efuse_pdata mtk_efuse_pdata = {
.uses_post_processing = false,
+ .needs_aligned_read = false,
};
static const struct of_device_id mtk_efuse_of_match[] = {
--
2.54.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 3/3] nvmem: mtk-efuse: add mt6572 support
2026-07-24 11:07 ` Roman Vivchar
@ 2026-07-24 11:07 ` Roman Vivchar
-1 siblings, 0 replies; 11+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-07-24 11:07 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Andrew-CT Chen, Lala Lin
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
From: Roman Vivchar <rva333@protonmail.com>
Add a platform data struct for the efuse controller.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
drivers/nvmem/mtk-efuse.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
index 178b9d85f813..99d061eef6e3 100644
--- a/drivers/nvmem/mtk-efuse.c
+++ b/drivers/nvmem/mtk-efuse.c
@@ -132,6 +132,11 @@ static int mtk_efuse_probe(struct platform_device *pdev)
return 0;
}
+static const struct mtk_efuse_pdata mtk_mt6572_efuse_pdata = {
+ .uses_post_processing = false,
+ .needs_aligned_read = true,
+};
+
static const struct mtk_efuse_pdata mtk_mt8186_efuse_pdata = {
.uses_post_processing = true,
.needs_aligned_read = false,
@@ -143,6 +148,7 @@ static const struct mtk_efuse_pdata mtk_efuse_pdata = {
};
static const struct of_device_id mtk_efuse_of_match[] = {
+ { .compatible = "mediatek,mt6572-efuse", .data = &mtk_mt6572_efuse_pdata },
{ .compatible = "mediatek,mt8173-efuse", .data = &mtk_efuse_pdata },
{ .compatible = "mediatek,mt8186-efuse", .data = &mtk_mt8186_efuse_pdata },
{ .compatible = "mediatek,efuse", .data = &mtk_efuse_pdata },
--
2.54.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 3/3] nvmem: mtk-efuse: add mt6572 support
@ 2026-07-24 11:07 ` Roman Vivchar
0 siblings, 0 replies; 11+ messages in thread
From: Roman Vivchar @ 2026-07-24 11:07 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Andrew-CT Chen, Lala Lin
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
Add a platform data struct for the efuse controller.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
drivers/nvmem/mtk-efuse.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
index 178b9d85f813..99d061eef6e3 100644
--- a/drivers/nvmem/mtk-efuse.c
+++ b/drivers/nvmem/mtk-efuse.c
@@ -132,6 +132,11 @@ static int mtk_efuse_probe(struct platform_device *pdev)
return 0;
}
+static const struct mtk_efuse_pdata mtk_mt6572_efuse_pdata = {
+ .uses_post_processing = false,
+ .needs_aligned_read = true,
+};
+
static const struct mtk_efuse_pdata mtk_mt8186_efuse_pdata = {
.uses_post_processing = true,
.needs_aligned_read = false,
@@ -143,6 +148,7 @@ static const struct mtk_efuse_pdata mtk_efuse_pdata = {
};
static const struct of_device_id mtk_efuse_of_match[] = {
+ { .compatible = "mediatek,mt6572-efuse", .data = &mtk_mt6572_efuse_pdata },
{ .compatible = "mediatek,mt8173-efuse", .data = &mtk_efuse_pdata },
{ .compatible = "mediatek,mt8186-efuse", .data = &mtk_mt8186_efuse_pdata },
{ .compatible = "mediatek,efuse", .data = &mtk_efuse_pdata },
--
2.54.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] dt-bindings: nvmem: mediatek: efuse: add mt6572
2026-07-24 11:07 ` Roman Vivchar
(?)
@ 2026-07-24 11:37 ` sashiko-bot
-1 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-07-24 11:37 UTC (permalink / raw)
To: Roman Vivchar; +Cc: devicetree, conor+dt, robh
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The new `mediatek,mt6572-efuse` compatible string is defined as a standalone enum without a generic fallback, yet the driver lacks support for it.
--
--- Patch [1]: [PATCH v2 1/3] dt-bindings: nvmem: mediatek: efuse: add mt6572 ---
commit 16da21605192748d95ca1fe2779220ec48ccf918
Author: Roman Vivchar <rva333@protonmail.com>
dt-bindings: nvmem: mediatek: efuse: add mt6572
This commit adds a compatible string for the MediaTek MT6572 SoC efuse
controller to the binding schema. It introduces a new enum block for both
the new mt6572 string and the existing mt8186 string.
> diff --git a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
> index f9323b3ecfc83..e109471649412 100644
> --- a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
> +++ b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
> @@ -24,13 +24,16 @@ properties:
>
> compatible:
> oneOf:
> + - enum:
> + - mediatek,mt6572-efuse
[Severity: Medium]
Will device trees using this new compatible string fail to probe?
The mediatek,mt6572-efuse string is defined here as a standalone enum
without a generic mediatek,efuse fallback. However, the mtk-efuse driver
in drivers/nvmem/mtk-efuse.c does not match mediatek,mt6572-efuse
specifically.
If a system integrator strictly follows this schema, the device node will
not probe. Conversely, if the device tree includes the mediatek,efuse
fallback so the driver can match and probe, it will fail dtbs_check
validation because this schema does not expect the fallback in an items
list.
Should mediatek,mt6572-efuse be defined alongside the generic
mediatek,efuse fallback instead of as a standalone enum?
> + - mediatek,mt8186-efuse
> +
> - items:
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260724-6572-nvmem-v2-0-e58d16a29621@protonmail.com?part=1
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/3] nvmem: mtk-efuse: add support for 32-bit aligned reads
2026-07-24 11:07 ` Roman Vivchar
(?)
@ 2026-07-24 11:40 ` sashiko-bot
-1 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-07-24 11:40 UTC (permalink / raw)
To: Roman Vivchar; +Cc: devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] The mt6572 configuration and OF match entries are missing, rendering `mtk_reg_read_aligned` dead code.
Pre-existing issues:
- [High] Dereference of `pdata` without a NULL pointer check causes a kernel panic if `device_get_match_data()` returns NULL.
--
--- Patch [2]: [PATCH v2 2/3] nvmem: mtk-efuse: add support for 32-bit aligned reads ---
commit 9dba40bd7cf45894283042b51926cffdb798412f
Author: Roman Vivchar <rva333@protonmail.com>
nvmem: mtk-efuse: add support for 32-bit aligned reads
This commit introduces a helper mtk_reg_read_aligned to enforce 32-bit
aligned register access for MediaTek SoCs like mt6572 that do not support
8-bit reads. It conditionally uses this new read function based on the
needs_aligned_read flag in the device's platform data.
> diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
> index af953e1d92302..178b9d85f813e 100644
> --- a/drivers/nvmem/mtk-efuse.c
> +++ b/drivers/nvmem/mtk-efuse.c
[ ... ]
> @@ -82,7 +108,12 @@ static int mtk_efuse_probe(struct platform_device *pdev)
> econfig.add_legacy_fixed_of_cells = true;
> econfig.stride = 1;
> econfig.word_size = 1;
> - econfig.reg_read = mtk_reg_read;
> +
> + if (pdata->needs_aligned_read)
[Severity: High]
This is a pre-existing issue, but it appears pdata can be NULL if the
device is instantiated without an OF/ACPI node (e.g., via sysfs manual
binding).
Since pdata is acquired via device_get_match_data(), won't unconditionally
dereferencing it here cause a kernel panic when matched by name instead of
device tree?
> + econfig.reg_read = mtk_reg_read_aligned;
> + else
> + econfig.reg_read = mtk_reg_read;
> +
> econfig.size = resource_size(res);
> econfig.priv = priv;
> econfig.dev = dev;
> @@ -103,10 +134,12 @@ static int mtk_efuse_probe(struct platform_device *pdev)
>
> static const struct mtk_efuse_pdata mtk_mt8186_efuse_pdata = {
> .uses_post_processing = true,
> + .needs_aligned_read = false,
> };
>
> static const struct mtk_efuse_pdata mtk_efuse_pdata = {
> .uses_post_processing = false,
> + .needs_aligned_read = false,
> };
>
> static const struct of_device_id mtk_efuse_of_match[] = {
[Severity: Medium]
The commit message mentions adding support for the mt6572 SoC, but are the
mtk_mt6572_efuse_pdata struct and the mediatek,mt6572-efuse compatible string
missing from mtk_efuse_of_match[]?
Without these entries, will mtk_reg_read_aligned() remain unreachable dead
code since needs_aligned_read is never true?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260724-6572-nvmem-v2-0-e58d16a29621@protonmail.com?part=2
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/3] nvmem: mtk-efuse: add mt6572 support
2026-07-24 11:07 ` Roman Vivchar
(?)
@ 2026-07-24 11:40 ` sashiko-bot
-1 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-07-24 11:40 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:
Pre-existing issues:
- [Medium] Flawed string matching logic in NVMEM cell fixup causes false positive matches and potential data corruption.
--
--- Patch [3]: [PATCH v2 3/3] nvmem: mtk-efuse: add mt6572 support ---
commit 859e63115931e7de172aeee767133c45a658b170
Author: Roman Vivchar <rva333@protonmail.com>
nvmem: mtk-efuse: add mt6572 support
This commit adds platform data to support the efuse controller on the mt6572
SoC. It configures the controller to use aligned reads and explicitly disables
post-processing for this device.
> diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
> index 178b9d85f813e..99d061eef6e33 100644
> --- a/drivers/nvmem/mtk-efuse.c
> +++ b/drivers/nvmem/mtk-efuse.c
[ ... ]
> @@ -132,6 +132,11 @@ static int mtk_efuse_probe(struct platform_device *pdev)
> return 0;
> }
>
> +static const struct mtk_efuse_pdata mtk_mt6572_efuse_pdata = {
> + .uses_post_processing = false,
[Severity: Medium]
This is a pre-existing issue, but looking at the post-processing logic that
is toggled by this flag, does the string matching logic cause false positive
matches?
drivers/nvmem/mtk-efuse.c:mtk_efuse_fixup_dt_cell_info() {
...
if (cell->nbits <= 3 &&
strncmp(cell->name, "gpu-speedbin", min(sz, strlen("gpu-speedbin"))) == 0)
cell->read_post_process = mtk_efuse_gpu_speedbin_pp;
...
}
Because strncmp() takes the minimum of the two string lengths, any cell name
that is a prefix of "gpu-speedbin" (such as "gpu" or "gpu-speed") and has
3 or fewer bits will incorrectly match and have its data unintentionally
modified by mtk_efuse_gpu_speedbin_pp() upon read. Can this lead to NVMEM
cell data corruption for unrelated cells?
> + .needs_aligned_read = true,
> +};
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260724-6572-nvmem-v2-0-e58d16a29621@protonmail.com?part=3
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-07-24 11:40 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 11:07 [PATCH v2 0/3] nvmem: mtk-efuse: mt6572 support Roman Vivchar via B4 Relay
2026-07-24 11:07 ` Roman Vivchar
2026-07-24 11:07 ` [PATCH v2 1/3] dt-bindings: nvmem: mediatek: efuse: add mt6572 Roman Vivchar via B4 Relay
2026-07-24 11:07 ` Roman Vivchar
2026-07-24 11:37 ` sashiko-bot
2026-07-24 11:07 ` [PATCH v2 2/3] nvmem: mtk-efuse: add support for 32-bit aligned reads Roman Vivchar via B4 Relay
2026-07-24 11:07 ` Roman Vivchar
2026-07-24 11:40 ` sashiko-bot
2026-07-24 11:07 ` [PATCH v2 3/3] nvmem: mtk-efuse: add mt6572 support Roman Vivchar via B4 Relay
2026-07-24 11:07 ` Roman Vivchar
2026-07-24 11:40 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.