Skip to content

Commit 6b1b0e6

Browse files
committed
clk: at91: select parent if main oscillator or bypass is enabled
Selecting the right parent for the main clock is done using only main oscillator enabled bit. In case we have this oscillator bypassed by an external signal (no driving on the XOUT line), we still use external clock, but with BYPASS bit set. So, in this case we must select the same parent as before. Create a macro that will select the right parent considering both bits from the MOR register. Use this macro when looking for the right parent. Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
1 parent 5d80920 commit 6b1b0e6

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

drivers/clk/at91/clk-main.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626

2727
#define MOR_KEY_MASK (0xff << 16)
2828

29+
#define clk_main_parent_select(s) (((s) & \
30+
(AT91_PMC_MOSCEN | \
31+
AT91_PMC_OSCBYPASS)) ? 1 : 0)
32+
2933
struct clk_main_osc {
3034
struct clk_hw hw;
3135
struct regmap *regmap;
@@ -118,7 +122,7 @@ static int clk_main_osc_is_prepared(struct clk_hw *hw)
118122

119123
regmap_read(regmap, AT91_PMC_SR, &status);
120124

121-
return (status & AT91_PMC_MOSCS) && (tmp & AT91_PMC_MOSCEN);
125+
return (status & AT91_PMC_MOSCS) && clk_main_parent_select(tmp);
122126
}
123127

124128
static const struct clk_ops main_osc_ops = {
@@ -455,7 +459,7 @@ static u8 clk_sam9x5_main_get_parent(struct clk_hw *hw)
455459

456460
regmap_read(clkmain->regmap, AT91_CKGR_MOR, &status);
457461

458-
return status & AT91_PMC_MOSCEN ? 1 : 0;
462+
return clk_main_parent_select(status);
459463
}
460464

461465
static const struct clk_ops sam9x5_main_ops = {
@@ -497,7 +501,7 @@ at91_clk_register_sam9x5_main(struct regmap *regmap,
497501
clkmain->hw.init = &init;
498502
clkmain->regmap = regmap;
499503
regmap_read(clkmain->regmap, AT91_CKGR_MOR, &status);
500-
clkmain->parent = status & AT91_PMC_MOSCEN ? 1 : 0;
504+
clkmain->parent = clk_main_parent_select(status);
501505

502506
hw = &clkmain->hw;
503507
ret = clk_hw_register(NULL, &clkmain->hw);

0 commit comments

Comments
 (0)