* [PATCH RESEND v5 0/4] nvmem: mtk-efuse: mt6572 support
@ 2026-11-17 11:33 Roman Vivchar via B4 Relay
2026-11-17 11:33 ` [PATCH RESEND v5 1/4] dt-bindings: nvmem: mediatek: efuse: add mt6572 Roman Vivchar via B4 Relay
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-17 11:33 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 cpu speedbin fixup.
Patch 4 adds platform data for mt6572 SoC.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Changes in v5:
- Add new patch for CPU speedbin post-processing
- Set uses_post_processing to true in the mt6572 platform data
- Drop r-b tag on the patch 4 due to uses_post_processing changes
- Link to v4: https://patch.msgid.link/20260921-6572-nvmem-v4-0-e9c14156559a@protonmail.com
Changes in v4:
- Pick up Angelo's tags
- Rebase onto nvmem/for-next (2eda8d2a45ca ("Merge branches 'nvmem-fixes' and 'nvmem-for-v7.4' into nvnem-for-next"))
- Link to v3: https://patch.msgid.link/20260909-6572-nvmem-v3-0-c0c441656431@protonmail.com
Changes in v3:
- Pick up Rob's r-b tag for dt-bindings
- Patch 2 and 3 unchanged, for some reason cover letter and patch 1 were
missing on the web mirror...
- Link to v2: https://patch.msgid.link/20260724-6572-nvmem-v2-0-e58d16a29621@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 (4):
dt-bindings: nvmem: mediatek: efuse: add mt6572
nvmem: mtk-efuse: add support for 32-bit aligned reads
nvmem: mtk-efuse: add CPU speedbin post-processing
nvmem: mtk-efuse: add mt6572 support
.../devicetree/bindings/nvmem/mediatek,efuse.yaml | 5 +-
drivers/nvmem/mtk-efuse.c | 60 +++++++++++++++++++++-
2 files changed, 63 insertions(+), 2 deletions(-)
---
base-commit: 2eda8d2a45caa955a5cb1d897bf6024d22041995
change-id: 20260710-6572-nvmem-eb98c7a73351
Best regards,
--
Roman Vivchar <rva333@protonmail.com>
--
rva3 <rva333@protonmail.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH RESEND v5 1/4] dt-bindings: nvmem: mediatek: efuse: add mt6572
2026-11-17 11:33 [PATCH RESEND v5 0/4] nvmem: mtk-efuse: mt6572 support Roman Vivchar via B4 Relay
@ 2026-11-17 11:33 ` Roman Vivchar via B4 Relay
2026-11-17 11:33 ` [PATCH RESEND v5 2/4] nvmem: mtk-efuse: add support for 32-bit aligned reads Roman Vivchar via B4 Relay
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-17 11:33 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.
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
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.56.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH RESEND v5 2/4] nvmem: mtk-efuse: add support for 32-bit aligned reads
2026-11-17 11:33 [PATCH RESEND v5 0/4] nvmem: mtk-efuse: mt6572 support Roman Vivchar via B4 Relay
2026-11-17 11:33 ` [PATCH RESEND v5 1/4] dt-bindings: nvmem: mediatek: efuse: add mt6572 Roman Vivchar via B4 Relay
@ 2026-11-17 11:33 ` Roman Vivchar via B4 Relay
2026-11-17 11:33 ` [PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing Roman Vivchar via B4 Relay
2026-11-17 11:33 ` [PATCH RESEND v5 4/4] nvmem: mtk-efuse: add mt6572 support Roman Vivchar via B4 Relay
3 siblings, 0 replies; 11+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-17 11:33 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.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
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 00a84ea963a8..980c29d01337 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/io.h>
@@ -13,12 +14,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)
{
@@ -81,7 +107,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;
@@ -102,10 +133,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.56.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing
2026-11-17 11:33 [PATCH RESEND v5 0/4] nvmem: mtk-efuse: mt6572 support Roman Vivchar via B4 Relay
2026-11-17 11:33 ` [PATCH RESEND v5 1/4] dt-bindings: nvmem: mediatek: efuse: add mt6572 Roman Vivchar via B4 Relay
2026-11-17 11:33 ` [PATCH RESEND v5 2/4] nvmem: mtk-efuse: add support for 32-bit aligned reads Roman Vivchar via B4 Relay
@ 2026-11-17 11:33 ` Roman Vivchar via B4 Relay
2026-11-17 11:56 ` sashiko-bot
2026-11-17 11:56 ` AngeloGioacchino Del Regno
2026-11-17 11:33 ` [PATCH RESEND v5 4/4] nvmem: mtk-efuse: add mt6572 support Roman Vivchar via B4 Relay
3 siblings, 2 replies; 11+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-17 11:33 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>
MediaTek SoCs are often released under the same marketing name, but with
different suffix for the speedbin. For example, mt6572m has 1 GHz limit,
mt6572a - 1.2 GHz, mt6572w - 1.4 GHz.
Since the speedbin is stored as a number in the efuse, add support for
converting it to the bitmask for opp-supported-hw usage in the DT.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
drivers/nvmem/mtk-efuse.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
index 980c29d01337..d2e5c69c580e 100644
--- a/drivers/nvmem/mtk-efuse.c
+++ b/drivers/nvmem/mtk-efuse.c
@@ -70,6 +70,18 @@ static int mtk_efuse_gpu_speedbin_pp(void *context, const char *id, int index,
return 0;
}
+static int mtk_efuse_cpu_speedbin_pp(void *context, const char *id, int index,
+ unsigned int offset, void *data, size_t bytes)
+{
+ u8 *val = data;
+
+ if (val[0] >= 8)
+ return -EINVAL;
+
+ val[0] = BIT(val[0]);
+ return 0;
+}
+
static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
struct nvmem_cell_info *cell)
{
@@ -83,6 +95,13 @@ static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
if (cell->nbits <= 3 &&
strncmp(cell->name, "gpu-speedbin", min(sz, strlen("gpu-speedbin"))) == 0)
cell->read_post_process = mtk_efuse_gpu_speedbin_pp;
+
+ /*
+ * On mobile SoCs, the CPU speedbin is a number. Convert it to
+ * a bitmask for supported-hw usage.
+ */
+ if (strncmp(cell->name, "cpu-speedbin", min(sz, strlen("cpu-speedbin"))) == 0)
+ cell->read_post_process = mtk_efuse_cpu_speedbin_pp;
}
static int mtk_efuse_probe(struct platform_device *pdev)
--
2.56.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH RESEND v5 4/4] nvmem: mtk-efuse: add mt6572 support
2026-11-17 11:33 [PATCH RESEND v5 0/4] nvmem: mtk-efuse: mt6572 support Roman Vivchar via B4 Relay
` (2 preceding siblings ...)
2026-11-17 11:33 ` [PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing Roman Vivchar via B4 Relay
@ 2026-11-17 11:33 ` Roman Vivchar via B4 Relay
2026-11-17 11:56 ` AngeloGioacchino Del Regno
3 siblings, 1 reply; 11+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-17 11:33 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.
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 d2e5c69c580e..24d302a15528 100644
--- a/drivers/nvmem/mtk-efuse.c
+++ b/drivers/nvmem/mtk-efuse.c
@@ -150,6 +150,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 = true,
+ .needs_aligned_read = true,
+};
+
static const struct mtk_efuse_pdata mtk_mt8186_efuse_pdata = {
.uses_post_processing = true,
.needs_aligned_read = false,
@@ -161,6 +166,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.56.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing
2026-11-17 11:33 ` [PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing Roman Vivchar via B4 Relay
@ 2026-11-17 11:56 ` sashiko-bot
2026-11-17 11:56 ` AngeloGioacchino Del Regno
1 sibling, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-11-17 11:56 UTC (permalink / raw)
To: Roman Vivchar; +Cc: devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] nvmem: mtk-efuse: prefix false match in
mtk_efuse_fixup_dt_cell_info()
--
commit c5f5a828d690918eacfadf756d8f32a95a9237dd
Author: Roman Vivchar <rva333@protonmail.com>
nvmem: mtk-efuse: add CPU speedbin post-processing
This commit adds a post-processing callback for "cpu-speedbin" nvmem cells to
convert numeric CPU speedbin values into bitmasks for opp-supported-hw.
> diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
> index 980c29d013375..d2e5c69c580e3 100644
> --- a/drivers/nvmem/mtk-efuse.c
> +++ b/drivers/nvmem/mtk-efuse.c
> @@ -70,6 +70,18 @@ static int mtk_efuse_gpu_speedbin_pp(void *context, const char *id, int index,
> return 0;
> }
>
> +static int mtk_efuse_cpu_speedbin_pp(void *context, const char *id, int index,
> + unsigned int offset, void *data, size_t bytes)
> +{
> + u8 *val = data;
> +
> + if (val[0] >= 8)
> + return -EINVAL;
> +
> + val[0] = BIT(val[0]);
> + return 0;
> +}
> +
> static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
> struct nvmem_cell_info *cell)
> {
> @@ -83,6 +95,13 @@ static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
> if (cell->nbits <= 3 &&
> strncmp(cell->name, "gpu-speedbin", min(sz, strlen("gpu-speedbin"))) == 0)
> cell->read_post_process = mtk_efuse_gpu_speedbin_pp;
> +
> + /*
> + * On mobile SoCs, the CPU speedbin is a number. Convert it to
> + * a bitmask for supported-hw usage.
> + */
> + if (strncmp(cell->name, "cpu-speedbin", min(sz, strlen("cpu-speedbin"))) == 0)
> + cell->read_post_process = mtk_efuse_cpu_speedbin_pp;
> }
[Severity: Medium]
Can this strncmp() check match unrelated cells whose name is a shorter
prefix of "cpu-speedbin"?
Because sz is strlen(cell->name), min(sz, strlen("cpu-speedbin")) evaluates
to sz whenever cell->name is shorter than "cpu-speedbin", and unlike the
"gpu-speedbin" check above, cell->nbits is not checked. Any shorter prefix
such as "cpu" will get mtk_efuse_cpu_speedbin_pp() attached, causing reads
of that cell to fail with -EINVAL or have their first byte overwritten with
BIT(val[0]). Using strcmp(cell->name, "cpu-speedbin") == 0 or
strncmp(cell->name, "cpu-speedbin", strlen("cpu-speedbin")) == 0 would avoid
matching shorter prefixes.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-6572-nvmem-v5-0-9b561a8a83e1@protonmail.com?part=3
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing
2026-11-17 11:33 ` [PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing Roman Vivchar via B4 Relay
2026-11-17 11:56 ` sashiko-bot
@ 2026-11-17 11:56 ` AngeloGioacchino Del Regno
2026-11-17 12:02 ` Roman Vivchar
1 sibling, 1 reply; 11+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-11-17 11:56 UTC (permalink / raw)
To: rva333, Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, Andrew-CT Chen, Lala Lin
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
On 11/17/26 12:33, Roman Vivchar via B4 Relay wrote:
> From: Roman Vivchar <rva333@protonmail.com>
>
> MediaTek SoCs are often released under the same marketing name, but with
> different suffix for the speedbin. For example, mt6572m has 1 GHz limit,
> mt6572a - 1.2 GHz, mt6572w - 1.4 GHz.
>
> Since the speedbin is stored as a number in the efuse, add support for
> converting it to the bitmask for opp-supported-hw usage in the DT.
>
> Signed-off-by: Roman Vivchar <rva333@protonmail.com>
> ---
> drivers/nvmem/mtk-efuse.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
> index 980c29d01337..d2e5c69c580e 100644
> --- a/drivers/nvmem/mtk-efuse.c
> +++ b/drivers/nvmem/mtk-efuse.c
> @@ -70,6 +70,18 @@ static int mtk_efuse_gpu_speedbin_pp(void *context, const char *id, int index,
> return 0;
> }
>
> +static int mtk_efuse_cpu_speedbin_pp(void *context, const char *id, int index,
> + unsigned int offset, void *data, size_t bytes)
You can *literally* reuse mtk_efuse_gpu_speedbin_pp....
> +{
> + u8 *val = data;
> +
> + if (val[0] >= 8)
> + return -EINVAL;
> +
> + val[0] = BIT(val[0]);
> + return 0;
> +}
> +
> static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
> struct nvmem_cell_info *cell)
> {
> @@ -83,6 +95,13 @@ static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
> if (cell->nbits <= 3 &&
> strncmp(cell->name, "gpu-speedbin", min(sz, strlen("gpu-speedbin"))) == 0)
> cell->read_post_process = mtk_efuse_gpu_speedbin_pp;
> +
> + /*
> + * On mobile SoCs, the CPU speedbin is a number. Convert it to
Other SoCs have got the same efuse style as mobile SoCs: anyway, all MediaTek
SoCs (apart from networking ones) are (in a way or another) variants of the
mobile ones.
if (cell->nbits <= 3 &&
strncmp(cell->name, "gpu-speedbin", min(sz, strlen("gpu-speedbin"))) == 0 ||
strncmp(cell->name, "cpu-speedbin", min(sz, strlen("cpu-speedbin"))) == 0)
cell->read_post_process = mtk_efuse_gpu_speedbin_pp;
Cheers,
Angelo
> + * a bitmask for supported-hw usage.
> + */
> + if (strncmp(cell->name, "cpu-speedbin", min(sz, strlen("cpu-speedbin"))) == 0)
> + cell->read_post_process = mtk_efuse_cpu_speedbin_pp;
> }
>
> static int mtk_efuse_probe(struct platform_device *pdev)
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND v5 4/4] nvmem: mtk-efuse: add mt6572 support
2026-11-17 11:33 ` [PATCH RESEND v5 4/4] nvmem: mtk-efuse: add mt6572 support Roman Vivchar via B4 Relay
@ 2026-11-17 11:56 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 11+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-11-17 11:56 UTC (permalink / raw)
To: rva333, Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, Andrew-CT Chen, Lala Lin
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
On 11/17/26 12:33, Roman Vivchar via B4 Relay wrote:
> From: Roman Vivchar <rva333@protonmail.com>
>
> Add a platform data struct for the efuse controller.
>
> Signed-off-by: Roman Vivchar <rva333@protonmail.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing
2026-11-17 11:56 ` AngeloGioacchino Del Regno
@ 2026-11-17 12:02 ` Roman Vivchar
2026-11-17 12:08 ` AngeloGioacchino Del Regno
0 siblings, 1 reply; 11+ messages in thread
From: Roman Vivchar @ 2026-11-17 12:02 UTC (permalink / raw)
To: AngeloGioacchino Del Regno
Cc: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, Andrew-CT Chen, Lala Lin,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
Hi Angelo,
On Tuesday, November 17th, 2026 at 1:56 PM, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote:
> On 11/17/26 12:33, Roman Vivchar via B4 Relay wrote:
> > From: Roman Vivchar <rva333@protonmail.com>
> >
> > MediaTek SoCs are often released under the same marketing name, but with
> > different suffix for the speedbin. For example, mt6572m has 1 GHz limit,
> > mt6572a - 1.2 GHz, mt6572w - 1.4 GHz.
> >
> > Since the speedbin is stored as a number in the efuse, add support for
> > converting it to the bitmask for opp-supported-hw usage in the DT.
> >
> > Signed-off-by: Roman Vivchar <rva333@protonmail.com>
> > ---
> > drivers/nvmem/mtk-efuse.c | 19 +++++++++++++++++++
> > 1 file changed, 19 insertions(+)
> >
> > diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
> > index 980c29d01337..d2e5c69c580e 100644
> > --- a/drivers/nvmem/mtk-efuse.c
> > +++ b/drivers/nvmem/mtk-efuse.c
> > @@ -70,6 +70,18 @@ static int mtk_efuse_gpu_speedbin_pp(void *context, const char *id, int index,
> > return 0;
> > }
> >
> > +static int mtk_efuse_cpu_speedbin_pp(void *context, const char *id, int index,
> > + unsigned int offset, void *data, size_t bytes)
>
> You can *literally* reuse mtk_efuse_gpu_speedbin_pp....
No, I can't. On later SoCs CPU speedbin has different encoding.
For example, on mt6768 it can be stored in either low or high 4 bits.
This is out of scope for this series, but I'd like if we kept this
callback for the future SoCs.
>
> > +{
> > + u8 *val = data;
> > +
> > + if (val[0] >= 8)
> > + return -EINVAL;
> > +
> > + val[0] = BIT(val[0]);
> > + return 0;
> > +}
> > +
> > static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
> > struct nvmem_cell_info *cell)
> > {
> > @@ -83,6 +95,13 @@ static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
> > if (cell->nbits <= 3 &&
> > strncmp(cell->name, "gpu-speedbin", min(sz, strlen("gpu-speedbin"))) == 0)
> > cell->read_post_process = mtk_efuse_gpu_speedbin_pp;
> > +
> > + /*
> > + * On mobile SoCs, the CPU speedbin is a number. Convert it to
>
> Other SoCs have got the same efuse style as mobile SoCs: anyway, all MediaTek
> SoCs (apart from networking ones) are (in a way or another) variants of the
> mobile ones.
They're not really variants, some of them have no direct mt81xx/83xx sibling.
Best regards,
Roman
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing
2026-11-17 12:02 ` Roman Vivchar
@ 2026-11-17 12:08 ` AngeloGioacchino Del Regno
2026-11-17 12:16 ` Roman Vivchar
0 siblings, 1 reply; 11+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-11-17 12:08 UTC (permalink / raw)
To: Roman Vivchar
Cc: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, Andrew-CT Chen, Lala Lin,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
On 11/17/26 13:02, Roman Vivchar wrote:
> Hi Angelo,
>
> On Tuesday, November 17th, 2026 at 1:56 PM, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote:
>
>> On 11/17/26 12:33, Roman Vivchar via B4 Relay wrote:
>>> From: Roman Vivchar <rva333@protonmail.com>
>>>
>>> MediaTek SoCs are often released under the same marketing name, but with
>>> different suffix for the speedbin. For example, mt6572m has 1 GHz limit,
>>> mt6572a - 1.2 GHz, mt6572w - 1.4 GHz.
>>>
>>> Since the speedbin is stored as a number in the efuse, add support for
>>> converting it to the bitmask for opp-supported-hw usage in the DT.
>>>
>>> Signed-off-by: Roman Vivchar <rva333@protonmail.com>
>>> ---
>>> drivers/nvmem/mtk-efuse.c | 19 +++++++++++++++++++
>>> 1 file changed, 19 insertions(+)
>>>
>>> diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
>>> index 980c29d01337..d2e5c69c580e 100644
>>> --- a/drivers/nvmem/mtk-efuse.c
>>> +++ b/drivers/nvmem/mtk-efuse.c
>>> @@ -70,6 +70,18 @@ static int mtk_efuse_gpu_speedbin_pp(void *context, const char *id, int index,
>>> return 0;
>>> }
>>>
>>> +static int mtk_efuse_cpu_speedbin_pp(void *context, const char *id, int index,
>>> + unsigned int offset, void *data, size_t bytes)
>>
>> You can *literally* reuse mtk_efuse_gpu_speedbin_pp....
>
> No, I can't. On later SoCs CPU speedbin has different encoding.
> For example, on mt6768 it can be stored in either low or high 4 bits.
That's the part where you pass the right nbits in devicetree for the speedbin cell,
being it still 4 bits, that statement doesn't change the outcome.
> This is out of scope for this series, but I'd like if we kept this
> callback for the future SoCs.
All that the logic of your mtk_efuse_cpu_speedbin_pp is doing is assigning
BIT(val[0])
to val[0].
All that the logic of mtk_efuse_gpu_speedbin_pp is doing is assigning
BIT(val[0])
to val[0].
To me, that looks code duplication, and duplication is bad.
>
>>
>>> +{
>>> + u8 *val = data;
>>> +
>>> + if (val[0] >= 8)
>>> + return -EINVAL;
>>> +
>>> + val[0] = BIT(val[0]);
>>> + return 0;
>>> +}
>>> +
>>> static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
>>> struct nvmem_cell_info *cell)
>>> {
>>> @@ -83,6 +95,13 @@ static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
>>> if (cell->nbits <= 3 &&
>>> strncmp(cell->name, "gpu-speedbin", min(sz, strlen("gpu-speedbin"))) == 0)
>>> cell->read_post_process = mtk_efuse_gpu_speedbin_pp;
>>> +
>>> + /*
>>> + * On mobile SoCs, the CPU speedbin is a number. Convert it to
>>
>> Other SoCs have got the same efuse style as mobile SoCs: anyway, all MediaTek
>> SoCs (apart from networking ones) are (in a way or another) variants of the
>> mobile ones.
>
> They're not really variants, some of them have no direct mt81xx/83xx sibling.
>
Noone looked hard to find the siblings for some of them - though there might be
one (and just one) that has no sibling :-)
Regards,
Angelo
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing
2026-11-17 12:08 ` AngeloGioacchino Del Regno
@ 2026-11-17 12:16 ` Roman Vivchar
0 siblings, 0 replies; 11+ messages in thread
From: Roman Vivchar @ 2026-11-17 12:16 UTC (permalink / raw)
To: AngeloGioacchino Del Regno
Cc: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, Andrew-CT Chen, Lala Lin,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
On Tuesday, November 17th, 2026 at 2:08 PM, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote:
> On 11/17/26 13:02, Roman Vivchar wrote:
> > Hi Angelo,
> >
> > On Tuesday, November 17th, 2026 at 1:56 PM, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote:
> >
> >> On 11/17/26 12:33, Roman Vivchar via B4 Relay wrote:
> >>> From: Roman Vivchar <rva333@protonmail.com>
> >>>
> >>> MediaTek SoCs are often released under the same marketing name, but with
> >>> different suffix for the speedbin. For example, mt6572m has 1 GHz limit,
> >>> mt6572a - 1.2 GHz, mt6572w - 1.4 GHz.
> >>>
> >>> Since the speedbin is stored as a number in the efuse, add support for
> >>> converting it to the bitmask for opp-supported-hw usage in the DT.
> >>>
> >>> Signed-off-by: Roman Vivchar <rva333@protonmail.com>
> >>> ---
> >>> drivers/nvmem/mtk-efuse.c | 19 +++++++++++++++++++
> >>> 1 file changed, 19 insertions(+)
> >>>
> >>> diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
> >>> index 980c29d01337..d2e5c69c580e 100644
> >>> --- a/drivers/nvmem/mtk-efuse.c
> >>> +++ b/drivers/nvmem/mtk-efuse.c
> >>> @@ -70,6 +70,18 @@ static int mtk_efuse_gpu_speedbin_pp(void *context, const char *id, int index,
> >>> return 0;
> >>> }
> >>>
> >>> +static int mtk_efuse_cpu_speedbin_pp(void *context, const char *id, int index,
> >>> + unsigned int offset, void *data, size_t bytes)
> >>
> >> You can *literally* reuse mtk_efuse_gpu_speedbin_pp....
> >
> > No, I can't. On later SoCs CPU speedbin has different encoding.
> > For example, on mt6768 it can be stored in either low or high 4 bits.
>
> That's the part where you pass the right nbits in devicetree for the speedbin cell,
> being it still 4 bits, that statement doesn't change the outcome.
>
> > This is out of scope for this series, but I'd like if we kept this
> > callback for the future SoCs.
>
> All that the logic of your mtk_efuse_cpu_speedbin_pp is doing is assigning
>
> BIT(val[0])
>
> to val[0].
>
> All that the logic of mtk_efuse_gpu_speedbin_pp is doing is assigning
>
> BIT(val[0])
>
> to val[0].
>
> To me, that looks code duplication, and duplication is bad.
This is true for this exact patch, but for newer SoC I have other code:
if (val[0] & 0x0f)
seg = val[0] & 0x0f;
else
seg = bitrev8(val[0]);
if (seg >= 16)
return -EINVAL;
if (bytes >= 4)
put_unaligned_le32(BIT(seg), data);
else if (bytes >= 2)
put_unaligned_le16(BIT(seg), data);
else if (seg < 8)
val[0] = BIT(seg);
else
return -EINVAL;
return 0;
If you prefer using GPU post-processing callback in this series and
adding CPU only when newer SoC support arrives, please let me know.
>
> >
> >>
> >>> +{
> >>> + u8 *val = data;
> >>> +
> >>> + if (val[0] >= 8)
> >>> + return -EINVAL;
> >>> +
> >>> + val[0] = BIT(val[0]);
> >>> + return 0;
> >>> +}
> >>> +
> >>> static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
> >>> struct nvmem_cell_info *cell)
> >>> {
> >>> @@ -83,6 +95,13 @@ static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
> >>> if (cell->nbits <= 3 &&
> >>> strncmp(cell->name, "gpu-speedbin", min(sz, strlen("gpu-speedbin"))) == 0)
> >>> cell->read_post_process = mtk_efuse_gpu_speedbin_pp;
> >>> +
> >>> + /*
> >>> + * On mobile SoCs, the CPU speedbin is a number. Convert it to
> >>
> >> Other SoCs have got the same efuse style as mobile SoCs: anyway, all MediaTek
> >> SoCs (apart from networking ones) are (in a way or another) variants of the
> >> mobile ones.
> >
> > They're not really variants, some of them have no direct mt81xx/83xx sibling.
> >
> Noone looked hard to find the siblings for some of them - though there might be
> one (and just one) that has no sibling :-)
Some like mt6595/6795 are indeed very close to 8173. Though most SoCs are
usually mix of mt81xx, like mt6768 includes mt8183, 8186 and 8192 IPs.
Best regards,
Roman
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-11-17 12:16 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 11:33 [PATCH RESEND v5 0/4] nvmem: mtk-efuse: mt6572 support Roman Vivchar via B4 Relay
2026-11-17 11:33 ` [PATCH RESEND v5 1/4] dt-bindings: nvmem: mediatek: efuse: add mt6572 Roman Vivchar via B4 Relay
2026-11-17 11:33 ` [PATCH RESEND v5 2/4] nvmem: mtk-efuse: add support for 32-bit aligned reads Roman Vivchar via B4 Relay
2026-11-17 11:33 ` [PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing Roman Vivchar via B4 Relay
2026-11-17 11:56 ` sashiko-bot
2026-11-17 11:56 ` AngeloGioacchino Del Regno
2026-11-17 12:02 ` Roman Vivchar
2026-11-17 12:08 ` AngeloGioacchino Del Regno
2026-11-17 12:16 ` Roman Vivchar
2026-11-17 11:33 ` [PATCH RESEND v5 4/4] nvmem: mtk-efuse: add mt6572 support Roman Vivchar via B4 Relay
2026-11-17 11:56 ` AngeloGioacchino Del Regno
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox