On newer SoCs like Milos the CAMSS_TOP_GDSC power domains requires the
enablement of the multimedia NoC, otherwise the GDSC will be stuck on
'off'.

Add support for getting an interconnect path as specified in the SoC
clock driver, and enabling/disabling that interconnect path when the
GDSC is being enabled/disabled.

Signed-off-by: Luca Weiss <[email protected]>
---
icc_enable()/icc_disable() seems like a nice API but doesn't work
without setting the bandwidth first, so it's not very useful for this
driver, at least I couldn't figure out how to use it correctly.
---
 drivers/clk/qcom/gdsc.c | 19 +++++++++++++++++++
 drivers/clk/qcom/gdsc.h |  5 +++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c
index 7deabf8400cf..ff1acaa3e008 100644
--- a/drivers/clk/qcom/gdsc.c
+++ b/drivers/clk/qcom/gdsc.c
@@ -7,6 +7,7 @@
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/export.h>
+#include <linux/interconnect.h>
 #include <linux/jiffies.h>
 #include <linux/kernel.h>
 #include <linux/ktime.h>
@@ -261,6 +262,8 @@ static int gdsc_enable(struct generic_pm_domain *domain)
        struct gdsc *sc = domain_to_gdsc(domain);
        int ret;
 
+       icc_set_bw(sc->icc_path, 1, 1);
+
        if (sc->pwrsts == PWRSTS_ON)
                return gdsc_deassert_reset(sc);
 
@@ -360,6 +363,8 @@ static int gdsc_disable(struct generic_pm_domain *domain)
        if (sc->flags & CLAMP_IO)
                gdsc_assert_clamp_io(sc);
 
+       icc_set_bw(sc->icc_path, 0, 0);
+
        return 0;
 }
 
@@ -574,6 +579,20 @@ int gdsc_register(struct gdsc_desc *desc,
        if (!data->domains)
                return -ENOMEM;
 
+       for (i = 0; i < num; i++) {
+               if (!scs[i] || !scs[i]->needs_icc)
+                       continue;
+
+               scs[i]->icc_path = devm_of_icc_get_by_index(dev, 
scs[i]->icc_path_index);
+               if (IS_ERR(scs[i]->icc_path)) {
+                       ret = PTR_ERR(scs[i]->icc_path);
+                       if (ret != -ENODEV)
+                               return ret;
+
+                       scs[i]->icc_path = NULL;
+               }
+       }
+
        for (i = 0; i < num; i++) {
                if (!scs[i] || !scs[i]->supply)
                        continue;
diff --git a/drivers/clk/qcom/gdsc.h b/drivers/clk/qcom/gdsc.h
index dd843e86c05b..92ff6bcce7b1 100644
--- a/drivers/clk/qcom/gdsc.h
+++ b/drivers/clk/qcom/gdsc.h
@@ -9,6 +9,7 @@
 #include <linux/err.h>
 #include <linux/pm_domain.h>
 
+struct icc_path;
 struct regmap;
 struct regulator;
 struct reset_controller_dev;
@@ -74,6 +75,10 @@ struct gdsc {
 
        const char                      *supply;
        struct regulator                *rsupply;
+
+       bool                            needs_icc;
+       unsigned int                    icc_path_index;
+       struct icc_path                 *icc_path;
 };
 
 struct gdsc_desc {

-- 
2.52.0


Reply via email to