diff mbox

[3/3] thermal: rcar: add .get_trip_type/temp and .notify support

Message ID 87ehjhw0ty.wl%kuninori.morimoto.gx@renesas.com (mailing list archive)
State Not Applicable, archived
Delegated to: Zhang Rui
Headers show

Commit Message

Kuninori Morimoto Nov. 26, 2012, 2:32 a.m. UTC
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(-)

Comments

Kuninori Morimoto Dec. 3, 2012, 12:15 a.m. UTC | #1
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
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhang, Rui Dec. 3, 2012, 1:02 a.m. UTC | #2
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

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhang, Rui Dec. 3, 2012, 1:09 a.m. UTC | #3
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


--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kuninori Morimoto Dec. 3, 2012, 2:11 a.m. UTC | #4
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
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kuninori Morimoto Dec. 3, 2012, 2:20 a.m. UTC | #5
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
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhang, Rui Dec. 3, 2012, 2:22 a.m. UTC | #6
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

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhang, Rui Dec. 3, 2012, 2:25 a.m. UTC | #7
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


--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kuninori Morimoto Dec. 3, 2012, 2:39 a.m. UTC | #8
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
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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