[PATCH v7 28/37] memory: tegra20-emc: Add minimal runtime PM support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



EMC is always enabled, mark it as enabled. This makes the OPP and GENPD
API usage more consistent since otherwise we're changing performance state
of a power domain for the device that doesn't support power management.

Signed-off-by: Dmitry Osipenko <digetx@xxxxxxxxx>
---
 drivers/memory/tegra/tegra20-emc.c | 31 ++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/memory/tegra/tegra20-emc.c b/drivers/memory/tegra/tegra20-emc.c
index c3462dbc8c22..22087009fa0c 100644
--- a/drivers/memory/tegra/tegra20-emc.c
+++ b/drivers/memory/tegra/tegra20-emc.c
@@ -20,6 +20,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_opp.h>
+#include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/sort.h>
 #include <linux/types.h>
@@ -1028,6 +1029,32 @@ static int tegra_emc_devfreq_init(struct tegra_emc *emc)
 	return 0;
 }
 
+static void devm_tegra_emc_disable_runtime_pm(void *dev)
+{
+	pm_runtime_put(dev);
+	pm_runtime_disable(dev);
+}
+
+static int tegra_emc_init_pm(struct tegra_emc *emc)
+{
+	int err;
+
+	pm_runtime_enable(emc->dev);
+	err = pm_runtime_resume_and_get(emc->dev);
+	if (err) {
+		pm_runtime_disable(emc->dev);
+		return err;
+	}
+
+	err = devm_add_action_or_reset(emc->dev,
+				       devm_tegra_emc_disable_runtime_pm,
+				       emc->dev);
+	if (err)
+		return err;
+
+	return 0;
+}
+
 static int tegra_emc_probe(struct platform_device *pdev)
 {
 	struct tegra_core_opp_params opp_params = {};
@@ -1076,6 +1103,10 @@ static int tegra_emc_probe(struct platform_device *pdev)
 	if (err)
 		return err;
 
+	err = tegra_emc_init_pm(emc);
+	if (err)
+		return err;
+
 	opp_params.init_state = true;
 
 	err = devm_tegra_core_dev_init_opp_table(&pdev->dev, &opp_params);
-- 
2.30.2




[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux