Skip to content

Commit 1c6a7ea

Browse files
ConchuODbebarino
authored andcommitted
clk: microchip: mpfs: add RTCREF clock control
The reference clock used by the PolarFire SoC's onboard rtc was missing from the clock driver. Add this clock at the "config" clock level, with the external reference clock as its parent. Fixes: 635e5e7 ("clk: microchip: Add driver for Microchip PolarFire SoC") Reviewed-by: Daire McNamara <[email protected]> Signed-off-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Palmer Dabbelt <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 445c2da commit 1c6a7ea

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

drivers/clk/microchip/clk-mpfs.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define REG_MSSPLL_POSTDIV_CR 0x10u
1616
#define REG_MSSPLL_SSCG_2_CR 0x2Cu
1717
#define REG_CLOCK_CONFIG_CR 0x08u
18+
#define REG_RTC_CLOCK_CR 0x0Cu
1819
#define REG_SUBBLK_CLOCK_CR 0x84u
1920
#define REG_SUBBLK_RESET_CR 0x88u
2021

@@ -96,6 +97,17 @@ static const struct clk_div_table mpfs_div_ahb_table[] = {
9697
{ 0, 0 }
9798
};
9899

100+
/*
101+
* The only two supported reference clock frequencies for the PolarFire SoC are
102+
* 100 and 125 MHz, as the rtc reference is required to be 1 MHz.
103+
* It therefore only needs to have divider table entries corresponding to
104+
* divide by 100 and 125.
105+
*/
106+
static const struct clk_div_table mpfs_div_rtcref_table[] = {
107+
{ 100, 100 }, { 125, 125 },
108+
{ 0, 0 }
109+
};
110+
99111
static unsigned long mpfs_clk_msspll_recalc_rate(struct clk_hw *hw, unsigned long prate)
100112
{
101113
struct mpfs_msspll_hw_clock *msspll_hw = to_mpfs_msspll_clk(hw);
@@ -234,6 +246,16 @@ static struct mpfs_cfg_hw_clock mpfs_cfg_clks[] = {
234246
REG_CLOCK_CONFIG_CR),
235247
CLK_CFG(CLK_AHB, "clk_ahb", "clk_msspll", 4, 2, mpfs_div_ahb_table, 0,
236248
REG_CLOCK_CONFIG_CR),
249+
{
250+
.cfg.id = CLK_RTCREF,
251+
.cfg.shift = 0,
252+
.cfg.width = 12,
253+
.cfg.table = mpfs_div_rtcref_table,
254+
.cfg.reg_offset = REG_RTC_CLOCK_CR,
255+
.cfg.flags = CLK_DIVIDER_ONE_BASED,
256+
.hw.init =
257+
CLK_HW_INIT_PARENTS_DATA("clk_rtcref", mpfs_ext_ref, &mpfs_clk_cfg_ops, 0),
258+
}
237259
};
238260

239261
static int mpfs_clk_register_cfg(struct device *dev, struct mpfs_cfg_hw_clock *cfg_hw,
@@ -359,7 +381,7 @@ static struct mpfs_periph_hw_clock mpfs_periph_clks[] = {
359381
CLK_PERIPH(CLK_MAC0, "clk_periph_mac0", PARENT_CLK(AHB), 1, 0),
360382
CLK_PERIPH(CLK_MAC1, "clk_periph_mac1", PARENT_CLK(AHB), 2, 0),
361383
CLK_PERIPH(CLK_MMC, "clk_periph_mmc", PARENT_CLK(AHB), 3, 0),
362-
CLK_PERIPH(CLK_TIMER, "clk_periph_timer", PARENT_CLK(AHB), 4, 0),
384+
CLK_PERIPH(CLK_TIMER, "clk_periph_timer", PARENT_CLK(RTCREF), 4, 0),
363385
CLK_PERIPH(CLK_MMUART0, "clk_periph_mmuart0", PARENT_CLK(AHB), 5, CLK_IS_CRITICAL),
364386
CLK_PERIPH(CLK_MMUART1, "clk_periph_mmuart1", PARENT_CLK(AHB), 6, 0),
365387
CLK_PERIPH(CLK_MMUART2, "clk_periph_mmuart2", PARENT_CLK(AHB), 7, 0),

0 commit comments

Comments
 (0)