]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
clk: meson: Support PLL with fixed fractional denominators
authorChuan Liu <chuan.liu@amlogic.com>
Mon, 9 Sep 2024 10:08:56 +0000 (18:08 +0800)
committerJerome Brunet <jbrunet@baylibre.com>
Mon, 30 Sep 2024 09:27:36 +0000 (11:27 +0200)
Some PLLS with fractional multipliers have fractional denominators with
fixed values, instead of the previous "(1 << pll-> frc.width)".

Signed-off-by: Chuan Liu <chuan.liu@amlogic.com>
Link: https://lore.kernel.org/r/20240909-fix_clk-v3-1-a6d8f6333c04@amlogic.com
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
drivers/clk/meson/clk-pll.c
drivers/clk/meson/clk-pll.h

index bc570a2ff3a3f8dceddd96ddebbc53e72afd2c48..89f0f04a16abad99748e1ff3784e7ed91abd0f88 100644 (file)
@@ -57,12 +57,13 @@ static unsigned long __pll_params_to_rate(unsigned long parent_rate,
                                          struct meson_clk_pll_data *pll)
 {
        u64 rate = (u64)parent_rate * m;
+       unsigned int frac_max = pll->frac_max ? pll->frac_max :
+                                               (1 << pll->frac.width);
 
        if (frac && MESON_PARM_APPLICABLE(&pll->frac)) {
                u64 frac_rate = (u64)parent_rate * frac;
 
-               rate += DIV_ROUND_UP_ULL(frac_rate,
-                                        (1 << pll->frac.width));
+               rate += DIV_ROUND_UP_ULL(frac_rate, frac_max);
        }
 
        return DIV_ROUND_UP_ULL(rate, n);
@@ -100,7 +101,8 @@ static unsigned int __pll_params_with_frac(unsigned long rate,
                                           unsigned int n,
                                           struct meson_clk_pll_data *pll)
 {
-       unsigned int frac_max = (1 << pll->frac.width);
+       unsigned int frac_max = pll->frac_max ? pll->frac_max :
+                                               (1 << pll->frac.width);
        u64 val = (u64)rate * n;
 
        /* Bail out if we are already over the requested rate */
index 7b6b87274073d03d11256f96cc191f071279e0ab..949157fb7bf55a1cec94a6e470a5232a93a83fab 100644 (file)
@@ -43,6 +43,7 @@ struct meson_clk_pll_data {
        unsigned int init_count;
        const struct pll_params_table *table;
        const struct pll_mult_range *range;
+       unsigned int frac_max;
        u8 flags;
 };