[PATCH v2 1/2] clk: sunxi-ng: nkm: consider alternative parent rates when finding rate
Maxime Ripard
maxime at cerno.tech
Mon Jun 12 05:31:21 PDT 2023
On Mon, Jun 12, 2023 at 10:51:52AM +0200, Frank Oltmanns wrote:
> > @@ -28,12 +68,17 @@ static unsigned long ccu_nkm_find_best(unsigned long parent, unsigned long rate,
> > for (_m = nkm->min_m; _m <= nkm->max_m; _m++) {
>
> According to the manual M/N has to be <= 3. Therefore we need a
> different maximum value for the _m-for-loop:
>
> unsigned long max_m = min(3 * _n, nkm->max_m);
> for (_m = nkm->min_m; _m <= max_m; _m++) {
>
> I suggest that I add an optional member max_mn_ratio to the structs
> ccu_nkm and _ccu_nkm. Optional meaning: Ignore if 0.
Which workload is affected by this restriction?
> > unsigned long tmp_rate;
> >
> > - tmp_rate = parent * _n * _k / _m;
> > -
> > + if (parent_hw) {
> > + tmp_parent = optimal_parent_rate(rate, _n, _k, _m);
> > + tmp_parent = clk_hw_round_rate(parent_hw, tmp_parent);
> > + }
>
> Another constraint is PLL-VIDEO0 rate / M >= 24 MHz. Therefore we also need:
> if (tmp_parent < 24000000 * _m)
> continue;
>
> So, we need another optional member min_m_times_parent or, for
> shortness, maybe min_m_parent. I could use help finding a good name for
> this.
Again, if it's not causing any harm I'd rather keep the code as simple
and maintainable as possible.
Maxime
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20230612/f35bbb66/attachment.sig>
More information about the linux-arm-kernel
mailing list