Skip to content

Commit e4000f4

Browse files
committed
Merge branch 'linux-6.6-trunk/at91/clk' into linux-6.6-mchp
2 parents 45658be + 5349329 commit e4000f4

7 files changed

Lines changed: 1027 additions & 16 deletions

File tree

drivers/clk/at91/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ obj-$(CONFIG_SOC_AT91SAM9) += at91sam9260.o at91sam9rl.o at91sam9x5.o dt-compat.
2020
obj-$(CONFIG_SOC_AT91SAM9) += at91sam9g45.o dt-compat.o
2121
obj-$(CONFIG_SOC_AT91SAM9) += at91sam9n12.o at91sam9x5.o dt-compat.o
2222
obj-$(CONFIG_SOC_SAM9X60) += sam9x60.o
23+
obj-$(CONFIG_SOC_SAM9X7) += sam9x7.o
2324
obj-$(CONFIG_SOC_SAMA5D3) += sama5d3.o dt-compat.o
2425
obj-$(CONFIG_SOC_SAMA5D4) += sama5d4.o dt-compat.o
2526
obj-$(CONFIG_SOC_SAMA5D2) += sama5d2.o dt-compat.o

drivers/clk/at91/clk-sam9x60-pll.c

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
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

3128
struct 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

8487
static 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+
436447
static 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+
610631
struct clk_hw * __init
611632
sam9x60_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;

drivers/clk/at91/pmc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct clk_pll_layout {
6464
u8 frac_shift;
6565
u8 div_shift;
6666
u8 endiv_shift;
67+
u8 div2;
6768
};
6869

6970
extern const struct clk_pll_layout at91rm9200_pll_layout;
@@ -75,6 +76,7 @@ struct clk_pll_characteristics {
7576
struct clk_range input;
7677
int num_output;
7778
const struct clk_range *output;
79+
const struct clk_range *core_output;
7880
u16 *icpll;
7981
u8 *out;
8082
u8 upll : 1;

drivers/clk/at91/sam9x60.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@ static const struct clk_range plla_outputs[] = {
2626
{ .min = 2343750, .max = 1200000000 },
2727
};
2828

29+
/* Fractional PLL core output range. */
30+
static const struct clk_range core_outputs[] = {
31+
{ .min = 600000000, .max = 1200000000 },
32+
};
33+
2934
static const struct clk_pll_characteristics plla_characteristics = {
3035
.input = { .min = 12000000, .max = 48000000 },
3136
.num_output = ARRAY_SIZE(plla_outputs),
3237
.output = plla_outputs,
38+
.core_output = core_outputs,
3339
};
3440

3541
static const struct clk_range upll_outputs[] = {
@@ -40,6 +46,7 @@ static const struct clk_pll_characteristics upll_characteristics = {
4046
.input = { .min = 12000000, .max = 48000000 },
4147
.num_output = ARRAY_SIZE(upll_outputs),
4248
.output = upll_outputs,
49+
.core_output = core_outputs,
4350
.upll = true,
4451
};
4552

0 commit comments

Comments
 (0)