Skip to content

Commit bd5e2ea

Browse files
committed
Merge branch 'clk-at91' into clk-next
* clk-at91: clk: at91: programmable: remove unneeded register read clk: at91: optimize clk_round_rate() for AUDIO_PLL clk: at91: enable AUDIOPLL as source for PCKx on SAMA5D2
2 parents efb1e0b + 97d010d commit bd5e2ea

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,12 @@ static long clk_audio_pll_pmc_round_rate(struct clk_hw *hw, unsigned long rate,
340340
pr_debug("A PLL/PMC: %s, rate = %lu (parent_rate = %lu)\n", __func__,
341341
rate, *parent_rate);
342342

343-
for (div = 1; div <= AUDIO_PLL_QDPMC_MAX; div++) {
343+
if (!rate)
344+
return 0;
345+
346+
best_parent_rate = clk_round_rate(pclk->clk, 1);
347+
div = max(best_parent_rate / rate, 1UL);
348+
for (; div <= AUDIO_PLL_QDPMC_MAX; div++) {
344349
best_parent_rate = clk_round_rate(pclk->clk, rate * div);
345350
tmp_rate = best_parent_rate / div;
346351
tmp_diff = abs(rate - tmp_rate);
@@ -350,6 +355,8 @@ static long clk_audio_pll_pmc_round_rate(struct clk_hw *hw, unsigned long rate,
350355
best_rate = tmp_rate;
351356
best_diff = tmp_diff;
352357
tmp_qd = div;
358+
if (!best_diff)
359+
break; /* got exact match */
353360
}
354361
}
355362

drivers/clk/at91/clk-programmable.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,8 @@ static int clk_programmable_set_rate(struct clk_hw *hw, unsigned long rate,
132132
struct clk_programmable *prog = to_clk_programmable(hw);
133133
const struct clk_programmable_layout *layout = prog->layout;
134134
unsigned long div = parent_rate / rate;
135-
unsigned int pckr;
136135
int shift = 0;
137136

138-
regmap_read(prog->regmap, AT91_PMC_PCKR(prog->id), &pckr);
139-
140137
if (!div)
141138
return -EINVAL;
142139

drivers/clk/at91/sama5d2.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,14 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
241241
parent_names[2] = "plladivck";
242242
parent_names[3] = "utmick";
243243
parent_names[4] = "masterck";
244+
parent_names[5] = "audiopll_pmcck";
244245
for (i = 0; i < 3; i++) {
245246
char name[6];
246247

247248
snprintf(name, sizeof(name), "prog%d", i);
248249

249250
hw = at91_clk_register_programmable(regmap, name,
250-
parent_names, 5, i,
251+
parent_names, 6, i,
251252
&at91sam9x5_programmable_layout);
252253
if (IS_ERR(hw))
253254
goto err_free;

0 commit comments

Comments
 (0)