devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: rcar: add .set_trip_temp support
@ 2015-11-25  5:42 Kuninori Morimoto
  2015-11-30 18:51 ` Eduardo Valentin
  0 siblings, 1 reply; 3+ messages in thread
From: Kuninori Morimoto @ 2015-11-25  5:42 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala
  Cc: devicetree, linux-sh, linux-pm, Ryusuke Sakato, linux-kernel,
	osd2@lm.renesas.com


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

You can set trip temp if your kernel has CONFIG_THERMAL_WRITABLE_TRIPS

echo $temp > /sys/class/thermal/thermal_zone0/trip_point_0_temp

-45000 < $temp < 125000 is supported
Default is 90000

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
  This patch is v2 of "[PATCH] thermal: rcar: enable to set tripN-temp via DT"
  I think it will be full-DT feature if it uses of-thermal, but this driver is used
  from non-DT SoC too. We would like to keep non-DT support.
  And we would like to do is only exchange trip temp.
  .set_trip_temp is very enouth for it at this point.
  But, it can use of-thermal feature in the future.

 drivers/thermal/rcar_thermal.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 5d4ae7d..1eaa1be 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -63,6 +63,7 @@ struct rcar_thermal_priv {
 	struct mutex lock;
 	struct list_head list;
 	int id;
+	int trip_temp;
 	u32 ctemp;
 };
 
@@ -222,7 +223,7 @@ static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
 
 	/* see rcar_thermal_get_temp() */
 	switch (trip) {
-	case 0: /* +90 <= temp */
+	case 0:
 		*type = THERMAL_TRIP_CRITICAL;
 		break;
 	default:
@@ -241,8 +242,8 @@ static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
 
 	/* see rcar_thermal_get_temp() */
 	switch (trip) {
-	case 0: /* +90 <= temp */
-		*temp = MCELSIUS(90);
+	case 0:
+		*temp = priv->trip_temp;
 		break;
 	default:
 		dev_err(dev, "rcar driver trip error\n");
@@ -270,10 +271,27 @@ static int rcar_thermal_notify(struct thermal_zone_device *zone,
 	return 0;
 }
 
+static int rcar_thermal_set_trip_temp(struct thermal_zone_device *zone,
+				    int trip, int temp)
+{
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+
+	if (trip != 0)
+		return -EINVAL;
+
+	if (temp < -45000 || temp > 125000)
+		return -EINVAL;
+
+	priv->trip_temp = temp;
+
+	return 0;
+}
+
 static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
 	.get_temp	= rcar_thermal_get_temp,
 	.get_trip_type	= rcar_thermal_get_trip_type,
 	.get_trip_temp	= rcar_thermal_get_trip_temp,
+	.set_trip_temp	= rcar_thermal_set_trip_temp,
 	.notify		= rcar_thermal_notify,
 };
 
@@ -418,13 +436,14 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 
 		priv->common = common;
 		priv->id = i;
+		priv->trip_temp = MCELSIUS(90); /* default*/
 		mutex_init(&priv->lock);
 		INIT_LIST_HEAD(&priv->list);
 		INIT_DELAYED_WORK(&priv->work, rcar_thermal_work);
 		rcar_thermal_update_temp(priv);
 
 		priv->zone = thermal_zone_device_register("rcar_thermal",
-						1, 0, priv,
+						1, 1, priv,
 						&rcar_thermal_zone_ops, NULL, 0,
 						idle);
 		if (IS_ERR(priv->zone)) {
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] thermal: rcar: add .set_trip_temp support
  2015-11-25  5:42 [PATCH] thermal: rcar: add .set_trip_temp support Kuninori Morimoto
@ 2015-11-30 18:51 ` Eduardo Valentin
  2015-12-01  3:00   ` Kuninori Morimoto
  0 siblings, 1 reply; 3+ messages in thread
From: Eduardo Valentin @ 2015-11-30 18:51 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Zhang Rui, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, devicetree, linux-sh, linux-pm, Ryusuke Sakato,
	linux-kernel, osd2@lm.renesas.com

On Wed, Nov 25, 2015 at 05:42:27AM +0000, Kuninori Morimoto wrote:
> 
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> You can set trip temp if your kernel has CONFIG_THERMAL_WRITABLE_TRIPS
> 
> echo $temp > /sys/class/thermal/thermal_zone0/trip_point_0_temp
> 
> -45000 < $temp < 125000 is supported
> Default is 90000
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>   This patch is v2 of "[PATCH] thermal: rcar: enable to set tripN-temp via DT"
>   I think it will be full-DT feature if it uses of-thermal, but this driver is used
>   from non-DT SoC too. We would like to keep non-DT support.
>   And we would like to do is only exchange trip temp.
>   .set_trip_temp is very enouth for it at this point.
>   But, it can use of-thermal feature in the future.

Kuninori,


According to discussion on your first version [1], this patch is not needed
anymore, right?

If you want to add the support for writable trip points, please, add the
support to of-thermal, as this driver supports only DT booting boards.


[1] - https://lkml.org/lkml/2015/11/25/888
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] thermal: rcar: add .set_trip_temp support
  2015-11-30 18:51 ` Eduardo Valentin
@ 2015-12-01  3:00   ` Kuninori Morimoto
  0 siblings, 0 replies; 3+ messages in thread
From: Kuninori Morimoto @ 2015-12-01  3:00 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, devicetree, linux-sh, linux-pm, Ryusuke Sakato,
	linux-kernel, osd2@lm.renesas.com


Hi Eduardo

> According to discussion on your first version [1], this patch is not needed
> anymore, right?
> 
> If you want to add the support for writable trip points, please, add the
> support to of-thermal, as this driver supports only DT booting boards.

Thanks. I will investigate it.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-01  3:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-25  5:42 [PATCH] thermal: rcar: add .set_trip_temp support Kuninori Morimoto
2015-11-30 18:51 ` Eduardo Valentin
2015-12-01  3:00   ` Kuninori Morimoto

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).