Skip to content

Commit e5fa173

Browse files
committed
Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
Pull clk driver fixes from Stephen Boyd: "Here's the last batch of clk driver fixes for this release. These patches fix serious problems, for example, i.MX has an issue where changing the NAND clk frequency hangs the system. On Allwinner H6 the GPU is being overclocked which could lead to long term hardware damage. And finally on some Broadcom SoCs the serial console stopped working because the clk tree hierarchy description got broken by an inadvertant DT node name change. That's fixed by using 'clock-output-names' to generate a stable and unique name for clks so the framework can properly link things up. There's also a couple build fixes in here. One to fix CONFIG_OF=n builds and one to avoid an array out of bounds bug that happens during clk registration on microchip. I hope that KASAN would have found that OOB problem, but probably KASAN wasn't attempted. Instead LLVM/clang compilation caused an oops, while GCC didn't" * tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux: clk: imx93: drop of_match_ptr clk: iproc: Do not rely on node name for correct PLL setup clk: sunxi-ng: h6: Fix default PLL GPU rate clk: imx: imx6sx: remove the SET_RATE_PARENT flag for QSPI clocks clk: microchip: mpfs: make the rtc's ahb clock critical clk: microchip: mpfs: fix clk_cfg array bounds violation clk: ingenic-tcu: Properly enable registers before accessing timers
2 parents c816f2e + daaa2fb commit e5fa173

File tree

6 files changed

+31
-21
lines changed

6 files changed

+31
-21
lines changed

drivers/clk/bcm/clk-iproc-pll.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ void iproc_pll_clk_setup(struct device_node *node,
726726
const char *parent_name;
727727
struct iproc_clk *iclk_array;
728728
struct clk_hw_onecell_data *clk_data;
729+
const char *clk_name;
729730

730731
if (WARN_ON(!pll_ctrl) || WARN_ON(!clk_ctrl))
731732
return;
@@ -773,7 +774,12 @@ void iproc_pll_clk_setup(struct device_node *node,
773774
iclk = &iclk_array[0];
774775
iclk->pll = pll;
775776

776-
init.name = node->name;
777+
ret = of_property_read_string_index(node, "clock-output-names",
778+
0, &clk_name);
779+
if (WARN_ON(ret))
780+
goto err_pll_register;
781+
782+
init.name = clk_name;
777783
init.ops = &iproc_pll_ops;
778784
init.flags = 0;
779785
parent_name = of_clk_get_parent_name(node, 0);
@@ -793,13 +799,11 @@ void iproc_pll_clk_setup(struct device_node *node,
793799
goto err_pll_register;
794800

795801
clk_data->hws[0] = &iclk->hw;
802+
parent_name = clk_name;
796803

797804
/* now initialize and register all leaf clocks */
798805
for (i = 1; i < num_clks; i++) {
799-
const char *clk_name;
800-
801806
memset(&init, 0, sizeof(init));
802-
parent_name = node->name;
803807

804808
ret = of_property_read_string_index(node, "clock-output-names",
805809
i, &clk_name);

drivers/clk/imx/clk-imx6sx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,13 @@ static void __init imx6sx_clocks_init(struct device_node *ccm_node)
280280
hws[IMX6SX_CLK_SSI3_SEL] = imx_clk_hw_mux("ssi3_sel", base + 0x1c, 14, 2, ssi_sels, ARRAY_SIZE(ssi_sels));
281281
hws[IMX6SX_CLK_SSI2_SEL] = imx_clk_hw_mux("ssi2_sel", base + 0x1c, 12, 2, ssi_sels, ARRAY_SIZE(ssi_sels));
282282
hws[IMX6SX_CLK_SSI1_SEL] = imx_clk_hw_mux("ssi1_sel", base + 0x1c, 10, 2, ssi_sels, ARRAY_SIZE(ssi_sels));
283-
hws[IMX6SX_CLK_QSPI1_SEL] = imx_clk_hw_mux_flags("qspi1_sel", base + 0x1c, 7, 3, qspi1_sels, ARRAY_SIZE(qspi1_sels), CLK_SET_RATE_PARENT);
283+
hws[IMX6SX_CLK_QSPI1_SEL] = imx_clk_hw_mux("qspi1_sel", base + 0x1c, 7, 3, qspi1_sels, ARRAY_SIZE(qspi1_sels));
284284
hws[IMX6SX_CLK_PERCLK_SEL] = imx_clk_hw_mux("perclk_sel", base + 0x1c, 6, 1, perclk_sels, ARRAY_SIZE(perclk_sels));
285285
hws[IMX6SX_CLK_VID_SEL] = imx_clk_hw_mux("vid_sel", base + 0x20, 21, 3, vid_sels, ARRAY_SIZE(vid_sels));
286286
hws[IMX6SX_CLK_ESAI_SEL] = imx_clk_hw_mux("esai_sel", base + 0x20, 19, 2, audio_sels, ARRAY_SIZE(audio_sels));
287287
hws[IMX6SX_CLK_CAN_SEL] = imx_clk_hw_mux("can_sel", base + 0x20, 8, 2, can_sels, ARRAY_SIZE(can_sels));
288288
hws[IMX6SX_CLK_UART_SEL] = imx_clk_hw_mux("uart_sel", base + 0x24, 6, 1, uart_sels, ARRAY_SIZE(uart_sels));
289-
hws[IMX6SX_CLK_QSPI2_SEL] = imx_clk_hw_mux_flags("qspi2_sel", base + 0x2c, 15, 3, qspi2_sels, ARRAY_SIZE(qspi2_sels), CLK_SET_RATE_PARENT);
289+
hws[IMX6SX_CLK_QSPI2_SEL] = imx_clk_hw_mux("qspi2_sel", base + 0x2c, 15, 3, qspi2_sels, ARRAY_SIZE(qspi2_sels));
290290
hws[IMX6SX_CLK_SPDIF_SEL] = imx_clk_hw_mux("spdif_sel", base + 0x30, 20, 2, audio_sels, ARRAY_SIZE(audio_sels));
291291
hws[IMX6SX_CLK_AUDIO_SEL] = imx_clk_hw_mux("audio_sel", base + 0x30, 7, 2, audio_sels, ARRAY_SIZE(audio_sels));
292292
hws[IMX6SX_CLK_ENET_PRE_SEL] = imx_clk_hw_mux("enet_pre_sel", base + 0x34, 15, 3, enet_pre_sels, ARRAY_SIZE(enet_pre_sels));

drivers/clk/imx/clk-imx93.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static struct platform_driver imx93_clk_driver = {
332332
.driver = {
333333
.name = "imx93-ccm",
334334
.suppress_bind_attrs = true,
335-
.of_match_table = of_match_ptr(imx93_clk_of_match),
335+
.of_match_table = imx93_clk_of_match,
336336
},
337337
};
338338
module_platform_driver(imx93_clk_driver);

drivers/clk/ingenic/tcu.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,11 @@ static bool ingenic_tcu_enable_regs(struct clk_hw *hw)
101101
bool enabled = false;
102102

103103
/*
104-
* If the SoC has no global TCU clock, we must ungate the channel's
105-
* clock to be able to access its registers.
106-
* If we have a TCU clock, it will be enabled automatically as it has
107-
* been attached to the regmap.
104+
* According to the programming manual, a timer channel's registers can
105+
* only be accessed when the channel's stop bit is clear.
108106
*/
109-
if (!tcu->clk) {
110-
enabled = !!ingenic_tcu_is_enabled(hw);
111-
regmap_write(tcu->map, TCU_REG_TSCR, BIT(info->gate_bit));
112-
}
107+
enabled = !!ingenic_tcu_is_enabled(hw);
108+
regmap_write(tcu->map, TCU_REG_TSCR, BIT(info->gate_bit));
113109

114110
return enabled;
115111
}
@@ -120,8 +116,7 @@ static void ingenic_tcu_disable_regs(struct clk_hw *hw)
120116
const struct ingenic_tcu_clk_info *info = tcu_clk->info;
121117
struct ingenic_tcu *tcu = tcu_clk->tcu;
122118

123-
if (!tcu->clk)
124-
regmap_write(tcu->map, TCU_REG_TSSR, BIT(info->gate_bit));
119+
regmap_write(tcu->map, TCU_REG_TSSR, BIT(info->gate_bit));
125120
}
126121

127122
static u8 ingenic_tcu_get_parent(struct clk_hw *hw)

drivers/clk/microchip/clk-mpfs.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ static const struct clk_ops mpfs_clk_cfg_ops = {
239239
.hw.init = CLK_HW_INIT(_name, _parent, &mpfs_clk_cfg_ops, 0), \
240240
}
241241

242+
#define CLK_CPU_OFFSET 0u
243+
#define CLK_AXI_OFFSET 1u
244+
#define CLK_AHB_OFFSET 2u
245+
#define CLK_RTCREF_OFFSET 3u
246+
242247
static struct mpfs_cfg_hw_clock mpfs_cfg_clks[] = {
243248
CLK_CFG(CLK_CPU, "clk_cpu", "clk_msspll", 0, 2, mpfs_div_cpu_axi_table, 0,
244249
REG_CLOCK_CONFIG_CR),
@@ -362,14 +367,16 @@ static const struct clk_ops mpfs_periph_clk_ops = {
362367
_flags), \
363368
}
364369

365-
#define PARENT_CLK(PARENT) (&mpfs_cfg_clks[CLK_##PARENT].hw)
370+
#define PARENT_CLK(PARENT) (&mpfs_cfg_clks[CLK_##PARENT##_OFFSET].hw)
366371

367372
/*
368373
* Critical clocks:
369374
* - CLK_ENVM: reserved by hart software services (hss) superloop monitor/m mode interrupt
370375
* trap handler
371376
* - CLK_MMUART0: reserved by the hss
372377
* - CLK_DDRC: provides clock to the ddr subsystem
378+
* - CLK_RTC: the onboard RTC's AHB bus clock must be kept running as the rtc will stop
379+
* if the AHB interface clock is disabled
373380
* - CLK_FICx: these provide the processor side clocks to the "FIC" (Fabric InterConnect)
374381
* clock domain crossers which provide the interface to the FPGA fabric. Disabling them
375382
* causes the FPGA fabric to go into reset.
@@ -394,7 +401,7 @@ static struct mpfs_periph_hw_clock mpfs_periph_clks[] = {
394401
CLK_PERIPH(CLK_CAN0, "clk_periph_can0", PARENT_CLK(AHB), 14, 0),
395402
CLK_PERIPH(CLK_CAN1, "clk_periph_can1", PARENT_CLK(AHB), 15, 0),
396403
CLK_PERIPH(CLK_USB, "clk_periph_usb", PARENT_CLK(AHB), 16, 0),
397-
CLK_PERIPH(CLK_RTC, "clk_periph_rtc", PARENT_CLK(AHB), 18, 0),
404+
CLK_PERIPH(CLK_RTC, "clk_periph_rtc", PARENT_CLK(AHB), 18, CLK_IS_CRITICAL),
398405
CLK_PERIPH(CLK_QSPI, "clk_periph_qspi", PARENT_CLK(AHB), 19, 0),
399406
CLK_PERIPH(CLK_GPIO0, "clk_periph_gpio0", PARENT_CLK(AHB), 20, 0),
400407
CLK_PERIPH(CLK_GPIO1, "clk_periph_gpio1", PARENT_CLK(AHB), 21, 0),

drivers/clk/sunxi-ng/ccu-sun50i-h6.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,9 +1191,13 @@ static int sun50i_h6_ccu_probe(struct platform_device *pdev)
11911191
if (IS_ERR(reg))
11921192
return PTR_ERR(reg);
11931193

1194-
/* Force PLL_GPU output divider bits to 0 */
1194+
/*
1195+
* Force PLL_GPU output divider bits to 0 and adjust
1196+
* multiplier to sensible default value of 432 MHz.
1197+
*/
11951198
val = readl(reg + SUN50I_H6_PLL_GPU_REG);
1196-
val &= ~BIT(0);
1199+
val &= ~(GENMASK(15, 8) | BIT(0));
1200+
val |= 17 << 8;
11971201
writel(val, reg + SUN50I_H6_PLL_GPU_REG);
11981202

11991203
/* Force GPU_CLK divider bits to 0 */

0 commit comments

Comments
 (0)