Skip to contentSkip to conversation

thermal: tegra: add PM support

PATCH Superseded Wei Ni 2 participants 3 messages Jan 13, 2016 – Jan 15, 2016

Subsystems (2)

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Wei Ni

author
#0 lore raw

PATCH 8/10 thermal: tegra: add PM support

Add suspend/resume function in soctherm driver.
And enable it for Tegra124 and Tegra210.

---
 drivers/thermal/tegra/tegra124_soctherm.c |   9 ++
 drivers/thermal/tegra/tegra210_soctherm.c |   9 ++
 drivers/thermal/tegra/tegra_soctherm.c    | 154 +++++++++++++++++++++---------
 drivers/thermal/tegra/tegra_soctherm.h    |   5 +
 4 files changed, 130 insertions(+), 47 deletions(-)
drivers/thermal/tegra/tegra124_soctherm.c +9 -0
index 13d7f4e3a3d7..04cb419dbabc 100644
@@ -205,6 +205,14 @@ static const struct of_device_id tegra124_soctherm_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, tegra_soctherm_of_match);
 
+#ifdef CONFIG_PM_SLEEP
+static SIMPLE_DEV_PM_OPS(tegra124_soctherm_pm,
+			 soctherm_suspend, soctherm_resume);
+#define TEGRA124_SOC_THERM_PM      (&tegra124_soctherm_pm)
+#else
+#define TEGRA124_SOC_THERM_PM      NULL
+#endif
+
 static int tegra124_soctherm_probe(struct platform_device *pdev)
 {
 	return tegra_soctherm_probe(pdev,
@@ -218,6 +226,7 @@ static struct platform_driver tegra124_soctherm_driver = {
 	.remove = tegra_soctherm_remove,
 	.driver = {
 		.name = "tegra124_soctherm",
+		.pm = TEGRA124_SOC_THERM_PM,
 		.of_match_table = tegra124_soctherm_of_match,
 	},
 };
drivers/thermal/tegra/tegra210_soctherm.c +9 -0
index 91f48990dd8e..551faa3f7a6c 100644
@@ -208,6 +208,14 @@ MODULE_DEVICE_TABLE(of, tegra_soctherm_of_match);
 
 #define TEGRA210_FUSE_CP_REV 0x90
 
+#ifdef CONFIG_PM_SLEEP
+static SIMPLE_DEV_PM_OPS(tegra210_soctherm_pm,
+			 soctherm_suspend, soctherm_resume);
+#define TEGRA210_SOC_THERM_PM      (&tegra210_soctherm_pm)
+#else
+#define TEGRA210_SOC_THERM_PM      NULL
+#endif
+
 static int tegra210_soctherm_probe(struct platform_device *pdev)
 {
 	u32 rev;
@@ -227,6 +235,7 @@ static struct platform_driver tegra210_soctherm_driver = {
 	.driver = {
 		.name = "tegra210_soctherm",
 		.owner = THIS_MODULE,
+		.pm = TEGRA210_SOC_THERM_PM,
 		.of_match_table = tegra210_soctherm_of_match,
 	},
 };
drivers/thermal/tegra/tegra_soctherm.c +107 -47

209 lines not on this page · raw message

drivers/thermal/tegra/tegra_soctherm.h +5 -0
index 1017424e6e85..9b3a55f81fdb 100644
@@ -111,5 +111,10 @@ int tegra_soctherm_probe(struct platform_device *pdev,
 			 const struct tegra_soctherm_fuse *tfuse);
 int tegra_soctherm_remove(struct platform_device *pdev);
 
+#ifdef CONFIG_PM_SLEEP
+int soctherm_suspend(struct device *dev);
+int soctherm_resume(struct device *dev);
+#endif
+
 #endif
 
Signature · 1 line
1.9.1
#1 lore raw
Quoted 10 lines · Wei Ni

Add suspend/resume function in soctherm driver.
And enable it for Tegra124 and Tegra210.

---
 drivers/thermal/tegra/tegra124_soctherm.c |   9 ++
 drivers/thermal/tegra/tegra210_soctherm.c |   9 ++
 drivers/thermal/tegra/tegra_soctherm.c    | 154 +++++++++++++++++++++---------
 drivers/thermal/tegra/tegra_soctherm.h    |   5 +
 4 files changed, 130 insertions(+), 47 deletions(-)

This all looks like it'd be a better candidate for runtime PM. The implementation would be mostly the same, except that you'd need to add a few more things to tegra_soctherm_probe() and use the runtime PM API to enable/disable the device (clocks, resets, ...). System sleep should then be taken care of automatically.

Another comment irrespective of that...

Quoted 5 lines
drivers/thermal/tegra/tegra124_soctherm.c +0 -0
index 13d7f4e3a3d7..04cb419dbabc 100644

drivers/thermal/tegra/tegra124_soctherm.c static const struct of_device_id tegra124_soctherm_of_match[] = { · line 214

Quoted 10 lines
drivers/thermal/tegra/tegra124_soctherm.c +7 -0
@@ -205,6 +205,14 @@ static const struct of_device_id tegra124_soctherm_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, tegra_soctherm_of_match);
 
+#ifdef CONFIG_PM_SLEEP
+static SIMPLE_DEV_PM_OPS(tegra124_soctherm_pm,
+			 soctherm_suspend, soctherm_resume);
+#define TEGRA124_SOC_THERM_PM      (&tegra124_soctherm_pm)
+#else
+#define TEGRA124_SOC_THERM_PM      NULL
+#endif

I wouldn't bother with the #ifdef, just always define the structure.

Thierry

author
#2 lore raw
Quoted 14 lines · Thierry Reding

* PGP Signed by an unknown key

Quoted 10 lines · Wei Ni

Add suspend/resume function in soctherm driver.
And enable it for Tegra124 and Tegra210.

---
 drivers/thermal/tegra/tegra124_soctherm.c |   9 ++
 drivers/thermal/tegra/tegra210_soctherm.c |   9 ++
 drivers/thermal/tegra/tegra_soctherm.c    | 154 +++++++++++++++++++++---------
 drivers/thermal/tegra/tegra_soctherm.h    |   5 +
 4 files changed, 130 insertions(+), 47 deletions(-)
Quoted 5 lines

This all looks like it'd be a better candidate for runtime PM. The implementation would be mostly the same, except that you'd need to add a few more things to tegra_soctherm_probe() and use the runtime PM API to enable/disable the device (clocks, resets, ...). System sleep should then be taken care of automatically.

We can not handle it as runtime PM, because this is used to monitor the temperatures, once they reach to critical value, it need to trigger operations to protect system, such as shutdown or throttle. If this device suspend in runtime, then it can't handle these events.

Quoted 11 lines

Another comment irrespective of that...

Quoted 8 lines
drivers/thermal/tegra/tegra124_soctherm.c +0 -0
index 13d7f4e3a3d7..04cb419dbabc 100644
@@ -205,6 +205,14 @@ static const struct of_device_id tegra124_soctherm_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, tegra_soctherm_of_match);
 
Quoted 9 lines

drivers/thermal/tegra/tegra124_soctherm.c static const struct of_device_id tegra124_soctherm_of_match[] = { · line 214

Quoted 7 lines
drivers/thermal/tegra/tegra124_soctherm.c +7 -0
+#ifdef CONFIG_PM_SLEEP
+static SIMPLE_DEV_PM_OPS(tegra124_soctherm_pm,
+			 soctherm_suspend, soctherm_resume);
+#define TEGRA124_SOC_THERM_PM      (&tegra124_soctherm_pm)
+#else
+#define TEGRA124_SOC_THERM_PM      NULL
+#endif

I wouldn't bother with the #ifdef, just always define the structure.

Ok, will remove them.

Quoted 6 lines

Thierry

* Unknown Key
* 0x7F3EB3A1