Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 635e5e73370e ("clk: microchip: Add driver for Microchip PolarFire SoC")
Reviewed-by: Daire McNamara <daire.mcnamara@microchip.com>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20220413075835.3354193-9-conor.dooley@microchip.com
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Conor Dooley and committed by
Stephen Boyd
1c6a7ea3 445c2da8

+23 -1
+23 -1
drivers/clk/microchip/clk-mpfs.c
··· 15 15 #define REG_MSSPLL_POSTDIV_CR 0x10u 16 16 #define REG_MSSPLL_SSCG_2_CR 0x2Cu 17 17 #define REG_CLOCK_CONFIG_CR 0x08u 18 + #define REG_RTC_CLOCK_CR 0x0Cu 18 19 #define REG_SUBBLK_CLOCK_CR 0x84u 19 20 #define REG_SUBBLK_RESET_CR 0x88u 20 21 ··· 94 93 95 94 static const struct clk_div_table mpfs_div_ahb_table[] = { 96 95 { 1, 2 }, { 2, 4}, { 3, 8 }, 96 + { 0, 0 } 97 + }; 98 + 99 + /* 100 + * The only two supported reference clock frequencies for the PolarFire SoC are 101 + * 100 and 125 MHz, as the rtc reference is required to be 1 MHz. 102 + * It therefore only needs to have divider table entries corresponding to 103 + * divide by 100 and 125. 104 + */ 105 + static const struct clk_div_table mpfs_div_rtcref_table[] = { 106 + { 100, 100 }, { 125, 125 }, 97 107 { 0, 0 } 98 108 }; 99 109 ··· 246 234 REG_CLOCK_CONFIG_CR), 247 235 CLK_CFG(CLK_AHB, "clk_ahb", "clk_msspll", 4, 2, mpfs_div_ahb_table, 0, 248 236 REG_CLOCK_CONFIG_CR), 237 + { 238 + .cfg.id = CLK_RTCREF, 239 + .cfg.shift = 0, 240 + .cfg.width = 12, 241 + .cfg.table = mpfs_div_rtcref_table, 242 + .cfg.reg_offset = REG_RTC_CLOCK_CR, 243 + .cfg.flags = CLK_DIVIDER_ONE_BASED, 244 + .hw.init = 245 + CLK_HW_INIT_PARENTS_DATA("clk_rtcref", mpfs_ext_ref, &mpfs_clk_cfg_ops, 0), 246 + } 249 247 }; 250 248 251 249 static int mpfs_clk_register_cfg(struct device *dev, struct mpfs_cfg_hw_clock *cfg_hw, ··· 381 359 CLK_PERIPH(CLK_MAC0, "clk_periph_mac0", PARENT_CLK(AHB), 1, 0), 382 360 CLK_PERIPH(CLK_MAC1, "clk_periph_mac1", PARENT_CLK(AHB), 2, 0), 383 361 CLK_PERIPH(CLK_MMC, "clk_periph_mmc", PARENT_CLK(AHB), 3, 0), 384 - CLK_PERIPH(CLK_TIMER, "clk_periph_timer", PARENT_CLK(AHB), 4, 0), 362 + CLK_PERIPH(CLK_TIMER, "clk_periph_timer", PARENT_CLK(RTCREF), 4, 0), 385 363 CLK_PERIPH(CLK_MMUART0, "clk_periph_mmuart0", PARENT_CLK(AHB), 5, CLK_IS_CRITICAL), 386 364 CLK_PERIPH(CLK_MMUART1, "clk_periph_mmuart1", PARENT_CLK(AHB), 6, 0), 387 365 CLK_PERIPH(CLK_MMUART2, "clk_periph_mmuart2", PARENT_CLK(AHB), 7, 0),