These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / arch / arm / mach-shmobile / pm-rmobile.c
index 9501820..46d0a1d 100644 (file)
@@ -12,6 +12,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  */
+#include <linux/clk/shmobile.h>
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/of.h>
 #define PSTR_RETRIES   100
 #define PSTR_DELAY_US  10
 
+static inline
+struct rmobile_pm_domain *to_rmobile_pd(struct generic_pm_domain *d)
+{
+       return container_of(d, struct rmobile_pm_domain, genpd);
+}
+
 static int rmobile_pd_power_down(struct generic_pm_domain *genpd)
 {
        struct rmobile_pm_domain *rmobile_pd = to_rmobile_pd(genpd);
@@ -42,7 +49,7 @@ static int rmobile_pd_power_down(struct generic_pm_domain *genpd)
        if (rmobile_pd->bit_shift == ~0)
                return -EBUSY;
 
-       mask = 1 << rmobile_pd->bit_shift;
+       mask = BIT(rmobile_pd->bit_shift);
        if (rmobile_pd->suspend) {
                int ret = rmobile_pd->suspend();
 
@@ -79,7 +86,7 @@ static int __rmobile_pd_power_up(struct rmobile_pm_domain *rmobile_pd,
        if (rmobile_pd->bit_shift == ~0)
                return 0;
 
-       mask = 1 << rmobile_pd->bit_shift;
+       mask = BIT(rmobile_pd->bit_shift);
        if (__raw_readl(rmobile_pd->base + PSTR) & mask)
                goto out;
 
@@ -118,36 +125,6 @@ static bool rmobile_pd_active_wakeup(struct device *dev)
        return true;
 }
 
-static int rmobile_pd_attach_dev(struct generic_pm_domain *domain,
-                                struct device *dev)
-{
-       int error;
-
-       error = pm_clk_create(dev);
-       if (error) {
-               dev_err(dev, "pm_clk_create failed %d\n", error);
-               return error;
-       }
-
-       error = pm_clk_add(dev, NULL);
-       if (error) {
-               dev_err(dev, "pm_clk_add failed %d\n", error);
-               goto fail;
-       }
-
-       return 0;
-
-fail:
-       pm_clk_destroy(dev);
-       return error;
-}
-
-static void rmobile_pd_detach_dev(struct generic_pm_domain *domain,
-                                 struct device *dev)
-{
-       pm_clk_destroy(dev);
-}
-
 static void rmobile_init_pm_domain(struct rmobile_pm_domain *rmobile_pd)
 {
        struct generic_pm_domain *genpd = &rmobile_pd->genpd;
@@ -158,48 +135,11 @@ static void rmobile_init_pm_domain(struct rmobile_pm_domain *rmobile_pd)
        genpd->dev_ops.active_wakeup    = rmobile_pd_active_wakeup;
        genpd->power_off                = rmobile_pd_power_down;
        genpd->power_on                 = rmobile_pd_power_up;
-       genpd->attach_dev               = rmobile_pd_attach_dev;
-       genpd->detach_dev               = rmobile_pd_detach_dev;
+       genpd->attach_dev               = cpg_mstp_attach_dev;
+       genpd->detach_dev               = cpg_mstp_detach_dev;
        __rmobile_pd_power_up(rmobile_pd, false);
 }
 
-#ifdef CONFIG_ARCH_SHMOBILE_LEGACY
-
-void rmobile_init_domains(struct rmobile_pm_domain domains[], int num)
-{
-       int j;
-
-       for (j = 0; j < num; j++)
-               rmobile_init_pm_domain(&domains[j]);
-}
-
-void rmobile_add_device_to_domain_td(const char *domain_name,
-                                    struct platform_device *pdev,
-                                    struct gpd_timing_data *td)
-{
-       struct device *dev = &pdev->dev;
-
-       __pm_genpd_name_add_device(domain_name, dev, td);
-}
-
-void rmobile_add_devices_to_domains(struct pm_domain_device data[],
-                                   int size)
-{
-       struct gpd_timing_data latencies = {
-               .stop_latency_ns = DEFAULT_DEV_LATENCY_NS,
-               .start_latency_ns = DEFAULT_DEV_LATENCY_NS,
-               .save_state_latency_ns = DEFAULT_DEV_LATENCY_NS,
-               .restore_state_latency_ns = DEFAULT_DEV_LATENCY_NS,
-       };
-       int j;
-
-       for (j = 0; j < size; j++)
-               rmobile_add_device_to_domain_td(data[j].domain_name,
-                                               data[j].pdev, &latencies);
-}
-
-#else /* !CONFIG_ARCH_SHMOBILE_LEGACY */
-
 static int rmobile_pd_suspend_busy(void)
 {
        /*
@@ -373,8 +313,10 @@ static int __init rmobile_add_pm_domains(void __iomem *base,
                }
 
                pd = kzalloc(sizeof(*pd), GFP_KERNEL);
-               if (!pd)
+               if (!pd) {
+                       of_node_put(np);
                        return -ENOMEM;
+               }
 
                pd->genpd.name = np->name;
                pd->base = base;
@@ -430,5 +372,3 @@ static int __init rmobile_init_pm_domains(void)
 }
 
 core_initcall(rmobile_init_pm_domains);
-
-#endif /* !CONFIG_ARCH_SHMOBILE_LEGACY */