2323#define UPLL_DIV 2
2424#define PLL_MUL_MAX (FIELD_GET(PMC_PLL_CTRL1_MUL_MSK, UINT_MAX) + 1)
2525
26- #define FCORE_MIN (600000000)
27- #define FCORE_MAX (1200000000)
28-
2926#define PLL_MAX_ID 7
3027
3128struct sam9x60_pll_core {
@@ -76,9 +73,15 @@ static unsigned long sam9x60_frac_pll_recalc_rate(struct clk_hw *hw,
7673{
7774 struct sam9x60_pll_core * core = to_sam9x60_pll_core (hw );
7875 struct sam9x60_frac * frac = to_sam9x60_frac (core );
76+ unsigned long freq ;
7977
80- return parent_rate * (frac -> mul + 1 ) +
78+ freq = parent_rate * (frac -> mul + 1 ) +
8179 DIV_ROUND_CLOSEST_ULL ((u64 )parent_rate * frac -> frac , (1 << 22 ));
80+
81+ if (core -> layout -> div2 )
82+ freq >>= 1 ;
83+
84+ return freq ;
8285}
8386
8487static int sam9x60_frac_pll_set (struct sam9x60_pll_core * core )
@@ -194,7 +197,8 @@ static long sam9x60_frac_pll_compute_mul_frac(struct sam9x60_pll_core *core,
194197 unsigned long nmul = 0 ;
195198 unsigned long nfrac = 0 ;
196199
197- if (rate < FCORE_MIN || rate > FCORE_MAX )
200+ if (rate < core -> characteristics -> core_output [0 ].min ||
201+ rate > core -> characteristics -> core_output [0 ].max )
198202 return - ERANGE ;
199203
200204 /*
@@ -214,7 +218,8 @@ static long sam9x60_frac_pll_compute_mul_frac(struct sam9x60_pll_core *core,
214218 }
215219
216220 /* Check if resulted rate is a valid. */
217- if (tmprate < FCORE_MIN || tmprate > FCORE_MAX )
221+ if (tmprate < core -> characteristics -> core_output [0 ].min ||
222+ tmprate > core -> characteristics -> core_output [0 ].max )
218223 return - ERANGE ;
219224
220225 if (update ) {
@@ -433,6 +438,12 @@ static unsigned long sam9x60_div_pll_recalc_rate(struct clk_hw *hw,
433438 return DIV_ROUND_CLOSEST_ULL (parent_rate , (div -> div + 1 ));
434439}
435440
441+ static unsigned long sam9x60_fixed_div_pll_recalc_rate (struct clk_hw * hw ,
442+ unsigned long parent_rate )
443+ {
444+ return parent_rate >> 1 ;
445+ }
446+
436447static long sam9x60_div_pll_compute_div (struct sam9x60_pll_core * core ,
437448 unsigned long * parent_rate ,
438449 unsigned long rate )
@@ -607,6 +618,16 @@ static const struct clk_ops sam9x60_div_pll_ops_chg = {
607618 .restore_context = sam9x60_div_pll_restore_context ,
608619};
609620
621+ static const struct clk_ops sam9x60_fixed_div_pll_ops = {
622+ .prepare = sam9x60_div_pll_prepare ,
623+ .unprepare = sam9x60_div_pll_unprepare ,
624+ .is_prepared = sam9x60_div_pll_is_prepared ,
625+ .recalc_rate = sam9x60_fixed_div_pll_recalc_rate ,
626+ .round_rate = sam9x60_div_pll_round_rate ,
627+ .save_context = sam9x60_div_pll_save_context ,
628+ .restore_context = sam9x60_div_pll_restore_context ,
629+ };
630+
610631struct clk_hw * __init
611632sam9x60_clk_register_frac_pll (struct regmap * regmap , spinlock_t * lock ,
612633 const char * name , const char * parent_name ,
@@ -669,7 +690,8 @@ sam9x60_clk_register_frac_pll(struct regmap *regmap, spinlock_t *lock,
669690 goto free ;
670691 }
671692
672- ret = sam9x60_frac_pll_compute_mul_frac (& frac -> core , FCORE_MIN ,
693+ ret = sam9x60_frac_pll_compute_mul_frac (& frac -> core ,
694+ characteristics -> core_output [0 ].min ,
673695 parent_rate , true);
674696 if (ret < 0 ) {
675697 hw = ERR_PTR (ret );
@@ -725,10 +747,16 @@ sam9x60_clk_register_div_pll(struct regmap *regmap, spinlock_t *lock,
725747 else
726748 init .parent_names = & parent_name ;
727749 init .num_parents = 1 ;
728- if (flags & CLK_SET_RATE_GATE )
729- init .ops = & sam9x60_div_pll_ops ;
730- else
731- init .ops = & sam9x60_div_pll_ops_chg ;
750+
751+ if (layout -> div2 ) {
752+ init .ops = & sam9x60_fixed_div_pll_ops ;
753+ } else {
754+ if (flags & CLK_SET_RATE_GATE )
755+ init .ops = & sam9x60_div_pll_ops ;
756+ else
757+ init .ops = & sam9x60_div_pll_ops_chg ;
758+ }
759+
732760 init .flags = flags ;
733761
734762 div -> core .id = id ;
0 commit comments