clk: qcom: cpu-8996: stability fixes
Subsystems (5)
v3 cover clk: qcom: cpu-8996: stability fixes
This series provides stability fixes for the MSM8996 boot process. It changes the order of calls during the CPU PLL setup, makes it use GPLL0 (through sys_apcs_aux) during PLL init, finetunes the ACD, etc.
Dependency: [1]
[1] https://lore.kernel.org/linux-arm-msm/[email protected]/
Changes since v2:
- Expanded commit message for the PLL frequency setup (Konrad)
- Removed the extra 'the' from the comment (Korad)
- Fixed indentation of the udelay in the PLL config sequence patch (Konrad)
Changes since v1:
- Included bindings update (Stephen)
Dmitry Baryshkov (14):
dt-bindings: clock: qcom,msm8996-apcc: add sys_apcs_aux clock
clk: qcom: clk-alpha-pll: program PLL_TEST/PLL_TEST_U if required
clk: qcom: cpu-8996: correct PLL programming
clk: qcom: cpu-8996: fix the init clock rate
clk: qcom: cpu-8996: support using GPLL0 as SMUX input
clk: qcom: cpu-8996: skip ACD init if the setup is valid
clk: qcom: cpu-8996: simplify the cpu_clk_notifier_cb
clk: qcom: cpu-8996: setup PLLs before registering clocks
clk: qcom: cpu-8996: move qcom_cpu_clk_msm8996_acd_init call
clk: qcom: cpu-8996: fix PLL configuration sequence
clk: qcom: cpu-8996: fix ACD initialization
clk: qcom: cpu-8996: fix PLL clock ops
clk: qcom: cpu-8996: change setup sequence to follow vendor kernel
arm64: dts: qcom: msm8996: support using GPLL0 as kryocc input
.../bindings/clock/qcom,msm8996-apcc.yaml | 6 +- arch/arm64/boot/dts/qcom/msm8996.dtsi | 4 +- drivers/clk/qcom/clk-alpha-pll.c | 5 + drivers/clk/qcom/clk-cpu-8996.c | 145 +++++++++++++----- 4 files changed, 115 insertions(+), 45 deletions(-)
Signature · 1 line
2.39.0
PATCH v3 1/14 dt-bindings: clock: qcom,msm8996-apcc: add sys_apcs_aux clock
The MSM8996 CPU clock controller can make use of the sys_apcs_aux clock. Add it to the bindings.
--- .../devicetree/bindings/clock/qcom,msm8996-apcc.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/clock/qcom,msm8996-apcc.yaml +4 -2
@@ -27,10 +27,12 @@ properties: clocks: items: - description: XO source + - description: SYS APCS AUX clock clock-names: items: - const: xo + - const: sys_apcs_aux required: - compatible
@@ -48,6 +50,6 @@ examples: reg = <0x6400000 0x90000>; #clock-cells = <1>; - clocks = <&xo_board>; - clock-names = "xo"; + clocks = <&xo_board>, <&apcs_glb>; + clock-names = "xo", "sys_apcs_aux"; };
Signature · 1 line
2.39.0
PATCH v3 2/14 clk: qcom: clk-alpha-pll: program PLL_TEST/PLL_TEST_U if required
In reply to Dmitry BaryshkovProgram PLL_TEST and PLL_TEST_U registers if required by the pll configuration.
--- drivers/clk/qcom/clk-alpha-pll.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/clk/qcom/clk-alpha-pll.c +5 -0
@@ -358,6 +358,11 @@ void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,regmap_update_bits (regmap,PLL_USER_CTL (pll), mask, val); +clk_alpha_pll_write_config (regmap,PLL_TEST_CTL (pll), + config->test_ctl_val); +clk_alpha_pll_write_config (regmap,PLL_TEST_CTL_U (pll), + config->test_ctl_hi_val); +if (pll->flags &SUPPORTS_FSM_MODE )qcom_pll_set_fsm_mode (regmap,PLL_MODE (pll),6 ,0 ); }
Signature · 1 line
2.39.0
Re: [PATCH v3 02/14] clk: qcom: clk-alpha-pll: program PLL_TEST/PLL_TEST_U if required
Quoted 5 lines · Dmitry Baryshkov
Program
PLL_TESTandPLL_TEST_Uregisters if required by the pll configuration.Signed-off-by Dmitry Baryshkov <[email protected]>---
Konrad
Quoted 19 lines
drivers/clk/qcom/clk-alpha-pll.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/clk/qcom/clk-alpha-pll.c +5
-0@@ -358,6 +358,11 @@ void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,regmap_update_bits (regmap,PLL_USER_CTL (pll), mask, val); +clk_alpha_pll_write_config (regmap,PLL_TEST_CTL (pll), + config->test_ctl_val); +clk_alpha_pll_write_config (regmap,PLL_TEST_CTL_U (pll), + config->test_ctl_hi_val); +if (pll->flags &SUPPORTS_FSM_MODE )qcom_pll_set_fsm_mode (regmap,PLL_MODE (pll),6 ,0 ); }
PATCH v3 3/14 clk: qcom: cpu-8996: correct PLL programming
In reply to Dmitry BaryshkovChange PLL programming to follow the downstream setup.
--- drivers/clk/qcom/clk-cpu-8996.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/clk/qcom/clk-cpu-8996.c +3 -4
@@ -93,12 +93,9 @@ static const u8 prim_pll_regs[PLL_OFF_MAX_REGS] = {static const u8 alt_pll_regs[PLL_OFF_MAX_REGS ] = { [PLL_OFF_L_VAL ] =0x04 , [PLL_OFF_ALPHA_VAL ] =0x08 , - [PLL_OFF_ALPHA_VAL_U ] =0x0c , [PLL_OFF_USER_CTL ] =0x10 , - [PLL_OFF_USER_CTL_U ] =0x14 , [PLL_OFF_CONFIG_CTL ] =0x18 , [PLL_OFF_TEST_CTL ] =0x20 , - [PLL_OFF_TEST_CTL_U ] =0x24 , [PLL_OFF_STATUS ] =0x28 , };
@@ -106,8 +103,10 @@ static const u8 alt_pll_regs[PLL_OFF_MAX_REGS] = {static const struct alpha_pll_config hfpll_config = { .l =60 , - .config_ctl_val =0x200d4aa8 , + .config_ctl_val =0x200d4828 , .config_ctl_hi_val =0x006 , + .test_ctl_val =0x1c000000 , + .test_ctl_hi_val =0x00004000 , .pre_div_mask =BIT (12 ), .post_div_mask =0x3 <<8 , .post_div_val =0x1 <<8 ,
Signature · 1 line
2.39.0
PATCH v3 4/14 clk: qcom: cpu-8996: fix the init clock rate
In reply to Dmitry BaryshkovCurrent multiplier (60) results in CPU getting the rate which is unlisted in the CPU frequency tables (60 * 19.2 = 1152 MHz). This results in warnings from the cpufreq during startup.
Change PLL programming (l = 54) to init CPU clocks to start with the frequency of 54 * 19.2 = 1036.8 MHz which is supported by both power and performance clusters from all speed bins.
--- drivers/clk/qcom/clk-cpu-8996.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/clk-cpu-8996.c +1 -1
@@ -102,7 +102,7 @@ static const u8 alt_pll_regs[PLL_OFF_MAX_REGS] = {/* PLLs */ static const struct alpha_pll_config hfpll_config = { - .l =60 , + .l =54 , .config_ctl_val =0x200d4828 , .config_ctl_hi_val =0x006 , .test_ctl_val =0x1c000000 ,
Signature · 1 line
2.39.0
Re: [PATCH v3 04/14] clk: qcom: cpu-8996: fix the init clock rate
Quoted 10 lines · Dmitry Baryshkov
Current multiplier (60) results in CPU getting the rate which is unlisted in the CPU frequency tables (60 * 19.2 = 1152 MHz). This results in warnings from the cpufreq during startup.
Change PLL programming (l = 54) to init CPU clocks to start with the frequency of 54 * 19.2 = 1036.8 MHz which is supported by both power and performance clusters from all speed bins.
Signed-off-by Dmitry Baryshkov <[email protected]>---
Konrad
Quoted 16 lines
drivers/clk/qcom/clk-cpu-8996.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/clk/qcom/clk-cpu-8996.c +1
-1@@ -102,7 +102,7 @@ static const u8 alt_pll_regs[PLL_OFF_MAX_REGS] = {/* PLLs */ static const struct alpha_pll_config hfpll_config = { - .l =60 , + .l =54 , .config_ctl_val =0x200d4828 , .config_ctl_hi_val =0x006 , .test_ctl_val =0x1c000000 ,
PATCH v3 5/14 clk: qcom: cpu-8996: support using GPLL0 as SMUX input
In reply to Dmitry BaryshkovIn some cases the driver might need using GPLL0 to drive CPU clocks. Bring it in through the sys_apcs_aux clock.
--- drivers/clk/qcom/clk-cpu-8996.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/clk/qcom/clk-cpu-8996.c +12 -0
@@ -12,6 +12,8 @@* +-------+ * XO | | * +------------------>0 | +* SYS_APCS_AUX | | +* +------------------>3 | * | | * PLL/2 | SMUX +----+ * +------->1 | |
@@ -310,20 +312,29 @@ static const struct clk_ops clk_cpu_8996_pmux_ops = { .determine_rate = clk_cpu_8996_pmux_determine_rate, }; +static const struct parent_map smux_parent_map[] = { + { .cfg =0 , },/* xo */ + { .cfg =1 , },/* pll */ + { .cfg =3 , },/* sys_apcs_aux */ +}; +static const struct clk_parent_data pwrcl_smux_parents[] = { { .fw_name ="xo" }, { .hw = &pwrcl_pll_postdiv.hw }, + { .fw_name ="sys_apcs_aux" }, };static const struct clk_parent_data perfcl_smux_parents[] = { { .fw_name ="xo" }, { .hw = &perfcl_pll_postdiv.hw }, + { .fw_name ="sys_apcs_aux" }, };static struct clk_regmap_mux pwrcl_smux = { .reg =PWRCL_REG_OFFSET +MUX_OFFSET , .shift =2 , .width =2 , + .parent_map = smux_parent_map, .clkr.hw.init = &(struct clk_init_data ) { .name ="pwrcl_smux" , .parent_data = pwrcl_smux_parents,
@@ -337,6 +348,7 @@ static struct clk_regmap_mux perfcl_smux = { .reg = PERFCL_REG_OFFSET + MUX_OFFSET, .shift = 2, .width = 2, + .parent_map = smux_parent_map, .clkr.hw.init = &(struct clk_init_data ) { .name ="perfcl_smux" , .parent_data = perfcl_smux_parents,
Signature · 1 line
2.39.0
PATCH v3 6/14 clk: qcom: cpu-8996: skip ACD init if the setup is valid
In reply to Dmitry BaryshkovCheck whether L2 registers contain correct values and skip programming if they are valid. This follows the code present downstream.
--- drivers/clk/qcom/clk-cpu-8996.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/clk/qcom/clk-cpu-8996.c +6 -0
@@ -472,10 +472,15 @@ static void __iomem *base;static void qcom_cpu_clk_msm8996_acd_init (void __iomem *base) {u64 hwid; +u32 val;unsigned long flags;spin_lock_irqsave (&qcom_clk_acd_lock, flags); + val =kryo_l2_get_indirect_reg (L2ACDTD_REG ); +if (val ==0x00006a11 ) + goto out; + hwid =read_cpuid_mpidr () &CPU_AFINITY_MASK ;kryo_l2_set_indirect_reg (L2ACDTD_REG ,0x00006a11 );
@@ -492,6 +497,7 @@ static void qcom_cpu_clk_msm8996_acd_init(void __iomem *base)writel (0xf , base +PERFCL_REG_OFFSET +SSSCTL_OFFSET ); } +out:spin_unlock_irqrestore (&qcom_clk_acd_lock, flags); }
Signature · 1 line
2.39.0
PATCH v3 7/14 clk: qcom: cpu-8996: simplify the cpu_clk_notifier_cb
In reply to Dmitry Baryshkov- Do not use the Alt PLL completely. Switch to smux when necessary to prevent overvolting
- Restore the parent in case the rate change aborts for some reason
- Do not duplicate resetting the parent in set_parent operation.
--- drivers/clk/qcom/clk-cpu-8996.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
drivers/clk/qcom/clk-cpu-8996.c +19 -12
@@ -506,27 +506,34 @@ static int cpu_clk_notifier_cb(struct notifier_block *nb, unsigned long event, {struct clk_cpu_8996_pmux *cpuclk =to_clk_cpu_8996_pmux_nb (nb);struct clk_notifier_data *cnd = data; -int ret;switch (event) {case PRE_RATE_CHANGE : - ret =clk_cpu_8996_pmux_set_parent (&cpuclk->clkr.hw,ALT_INDEX );qcom_cpu_clk_msm8996_acd_init (base); + +/* +* Avoid overvolting. clk_core_set_rate_nolock() walks from top +* to bottom, so it will change the rate of the PLL before +* chaging the parent of PMUX. This can result in pmux getting +* clocked twice the expected rate. +* +* Manually switch to PLL/2 here. +*/ +if (cnd->new_rate <DIV_2_THRESHOLD && + cnd->old_rate >DIV_2_THRESHOLD ) +clk_cpu_8996_pmux_set_parent (&cpuclk->clkr.hw,SMUX_INDEX ); +break ; -case POST_RATE_CHANGE : -if (cnd->new_rate <DIV_2_THRESHOLD ) - ret =clk_cpu_8996_pmux_set_parent (&cpuclk->clkr.hw, -SMUX_INDEX ); -else - ret =clk_cpu_8996_pmux_set_parent (&cpuclk->clkr.hw, -ACD_INDEX ); -break ; +case ABORT_RATE_CHANGE : +/* Revert manual change */ +if (cnd->new_rate <DIV_2_THRESHOLD && + cnd->old_rate >DIV_2_THRESHOLD ) +clk_cpu_8996_pmux_set_parent (&cpuclk->clkr.hw,ACD_INDEX );default : - ret =0 ;break ; } -return notifier_from_errno (ret); +return NOTIFY_OK ; };static int qcom_cpu_clk_msm8996_driver_probe (struct platform_device *pdev)
Signature · 1 line
2.39.0
PATCH v3 8/14 clk: qcom: cpu-8996: setup PLLs before registering clocks
In reply to Dmitry BaryshkovSetup all PLLs before registering clocks in the common clock framework. This ensures that the clocks are not accessed before being setup in the known way and that the CCF is in sync with the actual HW programming.
--- drivers/clk/qcom/clk-cpu-8996.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/clk/qcom/clk-cpu-8996.c +5 -5
@@ -430,6 +430,11 @@ static int qcom_cpu_clk_msm8996_register_clks(struct device *dev, {int i, ret; +clk_alpha_pll_configure (&pwrcl_pll, regmap, &hfpll_config); +clk_alpha_pll_configure (&perfcl_pll, regmap, &hfpll_config); +clk_alpha_pll_configure (&pwrcl_alt_pll, regmap, &altpll_config); +clk_alpha_pll_configure (&perfcl_alt_pll, regmap, &altpll_config); +for (i =0 ; i <ARRAY_SIZE (cpu_msm8996_hw_clks); i++) { ret =devm_clk_hw_register (dev, cpu_msm8996_hw_clks[i]);if (ret)
@@ -442,11 +447,6 @@ static int qcom_cpu_clk_msm8996_register_clks(struct device *dev,return ret; } -clk_alpha_pll_configure (&pwrcl_pll, regmap, &hfpll_config); -clk_alpha_pll_configure (&perfcl_pll, regmap, &hfpll_config); -clk_alpha_pll_configure (&pwrcl_alt_pll, regmap, &altpll_config); -clk_alpha_pll_configure (&perfcl_alt_pll, regmap, &altpll_config); -/* Enable alt PLLs */ clk_prepare_enable (pwrcl_alt_pll.clkr.hw.clk);clk_prepare_enable (perfcl_alt_pll.clkr.hw.clk);
Signature · 1 line
2.39.0
PATCH v3 9/14 clk: qcom: cpu-8996: move qcom_cpu_clk_msm8996_acd_init call
In reply to Dmitry BaryshkovInitialize ACD configuration from qcom_cpu_clk_msm8996_register_clks(), before registering all clocks. This way we can be sure that the clock is fully configured before letting CCF touch it.
--- drivers/clk/qcom/clk-cpu-8996.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/clk/qcom/clk-cpu-8996.c +9 -7
@@ -425,6 +425,8 @@ static struct clk_regmap *cpu_msm8996_clks[] = { &perfcl_pmux.clkr, }; +static void qcom_cpu_clk_msm8996_acd_init (struct regmap *regmap); +static int qcom_cpu_clk_msm8996_register_clks (struct device *dev,struct regmap *regmap) {
@@ -435,6 +437,8 @@ static int qcom_cpu_clk_msm8996_register_clks(struct device *dev,clk_alpha_pll_configure (&pwrcl_alt_pll, regmap, &altpll_config);clk_alpha_pll_configure (&perfcl_alt_pll, regmap, &altpll_config); +qcom_cpu_clk_msm8996_acd_init (regmap); +for (i =0 ; i <ARRAY_SIZE (cpu_msm8996_hw_clks); i++) { ret =devm_clk_hw_register (dev, cpu_msm8996_hw_clks[i]);if (ret)
@@ -467,9 +471,8 @@ static int qcom_cpu_clk_msm8996_register_clks(struct device *dev,#define L2ACDSSCR_REG 0x589ULLstatic DEFINE_SPINLOCK (qcom_clk_acd_lock); -static void __iomem *base; -static void qcom_cpu_clk_msm8996_acd_init (void __iomem *base) +static void qcom_cpu_clk_msm8996_acd_init (struct regmap *regmap) {u64 hwid;u32 val;
@@ -488,13 +491,13 @@ static void qcom_cpu_clk_msm8996_acd_init(void __iomem *base)kryo_l2_set_indirect_reg (L2ACDSSCR_REG ,0x00000601 );if (PWRCL_CPU_REG_MASK == (hwid |PWRCL_CPU_REG_MASK )) { -writel (0xf , base +PWRCL_REG_OFFSET +SSSCTL_OFFSET ); +regmap_write (regmap,PWRCL_REG_OFFSET +SSSCTL_OFFSET ,0xf );kryo_l2_set_indirect_reg (L2ACDCR_REG ,0x002c5ffd ); }if (PERFCL_CPU_REG_MASK == (hwid |PERFCL_CPU_REG_MASK )) {kryo_l2_set_indirect_reg (L2ACDCR_REG ,0x002c5ffd ); -writel (0xf , base +PERFCL_REG_OFFSET +SSSCTL_OFFSET ); +regmap_write (regmap,PERFCL_REG_OFFSET +SSSCTL_OFFSET ,0xf ); } out:
@@ -509,7 +512,7 @@ static int cpu_clk_notifier_cb(struct notifier_block *nb, unsigned long event,switch (event) {case PRE_RATE_CHANGE : -qcom_cpu_clk_msm8996_acd_init (base); +qcom_cpu_clk_msm8996_acd_init (cpuclk->clkr.regmap);/* * Avoid overvolting. clk_core_set_rate_nolock() walks from top
@@ -538,6 +541,7 @@ static int cpu_clk_notifier_cb(struct notifier_block *nb, unsigned long event,static int qcom_cpu_clk_msm8996_driver_probe (struct platform_device *pdev) { +static void __iomem *base;struct regmap *regmap;struct clk_hw_onecell_data *data;struct device *dev = &pdev->dev;
@@ -559,8 +563,6 @@ static int qcom_cpu_clk_msm8996_driver_probe(struct platform_device *pdev)if (ret)return ret; -qcom_cpu_clk_msm8996_acd_init (base); - data->hws[0 ] = &pwrcl_pmux.clkr.hw; data->hws[1 ] = &perfcl_pmux.clkr.hw; data->num =2 ;
Signature · 1 line
2.39.0
PATCH v3 10/14 clk: qcom: cpu-8996: fix PLL configuration sequence
In reply to Dmitry BaryshkovSwitch both power and performance clocks to the GPLL0/2 (sys_apcs_aux) before PLL configuration. Switch them to the ACD afterwards.
--- drivers/clk/qcom/clk-cpu-8996.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/clk/qcom/clk-cpu-8996.c +14 -0
@@ -432,13 +432,27 @@ static int qcom_cpu_clk_msm8996_register_clks(struct device *dev, {int i, ret; +/* Select GPLL0 for 300MHz for both clusters */ +regmap_write (regmap,PERFCL_REG_OFFSET +MUX_OFFSET ,0xc ); +regmap_write (regmap,PWRCL_REG_OFFSET +MUX_OFFSET ,0xc ); + +/* Ensure write goes through before PLLs are reconfigured */ +udelay (5 ); +clk_alpha_pll_configure (&pwrcl_pll, regmap, &hfpll_config);clk_alpha_pll_configure (&perfcl_pll, regmap, &hfpll_config);clk_alpha_pll_configure (&pwrcl_alt_pll, regmap, &altpll_config);clk_alpha_pll_configure (&perfcl_alt_pll, regmap, &altpll_config); +/* Wait for PLL(s) to lock */ +udelay (50 ); +qcom_cpu_clk_msm8996_acd_init (regmap); +/* Switch clusters to use the ACD leg */ +regmap_write (regmap,PWRCL_REG_OFFSET +MUX_OFFSET ,0x2 ); +regmap_write (regmap,PERFCL_REG_OFFSET +MUX_OFFSET ,0x2 ); +for (i =0 ; i <ARRAY_SIZE (cpu_msm8996_hw_clks); i++) { ret =devm_clk_hw_register (dev, cpu_msm8996_hw_clks[i]);if (ret)
Signature · 1 line
2.39.0
Re: [PATCH v3 10/14] clk: qcom: cpu-8996: fix PLL configuration sequence
Quoted 5 lines · Dmitry Baryshkov
Switch both power and performance clocks to the GPLL0/2 (
sys_apcs_aux) before PLL configuration. Switch them to the ACD afterwards.Signed-off-by Dmitry Baryshkov <[email protected]>---
Konrad
Quoted 35 lines
drivers/clk/qcom/clk-cpu-8996.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/clk/qcom/clk-cpu-8996.c +14
-0@@ -432,13 +432,27 @@ static int qcom_cpu_clk_msm8996_register_clks(struct device *dev, {int i, ret; +/* Select GPLL0 for 300MHz for both clusters */ +regmap_write (regmap,PERFCL_REG_OFFSET +MUX_OFFSET ,0xc ); +regmap_write (regmap,PWRCL_REG_OFFSET +MUX_OFFSET ,0xc ); + +/* Ensure write goes through before PLLs are reconfigured */ +udelay (5 ); +clk_alpha_pll_configure (&pwrcl_pll, regmap, &hfpll_config);clk_alpha_pll_configure (&perfcl_pll, regmap, &hfpll_config);clk_alpha_pll_configure (&pwrcl_alt_pll, regmap, &altpll_config);clk_alpha_pll_configure (&perfcl_alt_pll, regmap, &altpll_config); +/* Wait for PLL(s) to lock */ +udelay (50 ); +qcom_cpu_clk_msm8996_acd_init (regmap); +/* Switch clusters to use the ACD leg */ +regmap_write (regmap,PWRCL_REG_OFFSET +MUX_OFFSET ,0x2 ); +regmap_write (regmap,PERFCL_REG_OFFSET +MUX_OFFSET ,0x2 ); +for (i =0 ; i <ARRAY_SIZE (cpu_msm8996_hw_clks); i++) { ret =devm_clk_hw_register (dev, cpu_msm8996_hw_clks[i]);if (ret)
PATCH v3 11/14 clk: qcom: cpu-8996: fix ACD initialization
In reply to Dmitry BaryshkovThe vendor kernel applies different order while programming SSSCTL and L2ACDCR registers on power and performance clusters. However it was demonstrated that doing this upstream results in the board reset. Make both clusters use the same sequence, which fixes the reset.
--- drivers/clk/qcom/clk-cpu-8996.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/clk/qcom/clk-cpu-8996.c +8 -12
@@ -475,9 +475,9 @@ static int qcom_cpu_clk_msm8996_register_clks(struct device *dev,return ret; } -#define CPU_AFINITY_MASK 0xFFF -#define PWRCL_CPU_REG_MASK 0x3 -#define PERFCL_CPU_REG_MASK 0x103 +#define CPU_CLUSTER_AFFINITY_MASK 0xf00 +#define PWRCL_AFFINITY_MASK 0x000 +#define PERFCL_AFFINITY_MASK 0x100#define L2ACDCR_REG 0x580ULL#define L2ACDTD_REG 0x581ULL
@@ -498,21 +498,17 @@ static void qcom_cpu_clk_msm8996_acd_init(struct regmap *regmap)if (val ==0x00006a11 ) goto out; - hwid =read_cpuid_mpidr () &CPU_AFINITY_MASK ; -kryo_l2_set_indirect_reg (L2ACDTD_REG ,0x00006a11 );kryo_l2_set_indirect_reg (L2ACDDVMRC_REG ,0x000e0f0f );kryo_l2_set_indirect_reg (L2ACDSSCR_REG ,0x00000601 ); -if (PWRCL_CPU_REG_MASK == (hwid |PWRCL_CPU_REG_MASK )) { -regmap_write (regmap,PWRCL_REG_OFFSET +SSSCTL_OFFSET ,0xf ); -kryo_l2_set_indirect_reg (L2ACDCR_REG ,0x002c5ffd ); - } +kryo_l2_set_indirect_reg (L2ACDCR_REG ,0x002c5ffd ); -if (PERFCL_CPU_REG_MASK == (hwid |PERFCL_CPU_REG_MASK )) { -kryo_l2_set_indirect_reg (L2ACDCR_REG ,0x002c5ffd ); + hwid =read_cpuid_mpidr (); +if ((hwid &CPU_CLUSTER_AFFINITY_MASK ) ==PWRCL_AFFINITY_MASK ) +regmap_write (regmap,PWRCL_REG_OFFSET +SSSCTL_OFFSET ,0xf ); +else regmap_write (regmap,PERFCL_REG_OFFSET +SSSCTL_OFFSET ,0xf ); - } out:spin_unlock_irqrestore (&qcom_clk_acd_lock, flags);
Signature · 1 line
2.39.0
Re: [PATCH v3 11/14] clk: qcom: cpu-8996: fix ACD initialization
Quoted 7 lines · Dmitry Baryshkov
The vendor kernel applies different order while programming SSSCTL and L2ACDCR registers on power and performance clusters. However it was demonstrated that doing this upstream results in the board reset. Make both clusters use the same sequence, which fixes the reset.
Signed-off-by Dmitry Baryshkov <[email protected]>---
Konrad
Quoted 47 lines
drivers/clk/qcom/clk-cpu-8996.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)drivers/clk/qcom/clk-cpu-8996.c +8
-12@@ -475,9 +475,9 @@ static int qcom_cpu_clk_msm8996_register_clks(struct device *dev,return ret; } -#define CPU_AFINITY_MASK 0xFFF -#define PWRCL_CPU_REG_MASK 0x3 -#define PERFCL_CPU_REG_MASK 0x103 +#define CPU_CLUSTER_AFFINITY_MASK 0xf00 +#define PWRCL_AFFINITY_MASK 0x000 +#define PERFCL_AFFINITY_MASK 0x100#define L2ACDCR_REG 0x580ULL#define L2ACDTD_REG 0x581ULL@@ -498,21 +498,17 @@ static void qcom_cpu_clk_msm8996_acd_init(struct regmap *regmap)if (val ==0x00006a11 ) goto out; - hwid =read_cpuid_mpidr () &CPU_AFINITY_MASK ; -kryo_l2_set_indirect_reg (L2ACDTD_REG ,0x00006a11 );kryo_l2_set_indirect_reg (L2ACDDVMRC_REG ,0x000e0f0f );kryo_l2_set_indirect_reg (L2ACDSSCR_REG ,0x00000601 ); -if (PWRCL_CPU_REG_MASK == (hwid |PWRCL_CPU_REG_MASK )) { -regmap_write (regmap,PWRCL_REG_OFFSET +SSSCTL_OFFSET ,0xf ); -kryo_l2_set_indirect_reg (L2ACDCR_REG ,0x002c5ffd ); - } +kryo_l2_set_indirect_reg (L2ACDCR_REG ,0x002c5ffd ); -if (PERFCL_CPU_REG_MASK == (hwid |PERFCL_CPU_REG_MASK )) { -kryo_l2_set_indirect_reg (L2ACDCR_REG ,0x002c5ffd ); + hwid =read_cpuid_mpidr (); +if ((hwid &CPU_CLUSTER_AFFINITY_MASK ) ==PWRCL_AFFINITY_MASK ) +regmap_write (regmap,PWRCL_REG_OFFSET +SSSCTL_OFFSET ,0xf ); +else regmap_write (regmap,PERFCL_REG_OFFSET +SSSCTL_OFFSET ,0xf ); - } out:spin_unlock_irqrestore (&qcom_clk_acd_lock, flags);
PATCH v3 12/14 clk: qcom: cpu-8996: fix PLL clock ops
In reply to Dmitry BaryshkovSwitch CPU PLLs to use clk_alpha_pll_hwfsm_ops, it seems to suit better.
--- drivers/clk/qcom/clk-cpu-8996.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/clk-cpu-8996.c +2 -2
@@ -128,7 +128,7 @@ static struct clk_alpha_pll pwrcl_pll = { .name = "pwrcl_pll", .parent_data = pll_parent, .num_parents = ARRAY_SIZE(pll_parent), - .ops = &clk_alpha_pll_huayra_ops, + .ops = &clk_alpha_pll_hwfsm_ops, }, };
@@ -140,7 +140,7 @@ static struct clk_alpha_pll perfcl_pll = { .name = "perfcl_pll", .parent_data = pll_parent, .num_parents = ARRAY_SIZE(pll_parent), - .ops = &clk_alpha_pll_huayra_ops, + .ops = &clk_alpha_pll_hwfsm_ops, }, };
Signature · 1 line
2.39.0
Re: [PATCH v3 12/14] clk: qcom: cpu-8996: fix PLL clock ops
Quoted 5 lines · Dmitry Baryshkov
Switch CPU PLLs to use
clk_alpha_pll_hwfsm_ops, it seems to suit better.Signed-off-by Dmitry Baryshkov <[email protected]>---
Konrad
Quoted 25 lines
drivers/clk/qcom/clk-cpu-8996.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/clk/qcom/clk-cpu-8996.c +2
-2@@ -128,7 +128,7 @@ static struct clk_alpha_pll pwrcl_pll = { .name = "pwrcl_pll", .parent_data = pll_parent, .num_parents = ARRAY_SIZE(pll_parent), - .ops = &clk_alpha_pll_huayra_ops, + .ops = &clk_alpha_pll_hwfsm_ops, }, };@@ -140,7 +140,7 @@ static struct clk_alpha_pll perfcl_pll = { .name = "perfcl_pll", .parent_data = pll_parent, .num_parents = ARRAY_SIZE(pll_parent), - .ops = &clk_alpha_pll_huayra_ops, + .ops = &clk_alpha_pll_hwfsm_ops, }, };
PATCH v3 13/14 clk: qcom: cpu-8996: change setup sequence to follow vendor kernel
In reply to Dmitry BaryshkovAdd missing register writes to CPU clocks setup procedure. This makes it follow the setup procedure used in msm-3.18 kernel.
--- drivers/clk/qcom/clk-cpu-8996.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
drivers/clk/qcom/clk-cpu-8996.c +29 -2
@@ -76,10 +76,16 @@ enum _pmux_input {#define PWRCL_REG_OFFSET 0x0#define PERFCL_REG_OFFSET 0x80000#define MUX_OFFSET 0x40 +#define CLK_CTL_OFFSET 0x44 +#define CLK_CTL_AUTO_CLK_SEL BIT(8)#define ALT_PLL_OFFSET 0x100#define SSSCTL_OFFSET 0x160 +#define PSCTL_OFFSET 0x164#define PMUX_MASK 0x3 +#define MUX_AUTO_CLK_SEL_ALWAYS_ON_MASK GENMASK(5, 4) +#define MUX_AUTO_CLK_SEL_ALWAYS_ON_GPLL0_SEL \ + FIELD_PREP(MUX_AUTO_CLK_SEL_ALWAYS_ON_MASK, 0x03)static const u8 prim_pll_regs[PLL_OFF_MAX_REGS ] = { [PLL_OFF_L_VAL ] =0x04 ,
@@ -439,6 +445,14 @@ static int qcom_cpu_clk_msm8996_register_clks(struct device *dev,/* Ensure write goes through before PLLs are reconfigured */ udelay (5 ); +/* Set the auto clock sel always-on source to GPLL0/2 (300MHz) */ +regmap_update_bits (regmap,PWRCL_REG_OFFSET +MUX_OFFSET , +MUX_AUTO_CLK_SEL_ALWAYS_ON_MASK , +MUX_AUTO_CLK_SEL_ALWAYS_ON_GPLL0_SEL ); +regmap_update_bits (regmap,PERFCL_REG_OFFSET +MUX_OFFSET , +MUX_AUTO_CLK_SEL_ALWAYS_ON_MASK , +MUX_AUTO_CLK_SEL_ALWAYS_ON_GPLL0_SEL ); +clk_alpha_pll_configure (&pwrcl_pll, regmap, &hfpll_config);clk_alpha_pll_configure (&perfcl_pll, regmap, &hfpll_config);clk_alpha_pll_configure (&pwrcl_alt_pll, regmap, &altpll_config);
@@ -447,11 +461,24 @@ static int qcom_cpu_clk_msm8996_register_clks(struct device *dev,/* Wait for PLL(s) to lock */ udelay (50 ); +/* Enable auto clock selection for both clusters */ +regmap_update_bits (regmap,PWRCL_REG_OFFSET +CLK_CTL_OFFSET , +CLK_CTL_AUTO_CLK_SEL ,CLK_CTL_AUTO_CLK_SEL ); +regmap_update_bits (regmap,PERFCL_REG_OFFSET +CLK_CTL_OFFSET , +CLK_CTL_AUTO_CLK_SEL ,CLK_CTL_AUTO_CLK_SEL ); + +/* Ensure write goes through before muxes are switched */ +udelay (5 ); +qcom_cpu_clk_msm8996_acd_init (regmap); +/* Pulse swallower and soft-start settings */ +regmap_write (regmap,PWRCL_REG_OFFSET +PSCTL_OFFSET ,0x00030005 ); +regmap_write (regmap,PERFCL_REG_OFFSET +PSCTL_OFFSET ,0x00030005 ); +/* Switch clusters to use the ACD leg */ -regmap_write (regmap,PWRCL_REG_OFFSET +MUX_OFFSET ,0x2 ); -regmap_write (regmap,PERFCL_REG_OFFSET +MUX_OFFSET ,0x2 ); +regmap_write (regmap,PWRCL_REG_OFFSET +MUX_OFFSET ,0x32 ); +regmap_write (regmap,PERFCL_REG_OFFSET +MUX_OFFSET ,0x32 );for (i =0 ; i <ARRAY_SIZE (cpu_msm8996_hw_clks); i++) { ret =devm_clk_hw_register (dev, cpu_msm8996_hw_clks[i]);
Signature · 1 line
2.39.0
PATCH v3 14/14 arm64: dts: qcom: msm8996: support using GPLL0 as kryocc input
In reply to Dmitry BaryshkovIn some cases the driver might need using GPLL0 to drive CPU clocks. Bring it in through the sys_apcs_aux clock.
--- arch/arm64/boot/dts/qcom/msm8996.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/msm8996.dtsi +2 -2
@@ -2948,8 +2948,8 @@ kryocc: clock-controller@6400000 { compatible = "qcom,msm8996-apcc"; reg = <0x06400000 0x90000>; - clock-names = "xo"; - clocks = <&rpmcc RPM_SMD_BB_CLK1>; + clock-names = "xo", "sys_apcs_aux"; + clocks = <&rpmcc RPM_SMD_BB_CLK1>, <&apcs_glb>; #clock-cells = <1>; };
Signature · 1 line
2.39.0
Re: (subset) [PATCH v3 00/14] clk: qcom: cpu-8996: stability fixes
In reply to Dmitry BaryshkovQuoted 9 lines · Dmitry Baryshkov
This series provides stability fixes for the MSM8996 boot process. It changes the order of calls during the CPU PLL setup, makes it use GPLL0 (through
sys_apcs_aux) during PLL init, finetunes the ACD, etc.Dependency: [1]
[1] https://lore.kernel.org/linux-arm-msm/[email protected]/
[...]
Applied, thanks!
[14/14] arm64: dts: qcom: msm8996: support using GPLL0 as kryocc input
commit: ac0d84d4556cecf81ba0b1631d25d9a395235a5c
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>