On Wed, 2022-06-29 at 16:54 +0800, Chen-Yu Tsai wrote:
On Tue, Jun 28, 2022 at 6:09 PM AngeloGioacchino Del Regno
<angelogioacchino.delregno@xxxxxxxxxxxxx> wrote:
Il 24/06/22 09:12, Edward-JW Yang ha scritto:
Hi AngeloGioacchino,
Thanks for all the advices.
On Mon, 2022-06-13 at 17:43 +0800, AngeloGioacchino Del Regno wrote:
Il 12/06/22 15:54, Johnson Wang ha scritto:
Add frequency hopping support and spread spectrum clocking
control for MT8186.
Signed-off-by: Edward-JW Yang <edward-jw.yang@xxxxxxxxxxxx>
Signed-off-by: Johnson Wang <johnson.wang@xxxxxxxxxxxx>
Before going on with the review, there's one important consideration:
the Frequency Hopping control is related to PLLs only (so, no other clock
types get in the mix).
Checking the code, the *main* thing that we do here is initializing the
FHCTL by setting some registers, and we're performing the actual frequency
hopping operation in clk-pll, which is right but, at this point, I think
that the best way to proceed is to add the "FHCTL superpowers" to clk-pll
itself, instead of adding multiple new files and devicetree bindings that
are specific to the FHCTL itself.
This would mean that the `fh-id` and `perms` params that you're setting in
the devicetree get transferred to clk-mt8186 (and hardcoded there), as to
extend the PLL declarations to include these two: that will also simplify
the driver so that you won't have to match names here and there.
Just an example:
PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x0224, 0x0230, 0,
PLL_AO, 0, 22, 0x0228, 24, 0, 0, 0, 0x0228, 2, FHCTL_PERM_DBG_DUMP),
Besides, there are another couple of reasons why you should do that instead,
of which:
- The devicetree should be "generic enough", we shall not see the direct value
to write to the registers in there (yet, perms assigns exactly that)
- These values won't change on a per-device basis, I believe? They're SoC-related,
not board-related, right?
In case they're board related (and/or related to TZ permissions), we can always add
a bool property to the apmixedsys to advertise that board X needs to use an
alternative permission (ex.: `mediatek,secure-fhctl`).
I think we should remain clk-fhctl files because FHCTL is a independent HW and is
not a necessary component of clk-pll.
I know what FHCTL is, but thank you anyway for the explanation, that's appreciated.
In any case, this not being a *mandatory* component doesn't mean that when it is
enabled it's not changing the way we manage the PLLs..........
Frequency hopping function from FHCTL is not used to replace original flow of
set_rate in clk-pll. They are two different ways to change PLL's frequency. The
I disagree: when we want to use FHCTL, we effectively hand-over PLL control from
APMIXEDSYS to the Frequency Hopping controller - and we're effectively replacing
the set_rate() logic of clk-pll.
Do you mean we need to drop the current set_rate() logic (direct register write) and
use Frequency Hopping Controller instead?
I need to mention that not all PLL support FHCTL, only those PLLs with FHCTL HW can
choose to use FHCTL. Take 8186 for example, there are three PLLs don't support FHCTL
HW.
So, we need both APMIXEDSYS and Frequency Hopping Controller in set_rate() logic to
handle this two types of PLL.
current set_rate method in clk-pll changes PLL register setting directly. Another
way uses FHCTL to change PLL rate.
...and of course, if we change that, we're effectively mutating the functionality
of the MediaTek clk-pll driver and please understand that seeing a clear mutation
in that driver is a bit more human-readable.
Besides, this makes me think about one question: is there any instance in which,
when FHCTL rate setting fails, we fall back to direct register writes?
I don't think that this is feasible because we have a register in FHCTL that
effectively hands over control to it, so direct register writes should not work
when the PLL is not under APMIXEDSYS control, but I'm asking just to be extremely
sure that my understanding is right.
It won't fall back to direct register writes when FHCTL rate setting fails. But, PLL
control mode will switch back to APMIXEDSYS after frequency hopping completed.
There are two cases that we need to fall back to direct register writes:
1. PLL support FHCTL but it doesn't want to use FHCTL.
2. PLL doesn't support FHCTL HW.
We will set some PLL's frequency be controlled
by clk-pll and some are controlled by FHCTL.
Another question: is this also changing on a per-board basis?
(note: the pll names in the example are random and not specific to anything)
Example: board A wants FHCTL on MMPLL, TVDPLL, MPLL, but *shall not* hand over
NNAPLL, MFGPLL
board B wants FHCTL on NNAPLL, TVDPLL but *shall not* hand over MMPLL
Granted that the two A, B boards are using the same SoC, can that ever happen?
This could happen if A, B boards have different desense issue.
And use `perms` param to decide
whether a PLL is using FHCTL to change its frequency.
The perms param seems to be about:
* Enabling debug (but you're not providing any way to actually use debugging
features, so what's the point?)
Debugging feature is not used yet, we can removed it.
* Handing over PLL control to FHCTL for hopping (can be as well done with
simply using a different .set_rate() callback instead of a flag)
There has some PLL that have FHCTL but don't want to use FHCTL. The flag is used in
this case.
* Enabling/disabling Spread Spectrum Clocking (and I think that this is a
legit use for flags, but if it's just one flag, you can as well use a
bool and manage this with a devicetree param like "enable-ssc")
That said, I think that the current way of enabling the FHCTL is more complicated
than how it should really be.
Here needs an option to decide whether to enable FHCTL-hopping or FHCTL-ssc since
these two are per-board basis.
We cannot force all PLL hand over to FHCTL for hopping casue not all PLLs support
FHCTL and not all PLLs have need of using FHCTL-hopping.
FHCTL has another function called SSC(spread spectrum clocking) which is used to
solve PLL de-sense problem. De-sense problem is board-related so we introduce a
`ssc-rate` param in the devicetree to decide whether SSC is enabled and how many
rate should be set. Mixing SSC function into clk-pll may cause clk-pll more
complex.
Thing is, I don't get why you think that adding SSC to clk-pll would complicate it
so much... it's really just a few register writes and nothing else, so I really
don't see where the problem is, here.
Another issue is that this driver may be largely incomplete, so perhaps I can't
really see the complications you're talking about? Is this the case?
Regarding keeping the FHCTL code in separated files, that's fine, but I would still
integrate it tightly in clk-pll and its registration flow, because - yes, this is
for sure not mandatory, but the main parameters are constant, they never change for
a specific PLL, as they're register offsets, bits and masks (which, again, will
never change as long as we're using the same SoC).
The driver may need to supoport microP by future HW design, standalone file clk-
fhctl.c helps to trigger init flow of such as ap-init-flow, microP-init-flow .....,
and those different init-flow also need to run some communication API with microP.
Those communication APIs are not suitable to merge into clk-pll.