Re: [PATCH v6 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing

From: Roman Vivchar

Date: Mon Nov 30 2026 - 15:54:52 EST


Hi Luca,

On Monday, November 30th, 2026 at 10:11 PM, Luca Leonardo Scorcia <l.scorcia@xxxxxxxxx> wrote:

> Hello, I am interested in this series as I have the same need to identify
> the cpu variant for OPPs on MT8167A/S/D.
>
> I have two questions:
>
> 1. Is post-processing really needed?

Yes.

> It seems that nvmem cells can use
> the bits property to retrieve only the necessary bits from the cell, e.g.:
>
> cpu_speed_bin: cpu-speed-bin@40 {
> reg = <0x40 0x4>;
> bits = <0 2>;
> };
>
> To me this seems more intuitive than driver-based post-processing and
> is already supported by device tree syntax. I did a quick test and it
> seems to work, but I'm sure there's some step that I'm missing.

I guess you're missing how this links with OPP tables. In short, there's
opp-supported-hw property, which expects a *bitmask*.

Let's assume the mt8167 A/S/D is 0 (the worst), 1 (medium) and 2 (the
best) in the efuse. There's e.g. 16 OPPs, some of them are shared for
worst and medium, and some are exclusive to the best. If we simply take
raw numbers, we can't create a bitmask.

That's why there's post-processing - we apply BIT (so 1 << n) to
the raw number, so we can have opp-supported-hw = <0x03> (after
post-processing: BIT(0) and BIT(1) = 3) for the shared opp, and
opp-supported-hw = <0x04> for best-tier OPP.
(note you can also mix BIT(1) and BIT(2) to exclude the worst speedbin).

> 2. Am I correct in saying that at the moment there is no upstream support
> for nvmem-cells references in the operating-points-v2 OPPs? How do you
> plan to connect your new cpu-speedbin support to OPPs?

There's generic nvmem-cells and nvmem-cell-names = "speed_grade" for
device_type = "cpu". I've posted series for mediatek-cpufreq driver
support some time ago [1], but it's blocked by this one.

If you want to look at more complex example regarding speedbins
and maybe pick some patches (note they're not very upstream ready),
you can take a look at mt6768 fork [2].

[1] https://lore.kernel.org/linux-mediatek/20260923-6572-cpufreq-v1-1-41f7af6d6d1a@xxxxxxxxxxxxxx/
[2] https://github.com/mt6768-mainline/linux

Best regards,
Roman