Skip to content

Commit a402c66

Browse files
varshini-rajendranclaudiubeznea
authored andcommitted
clk: at91: clk-sam9x60-pll: re-factor to support individual core freq outputs
SAM9X7 SoC family supports different core output frequencies for different PLL IDs. To handle the same in the PLL driver, a separate parameter core_output is added. The sam9x60 and sama7g5 SoC PMC drivers are aligned to the PLL driver by adding the core output freq range in the PLL characteristics configurations. Signed-off-by: Varshini Rajendran <[email protected]> Reviewed-by: Claudiu Beznea <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Claudiu Beznea <[email protected]>
1 parent 7f1bcdb commit a402c66

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

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

Lines changed: 6 additions & 6 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 {
@@ -194,7 +191,8 @@ static long sam9x60_frac_pll_compute_mul_frac(struct sam9x60_pll_core *core,
194191
unsigned long nmul = 0;
195192
unsigned long nfrac = 0;
196193

197-
if (rate < FCORE_MIN || rate > FCORE_MAX)
194+
if (rate < core->characteristics->core_output[0].min ||
195+
rate > core->characteristics->core_output[0].max)
198196
return -ERANGE;
199197

200198
/*
@@ -214,7 +212,8 @@ static long sam9x60_frac_pll_compute_mul_frac(struct sam9x60_pll_core *core,
214212
}
215213

216214
/* Check if resulted rate is a valid. */
217-
if (tmprate < FCORE_MIN || tmprate > FCORE_MAX)
215+
if (tmprate < core->characteristics->core_output[0].min ||
216+
tmprate > core->characteristics->core_output[0].max)
218217
return -ERANGE;
219218

220219
if (update) {
@@ -669,7 +668,8 @@ sam9x60_clk_register_frac_pll(struct regmap *regmap, spinlock_t *lock,
669668
goto free;
670669
}
671670

672-
ret = sam9x60_frac_pll_compute_mul_frac(&frac->core, FCORE_MIN,
671+
ret = sam9x60_frac_pll_compute_mul_frac(&frac->core,
672+
characteristics->core_output[0].min,
673673
parent_rate, true);
674674
if (ret < 0) {
675675
hw = ERR_PTR(ret);

drivers/clk/at91/pmc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ struct clk_pll_characteristics {
7575
struct clk_range input;
7676
int num_output;
7777
const struct clk_range *output;
78+
const struct clk_range *core_output;
7879
u16 *icpll;
7980
u8 *out;
8081
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

drivers/clk/at91/sama7g5.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,25 @@ static const struct clk_range pll_outputs[] = {
116116
{ .min = 2343750, .max = 1200000000 },
117117
};
118118

119+
/* Fractional PLL core output range. */
120+
static const struct clk_range core_outputs[] = {
121+
{ .min = 600000000, .max = 1200000000 },
122+
};
123+
119124
/* CPU PLL characteristics. */
120125
static const struct clk_pll_characteristics cpu_pll_characteristics = {
121126
.input = { .min = 12000000, .max = 50000000 },
122127
.num_output = ARRAY_SIZE(cpu_pll_outputs),
123128
.output = cpu_pll_outputs,
129+
.core_output = core_outputs,
124130
};
125131

126132
/* PLL characteristics. */
127133
static const struct clk_pll_characteristics pll_characteristics = {
128134
.input = { .min = 12000000, .max = 50000000 },
129135
.num_output = ARRAY_SIZE(pll_outputs),
130136
.output = pll_outputs,
137+
.core_output = core_outputs,
131138
};
132139

133140
/*

0 commit comments

Comments
 (0)