Message ID | 87pq36uo5v.wl%kuninori.morimoto.gx@renesas.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Delegated to: | Zhang Rui |
Headers | show |
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 -- 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
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 -- 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
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 -- 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
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 -- 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
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 -- 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 --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);
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(-)