1 From 898d0d6483a9360f1968e0a900465c1fa152a4a9 Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Sat, 30 Apr 2022 07:44:58 +0200
4 Subject: [PATCH 3/3] clk: qcom: clk-krait: add apq/ipq8064 errata workaround
6 Add apq/ipq8064 errata workaround where the sec_src clock gating needs to
7 be disabled during switching. krait-cc compatible is not enough to
8 handle this and limit this workaround to apq/ipq8064. We check machine
9 compatible to handle this.
11 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
12 Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
13 Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
14 Link: https://lore.kernel.org/r/20220430054458.31321-4-ansuelsmth@gmail.com
16 drivers/clk/qcom/clk-krait.c | 16 ++++++++++++++++
17 drivers/clk/qcom/clk-krait.h | 1 +
18 drivers/clk/qcom/krait-cc.c | 8 ++++++++
19 3 files changed, 25 insertions(+)
21 --- a/drivers/clk/qcom/clk-krait.c
22 +++ b/drivers/clk/qcom/clk-krait.c
24 static DEFINE_SPINLOCK(krait_clock_reg_lock);
27 +#define SECCLKAGD BIT(4)
29 static void __krait_mux_set_sel(struct krait_mux_clk *mux, int sel)
34 spin_lock_irqsave(&krait_clock_reg_lock, flags);
36 regval = krait_get_l2_indirect_reg(mux->offset);
38 + /* apq/ipq8064 Errata: disable sec_src clock gating during switch. */
39 + if (mux->disable_sec_src_gating) {
40 + regval |= SECCLKAGD;
41 + krait_set_l2_indirect_reg(mux->offset, regval);
44 regval &= ~(mux->mask << mux->shift);
45 regval |= (sel & mux->mask) << mux->shift;
47 @@ -33,6 +43,12 @@ static void __krait_mux_set_sel(struct k
49 krait_set_l2_indirect_reg(mux->offset, regval);
51 + /* apq/ipq8064 Errata: re-enabled sec_src clock gating. */
52 + if (mux->disable_sec_src_gating) {
53 + regval &= ~SECCLKAGD;
54 + krait_set_l2_indirect_reg(mux->offset, regval);
57 /* Wait for switch to complete. */
60 --- a/drivers/clk/qcom/clk-krait.h
61 +++ b/drivers/clk/qcom/clk-krait.h
62 @@ -15,6 +15,7 @@ struct krait_mux_clk {
66 + bool disable_sec_src_gating;
69 struct notifier_block clk_nb;
70 --- a/drivers/clk/qcom/krait-cc.c
71 +++ b/drivers/clk/qcom/krait-cc.c
72 @@ -139,6 +139,14 @@ krait_add_sec_mux(struct device *dev, in
76 + /* Checking for qcom,krait-cc-v1 or qcom,krait-cc-v2 is not
77 + * enough to limit this to apq/ipq8064. Directly check machine
78 + * compatible to correctly handle this errata.
80 + if (of_machine_is_compatible("qcom,ipq8064") ||
81 + of_machine_is_compatible("qcom,apq8064"))
82 + mux->disable_sec_src_gating = true;
84 init.name = kasprintf(GFP_KERNEL, "krait%s_sec_mux", s);