video: tegra: host: handle !PM_RUNTIME
Mayuresh Kulkarni [Thu, 27 Jun 2013 15:48:54 +0000 (20:48 +0530)]
when kernel config PM_RUNTIME is not enabled
we enable the clocks to module in .probe and
disable the clocks to module in .remove

bug 1303829

Change-Id: I95762df59db76972cfa7c942ec446fc4af0312f9
Signed-off-by: Mayuresh Kulkarni <mkulkarni@nvidia.com>
Reviewed-on: http://git-master/r/242964
Reviewed-by: Ken Adams <kadams@nvidia.com>
Tested-by: Ken Adams <kadams@nvidia.com>

13 files changed:
drivers/video/tegra/host/gk20a/gk20a.c
drivers/video/tegra/host/gk20a/gk20a.h
drivers/video/tegra/host/gr2d/gr2d.c
drivers/video/tegra/host/gr3d/gr3d.c
drivers/video/tegra/host/host1x/host1x.c
drivers/video/tegra/host/isp/isp.c
drivers/video/tegra/host/mpe/mpe.c
drivers/video/tegra/host/msenc/msenc.c
drivers/video/tegra/host/nvhost_acm.c
drivers/video/tegra/host/nvhost_acm.h
drivers/video/tegra/host/tsec/tsec.c
drivers/video/tegra/host/vi/vi.c
drivers/video/tegra/host/vic03/vic03.c

index fccb1fe..307890d 100644 (file)
@@ -596,6 +596,11 @@ int nvhost_init_gk20a_support(struct platform_device *dev)
 int nvhost_gk20a_init(struct platform_device *dev)
 {
        nvhost_dbg_fn("");
+
+#ifndef CONFIG_PM_RUNTIME
+       nvhost_gk20a_finalize_poweron(dev);
+#endif
+
        if (IS_ENABLED(CONFIG_TEGRA_GK20A_DEVFREQ))
                nvhost_gk20a_scale_hw_init(dev);
        return 0;
@@ -604,6 +609,9 @@ int nvhost_gk20a_init(struct platform_device *dev)
 static void nvhost_gk20a_deinit(struct platform_device *dev)
 {
        nvhost_dbg_fn("");
+#ifndef CONFIG_PM_RUNTIME
+       nvhost_gk20a_prepare_poweroff(dev);
+#endif
 }
 
 static void gk20a_free_hwctx(struct kref *ref)
@@ -852,12 +860,16 @@ static int gk20a_probe(struct platform_device *dev)
        pdata->pd.dev_ops.save_state = nvhost_module_prepare_poweroff;
 #endif
 
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay) {
                pm_runtime_set_autosuspend_delay(&dev->dev,
                        pdata->clockgate_delay);
                pm_runtime_use_autosuspend(&dev->dev);
        }
-       pm_runtime_enable(&dev->dev);
+       pm_runtime_enable(&dev->dev);
+#else
+       nvhost_module_enable_clk(&dev->dev);
+#endif
 
        err = nvhost_client_device_init(dev);
        if (err) {
@@ -888,6 +900,13 @@ static int __exit gk20a_remove(struct platform_device *dev)
        set_gk20a(dev, 0);
        kfree(g);
 
+#ifdef CONFIG_PM_RUNTIME
+       pm_runtime_put(&dev->dev);
+       pm_runtime_disable(&dev->dev);
+#else
+       nvhost_module_disable_clk(&dev->dev);
+#endif
+
        return 0;
 }
 
@@ -900,6 +919,9 @@ static struct platform_driver gk20a_driver = {
 #ifdef CONFIG_OF
                .of_match_table = tegra_gk20a_of_match,
 #endif
+#ifdef CONFIG_PM
+               .pm = &nvhost_module_pm_ops,
+#endif
        }
 };
 
index 664b5ba..ec74827 100644 (file)
@@ -199,5 +199,7 @@ static inline int support_gk20a_pmu(void)
 static inline int support_gk20a_pmu(void){return 0;}
 #endif
 
+int nvhost_gk20a_finalize_poweron(struct platform_device *dev);
+int nvhost_gk20a_prepare_poweroff(struct platform_device *dev);
 
 #endif /* _NVHOST_GK20A_H_ */
index bf1ac1c..ddbd289 100644 (file)
@@ -115,28 +115,40 @@ static int gr2d_probe(struct platform_device *dev)
        pdata->pd.dev_ops.restore_state = nvhost_module_finalize_poweron;
 #endif
 
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay) {
                pm_runtime_set_autosuspend_delay(&dev->dev,
                        pdata->clockgate_delay);
                pm_runtime_use_autosuspend(&dev->dev);
        }
        pm_runtime_enable(&dev->dev);
-
        pm_runtime_get_sync(&dev->dev);
+#else
+       nvhost_module_enable_clk(&dev->dev);
+#endif
+
        err = nvhost_client_device_init(dev);
+
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay)
                pm_runtime_put_sync_autosuspend(&dev->dev);
        else
                pm_runtime_put(&dev->dev);
        if (err)
                return err;
+#endif
 
        return 0;
 }
 
 static int __exit gr2d_remove(struct platform_device *dev)
 {
-       /* Add clean-up */
+#ifdef CONFIG_PM_RUNTIME
+       pm_runtime_put(&dev->dev);
+       pm_runtime_disable(&dev->dev);
+#else
+       nvhost_module_disable_clk(&dev->dev);
+#endif
        return 0;
 }
 
@@ -149,6 +161,9 @@ static struct platform_driver gr2d_driver = {
 #ifdef CONFIG_OF
                .of_match_table = tegra_gr2d_of_match,
 #endif
+#ifdef CONFIG_PM
+               .pm = &nvhost_module_pm_ops,
+#endif
        },
 };
 
index 01f473f..5d1b31f 100644 (file)
@@ -257,28 +257,39 @@ static int gr3d_probe(struct platform_device *dev)
        pdata->pd.domain.ops.resume = nvhost_client_device_resume;
 #endif
 
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay) {
                pm_runtime_set_autosuspend_delay(&dev->dev,
                        pdata->clockgate_delay);
                pm_runtime_use_autosuspend(&dev->dev);
        }
        pm_runtime_enable(&dev->dev);
-
        pm_runtime_get_sync(&dev->dev);
+#else
+       nvhost_module_enable_clk(&dev->dev);
+#endif
        err = nvhost_client_device_init(dev);
+
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay)
                pm_runtime_put_sync_autosuspend(&dev->dev);
        else
                pm_runtime_put(&dev->dev);
        if (err)
                return err;
+#endif
 
        return err;
 }
 
 static int __exit gr3d_remove(struct platform_device *dev)
 {
-       /* Add clean-up */
+#ifdef CONFIG_PM_RUNTIME
+       pm_runtime_put(&dev->dev);
+       pm_runtime_disable(&dev->dev);
+#else
+       nvhost_module_disable_clk(&dev->dev);
+#endif
        return 0;
 }
 
@@ -291,6 +302,9 @@ static struct platform_driver gr3d_driver = {
 #ifdef CONFIG_OF
                .of_match_table = tegra_gr3d_of_match,
 #endif
+#ifdef CONFIG_PM
+               .pm = &nvhost_module_pm_ops,
+#endif
        },
 };
 
index 38699bf..e71ac87 100644 (file)
@@ -565,7 +565,7 @@ static int nvhost_probe(struct platform_device *dev)
        struct nvhost_master *host;
        struct resource *regs;
        int syncpt_irq, generic_irq;
-       int i, err;
+       int err;
        struct nvhost_device_data *pdata = NULL;
 
        if (dev->dev.of_node) {
@@ -658,13 +658,11 @@ static int nvhost_probe(struct platform_device *dev)
        if (err)
                goto fail;
 
-       for (i = 0; i < pdata->num_clks; i++)
-               clk_prepare_enable(pdata->clk[i]);
-       nvhost_syncpt_reset(&host->syncpt);
-       for (i = 0; i < pdata->num_clks; i++)
-               clk_disable_unprepare(pdata->clk[i]);
-
+#ifdef CONFIG_PM_GENERIC_DOMAINS
        tegra_pd_add_device(&dev->dev);
+#endif
+
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay) {
                pm_runtime_set_autosuspend_delay(&dev->dev,
                        pdata->clockgate_delay);
@@ -672,6 +670,12 @@ static int nvhost_probe(struct platform_device *dev)
        }
        pm_runtime_enable(&dev->dev);
        pm_suspend_ignore_children(&dev->dev, true);
+       pm_runtime_get_sync(&dev->dev);
+#else
+       nvhost_module_enable_clk(&dev->dev);
+#endif
+
+       nvhost_syncpt_reset(&host->syncpt);
 
        nvhost_device_list_init();
        err = nvhost_device_list_add(dev);
@@ -680,6 +684,15 @@ static int nvhost_probe(struct platform_device *dev)
 
        nvhost_debug_init(host);
 
+#ifdef CONFIG_PM_RUNTIME
+       if (pdata->clockgate_delay)
+               pm_runtime_put_sync_autosuspend(&dev->dev);
+       else
+               pm_runtime_put(&dev->dev);
+       if (err)
+               return err;
+#endif
+
        dev_info(&dev->dev, "initialized\n");
        return 0;
 
@@ -697,6 +710,12 @@ static int __exit nvhost_remove(struct platform_device *dev)
        nvhost_intr_deinit(&host->intr);
        nvhost_syncpt_deinit(&host->syncpt);
        nvhost_free_resources(host);
+#ifdef CONFIG_PM_RUNTIME
+       pm_runtime_put(&dev->dev);
+       pm_runtime_disable(&dev->dev);
+#else
+       nvhost_module_disable_clk(&dev->dev);
+#endif
        return 0;
 }
 
index 547d9fd..75cf137 100644 (file)
@@ -127,20 +127,26 @@ static int isp_probe(struct platform_device *dev)
        if (err)
                return err;
 
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay) {
                pm_runtime_set_autosuspend_delay(&dev->dev,
                        pdata->clockgate_delay);
                pm_runtime_use_autosuspend(&dev->dev);
        }
-
        pm_runtime_enable(&dev->dev);
+#else
+       nvhost_module_enable_clk(&dev->dev);
+#endif
 
        return 0;
 }
 
 static int __exit isp_remove(struct platform_device *dev)
 {
-       /* Add clean-up */
+#ifdef CONFIG_PM_RUNTIME
+       pm_runtime_put(&dev->dev);
+       pm_runtime_disable(&dev->dev);
+#endif
        return 0;
 }
 
index 042b409..ae1a3d6 100644 (file)
@@ -710,28 +710,40 @@ static int mpe_probe(struct platform_device *dev)
        pdata->pd.domain.ops.resume = nvhost_client_device_resume;
 #endif
 
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay) {
                pm_runtime_set_autosuspend_delay(&dev->dev,
                        pdata->clockgate_delay);
                pm_runtime_use_autosuspend(&dev->dev);
        }
        pm_runtime_enable(&dev->dev);
-
        pm_runtime_get_sync(&dev->dev);
+#else
+       nvhost_module_enable_clk(&dev->dev);
+#endif
+
        err = nvhost_client_device_init(dev);
+
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay)
                pm_runtime_put_sync_autosuspend(&dev->dev);
        else
                pm_runtime_put(&dev->dev);
        if (err)
                return err;
+#endif
 
        return 0;
 }
 
 static int __exit mpe_remove(struct platform_device *dev)
 {
-       /* Add clean-up */
+#ifdef CONFIG_PM_RUNTIME
+       pm_runtime_put(&dev->dev);
+       pm_runtime_disable(&dev->dev);
+#else
+       nvhost_module_disable_clk(&dev->dev);
+#endif
        return 0;
 }
 
@@ -744,6 +756,9 @@ static struct platform_driver mpe_driver = {
 #ifdef CONFIG_OF
                .of_match_table = tegra_mpe_of_match,
 #endif
+#ifdef CONFIG_PM
+               .pm = &nvhost_module_pm_ops,
+#endif
        },
 };
 
index b383519..a09cc16 100644 (file)
@@ -496,32 +496,44 @@ static int msenc_probe(struct platform_device *dev)
 
        /* enable runtime pm. this is needed now since we need to call
         * _get_sync/_put during boot-up to ensure MC domain is ON */
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay) {
                pm_runtime_set_autosuspend_delay(&dev->dev,
                        pdata->clockgate_delay);
                pm_runtime_use_autosuspend(&dev->dev);
        }
        pm_runtime_enable(&dev->dev);
+       pm_runtime_get_sync(&dev->dev);
+#else
+       nvhost_module_enable_clk(&dev->dev);
+#endif
 
        err = nvhost_client_device_get_resources(dev);
        if (err)
                return err;
 
-       pm_runtime_get_sync(&dev->dev);
        err = nvhost_client_device_init(dev);
+
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay)
                pm_runtime_put_sync_autosuspend(&dev->dev);
        else
                pm_runtime_put(&dev->dev);
        if (err)
                return err;
+#endif
 
        return 0;
 }
 
 static int __exit msenc_remove(struct platform_device *dev)
 {
-       /* Add clean-up */
+#ifdef CONFIG_PM_RUNTIME
+       pm_runtime_put(&dev->dev);
+       pm_runtime_disable(&dev->dev);
+#else
+       nvhost_module_disable_clk(&dev->dev);
+#endif
        return 0;
 }
 
@@ -534,6 +546,9 @@ static struct platform_driver msenc_driver = {
 #ifdef CONFIG_OF
                .of_match_table = tegra_msenc_of_match,
 #endif
+#ifdef CONFIG_PM
+               .pm = &nvhost_module_pm_ops,
+#endif
        }
 };
 
index 1252acc..063e00e 100644 (file)
@@ -147,7 +147,9 @@ void nvhost_module_busy(struct platform_device *dev)
        if (dev->dev.parent && (dev->dev.parent != &platform_bus))
                nvhost_module_busy(nvhost_get_parent(dev));
 
+#ifdef CONFIG_PM_RUNTIME
        pm_runtime_get_sync(&dev->dev);
+#endif
 
        if (pdata->busy)
                pdata->busy(dev);
@@ -163,10 +165,6 @@ void nvhost_module_idle_mult(struct platform_device *dev, int refs)
                if (pdata->idle)
                        pdata->idle(dev);
        }
-#else
-       if (pdata->idle)
-               pdata->idle(dev);
-#endif
 
        while (refs--) {
                pm_runtime_mark_last_busy(&dev->dev);
@@ -175,6 +173,10 @@ void nvhost_module_idle_mult(struct platform_device *dev, int refs)
                else
                        pm_runtime_put(&dev->dev);
        }
+#else
+       if (pdata->idle)
+               pdata->idle(dev);
+#endif
 
        /* Explicitly turn off the host1x clocks */
        if (dev->dev.parent && (dev->dev.parent != &platform_bus))
@@ -572,6 +574,13 @@ void nvhost_module_deinit(struct platform_device *dev)
 
 }
 
+#ifdef CONFIG_PM
+const struct dev_pm_ops nvhost_module_pm_ops = {
+       SET_RUNTIME_PM_OPS(nvhost_module_disable_clk,
+               nvhost_module_enable_clk, NULL)
+};
+#endif
+
 /* common runtime pm and power domain APIs */
 int nvhost_module_add_domain(struct generic_pm_domain *domain,
        struct platform_device *pdev)
@@ -587,7 +596,6 @@ int nvhost_module_add_domain(struct generic_pm_domain *domain,
        if (!pdata->can_powergate)
 #ifdef CONFIG_PM_GENERIC_DOMAINS
                pm_domain_gov = &pm_domain_always_on_gov;
-#endif
 
        if (__pm_genpd_name_add_device(domain->name, &pdev->dev, NULL)) {
                pm_genpd_init(domain, pm_domain_gov, true);
@@ -597,6 +605,7 @@ int nvhost_module_add_domain(struct generic_pm_domain *domain,
                                        pdata->powergate_delay);
                tegra_pd_add_sd(domain);
        }
+#endif
 
        return ret;
 }
index 03c579e..620fcec 100644 (file)
@@ -29,6 +29,8 @@
 #include <linux/pm_runtime.h>
 #include <linux/nvhost.h>
 
+extern const struct dev_pm_ops nvhost_module_pm_ops;
+
 /* Sets clocks and powergating state for a module */
 int nvhost_module_init(struct platform_device *ndev);
 void nvhost_module_deinit(struct platform_device *dev);
index 31bc272..6eab095 100644 (file)
@@ -579,15 +579,21 @@ static int tsec_probe(struct platform_device *dev)
 
        tsec = dev;
 
+#ifdef CONFIG_PM_GENERIC_DOMAINS
        tegra_pd_add_device(&dev->dev);
+#endif
+
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay) {
                pm_runtime_set_autosuspend_delay(&dev->dev,
                        pdata->clockgate_delay);
                pm_runtime_use_autosuspend(&dev->dev);
        }
        pm_runtime_enable(&dev->dev);
-
        pm_runtime_get_sync(&dev->dev);
+#else
+       nvhost_module_enable_clk(&dev->dev);
+#endif
 
        err = nvhost_client_device_init(dev);
        if (err)
@@ -598,10 +604,12 @@ static int tsec_probe(struct platform_device *dev)
        udelay(10);
        tegra_periph_reset_deassert(pdata->clk[0]);
 
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay)
                pm_runtime_put_sync_autosuspend(&dev->dev);
        else
                pm_runtime_put(&dev->dev);
+#endif
 
        return err;
 }
@@ -610,9 +618,16 @@ static int __exit tsec_remove(struct platform_device *dev)
 {
        struct nvhost_master *host = nvhost_get_host(dev);
 
-       /* Add clean-up */
        host->intr.generic_isr[20] = NULL;
        host->intr.generic_isr_thread[20] = NULL;
+
+#ifdef CONFIG_PM_RUNTIME
+       pm_runtime_put(&dev->dev);
+       pm_runtime_disable(&dev->dev);
+#else
+       nvhost_module_disable_clk(&dev->dev);
+#endif
+
        return 0;
 }
 
index 619440b..9b2fc40 100644 (file)
@@ -147,13 +147,16 @@ static int vi_probe(struct platform_device *dev)
        if (err)
                goto camera_register_fail;
 
-       tegra_pd_add_device(&dev->dev);
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay) {
                pm_runtime_set_autosuspend_delay(&dev->dev,
                        pdata->clockgate_delay);
                pm_runtime_use_autosuspend(&dev->dev);
        }
        pm_runtime_enable(&dev->dev);
+#else
+       nvhost_module_enable_clk(&dev->dev);
+#endif
 
        return 0;
 
@@ -180,6 +183,13 @@ static int __exit vi_remove(struct platform_device *dev)
                return err;
 #endif
 
+#ifdef CONFIG_PM_RUNTIME
+       pm_runtime_put(&dev->dev);
+       pm_runtime_disable(&dev->dev);
+#else
+       nvhost_module_disable_clk(&dev->dev);
+#endif
+
        return 0;
 }
 
@@ -223,10 +233,8 @@ static int vi_resume(struct device *dev)
 static const struct dev_pm_ops vi_pm_ops = {
        .suspend = vi_suspend,
        .resume = vi_resume,
-#ifdef CONFIG_PM_RUNTIME
-       .runtime_suspend = nvhost_module_disable_clk,
-       .runtime_resume = nvhost_module_enable_clk,
-#endif
+       SET_RUNTIME_PM_OPS(nvhost_module_disable_clk,
+               nvhost_module_enable_clk, NULL)
 };
 #endif
 
index a78926f..f64a5ce 100644 (file)
@@ -677,19 +677,22 @@ static int vic03_probe(struct platform_device *dev)
        pdata->pd.dev_ops.restore_state = nvhost_module_finalize_poweron;
 #endif
 
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay) {
                pm_runtime_set_autosuspend_delay(&dev->dev,
                        pdata->clockgate_delay);
                pm_runtime_use_autosuspend(&dev->dev);
        }
        pm_runtime_enable(&dev->dev);
+       pm_runtime_get_sync(&dev->dev);
+#else
+       nvhost_module_enable_clk(&dev->dev);
+#endif
 
        err = nvhost_client_device_get_resources(dev);
        if (err)
                return err;
 
-       pm_runtime_get_sync(&dev->dev);
-
        err = nvhost_client_device_init(dev);
        if (err) {
                nvhost_dbg_fn("failed to init client device for %s",
@@ -706,17 +709,24 @@ static int vic03_probe(struct platform_device *dev)
                return err;
        }
 
+#ifdef CONFIG_PM_RUNTIME
        if (pdata->clockgate_delay)
                pm_runtime_put_sync_autosuspend(&dev->dev);
        else
                pm_runtime_put(&dev->dev);
+#endif
 
        return 0;
 }
 
 static int __exit vic03_remove(struct platform_device *dev)
 {
-       /* Add clean-up */
+#ifdef CONFIG_PM_RUNTIME
+       pm_runtime_put(&dev->dev);
+       pm_runtime_disable(&dev->dev);
+#else
+       nvhost_module_disable_clk(&dev->dev);
+#endif
        return 0;
 }
 
@@ -729,6 +739,9 @@ static struct platform_driver vic03_driver = {
 #ifdef CONFIG_OF
                .of_match_table = tegra_vic_of_match,
 #endif
+#ifdef CONFIG_PM
+               .pm = &nvhost_module_pm_ops,
+#endif
        }
 };