From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Roman Vivchar <rva333@protonmail.com>
Cc: Srinivas Kandagatla <srini@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Andrew-CT Chen <andrew-ct.chen@mediatek.com>,
Lala Lin <lala.lin@mediatek.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: Re: [PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing
Date: Tue, 17 Nov 2026 13:08:02 +0100 [thread overview]
Message-ID: <6935d7a4-2f91-4abf-81e9-f77c2b6c80d2@collabora.com> (raw)
In-Reply-To: <k8LLawty9o68P00hLr5LO1163o_m16f_vf8fBZvdD18nOatszy1i4Dp7DeC8Hv2--Q08YyZfhCRnQbVDps0lqB2zZrx-k_GxKUaqj6eT6r4=@protonmail.com>
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
next prev parent reply other threads:[~2026-11-17 12:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` AngeloGioacchino Del Regno
2026-11-17 12:02 ` Roman Vivchar
2026-11-17 12:08 ` AngeloGioacchino Del Regno [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6935d7a4-2f91-4abf-81e9-f77c2b6c80d2@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=andrew-ct.chen@mediatek.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lala.lin@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=robh@kernel.org \
--cc=rva333@protonmail.com \
--cc=srini@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®