ipq806x: 5.15: add krait-cc modernization patch and fixup
[openwrt/staging/dedeckeh.git] / target / linux / ipq806x / patches-5.15 / 121-08-clk-qcom-krait-cc-handle-secondary-mux-sourcing-out-.patch
1 From b6655ca513b3f1b40417287ab7f706409455fe48 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Thu, 15 Sep 2022 02:56:47 +0200
4 Subject: [PATCH 8/9] clk: qcom: krait-cc: handle secondary mux sourcing out of
5 PXO
6
7 The secondary mux can sourc out of PXO as the secondary MUX is attached
8 to QSB and to another mux that can source out of PXO or PLL8_VOTE.
9
10 Many device may run with uncorrect configuration with the mux sourcing
11 out of PXO instead of PLL8_VOTE.
12
13 To handle this case we add also PXO as required clocks and we check if
14 the frequency is currently set to PXO and force a correct rate if it's
15 the case.
16
17 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
18 ---
19 drivers/clk/qcom/krait-cc.c | 19 ++++++++++++++++++-
20 1 file changed, 18 insertions(+), 1 deletion(-)
21
22 diff --git a/drivers/clk/qcom/krait-cc.c b/drivers/clk/qcom/krait-cc.c
23 index e4fb3ff2b5b5..717eff44b6a4 100644
24 --- a/drivers/clk/qcom/krait-cc.c
25 +++ b/drivers/clk/qcom/krait-cc.c
26 @@ -317,7 +317,7 @@ static int krait_cc_probe(struct platform_device *pdev)
27 {
28 struct device *dev = &pdev->dev;
29 const struct of_device_id *id;
30 - unsigned long cur_rate, aux_rate, qsb_rate;
31 + unsigned long cur_rate, aux_rate, qsb_rate, pxo_rate;
32 int cpu;
33 struct clk *clk;
34 struct clk **clks;
35 @@ -327,6 +327,15 @@ static int krait_cc_probe(struct platform_device *pdev)
36 if (!id)
37 return -ENODEV;
38
39 + clk = clk_get(dev, "pxo");
40 + if (IS_ERR(clk))
41 + clk = __clk_lookup("pxo_board");
42 +
43 + if (IS_ERR_OR_NULL(clk))
44 + return clk == NULL ? -ENODEV : PTR_ERR(clk);
45 +
46 + pxo_rate = clk_get_rate(clk);
47 +
48 /*
49 * Per Documentation qsb should be provided from DTS.
50 * To address old implementation, register the fixed clock anyway.
51 @@ -394,6 +403,10 @@ static int krait_cc_probe(struct platform_device *pdev)
52 dev_info(dev, "L2 @ QSB rate. Forcing new rate.\n");
53 cur_rate = aux_rate;
54 }
55 + if (cur_rate == pxo_rate) {
56 + dev_info(dev, "L2 @ PXO rate. Forcing new rate.\n");
57 + cur_rate = aux_rate;
58 + }
59 clk_set_rate(l2_pri_mux_clk, aux_rate);
60 clk_set_rate(l2_pri_mux_clk, 2);
61 clk_set_rate(l2_pri_mux_clk, cur_rate);
62 @@ -405,6 +418,10 @@ static int krait_cc_probe(struct platform_device *pdev)
63 dev_info(dev, "CPU%d @ QSB rate. Forcing new rate.\n", cpu);
64 cur_rate = aux_rate;
65 }
66 + if (cur_rate ==pxo_rate) {
67 + dev_info(dev, "CPU%d @ PXO rate. Forcing new rate.\n", cpu);
68 + cur_rate = aux_rate;
69 + }
70
71 clk_set_rate(clk, aux_rate);
72 clk_set_rate(clk, 2);
73 --
74 2.37.2
75