ipq806x: update clk and cpufreq drivers
[openwrt/openwrt.git] / target / linux / ipq806x / patches-4.9 / 0041-clk-qcom-Add-support-for-Krait-clocks.patch
index 902e49d60cb221e2ce3993c787fa89a8954d7329..a6d0f0d7a6d39ff4e26b3ff03cf5ea434ac7f298 100644 (file)
@@ -1,7 +1,19 @@
-From b9747125a8e7633ed2701a70e32dbb0442193774 Mon Sep 17 00:00:00 2001
+From patchwork Fri Dec  8 09:42:25 2017
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [v4,07/12] clk: qcom: Add support for Krait clocks
+From: Sricharan R <sricharan@codeaurora.org>
+X-Patchwork-Id: 10102051
+Message-Id: <1512726150-7204-8-git-send-email-sricharan@codeaurora.org>
+To: mturquette@baylibre.com, sboyd@codeaurora.org,
+ devicetree@vger.kernel.org, linux-pm@vger.kernel.org,
+ linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
+ viresh.kumar@linaro.org, linux-arm-kernel@lists.infradead.org
+Cc: sricharan@codeaurora.org
+Date: Fri,  8 Dec 2017 15:12:25 +0530
+
 From: Stephen Boyd <sboyd@codeaurora.org>
-Date: Fri, 20 Mar 2015 23:45:28 -0700
-Subject: [PATCH 41/69] clk: qcom: Add support for Krait clocks
 
 The Krait clocks are made up of a series of muxes and a divider
 that choose between a fixed rate clock and dedicated HFPLLs for
@@ -13,9 +25,9 @@ Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
 ---
  drivers/clk/qcom/Kconfig     |   4 ++
  drivers/clk/qcom/Makefile    |   1 +
- drivers/clk/qcom/clk-krait.c | 167 +++++++++++++++++++++++++++++++++++++++++++
- drivers/clk/qcom/clk-krait.h |  4+++++++++++++
- 4 files changed, 221 insertions(+)
+ drivers/clk/qcom/clk-krait.c | 134 +++++++++++++++++++++++++++++++++++++++++++
+ drivers/clk/qcom/clk-krait.h |  48 ++++++++++++++++
+ 4 files changed, 187 insertions(+)
  create mode 100644 drivers/clk/qcom/clk-krait.c
  create mode 100644 drivers/clk/qcom/clk-krait.h
 
@@ -41,7 +53,7 @@ Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
  clk-qcom-$(CONFIG_QCOM_GDSC) += gdsc.o
 --- /dev/null
 +++ b/drivers/clk/qcom/clk-krait.c
-@@ -0,0 +1,167 @@
+@@ -0,0 +1,134 @@
 +/*
 + * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
 + *
@@ -103,6 +115,7 @@ Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
 +      /* Don't touch mux if CPU is off as it won't work */
 +      if (__clk_is_enabled(hw->clk))
 +              __krait_mux_set_sel(mux, sel);
++
 +      return 0;
 +}
 +
@@ -119,44 +132,10 @@ Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
 +      return clk_mux_get_parent(hw, sel, mux->parent_map, 0);
 +}
 +
-+static struct clk_hw *krait_mux_get_safe_parent(struct clk_hw *hw,
-+                                              unsigned long *safe_freq)
-+{
-+      int i;
-+      struct krait_mux_clk *mux = to_krait_mux_clk(hw);
-+      int num_parents = clk_hw_get_num_parents(hw);
-+
-+      i = mux->safe_sel;
-+      for (i = 0; i < num_parents; i++)
-+              if (mux->safe_sel == mux->parent_map[i])
-+                      break;
-+
-+      return clk_hw_get_parent_by_index(hw, i);
-+}
-+
-+static int krait_mux_enable(struct clk_hw *hw)
-+{
-+      struct krait_mux_clk *mux = to_krait_mux_clk(hw);
-+
-+      __krait_mux_set_sel(mux, mux->en_mask);
-+
-+      return 0;
-+}
-+
-+static void krait_mux_disable(struct clk_hw *hw)
-+{
-+      struct krait_mux_clk *mux = to_krait_mux_clk(hw);
-+
-+      __krait_mux_set_sel(mux, mux->safe_sel);
-+}
-+
 +const struct clk_ops krait_mux_clk_ops = {
-+      .enable = krait_mux_enable,
-+      .disable = krait_mux_disable,
 +      .set_parent = krait_mux_set_parent,
 +      .get_parent = krait_mux_get_parent,
 +      .determine_rate = __clk_mux_determine_rate_closest,
-+      .get_safe_parent = krait_mux_get_safe_parent,
 +};
 +EXPORT_SYMBOL_GPL(krait_mux_clk_ops);
 +
@@ -169,7 +148,7 @@ Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
 +}
 +
 +static int krait_div2_set_rate(struct clk_hw *hw, unsigned long rate,
-+                      unsigned long parent_rate)
++                             unsigned long parent_rate)
 +{
 +      struct krait_div2_clk *d = to_krait_div2_clk(hw);
 +      unsigned long flags;
@@ -211,7 +190,7 @@ Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
 +EXPORT_SYMBOL_GPL(krait_div2_clk_ops);
 --- /dev/null
 +++ b/drivers/clk/qcom/clk-krait.h
-@@ -0,0 +1,49 @@
+@@ -0,0 +1,48 @@
 +/*
 + * Copyright (c) 2013, The Linux Foundation. All rights reserved.
 + *
@@ -232,8 +211,6 @@ Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
 +
 +struct krait_mux_clk {
 +      unsigned int    *parent_map;
-+      bool            has_safe_parent;
-+      u8              safe_sel;
 +      u32             offset;
 +      u32             mask;
 +      u32             shift;
@@ -241,6 +218,7 @@ Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
 +      bool            lpl;
 +
 +      struct clk_hw   hw;
++      struct notifier_block   clk_nb;
 +};
 +
 +#define to_krait_mux_clk(_hw) container_of(_hw, struct krait_mux_clk, hw)