From: Kuninori Morimoto <[email protected]>
Current rcar thermal driver is using 90 degrees as trip temp, but it
should be based on each SoC / platform.
This patch enables to set trip temp via DT. (It uses db8500-thermal
style for it)
It will use 90 degrees as default trip temp if DT doesn't have it.
Signed-off-by: Kuninori Morimoto <[email protected]>
---
.../devicetree/bindings/thermal/rcar-thermal.txt | 2 ++
drivers/thermal/rcar_thermal.c | 34 ++++++++++++++++++++--
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
index 332e625..6c57f7e 100644
--- a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
@@ -18,6 +18,8 @@ Required properties:
Option properties:
- interrupts : use interrupt
+- tripN-temp : temperature of trip point N. it will use 90000 as default
+ if DT doesn't have tripN-temp
Example (non interrupt support):
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 5d4ae7d..d1d0b58 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");
@@ -361,6 +362,30 @@ static irqreturn_t rcar_thermal_irq(int irq, void *data)
/*
* platform functions
*/
+static void rcar_thermal_of_parse(struct rcar_thermal_priv *priv)
+{
+ struct device *dev = rcar_priv_to_dev(priv);
+ struct device_node *np = dev->of_node;
+ char prop_name[32];
+ s32 val;
+
+ /*
+ * let's use db8500 thermal style
+ */
+ sprintf(prop_name, "trip%d-temp", priv->id);
+ if (of_property_read_s32(np, prop_name, &val))
+ return;
+
+ if (val < -45000 ||
+ val > 125000) {
+ dev_err(dev, "unsupported trip temp, use default\n");
+ return;
+ }
+
+ /* overwrite trip temp */
+ priv->trip_temp = val;
+}
+
static int rcar_thermal_probe(struct platform_device *pdev)
{
struct rcar_thermal_common *common;
@@ -418,11 +443,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);
+ rcar_thermal_of_parse(priv);
+
priv->zone = thermal_zone_device_register("rcar_thermal",
1, 0, priv,
&rcar_thermal_zone_ops, NULL, 0,
--
1.9.1
Morimoto-san,
On Wed, Nov 25, 2015 at 01:45:14AM +0000, Kuninori Morimoto wrote:
>
> From: Kuninori Morimoto <[email protected]>
>
> Current rcar thermal driver is using 90 degrees as trip temp, but it
> should be based on each SoC / platform.
> This patch enables to set trip temp via DT. (It uses db8500-thermal
> style for it)
> It will use 90 degrees as default trip temp if DT doesn't have it.
>
> Signed-off-by: Kuninori Morimoto <[email protected]>
> ---
> .../devicetree/bindings/thermal/rcar-thermal.txt | 2 ++
> drivers/thermal/rcar_thermal.c | 34 ++++++++++++++++++++--
> 2 files changed, 33 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
> index 332e625..6c57f7e 100644
> --- a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
> +++ b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
> @@ -18,6 +18,8 @@ Required properties:
> Option properties:
>
> - interrupts : use interrupt
> +- tripN-temp : temperature of trip point N. it will use 90000 as default
> + if DT doesn't have tripN-temp
First of all, you are creating an entry with is specific to your driver.
That requires it to use proper prefixing.
Besides, your property is already covered by of-thermal. Please convert
your driver to use of-thermal, this way it will give you the flexibility
to configure thermal data in DT.
BR,
Hi Eduardo
Thank you for your feedback
> > From: Kuninori Morimoto <[email protected]>
> >
> > Current rcar thermal driver is using 90 degrees as trip temp, but it
> > should be based on each SoC / platform.
> > This patch enables to set trip temp via DT. (It uses db8500-thermal
> > style for it)
> > It will use 90 degrees as default trip temp if DT doesn't have it.
> >
> > Signed-off-by: Kuninori Morimoto <[email protected]>
> > ---
> > .../devicetree/bindings/thermal/rcar-thermal.txt | 2 ++
> > drivers/thermal/rcar_thermal.c | 34 ++++++++++++++++++++--
> > 2 files changed, 33 insertions(+), 3 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
> > index 332e625..6c57f7e 100644
> > --- a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
> > +++ b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
> > @@ -18,6 +18,8 @@ Required properties:
> > Option properties:
> >
> > - interrupts : use interrupt
> > +- tripN-temp : temperature of trip point N. it will use 90000 as default
> > + if DT doesn't have tripN-temp
>
> First of all, you are creating an entry with is specific to your driver.
> That requires it to use proper prefixing.
>
> Besides, your property is already covered by of-thermal. Please convert
> your driver to use of-thermal, this way it will give you the flexibility
> to configure thermal data in DT.
I see, but we need to keep compatibility for non-DT SoC.
(This driver is used from both DT, non-DT SoC)
Then, I noticed we can use .set_trip_temp, and it is very enough for us.
Hi Morimoto-san,
On Wed, Nov 25, 2015 at 6:23 AM, Kuninori Morimoto
<[email protected]> wrote:
>> Besides, your property is already covered by of-thermal. Please convert
>> your driver to use of-thermal, this way it will give you the flexibility
>> to configure thermal data in DT.
>
> I see, but we need to keep compatibility for non-DT SoC.
> (This driver is used from both DT, non-DT SoC)
Which SoCs with non-DT support use this driver in mainline?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi Geert
> <[email protected]> wrote:
> >> Besides, your property is already covered by of-thermal. Please convert
> >> your driver to use of-thermal, this way it will give you the flexibility
> >> to configure thermal data in DT.
> >
> > I see, but we need to keep compatibility for non-DT SoC.
> > (This driver is used from both DT, non-DT SoC)
>
> Which SoCs with non-DT support use this driver in mainline?
Oops, my bad.
I thought that this driver was used from SH too, but it didn't.