[PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing
AngeloGioacchino Del Regno
angelogioacchino.delregno at collabora.com
Tue Nov 17 03:56:16 PST 2026
On 11/17/26 12:33, Roman Vivchar via B4 Relay wrote:
> From: Roman Vivchar <rva333 at 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 at 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)
>
More information about the Linux-mediatek
mailing list