linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Valentin <eduardo.valentin@ti.com>
To: linux-pm@vger.kernel.org, durgadoss.r@intel.com, amit.daniel@samsung.com
Cc: rui.zhang@intel.com, Eduardo Valentin <eduardo.valentin@ti.com>
Subject: [RFC PATCH 3/4] thermal: ti-soc-thermal: use thermal DT infrastructure
Date: Tue, 9 Jul 2013 10:00:13 -0400	[thread overview]
Message-ID: <1373378414-28086-4-git-send-email-eduardo.valentin@ti.com> (raw)
In-Reply-To: <1373378414-28086-1-git-send-email-eduardo.valentin@ti.com>

This patch improves the ti-soc-thermal driver by adding the
support to build the thermal zones based on DT nodes.

The driver will have two options now to build the thermal
zones. The first option is the zones originally coded
in this driver. So, the driver behavior will be same
if there is no DT node describing the zones. The second
option, when it is found a DT node with thermal data,
will used the common infrastructure to build the thermal
zone and bind its cooling devices.

In either case, this driver still adds to the system
a cpufreq cooling device.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 35 +++++++++++++++-------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
index 4c5f55c37..213a883 100644
--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
@@ -31,6 +31,7 @@
 #include <linux/cpufreq.h>
 #include <linux/cpumask.h>
 #include <linux/cpu_cooling.h>
+#include <linux/of.h>
 
 #include "ti-thermal.h"
 #include "ti-bandgap.h"
@@ -75,11 +76,10 @@ static inline int ti_thermal_hotspot_temperature(int t, int s, int c)
 
 /* thermal zone ops */
 /* Get temperature callback function for thermal zone*/
-static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
-				      unsigned long *temp)
+static inline int __ti_thermal_get_temp(void *devdata, unsigned long *temp)
 {
 	struct thermal_zone_device *pcb_tz = NULL;
-	struct ti_thermal_data *data = thermal->devdata;
+	struct ti_thermal_data *data = devdata;
 	struct ti_bandgap *bgp;
 	const struct ti_temp_sensor *s;
 	int ret, tmp, slope, constant;
@@ -117,6 +117,14 @@ static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
 	return ret;
 }
 
+static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
+				      unsigned long *temp)
+{
+	struct ti_thermal_data *data = thermal->devdata;
+
+	return __ti_thermal_get_temp(data, temp);
+}
+
 /* Bind callback functions for thermal zone */
 static int ti_thermal_bind(struct thermal_zone_device *thermal,
 			   struct thermal_cooling_device *cdev)
@@ -302,17 +310,24 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,
 	if (!data)
 		return -EINVAL;
 
-	/* Create thermal zone */
-	data->ti_thermal = thermal_zone_device_register(domain,
+	/* in case this is specified by DT */
+	if (of_find_node_by_name(bgp->dev->of_node, "thermal_zone")) {
+		data->ti_thermal = thermal_zone_of_device_register(bgp->dev,
+						data, __ti_thermal_get_temp);
+		/* TODO: return */
+	} else {
+		/* Create thermal zone */
+		data->ti_thermal = thermal_zone_device_register(domain,
 				OMAP_TRIP_NUMBER, 0, data, &ti_thermal_ops,
 				NULL, FAST_TEMP_MONITORING_RATE,
 				FAST_TEMP_MONITORING_RATE);
-	if (IS_ERR(data->ti_thermal)) {
-		dev_err(bgp->dev, "thermal zone device is NULL\n");
-		return PTR_ERR(data->ti_thermal);
+		if (IS_ERR(data->ti_thermal)) {
+			dev_err(bgp->dev, "thermal zone device is NULL\n");
+			return PTR_ERR(data->ti_thermal);
+		}
+		data->ti_thermal->polling_delay = FAST_TEMP_MONITORING_RATE;
+		ti_bandgap_set_sensor_data(bgp, id, data);
 	}
-	data->ti_thermal->polling_delay = FAST_TEMP_MONITORING_RATE;
-	ti_bandgap_set_sensor_data(bgp, id, data);
 
 	return 0;
 }
-- 
1.8.2.1.342.gfa7285d


  parent reply	other threads:[~2013-07-09 14:00 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-09 14:00 [RFC PATCH 0/4] thermal: introduce DT thermal builder Eduardo Valentin
2013-07-09 14:00 ` [RFC PATCH 1/4] thermal: hwmon: move hwmon support to single file Eduardo Valentin
2013-07-09 16:04   ` R, Durgadoss
2013-07-09 16:54     ` Eduardo Valentin
2013-07-09 17:14       ` R, Durgadoss
2013-07-17  9:49       ` Wei Ni
2013-07-17 10:07         ` R, Durgadoss
2013-08-15  6:21   ` Zhang Rui
2013-07-09 14:00 ` [RFC PATCH 2/4] thermal: introduce device tree parser Eduardo Valentin
2013-07-09 16:14   ` R, Durgadoss
2013-07-17 14:51     ` Eduardo Valentin
2013-07-10  6:48   ` Wei Ni
2013-07-10 15:16     ` Stephen Warren
2013-07-15 14:30       ` Eduardo Valentin
2013-07-15 11:54     ` Eduardo Valentin
2013-07-15 17:03       ` R, Durgadoss
2013-07-15 17:16         ` Eduardo Valentin
2013-07-09 14:00 ` Eduardo Valentin [this message]
2013-07-15 12:12   ` [RFC PATCH 3/4] thermal: ti-soc-thermal: use thermal DT infrastructure Lucas Stach
2013-07-15 12:33     ` Eduardo Valentin
2013-07-15 12:59       ` Lucas Stach
2013-07-15 13:25         ` Eduardo Valentin
2013-07-15 13:36           ` Eduardo Valentin
2013-07-15 13:38             ` Eduardo Valentin
2013-07-15 14:05             ` Lucas Stach
2013-07-15 14:14               ` Eduardo Valentin
2013-07-16  9:54                 ` Lucas Stach
2013-07-16 13:29                   ` Eduardo Valentin
2013-07-15 13:53           ` Lucas Stach
2013-07-15 14:09             ` Eduardo Valentin
2013-07-09 14:00 ` [RFC PATCH 4/4] arm: dts: add omap4430 thermal data Eduardo Valentin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1373378414-28086-4-git-send-email-eduardo.valentin@ti.com \
    --to=eduardo.valentin@ti.com \
    --cc=amit.daniel@samsung.com \
    --cc=durgadoss.r@intel.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).