linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] thermal: rcar: add emergency power down
@ 2012-11-22  6:49 Kuninori Morimoto
  2012-11-22  6:50 ` [PATCH 1/2] thermal: rcar: add rcar_zone_to_priv() macro Kuninori Morimoto
  2012-11-22  6:50 ` [PATCH 2/2] thermal: rcar: add .get_trip_type/temp and .notify support Kuninori Morimoto
  0 siblings, 2 replies; 24+ messages in thread
From: Kuninori Morimoto @ 2012-11-22  6:49 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Simon, Magnus, linux-pm


Hi Zhang

These patches adds emergency shutdown on rcar_thermal.c

This "force shutdown" should be updated to use cooling device in future.
But it is enough for now.

Kuninori Morimoto (2):
      thermal: rcar: add rcar_zone_to_priv() macro
      thermal: rcar: add .get_trip_type/temp and .notify support

 drivers/thermal/rcar_thermal.c |   87 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 82 insertions(+), 5 deletions(-)

Best regards
---
Kuninori Morimoto

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

* [PATCH 1/2] thermal: rcar: add rcar_zone_to_priv() macro
  2012-11-22  6:49 [PATCH 0/2] thermal: rcar: add emergency power down Kuninori Morimoto
@ 2012-11-22  6:50 ` Kuninori Morimoto
  2012-11-25  9:24   ` Zhang Rui
  2012-11-22  6:50 ` [PATCH 2/2] thermal: rcar: add .get_trip_type/temp and .notify support Kuninori Morimoto
  1 sibling, 1 reply; 24+ messages in thread
From: Kuninori Morimoto @ 2012-11-22  6:50 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto

This patch adds rcar_zone_to_priv()
which is a helper macro for gettign private data.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/thermal/rcar_thermal.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index f7a1b57..454035c 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -43,6 +43,8 @@ struct rcar_thermal_priv {
 	u32 comp;
 };
 
+#define rcar_zone_to_priv(zone)		(zone->devdata)
+
 /*
  *		basic functions
  */
@@ -96,7 +98,7 @@ static void rcar_thermal_bset(struct rcar_thermal_priv *priv, u32 reg,
 static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
 			   unsigned long *temp)
 {
-	struct rcar_thermal_priv *priv = zone->devdata;
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
 	int val, min, max, tmp;
 
 	tmp = -200; /* default */
@@ -235,7 +237,7 @@ error_free_priv:
 static int rcar_thermal_remove(struct platform_device *pdev)
 {
 	struct thermal_zone_device *zone = platform_get_drvdata(pdev);
-	struct rcar_thermal_priv *priv = zone->devdata;
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
 
 	thermal_zone_device_unregister(zone);
 	platform_set_drvdata(pdev, NULL);
-- 
1.7.9.5


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

* [PATCH 2/2] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-11-22  6:49 [PATCH 0/2] thermal: rcar: add emergency power down Kuninori Morimoto
  2012-11-22  6:50 ` [PATCH 1/2] thermal: rcar: add rcar_zone_to_priv() macro Kuninori Morimoto
@ 2012-11-22  6:50 ` Kuninori Morimoto
  2012-11-22  7:05   ` Magnus Damm
  2012-11-23  6:29   ` Zhang Rui
  1 sibling, 2 replies; 24+ messages in thread
From: Kuninori Morimoto @ 2012-11-22  6:50 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto

This patch adds .get_trip_type(), .get_trip_temp(), and .notify()
on rcar_thermal_zone_ops.
Driver will try platform power OFF if it reached to
critical temperature.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/thermal/rcar_thermal.c |   81 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 78 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 454035c..16723ba 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -22,10 +22,13 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/reboot.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/thermal.h>
 
+#define IDLE_INTERVAL	5000
+
 #define THSCR	0x2c
 #define THSSR	0x30
 
@@ -172,11 +175,82 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
 	}
 
 	*temp = tmp;
+
+	return 0;
+}
+
+static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
+				      int trip, enum thermal_trip_type *type)
+{
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+
+	/* see rcar_thermal_get_temp() */
+	switch (trip) {
+	case 0: /* -45 <= temp < +45 */
+		*type = THERMAL_TRIP_ACTIVE;
+		break;
+	case 1: /* +45 <= temp < +90 */
+		*type = THERMAL_TRIP_HOT;
+		break;
+	case 2: /* +90 <= temp < +135 */
+		*type = THERMAL_TRIP_CRITICAL;
+		break;
+	default:
+		dev_err(priv->dev, "rcar driver trip error\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
+				      int trip, unsigned long *temp)
+{
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+
+	/* see rcar_thermal_get_temp() */
+	switch (trip) {
+	case 0: /* -45 <= temp < +45 */
+		*temp = -45 - 1;
+		break;
+	case 1: /* +45 <= temp < +90 */
+		*temp = 45 - 1;
+		break;
+	case 2: /* +90 <= temp < +135 */
+		*temp = 90 - 1;
+		break;
+	default:
+		dev_err(priv->dev, "rcar driver trip error\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int rcar_thermal_notify(struct thermal_zone_device *zone,
+			       int trip, enum thermal_trip_type type)
+{
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+
+	switch (type) {
+	case THERMAL_TRIP_CRITICAL:
+		/* FIXME */
+		dev_warn(priv->dev,
+			 "Thermal reached to critical temperature\n");
+		machine_power_off();
+		break;
+	default:
+		break;
+	}
+
 	return 0;
 }
 
 static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
-	.get_temp = rcar_thermal_get_temp,
+	.get_temp	= rcar_thermal_get_temp,
+	.get_trip_type	= rcar_thermal_get_trip_type,
+	.get_trip_temp	= rcar_thermal_get_trip_temp,
+	.notify		= rcar_thermal_notify,
 };
 
 /*
@@ -212,8 +286,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 		goto error_free_priv;
 	}
 
-	zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv,
-					    &rcar_thermal_zone_ops, 0, 0);
+	zone = thermal_zone_device_register("rcar_thermal", 4, 0, priv,
+					    &rcar_thermal_zone_ops, 0,
+					    IDLE_INTERVAL);
 	if (IS_ERR(zone)) {
 		dev_err(&pdev->dev, "thermal zone device is NULL\n");
 		ret = PTR_ERR(zone);
-- 
1.7.9.5


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

* Re: [PATCH 2/2] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-11-22  6:50 ` [PATCH 2/2] thermal: rcar: add .get_trip_type/temp and .notify support Kuninori Morimoto
@ 2012-11-22  7:05   ` Magnus Damm
  2012-11-23  6:29   ` Zhang Rui
  1 sibling, 0 replies; 24+ messages in thread
From: Magnus Damm @ 2012-11-22  7:05 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Zhang Rui, Simon, linux-pm

Hello Morimoto-san,

On Thu, Nov 22, 2012 at 3:50 PM, Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
> This patch adds .get_trip_type(), .get_trip_temp(), and .notify()
> on rcar_thermal_zone_ops.
> Driver will try platform power OFF if it reached to
> critical temperature.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  drivers/thermal/rcar_thermal.c |   81 ++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 78 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index 454035c..16723ba 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -212,8 +286,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>                 goto error_free_priv;
>         }
>
> -       zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv,
> -                                           &rcar_thermal_zone_ops, 0, 0);
> +       zone = thermal_zone_device_register("rcar_thermal", 4, 0, priv,
> +                                           &rcar_thermal_zone_ops, 0,
> +                                           IDLE_INTERVAL);
>         if (IS_ERR(zone)) {
>                 dev_err(&pdev->dev, "thermal zone device is NULL\n");
>                 ret = PTR_ERR(zone);

Huh, so this IDLE_INTERVAL basically means that the driver currently is polled?

Good that this driver is for automotive systems and not mobile handsets. =)

Thanks,

/ magnus

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

* Re: [PATCH 2/2] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-11-22  6:50 ` [PATCH 2/2] thermal: rcar: add .get_trip_type/temp and .notify support Kuninori Morimoto
  2012-11-22  7:05   ` Magnus Damm
@ 2012-11-23  6:29   ` Zhang Rui
  2012-11-26  1:40     ` Kuninori Morimoto
  1 sibling, 1 reply; 24+ messages in thread
From: Zhang Rui @ 2012-11-23  6:29 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Simon, Magnus, linux-pm

On Wed, 2012-11-21 at 22:50 -0800, Kuninori Morimoto wrote:
> This patch adds .get_trip_type(), .get_trip_temp(), and .notify()
> on rcar_thermal_zone_ops.
> Driver will try platform power OFF if it reached to
> critical temperature.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  drivers/thermal/rcar_thermal.c |   81 ++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 78 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index 454035c..16723ba 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -22,10 +22,13 @@
>  #include <linux/io.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
> +#include <linux/reboot.h>
>  #include <linux/slab.h>
>  #include <linux/spinlock.h>
>  #include <linux/thermal.h>
>  
> +#define IDLE_INTERVAL	5000
> +
>  #define THSCR	0x2c
>  #define THSSR	0x30
>  
> @@ -172,11 +175,82 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
>  	}
>  
>  	*temp = tmp;
> +
> +	return 0;
> +}
> +
> +static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
> +				      int trip, enum thermal_trip_type *type)
> +{
> +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> +
> +	/* see rcar_thermal_get_temp() */
> +	switch (trip) {
> +	case 0: /* -45 <= temp < +45 */
> +		*type = THERMAL_TRIP_ACTIVE;
> +		break;
> +	case 1: /* +45 <= temp < +90 */
> +		*type = THERMAL_TRIP_HOT;
> +		break;
> +	case 2: /* +90 <= temp < +135 */
> +		*type = THERMAL_TRIP_CRITICAL;
> +		break;
> +	default:
> +		dev_err(priv->dev, "rcar driver trip error\n");
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
> +static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
> +				      int trip, unsigned long *temp)
> +{
> +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> +
> +	/* see rcar_thermal_get_temp() */
> +	switch (trip) {
> +	case 0: /* -45 <= temp < +45 */
> +		*temp = -45 - 1;
> +		break;

does this mean you expect the thermal driver to take some action when
the temperature is higher than -45C?

> +	case 1: /* +45 <= temp < +90 */
> +		*temp = 45 - 1;
> +		break;
what do you expect to happen when the temperature is higher than 45C but
lower than 90C?

> +	case 2: /* +90 <= temp < +135 */
> +		*temp = 90 - 1;
> +		break;
> +	default:
> +		dev_err(priv->dev, "rcar driver trip error\n");
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
> +static int rcar_thermal_notify(struct thermal_zone_device *zone,
> +			       int trip, enum thermal_trip_type type)
> +{
> +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> +
> +	switch (type) {
> +	case THERMAL_TRIP_CRITICAL:
> +		/* FIXME */
> +		dev_warn(priv->dev,
> +			 "Thermal reached to critical temperature\n");
> +		machine_power_off();
> +		break;
> +	default:
> +		break;
> +	}
> +
>  	return 0;
>  }
>  
>  static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
> -	.get_temp = rcar_thermal_get_temp,
> +	.get_temp	= rcar_thermal_get_temp,
> +	.get_trip_type	= rcar_thermal_get_trip_type,
> +	.get_trip_temp	= rcar_thermal_get_trip_temp,
> +	.notify		= rcar_thermal_notify,
>  };
>  
how does the active trip point work if you do not bind any cooling
devices to it?

>  /*
> @@ -212,8 +286,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>  		goto error_free_priv;
>  	}
>  
> -	zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv,
> -					    &rcar_thermal_zone_ops, 0, 0);
> +	zone = thermal_zone_device_register("rcar_thermal", 4, 0, priv,
> +					    &rcar_thermal_zone_ops, 0,
> +					    IDLE_INTERVAL);

there is no interrupt for any thermal changes on this platform,
including critical overheat, right?

thanks,
rui


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

* Re: [PATCH 1/2] thermal: rcar: add rcar_zone_to_priv() macro
  2012-11-22  6:50 ` [PATCH 1/2] thermal: rcar: add rcar_zone_to_priv() macro Kuninori Morimoto
@ 2012-11-25  9:24   ` Zhang Rui
  0 siblings, 0 replies; 24+ messages in thread
From: Zhang Rui @ 2012-11-25  9:24 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Simon, Magnus, linux-pm

On Wed, 2012-11-21 at 22:50 -0800, Kuninori Morimoto wrote:
> This patch adds rcar_zone_to_priv()
> which is a helper macro for gettign private data.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Patch rebased on thermal next.

>From 5d251a94e56673b4fd22451c068a7a410cd6c687 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Wed, 21 Nov 2012 22:50:12 -0800
Subject: [PATCH] thermal: rcar: add rcar_zone_to_priv() macro

This patch adds rcar_zone_to_priv()
which is a helper macro for gettign private data.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/thermal/rcar_thermal.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 81dce23..b8e6ffc 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -43,6 +43,8 @@ struct rcar_thermal_priv {
 	u32 comp;
 };
 
+#define rcar_zone_to_priv(zone)		(zone->devdata)
+
 /*
  *		basic functions
  */
@@ -96,7 +98,7 @@ static void rcar_thermal_bset(struct rcar_thermal_priv *priv, u32 reg,
 static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
 			   unsigned long *temp)
 {
-	struct rcar_thermal_priv *priv = zone->devdata;
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
 	int val, min, max, tmp;
 
 	tmp = -200; /* default */
-- 
1.7.7.6




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

* Re: [PATCH 2/2] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-11-23  6:29   ` Zhang Rui
@ 2012-11-26  1:40     ` Kuninori Morimoto
  2012-11-26  1:52       ` Zhang Rui
  0 siblings, 1 reply; 24+ messages in thread
From: Kuninori Morimoto @ 2012-11-26  1:40 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Simon, Magnus, linux-pm


Hi Zhang

Thank you for your reply

> > +static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
> > +				      int trip, unsigned long *temp)
> > +{
> > +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> > +
> > +	/* see rcar_thermal_get_temp() */
> > +	switch (trip) {
> > +	case 0: /* -45 <= temp < +45 */
> > +		*temp = -45 - 1;
> > +		break;
> 
> does this mean you expect the thermal driver to take some action when
> the temperature is higher than -45C?
> 
> > +	case 1: /* +45 <= temp < +90 */
> > +		*temp = 45 - 1;
> > +		break;
> what do you expect to happen when the temperature is higher than 45C but
> lower than 90C?
> 
> > +	case 2: /* +90 <= temp < +135 */
> > +		*temp = 90 - 1;
> > +		break;
> > +	default:
> > +		dev_err(priv->dev, "rcar driver trip error\n");
> > +		return -EINVAL;
> > +	}
(snip)
> >  static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
> > -	.get_temp = rcar_thermal_get_temp,
> > +	.get_temp	= rcar_thermal_get_temp,
> > +	.get_trip_type	= rcar_thermal_get_trip_type,
> > +	.get_trip_temp	= rcar_thermal_get_trip_temp,
> > +	.notify		= rcar_thermal_notify,
> >  };
> >  
> how does the active trip point work if you do not bind any cooling
> devices to it?
> 
> >  /*
> > @@ -212,8 +286,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)
> >  		goto error_free_priv;
> >  	}
> >  
> > -	zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv,
> > -					    &rcar_thermal_zone_ops, 0, 0);
> > +	zone = thermal_zone_device_register("rcar_thermal", 4, 0, priv,
> > +					    &rcar_thermal_zone_ops, 0,
> > +					    IDLE_INTERVAL);
> 
> there is no interrupt for any thermal changes on this platform,
> including critical overheat, right?

Now, we need critical shutdown only at this point.
Then, should I remove active/hot trip ?
If yes, I can send v2 patch.

BTW, does thermal frame work use 45C ? or 45*1000 mC ?
Maybe A * 1000 mC is correct ?

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 2/2] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-11-26  1:40     ` Kuninori Morimoto
@ 2012-11-26  1:52       ` Zhang Rui
  2012-11-26  2:30         ` [PATCH 0/3 v2] thermal: rcar: add critical shutdown support Kuninori Morimoto
  0 siblings, 1 reply; 24+ messages in thread
From: Zhang Rui @ 2012-11-26  1:52 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Simon, Magnus, linux-pm

On Sun, 2012-11-25 at 17:40 -0800, Kuninori Morimoto wrote:
> Hi Zhang
> 
> Thank you for your reply
> 
> > > +static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
> > > +				      int trip, unsigned long *temp)
> > > +{
> > > +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> > > +
> > > +	/* see rcar_thermal_get_temp() */
> > > +	switch (trip) {
> > > +	case 0: /* -45 <= temp < +45 */
> > > +		*temp = -45 - 1;
> > > +		break;
> > 
> > does this mean you expect the thermal driver to take some action when
> > the temperature is higher than -45C?
> > 
> > > +	case 1: /* +45 <= temp < +90 */
> > > +		*temp = 45 - 1;
> > > +		break;
> > what do you expect to happen when the temperature is higher than 45C but
> > lower than 90C?
> > 
> > > +	case 2: /* +90 <= temp < +135 */
> > > +		*temp = 90 - 1;
> > > +		break;
> > > +	default:
> > > +		dev_err(priv->dev, "rcar driver trip error\n");
> > > +		return -EINVAL;
> > > +	}
> (snip)
> > >  static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
> > > -	.get_temp = rcar_thermal_get_temp,
> > > +	.get_temp	= rcar_thermal_get_temp,
> > > +	.get_trip_type	= rcar_thermal_get_trip_type,
> > > +	.get_trip_temp	= rcar_thermal_get_trip_temp,
> > > +	.notify		= rcar_thermal_notify,
> > >  };
> > >  
> > how does the active trip point work if you do not bind any cooling
> > devices to it?
> > 
> > >  /*
> > > @@ -212,8 +286,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)
> > >  		goto error_free_priv;
> > >  	}
> > >  
> > > -	zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv,
> > > -					    &rcar_thermal_zone_ops, 0, 0);
> > > +	zone = thermal_zone_device_register("rcar_thermal", 4, 0, priv,
> > > +					    &rcar_thermal_zone_ops, 0,
> > > +					    IDLE_INTERVAL);
> > 
> > there is no interrupt for any thermal changes on this platform,
> > including critical overheat, right?
> 
> Now, we need critical shutdown only at this point.
> Then, should I remove active/hot trip ?
> If yes, I can send v2 patch.
> 
yep, please remove active and hot trip points.

> BTW, does thermal frame work use 45C ? or 45*1000 mC ?
> Maybe A * 1000 mC is correct ?
> 

I'm not sure if I understand correctly.
The unit of trip point temperature is Milli-Celsius.

thanks,
rui


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

* Re: [PATCH 0/3 v2] thermal: rcar: add critical shutdown support
  2012-11-26  1:52       ` Zhang Rui
@ 2012-11-26  2:30         ` Kuninori Morimoto
  2012-11-26  2:32           ` [PATCH 1/3] thermal: rcar: fixup the unit of temperature Kuninori Morimoto, Kuninori Morimoto
                             ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Kuninori Morimoto @ 2012-11-26  2:30 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Simon, Magnus, linux-pm


Hi Zhang

These are v2 patches for rcar thermal driver to add critical shutdown support.

Kuninori Morimoto (3):
      thermal: rcar: fixup the unit of temperature
      thermal: rcar: add rcar_zone_to_priv() macro
      thermal: rcar: add .get_trip_type/temp and .notify support

 drivers/thermal/rcar_thermal.c |   75 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 70 insertions(+), 5 deletions(-)

These are based on latest rzhang/next branch

Best regards
---
Kuninori Morimoto

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

* [PATCH 1/3] thermal: rcar: fixup the unit of temperature
  2012-11-26  2:30         ` [PATCH 0/3 v2] thermal: rcar: add critical shutdown support Kuninori Morimoto
@ 2012-11-26  2:32           ` Kuninori Morimoto, Kuninori Morimoto
  2012-11-26  2:59             ` Zhang Rui
  2012-11-26  2:32           ` [PATCH 2/3] thermal: rcar: add rcar_zone_to_priv() macro Kuninori Morimoto, Kuninori Morimoto
  2012-11-26  2:32           ` [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support Kuninori Morimoto, Kuninori Morimoto
  2 siblings, 1 reply; 24+ messages in thread
From: Kuninori Morimoto, Kuninori Morimoto @ 2012-11-26  2:32 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto

The unit of temperature is Milli-Celsius.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/thermal/rcar_thermal.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 81dce23..f2678ff 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -43,6 +43,8 @@ struct rcar_thermal_priv {
 	u32 comp;
 };
 
+#define MCELSIUS(temp)			((temp) * 1000)
+
 /*
  *		basic functions
  */
@@ -169,7 +171,7 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
 		}
 	}
 
-	*temp = tmp;
+	*temp = MCELSIUS(tmp);
 	return 0;
 }
 
-- 
1.7.9.5


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

* [PATCH 2/3] thermal: rcar: add rcar_zone_to_priv() macro
  2012-11-26  2:30         ` [PATCH 0/3 v2] thermal: rcar: add critical shutdown support Kuninori Morimoto
  2012-11-26  2:32           ` [PATCH 1/3] thermal: rcar: fixup the unit of temperature Kuninori Morimoto, Kuninori Morimoto
@ 2012-11-26  2:32           ` Kuninori Morimoto, Kuninori Morimoto
  2012-11-26  2:59             ` Zhang Rui
  2012-11-26  2:32           ` [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support Kuninori Morimoto, Kuninori Morimoto
  2 siblings, 1 reply; 24+ messages in thread
From: Kuninori Morimoto, Kuninori Morimoto @ 2012-11-26  2:32 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto

This patch adds rcar_zone_to_priv()
which is a helper macro for gettign private data.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/thermal/rcar_thermal.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index f2678ff..90db951 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -44,6 +44,7 @@ struct rcar_thermal_priv {
 };
 
 #define MCELSIUS(temp)			((temp) * 1000)
+#define rcar_zone_to_priv(zone)		(zone->devdata)
 
 /*
  *		basic functions
@@ -98,7 +99,7 @@ static void rcar_thermal_bset(struct rcar_thermal_priv *priv, u32 reg,
 static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
 			   unsigned long *temp)
 {
-	struct rcar_thermal_priv *priv = zone->devdata;
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
 	int val, min, max, tmp;
 
 	tmp = -200; /* default */
-- 
1.7.9.5


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

* [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-11-26  2:30         ` [PATCH 0/3 v2] thermal: rcar: add critical shutdown support Kuninori Morimoto
  2012-11-26  2:32           ` [PATCH 1/3] thermal: rcar: fixup the unit of temperature Kuninori Morimoto, Kuninori Morimoto
  2012-11-26  2:32           ` [PATCH 2/3] thermal: rcar: add rcar_zone_to_priv() macro Kuninori Morimoto, Kuninori Morimoto
@ 2012-11-26  2:32           ` Kuninori Morimoto, Kuninori Morimoto
  2012-12-03  0:15             ` Kuninori Morimoto
  2012-12-03  1:02             ` Zhang Rui
  2 siblings, 2 replies; 24+ messages in thread
From: Kuninori Morimoto, Kuninori Morimoto @ 2012-11-26  2:32 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto

This patch adds .get_trip_type(), .get_trip_temp(), and .notify()
on rcar_thermal_zone_ops.
Driver will try platform power OFF if it reached to
critical temperature.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/thermal/rcar_thermal.c |   68 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 65 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 90db951..e1aedcc 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -22,10 +22,13 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/reboot.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/thermal.h>
 
+#define IDLE_INTERVAL	5000
+
 #define THSCR	0x2c
 #define THSSR	0x30
 
@@ -176,8 +179,66 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
 	return 0;
 }
 
+static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
+				      int trip, enum thermal_trip_type *type)
+{
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+
+	/* see rcar_thermal_get_temp() */
+	switch (trip) {
+	case 0: /* +90 <= temp < +135 */
+		*type = THERMAL_TRIP_CRITICAL;
+		break;
+	default:
+		dev_err(priv->dev, "rcar driver trip error\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
+				      int trip, unsigned long *temp)
+{
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+
+	/* see rcar_thermal_get_temp() */
+	switch (trip) {
+	case 0: /* +90 <= temp < +135 */
+		*temp = MCELSIUS(90 - 1);
+		break;
+	default:
+		dev_err(priv->dev, "rcar driver trip error\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int rcar_thermal_notify(struct thermal_zone_device *zone,
+			       int trip, enum thermal_trip_type type)
+{
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+
+	switch (type) {
+	case THERMAL_TRIP_CRITICAL:
+		/* FIXME */
+		dev_warn(priv->dev,
+			 "Thermal reached to critical temperature\n");
+		machine_power_off();
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
 static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
-	.get_temp = rcar_thermal_get_temp,
+	.get_temp	= rcar_thermal_get_temp,
+	.get_trip_type	= rcar_thermal_get_trip_type,
+	.get_trip_temp	= rcar_thermal_get_trip_temp,
+	.notify		= rcar_thermal_notify,
 };
 
 /*
@@ -211,8 +272,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv,
-				    &rcar_thermal_zone_ops, NULL, 0, 0);
+	zone = thermal_zone_device_register("rcar_thermal", 1, 0, priv,
+					    &rcar_thermal_zone_ops, NULL, 0,
+					    IDLE_INTERVAL);
 	if (IS_ERR(zone)) {
 		dev_err(&pdev->dev, "thermal zone device is NULL\n");
 		return PTR_ERR(zone);
-- 
1.7.9.5


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

* Re: [PATCH 1/3] thermal: rcar: fixup the unit of temperature
  2012-11-26  2:32           ` [PATCH 1/3] thermal: rcar: fixup the unit of temperature Kuninori Morimoto, Kuninori Morimoto
@ 2012-11-26  2:59             ` Zhang Rui
  0 siblings, 0 replies; 24+ messages in thread
From: Zhang Rui @ 2012-11-26  2:59 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto

On Sun, 2012-11-25 at 18:32 -0800, Kuninori Morimoto wrote:
> The unit of temperature is Milli-Celsius.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

applied.

thanks,
rui
> ---
>  drivers/thermal/rcar_thermal.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index 81dce23..f2678ff 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -43,6 +43,8 @@ struct rcar_thermal_priv {
>  	u32 comp;
>  };
>  
> +#define MCELSIUS(temp)			((temp) * 1000)
> +
>  /*
>   *		basic functions
>   */
> @@ -169,7 +171,7 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
>  		}
>  	}
>  
> -	*temp = tmp;
> +	*temp = MCELSIUS(tmp);
>  	return 0;
>  }
>  



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

* Re: [PATCH 2/3] thermal: rcar: add rcar_zone_to_priv() macro
  2012-11-26  2:32           ` [PATCH 2/3] thermal: rcar: add rcar_zone_to_priv() macro Kuninori Morimoto, Kuninori Morimoto
@ 2012-11-26  2:59             ` Zhang Rui
  0 siblings, 0 replies; 24+ messages in thread
From: Zhang Rui @ 2012-11-26  2:59 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto

On Sun, 2012-11-25 at 18:32 -0800, Kuninori Morimoto wrote:
> This patch adds rcar_zone_to_priv()
> which is a helper macro for gettign private data.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

applied.

thanks,
rui
> ---
>  drivers/thermal/rcar_thermal.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index f2678ff..90db951 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -44,6 +44,7 @@ struct rcar_thermal_priv {
>  };
>  
>  #define MCELSIUS(temp)			((temp) * 1000)
> +#define rcar_zone_to_priv(zone)		(zone->devdata)
>  
>  /*
>   *		basic functions
> @@ -98,7 +99,7 @@ static void rcar_thermal_bset(struct rcar_thermal_priv *priv, u32 reg,
>  static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
>  			   unsigned long *temp)
>  {
> -	struct rcar_thermal_priv *priv = zone->devdata;
> +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
>  	int val, min, max, tmp;
>  
>  	tmp = -200; /* default */



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

* Re: [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-11-26  2:32           ` [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support Kuninori Morimoto, Kuninori Morimoto
@ 2012-12-03  0:15             ` Kuninori Morimoto
  2012-12-03  1:09               ` Zhang Rui
  2012-12-03  1:02             ` Zhang Rui
  1 sibling, 1 reply; 24+ messages in thread
From: Kuninori Morimoto @ 2012-12-03  0:15 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto


Hi Zhang

I couldn't find this patch on v3.8 list.
Is this patch not good ?

> This patch adds .get_trip_type(), .get_trip_temp(), and .notify()
> on rcar_thermal_zone_ops.
> Driver will try platform power OFF if it reached to
> critical temperature.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  drivers/thermal/rcar_thermal.c |   68 ++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 65 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index 90db951..e1aedcc 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -22,10 +22,13 @@
>  #include <linux/io.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
> +#include <linux/reboot.h>
>  #include <linux/slab.h>
>  #include <linux/spinlock.h>
>  #include <linux/thermal.h>
>  
> +#define IDLE_INTERVAL	5000
> +
>  #define THSCR	0x2c
>  #define THSSR	0x30
>  
> @@ -176,8 +179,66 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
>  	return 0;
>  }
>  
> +static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
> +				      int trip, enum thermal_trip_type *type)
> +{
> +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> +
> +	/* see rcar_thermal_get_temp() */
> +	switch (trip) {
> +	case 0: /* +90 <= temp < +135 */
> +		*type = THERMAL_TRIP_CRITICAL;
> +		break;
> +	default:
> +		dev_err(priv->dev, "rcar driver trip error\n");
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
> +static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
> +				      int trip, unsigned long *temp)
> +{
> +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> +
> +	/* see rcar_thermal_get_temp() */
> +	switch (trip) {
> +	case 0: /* +90 <= temp < +135 */
> +		*temp = MCELSIUS(90 - 1);
> +		break;
> +	default:
> +		dev_err(priv->dev, "rcar driver trip error\n");
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
> +static int rcar_thermal_notify(struct thermal_zone_device *zone,
> +			       int trip, enum thermal_trip_type type)
> +{
> +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> +
> +	switch (type) {
> +	case THERMAL_TRIP_CRITICAL:
> +		/* FIXME */
> +		dev_warn(priv->dev,
> +			 "Thermal reached to critical temperature\n");
> +		machine_power_off();
> +		break;
> +	default:
> +		break;
> +	}
> +
> +	return 0;
> +}
> +
>  static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
> -	.get_temp = rcar_thermal_get_temp,
> +	.get_temp	= rcar_thermal_get_temp,
> +	.get_trip_type	= rcar_thermal_get_trip_type,
> +	.get_trip_temp	= rcar_thermal_get_trip_temp,
> +	.notify		= rcar_thermal_notify,
>  };
>  
>  /*
> @@ -211,8 +272,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  	}
>  
> -	zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv,
> -				    &rcar_thermal_zone_ops, NULL, 0, 0);
> +	zone = thermal_zone_device_register("rcar_thermal", 1, 0, priv,
> +					    &rcar_thermal_zone_ops, NULL, 0,
> +					    IDLE_INTERVAL);
>  	if (IS_ERR(zone)) {
>  		dev_err(&pdev->dev, "thermal zone device is NULL\n");
>  		return PTR_ERR(zone);
> -- 
> 1.7.9.5
> 


Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-11-26  2:32           ` [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support Kuninori Morimoto, Kuninori Morimoto
  2012-12-03  0:15             ` Kuninori Morimoto
@ 2012-12-03  1:02             ` Zhang Rui
  2012-12-03  2:20               ` Kuninori Morimoto
  1 sibling, 1 reply; 24+ messages in thread
From: Zhang Rui @ 2012-12-03  1:02 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto

On Sun, 2012-11-25 at 18:32 -0800, Kuninori Morimoto wrote:
> This patch adds .get_trip_type(), .get_trip_temp(), and .notify()
> on rcar_thermal_zone_ops.
> Driver will try platform power OFF if it reached to
> critical temperature.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  drivers/thermal/rcar_thermal.c |   68 ++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 65 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index 90db951..e1aedcc 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -22,10 +22,13 @@
>  #include <linux/io.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
> +#include <linux/reboot.h>
>  #include <linux/slab.h>
>  #include <linux/spinlock.h>
>  #include <linux/thermal.h>
>  
> +#define IDLE_INTERVAL	5000
> +
>  #define THSCR	0x2c
>  #define THSSR	0x30
>  
> @@ -176,8 +179,66 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
>  	return 0;
>  }
>  
> +static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
> +				      int trip, enum thermal_trip_type *type)
> +{
> +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> +
> +	/* see rcar_thermal_get_temp() */
> +	switch (trip) {
> +	case 0: /* +90 <= temp < +135 */
> +		*type = THERMAL_TRIP_CRITICAL;
> +		break;
> +	default:
> +		dev_err(priv->dev, "rcar driver trip error\n");
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
> +static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
> +				      int trip, unsigned long *temp)
> +{
> +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> +
> +	/* see rcar_thermal_get_temp() */
> +	switch (trip) {
> +	case 0: /* +90 <= temp < +135 */
> +		*temp = MCELSIUS(90 - 1);

what does the comment above mean?
the system is supposed to run from 90C to 135C? but you're setting the
critical trip point to 89C.

thanks,
rui


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

* Re: [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-12-03  0:15             ` Kuninori Morimoto
@ 2012-12-03  1:09               ` Zhang Rui
  2012-12-03  2:11                 ` Kuninori Morimoto
  0 siblings, 1 reply; 24+ messages in thread
From: Zhang Rui @ 2012-12-03  1:09 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto

Hi, Kuninori,

On Sun, 2012-12-02 at 16:15 -0800, Kuninori Morimoto wrote:
> Hi Zhang
> 
> I couldn't find this patch on v3.8 list.
> Is this patch not good ?
> 
No, the patch looks okay.
This patch set is sent too late for 3.8. Usually patches need to stay in
linux-next for at least two weeks before they are pushing upstream,
especially when there are some big changes made in the patch.
so I just picked up the first two, and leave this one for 3.9.

thanks,
rui

> > This patch adds .get_trip_type(), .get_trip_temp(), and .notify()
> > on rcar_thermal_zone_ops.
> > Driver will try platform power OFF if it reached to
> > critical temperature.
> > 
> > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > ---
> >  drivers/thermal/rcar_thermal.c |   68 ++++++++++++++++++++++++++++++++++++++--
> >  1 file changed, 65 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> > index 90db951..e1aedcc 100644
> > --- a/drivers/thermal/rcar_thermal.c
> > +++ b/drivers/thermal/rcar_thermal.c
> > @@ -22,10 +22,13 @@
> >  #include <linux/io.h>
> >  #include <linux/module.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/reboot.h>
> >  #include <linux/slab.h>
> >  #include <linux/spinlock.h>
> >  #include <linux/thermal.h>
> >  
> > +#define IDLE_INTERVAL	5000
> > +
> >  #define THSCR	0x2c
> >  #define THSSR	0x30
> >  
> > @@ -176,8 +179,66 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
> >  	return 0;
> >  }
> >  
> > +static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
> > +				      int trip, enum thermal_trip_type *type)
> > +{
> > +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> > +
> > +	/* see rcar_thermal_get_temp() */
> > +	switch (trip) {
> > +	case 0: /* +90 <= temp < +135 */
> > +		*type = THERMAL_TRIP_CRITICAL;
> > +		break;
> > +	default:
> > +		dev_err(priv->dev, "rcar driver trip error\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
> > +				      int trip, unsigned long *temp)
> > +{
> > +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> > +
> > +	/* see rcar_thermal_get_temp() */
> > +	switch (trip) {
> > +	case 0: /* +90 <= temp < +135 */
> > +		*temp = MCELSIUS(90 - 1);
> > +		break;
> > +	default:
> > +		dev_err(priv->dev, "rcar driver trip error\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static int rcar_thermal_notify(struct thermal_zone_device *zone,
> > +			       int trip, enum thermal_trip_type type)
> > +{
> > +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> > +
> > +	switch (type) {
> > +	case THERMAL_TRIP_CRITICAL:
> > +		/* FIXME */
> > +		dev_warn(priv->dev,
> > +			 "Thermal reached to critical temperature\n");
> > +		machine_power_off();
> > +		break;
> > +	default:
> > +		break;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> >  static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
> > -	.get_temp = rcar_thermal_get_temp,
> > +	.get_temp	= rcar_thermal_get_temp,
> > +	.get_trip_type	= rcar_thermal_get_trip_type,
> > +	.get_trip_temp	= rcar_thermal_get_trip_temp,
> > +	.notify		= rcar_thermal_notify,
> >  };
> >  
> >  /*
> > @@ -211,8 +272,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)
> >  		return -ENOMEM;
> >  	}
> >  
> > -	zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv,
> > -				    &rcar_thermal_zone_ops, NULL, 0, 0);
> > +	zone = thermal_zone_device_register("rcar_thermal", 1, 0, priv,
> > +					    &rcar_thermal_zone_ops, NULL, 0,
> > +					    IDLE_INTERVAL);
> >  	if (IS_ERR(zone)) {
> >  		dev_err(&pdev->dev, "thermal zone device is NULL\n");
> >  		return PTR_ERR(zone);
> > -- 
> > 1.7.9.5
> > 
> 
> 
> Best regards
> ---
> Kuninori Morimoto



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

* Re: [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-12-03  1:09               ` Zhang Rui
@ 2012-12-03  2:11                 ` Kuninori Morimoto
  0 siblings, 0 replies; 24+ messages in thread
From: Kuninori Morimoto @ 2012-12-03  2:11 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto


Hi Zhang

> Hi, Kuninori,
> 
> On Sun, 2012-12-02 at 16:15 -0800, Kuninori Morimoto wrote:
> > Hi Zhang
> > 
> > I couldn't find this patch on v3.8 list.
> > Is this patch not good ?
> > 
> No, the patch looks okay.
> This patch set is sent too late for 3.8. Usually patches need to stay in
> linux-next for at least two weeks before they are pushing upstream,
> especially when there are some big changes made in the patch.
> so I just picked up the first two, and leave this one for 3.9.

OK. I see.
Thank you

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-12-03  1:02             ` Zhang Rui
@ 2012-12-03  2:20               ` Kuninori Morimoto
  2012-12-03  2:22                 ` Zhang Rui
  2012-12-03  2:25                 ` Zhang Rui
  0 siblings, 2 replies; 24+ messages in thread
From: Kuninori Morimoto @ 2012-12-03  2:20 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto


Hi Zhang

> > +static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
> > +				      int trip, unsigned long *temp)
> > +{
> > +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> > +
> > +	/* see rcar_thermal_get_temp() */
> > +	switch (trip) {
> > +	case 0: /* +90 <= temp < +135 */
> > +		*temp = MCELSIUS(90 - 1);
> 
> what does the comment above mean?
> the system is supposed to run from 90C to 135C? but you're setting the
> critical trip point to 89C.

Oops, sorry my original patch used old kernel for test.
Then it needed this -1.
But now it was already solved by this patch.

29321357ac6db54eeb8574da1f6c3e0ce8cfbb60
(thermal: fix off-by-1 error in trip point trigger condition)

I can fix this, but which is best for you ?
v2 patch ? or additional patch ?

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-12-03  2:20               ` Kuninori Morimoto
@ 2012-12-03  2:22                 ` Zhang Rui
  2012-12-03  2:25                 ` Zhang Rui
  1 sibling, 0 replies; 24+ messages in thread
From: Zhang Rui @ 2012-12-03  2:22 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto

On Sun, 2012-12-02 at 18:20 -0800, Kuninori Morimoto wrote:
> Hi Zhang
> 
> > > +static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
> > > +				      int trip, unsigned long *temp)
> > > +{
> > > +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> > > +
> > > +	/* see rcar_thermal_get_temp() */
> > > +	switch (trip) {
> > > +	case 0: /* +90 <= temp < +135 */
> > > +		*temp = MCELSIUS(90 - 1);
> > 
> > what does the comment above mean?
> > the system is supposed to run from 90C to 135C? but you're setting the
> > critical trip point to 89C.
> 
> Oops, sorry my original patch used old kernel for test.
> Then it needed this -1.
> But now it was already solved by this patch.
> 
> 29321357ac6db54eeb8574da1f6c3e0ce8cfbb60
> (thermal: fix off-by-1 error in trip point trigger condition)
> 
> I can fix this, but which is best for you ?
> v2 patch ? or additional patch ?
> 
please send V2.

thanks,
rui


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

* Re: [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-12-03  2:20               ` Kuninori Morimoto
  2012-12-03  2:22                 ` Zhang Rui
@ 2012-12-03  2:25                 ` Zhang Rui
  2012-12-03  2:39                   ` Kuninori Morimoto
  1 sibling, 1 reply; 24+ messages in thread
From: Zhang Rui @ 2012-12-03  2:25 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto

On Sun, 2012-12-02 at 18:20 -0800, Kuninori Morimoto wrote:
> Hi Zhang
> 
> > > +static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
> > > +				      int trip, unsigned long *temp)
> > > +{
> > > +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> > > +
> > > +	/* see rcar_thermal_get_temp() */
> > > +	switch (trip) {
> > > +	case 0: /* +90 <= temp < +135 */
BTW, the thing I do not understand is,
what does "135" in the comment mean?

thanks,
rui
> > > +		*temp = MCELSIUS(90 - 1);
> > 
> > what does the comment above mean?
> > the system is supposed to run from 90C to 135C? but you're setting the
> > critical trip point to 89C.
> 
> Oops, sorry my original patch used old kernel for test.
> Then it needed this -1.
> But now it was already solved by this patch.
> 
> 29321357ac6db54eeb8574da1f6c3e0ce8cfbb60
> (thermal: fix off-by-1 error in trip point trigger condition)
> 
> I can fix this, but which is best for you ?
> v2 patch ? or additional patch ?
> 

> Best regards
> ---
> Kuninori Morimoto



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

* Re: [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-12-03  2:25                 ` Zhang Rui
@ 2012-12-03  2:39                   ` Kuninori Morimoto
  2012-12-03  2:48                     ` [PATCH v2] " Kuninori Morimoto, Kuninori Morimoto
  0 siblings, 1 reply; 24+ messages in thread
From: Kuninori Morimoto @ 2012-12-03  2:39 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto


Hi Zhang

> > > > +static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
> > > > +				      int trip, unsigned long *temp)
> > > > +{
> > > > +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> > > > +
> > > > +	/* see rcar_thermal_get_temp() */
> > > > +	switch (trip) {
> > > > +	case 0: /* +90 <= temp < +135 */
> BTW, the thing I do not understand is,
> what does "135" in the comment mean?

135 is maximum temperature on this chip,
but I understand your point.
/* +90 <= temp */ is enough.
I will fix this comment in v2 too.

Best regards
---
Kuninori Morimoto

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

* [PATCH v2] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-12-03  2:39                   ` Kuninori Morimoto
@ 2012-12-03  2:48                     ` Kuninori Morimoto, Kuninori Morimoto
  2013-01-04  7:23                       ` Zhang Rui
  0 siblings, 1 reply; 24+ messages in thread
From: Kuninori Morimoto, Kuninori Morimoto @ 2012-12-03  2:48 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto

This patch adds .get_trip_type(), .get_trip_temp(), and .notify()
on rcar_thermal_zone_ops.
Driver will try platform power OFF if it reached to
critical temperature.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2

 - fixup (90 - 1) -> (90)
 - fixup comment /* +90 <= temp <= +135 */ -> /* +90 <= temp */

 drivers/thermal/rcar_thermal.c |   68 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 65 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 90db951..89979ff 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -22,10 +22,13 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/reboot.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/thermal.h>
 
+#define IDLE_INTERVAL	5000
+
 #define THSCR	0x2c
 #define THSSR	0x30
 
@@ -176,8 +179,66 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
 	return 0;
 }
 
+static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
+				      int trip, enum thermal_trip_type *type)
+{
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+
+	/* see rcar_thermal_get_temp() */
+	switch (trip) {
+	case 0: /* +90 <= temp */
+		*type = THERMAL_TRIP_CRITICAL;
+		break;
+	default:
+		dev_err(priv->dev, "rcar driver trip error\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
+				      int trip, unsigned long *temp)
+{
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+
+	/* see rcar_thermal_get_temp() */
+	switch (trip) {
+	case 0: /* +90 <= temp */
+		*temp = MCELSIUS(90);
+		break;
+	default:
+		dev_err(priv->dev, "rcar driver trip error\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int rcar_thermal_notify(struct thermal_zone_device *zone,
+			       int trip, enum thermal_trip_type type)
+{
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+
+	switch (type) {
+	case THERMAL_TRIP_CRITICAL:
+		/* FIXME */
+		dev_warn(priv->dev,
+			 "Thermal reached to critical temperature\n");
+		machine_power_off();
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
 static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
-	.get_temp = rcar_thermal_get_temp,
+	.get_temp	= rcar_thermal_get_temp,
+	.get_trip_type	= rcar_thermal_get_trip_type,
+	.get_trip_temp	= rcar_thermal_get_trip_temp,
+	.notify		= rcar_thermal_notify,
 };
 
 /*
@@ -211,8 +272,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv,
-				    &rcar_thermal_zone_ops, NULL, 0, 0);
+	zone = thermal_zone_device_register("rcar_thermal", 1, 0, priv,
+					    &rcar_thermal_zone_ops, NULL, 0,
+					    IDLE_INTERVAL);
 	if (IS_ERR(zone)) {
 		dev_err(&pdev->dev, "thermal zone device is NULL\n");
 		return PTR_ERR(zone);
-- 
1.7.9.5


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

* Re: [PATCH v2] thermal: rcar: add .get_trip_type/temp and .notify support
  2012-12-03  2:48                     ` [PATCH v2] " Kuninori Morimoto, Kuninori Morimoto
@ 2013-01-04  7:23                       ` Zhang Rui
  0 siblings, 0 replies; 24+ messages in thread
From: Zhang Rui @ 2013-01-04  7:23 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Simon, Magnus, linux-pm, Kuninori Morimoto

On Sun, 2012-12-02 at 18:48 -0800, Kuninori Morimoto wrote:
> This patch adds .get_trip_type(), .get_trip_temp(), and .notify()
> on rcar_thermal_zone_ops.
> Driver will try platform power OFF if it reached to
> critical temperature.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

applied to thermal-next tree.

thanks,
rui

> ---
> v1 -> v2
> 
>  - fixup (90 - 1) -> (90)
>  - fixup comment /* +90 <= temp <= +135 */ -> /* +90 <= temp */
> 
>  drivers/thermal/rcar_thermal.c |   68 ++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 65 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index 90db951..89979ff 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -22,10 +22,13 @@
>  #include <linux/io.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
> +#include <linux/reboot.h>
>  #include <linux/slab.h>
>  #include <linux/spinlock.h>
>  #include <linux/thermal.h>
>  
> +#define IDLE_INTERVAL	5000
> +
>  #define THSCR	0x2c
>  #define THSSR	0x30
>  
> @@ -176,8 +179,66 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
>  	return 0;
>  }
>  
> +static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
> +				      int trip, enum thermal_trip_type *type)
> +{
> +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> +
> +	/* see rcar_thermal_get_temp() */
> +	switch (trip) {
> +	case 0: /* +90 <= temp */
> +		*type = THERMAL_TRIP_CRITICAL;
> +		break;
> +	default:
> +		dev_err(priv->dev, "rcar driver trip error\n");
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
> +static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
> +				      int trip, unsigned long *temp)
> +{
> +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> +
> +	/* see rcar_thermal_get_temp() */
> +	switch (trip) {
> +	case 0: /* +90 <= temp */
> +		*temp = MCELSIUS(90);
> +		break;
> +	default:
> +		dev_err(priv->dev, "rcar driver trip error\n");
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
> +static int rcar_thermal_notify(struct thermal_zone_device *zone,
> +			       int trip, enum thermal_trip_type type)
> +{
> +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> +
> +	switch (type) {
> +	case THERMAL_TRIP_CRITICAL:
> +		/* FIXME */
> +		dev_warn(priv->dev,
> +			 "Thermal reached to critical temperature\n");
> +		machine_power_off();
> +		break;
> +	default:
> +		break;
> +	}
> +
> +	return 0;
> +}
> +
>  static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
> -	.get_temp = rcar_thermal_get_temp,
> +	.get_temp	= rcar_thermal_get_temp,
> +	.get_trip_type	= rcar_thermal_get_trip_type,
> +	.get_trip_temp	= rcar_thermal_get_trip_temp,
> +	.notify		= rcar_thermal_notify,
>  };
>  
>  /*
> @@ -211,8 +272,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  	}
>  
> -	zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv,
> -				    &rcar_thermal_zone_ops, NULL, 0, 0);
> +	zone = thermal_zone_device_register("rcar_thermal", 1, 0, priv,
> +					    &rcar_thermal_zone_ops, NULL, 0,
> +					    IDLE_INTERVAL);
>  	if (IS_ERR(zone)) {
>  		dev_err(&pdev->dev, "thermal zone device is NULL\n");
>  		return PTR_ERR(zone);



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

end of thread, other threads:[~2013-01-04  7:23 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-22  6:49 [PATCH 0/2] thermal: rcar: add emergency power down Kuninori Morimoto
2012-11-22  6:50 ` [PATCH 1/2] thermal: rcar: add rcar_zone_to_priv() macro Kuninori Morimoto
2012-11-25  9:24   ` Zhang Rui
2012-11-22  6:50 ` [PATCH 2/2] thermal: rcar: add .get_trip_type/temp and .notify support Kuninori Morimoto
2012-11-22  7:05   ` Magnus Damm
2012-11-23  6:29   ` Zhang Rui
2012-11-26  1:40     ` Kuninori Morimoto
2012-11-26  1:52       ` Zhang Rui
2012-11-26  2:30         ` [PATCH 0/3 v2] thermal: rcar: add critical shutdown support Kuninori Morimoto
2012-11-26  2:32           ` [PATCH 1/3] thermal: rcar: fixup the unit of temperature Kuninori Morimoto, Kuninori Morimoto
2012-11-26  2:59             ` Zhang Rui
2012-11-26  2:32           ` [PATCH 2/3] thermal: rcar: add rcar_zone_to_priv() macro Kuninori Morimoto, Kuninori Morimoto
2012-11-26  2:59             ` Zhang Rui
2012-11-26  2:32           ` [PATCH 3/3] thermal: rcar: add .get_trip_type/temp and .notify support Kuninori Morimoto, Kuninori Morimoto
2012-12-03  0:15             ` Kuninori Morimoto
2012-12-03  1:09               ` Zhang Rui
2012-12-03  2:11                 ` Kuninori Morimoto
2012-12-03  1:02             ` Zhang Rui
2012-12-03  2:20               ` Kuninori Morimoto
2012-12-03  2:22                 ` Zhang Rui
2012-12-03  2:25                 ` Zhang Rui
2012-12-03  2:39                   ` Kuninori Morimoto
2012-12-03  2:48                     ` [PATCH v2] " Kuninori Morimoto, Kuninori Morimoto
2013-01-04  7:23                       ` Zhang Rui

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