Skip to content

Commit 3d6f6d2

Browse files
amergnatbebarino
authored andcommitted
clk: mediatek: mt8365: Fix index issue
Before the patch [1], the clock probe was done directly in the clk-mt8365 driver. In this probe function, the array which stores the data clocks is sized using the higher defined numbers (*_NR_CLOCK) in the clock lists [2]. Currently, with the patch [1], the specific clk-mt8365 probe function is replaced by the mtk generic one [3], which size the clock data array by adding all the clock descriptor array size provided by the clk-mt8365 driver. Actually, all clock indexes come from the header file [2], that mean, if there are more clock (then more index) in the header file [2] than the number of clock declared in the clock descriptor arrays (which is the case currently), the clock data array will be undersized and then the generic probe function will overflow when it will try to write in "clk_data[CLK_INDEX]". Actually, instead of crashing at boot, the probe function returns an error in the log which looks like: "of_clk_hw_onecell_get: invalid index 135", then this clock isn't enabled. Solve this issue by adding in the driver the missing clocks declared in the header clock file [2]. [1]: Commit ffe91cb ("clk: mediatek: mt8365: Convert to mtk_clk_simple_{probe,remove}()") [2]: include/dt-bindings/clock/mediatek,mt8365-clk.h [3]: drivers/clk/mediatek/clk-mtk.c Fixes: ffe91cb ("clk: mediatek: mt8365: Convert to mtk_clk_simple_{probe,remove}()") Signed-off-by: Alexandre Mergnat <[email protected]> Link: https://lore.kernel.org/r/[email protected] Tested-by: Markus Schneider-Pargmann <[email protected]> Reviewed-by: Markus Schneider-Pargmann <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent ac9a786 commit 3d6f6d2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/clk/mediatek/clk-mt8365.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
static DEFINE_SPINLOCK(mt8365_clk_lock);
2424

2525
static const struct mtk_fixed_clk top_fixed_clks[] = {
26+
FIXED_CLK(CLK_TOP_CLK_NULL, "clk_null", NULL, 0),
2627
FIXED_CLK(CLK_TOP_I2S0_BCK, "i2s0_bck", NULL, 26000000),
2728
FIXED_CLK(CLK_TOP_DSI0_LNTC_DSICK, "dsi0_lntc_dsick", "clk26m",
2829
75000000),
@@ -559,6 +560,14 @@ static const struct mtk_clk_divider top_adj_divs[] = {
559560
0x324, 16, 8, CLK_DIVIDER_ROUND_CLOSEST),
560561
DIV_ADJ_F(CLK_TOP_APLL12_CK_DIV3, "apll12_ck_div3", "apll_i2s3_sel",
561562
0x324, 24, 8, CLK_DIVIDER_ROUND_CLOSEST),
563+
DIV_ADJ_F(CLK_TOP_APLL12_CK_DIV4, "apll12_ck_div4", "apll_tdmout_sel",
564+
0x328, 0, 8, CLK_DIVIDER_ROUND_CLOSEST),
565+
DIV_ADJ_F(CLK_TOP_APLL12_CK_DIV4B, "apll12_ck_div4b", "apll_tdmout_sel",
566+
0x328, 8, 8, CLK_DIVIDER_ROUND_CLOSEST),
567+
DIV_ADJ_F(CLK_TOP_APLL12_CK_DIV5, "apll12_ck_div5", "apll_tdmin_sel",
568+
0x328, 16, 8, CLK_DIVIDER_ROUND_CLOSEST),
569+
DIV_ADJ_F(CLK_TOP_APLL12_CK_DIV5B, "apll12_ck_div5b", "apll_tdmin_sel",
570+
0x328, 24, 8, CLK_DIVIDER_ROUND_CLOSEST),
562571
DIV_ADJ_F(CLK_TOP_APLL12_CK_DIV6, "apll12_ck_div6", "apll_spdif_sel",
563572
0x32c, 0, 8, CLK_DIVIDER_ROUND_CLOSEST),
564573
};
@@ -696,6 +705,7 @@ static const struct mtk_gate ifr_clks[] = {
696705
GATE_IFR3(CLK_IFR_GCPU, "ifr_gcpu", "axi_sel", 8),
697706
GATE_IFR3(CLK_IFR_TRNG, "ifr_trng", "axi_sel", 9),
698707
GATE_IFR3(CLK_IFR_AUXADC, "ifr_auxadc", "clk26m", 10),
708+
GATE_IFR3(CLK_IFR_CPUM, "ifr_cpum", "clk26m", 11),
699709
GATE_IFR3(CLK_IFR_AUXADC_MD, "ifr_auxadc_md", "clk26m", 14),
700710
GATE_IFR3(CLK_IFR_AP_DMA, "ifr_ap_dma", "axi_sel", 18),
701711
GATE_IFR3(CLK_IFR_DEBUGSYS, "ifr_debugsys", "axi_sel", 24),
@@ -717,6 +727,8 @@ static const struct mtk_gate ifr_clks[] = {
717727
GATE_IFR5(CLK_IFR_PWRAP_TMR, "ifr_pwrap_tmr", "clk26m", 12),
718728
GATE_IFR5(CLK_IFR_PWRAP_SPI, "ifr_pwrap_spi", "clk26m", 13),
719729
GATE_IFR5(CLK_IFR_PWRAP_SYS, "ifr_pwrap_sys", "clk26m", 14),
730+
GATE_MTK_FLAGS(CLK_IFR_MCU_PM_BK, "ifr_mcu_pm_bk", NULL, &ifr5_cg_regs,
731+
17, &mtk_clk_gate_ops_setclr, CLK_IGNORE_UNUSED),
720732
GATE_IFR5(CLK_IFR_IRRX_26M, "ifr_irrx_26m", "clk26m", 22),
721733
GATE_IFR5(CLK_IFR_IRRX_32K, "ifr_irrx_32k", "clk32k", 23),
722734
GATE_IFR5(CLK_IFR_I2C0_AXI, "ifr_i2c0_axi", "i2c_sel", 24),

0 commit comments

Comments
 (0)