linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: rockchip: enable hwmon
@ 2019-11-18  5:24 schaecsn
  2019-12-02 14:52 ` Stefan Schaeckeler
  0 siblings, 1 reply; 6+ messages in thread
From: schaecsn @ 2019-11-18  5:24 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Amit Kucheria,
	Heiko Stuebner, linux-pm, linux-arm-kernel, linux-rockchip,
	linux-kernel

Enable hwmon for the soc and gpu temperature sensors.

Signed-off-by: Stefan Schaeckeler <schaecsn@gmx.net>

---
 drivers/thermal/rockchip_thermal.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index 343c2f5c5a25..e47c60010259 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -19,6 +19,8 @@
 #include <linux/mfd/syscon.h>
 #include <linux/pinctrl/consumer.h>

+#include "thermal_hwmon.h"
+
 /**
  * If the temperature over a period of time High,
  * the resulting TSHUT gave CRU module,let it reset the entire chip,
@@ -1321,8 +1323,15 @@ static int rockchip_thermal_probe(struct platform_device *pdev)

 	thermal->chip->control(thermal->regs, true);

-	for (i = 0; i < thermal->chip->chn_num; i++)
+	for (i = 0; i < thermal->chip->chn_num; i++) {
 		rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
+		thermal->sensors[i].tzd->tzp->no_hwmon = false;
+		error = thermal_add_hwmon_sysfs(thermal->sensors[i].tzd);
+		if (error)
+			dev_warn(&pdev->dev,
+				 "failed to register sensor %d with hwmon: %d\n",
+				 i, error);
+	}

 	platform_set_drvdata(pdev, thermal);

@@ -1344,6 +1353,7 @@ static int rockchip_thermal_remove(struct platform_device *pdev)
 	for (i = 0; i < thermal->chip->chn_num; i++) {
 		struct rockchip_thermal_sensor *sensor = &thermal->sensors[i];

+		thermal_remove_hwmon_sysfs(sensor->tzd);
 		rockchip_thermal_toggle_sensor(sensor, false);
 	}

--
2.24.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] thermal: rockchip: enable hwmon
  2019-11-18  5:24 [PATCH] thermal: rockchip: enable hwmon schaecsn
@ 2019-12-02 14:52 ` Stefan Schaeckeler
  2019-12-09 17:08   ` Daniel Lezcano
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Schaeckeler @ 2019-12-02 14:52 UTC (permalink / raw)
  To: rui.zhang, edubezval, daniel.lezcano, amit.kucheria, heiko,
	linux-pm, linux-arm-kernel, linux-rockchip, linux-kernel

Hello linux power management mailing list and others,

New month, new try. Could someone review this patch, please. I would really
like to see the Rockchip RK3399 temperature sensors hooked up to the hwmon API.

~ Stefan

> Enable hwmon for the soc and gpu temperature sensors.
>
> Signed-off-by: Stefan Schaeckeler <schaecsn@gmx.net>
>
> ---
>  drivers/thermal/rockchip_thermal.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
> index 343c2f5c5a25..e47c60010259 100644
> --- a/drivers/thermal/rockchip_thermal.c
> +++ b/drivers/thermal/rockchip_thermal.c
> @@ -19,6 +19,8 @@
>  #include <linux/mfd/syscon.h>
>  #include <linux/pinctrl/consumer.h>
>
> +#include "thermal_hwmon.h"
> +
>  /**
>   * If the temperature over a period of time High,
>   * the resulting TSHUT gave CRU module,let it reset the entire chip,
> @@ -1321,8 +1323,15 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
>
>  	thermal->chip->control(thermal->regs, true);
>
> -	for (i = 0; i < thermal->chip->chn_num; i++)
> +	for (i = 0; i < thermal->chip->chn_num; i++) {
>  		rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
> +		thermal->sensors[i].tzd->tzp->no_hwmon = false;
> +		error = thermal_add_hwmon_sysfs(thermal->sensors[i].tzd);
> +		if (error)
> +			dev_warn(&pdev->dev,
> +				 "failed to register sensor %d with hwmon: %d\n",
> +				 i, error);
> +	}
>
>  	platform_set_drvdata(pdev, thermal);
>
> @@ -1344,6 +1353,7 @@ static int rockchip_thermal_remove(struct platform_device *pdev)
>  	for (i = 0; i < thermal->chip->chn_num; i++) {
>  		struct rockchip_thermal_sensor *sensor = &thermal->sensors[i];
>
> +		thermal_remove_hwmon_sysfs(sensor->tzd);
>  		rockchip_thermal_toggle_sensor(sensor, false);
>  	}
>
> --
> 2.24.0
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] thermal: rockchip: enable hwmon
  2019-12-02 14:52 ` Stefan Schaeckeler
@ 2019-12-09 17:08   ` Daniel Lezcano
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2019-12-09 17:08 UTC (permalink / raw)
  To: schaecsn, rui.zhang, edubezval, amit.kucheria, heiko, linux-pm,
	linux-arm-kernel, linux-rockchip, linux-kernel


Hi Stefan,


On 02/12/2019 15:52, Stefan Schaeckeler wrote:
> Hello linux power management mailing list and others,
> 
> New month, new try. Could someone review this patch, please. I would reall=
> y
> like to see the Rockchip RK3399 temperature sensors hooked up to the hwmon=
>  API.

I don't know what is happening but there are some spurious '3D'
characters. Please fix it, elaborate a bit the changelog and resend.
I'll review it.

Thanks


>> Enable hwmon for the soc and gpu temperature sensors.
>>
>> Signed-off-by: Stefan Schaeckeler <schaecsn@gmx.net>
>>
>> ---
>>  drivers/thermal/rockchip_thermal.c | 12 +++++++++++-
>>  1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockch=
> ip_thermal.c
>> index 343c2f5c5a25..e47c60010259 100644
>> --- a/drivers/thermal/rockchip_thermal.c
>> +++ b/drivers/thermal/rockchip_thermal.c
>> @@ -19,6 +19,8 @@
>>  #include <linux/mfd/syscon.h>
>>  #include <linux/pinctrl/consumer.h>
>>
>> +#include "thermal_hwmon.h"
>> +
>>  /**
>>   * If the temperature over a period of time High,
>>   * the resulting TSHUT gave CRU module,let it reset the entire chip,
>> @@ -1321,8 +1323,15 @@ static int rockchip_thermal_probe(struct platform=
> _device *pdev)
>>
>>  	thermal->chip->control(thermal->regs, true);
>>
>> -	for (i =3D 0; i < thermal->chip->chn_num; i++)
>> +	for (i =3D 0; i < thermal->chip->chn_num; i++) {
>>  		rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
>> +		thermal->sensors[i].tzd->tzp->no_hwmon =3D false;
>> +		error =3D thermal_add_hwmon_sysfs(thermal->sensors[i].tzd);
>> +		if (error)
>> +			dev_warn(&pdev->dev,
>> +				 "failed to register sensor %d with hwmon: %d\n",
>> +				 i, error);
>> +	}
>>
>>  	platform_set_drvdata(pdev, thermal);
>>
>> @@ -1344,6 +1353,7 @@ static int rockchip_thermal_remove(struct platform=
> _device *pdev)
>>  	for (i =3D 0; i < thermal->chip->chn_num; i++) {
>>  		struct rockchip_thermal_sensor *sensor =3D &thermal->sensors[i];
>>
>> +		thermal_remove_hwmon_sysfs(sensor->tzd);
>>  		rockchip_thermal_toggle_sensor(sensor, false);
>>  	}
>>
>> --
>> 2.24.0
>>


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] thermal: rockchip: enable hwmon
  2019-12-17  8:01 ` Daniel Lezcano
@ 2019-12-17  8:02   ` Chen-Yu Tsai
  0 siblings, 0 replies; 6+ messages in thread
From: Chen-Yu Tsai @ 2019-12-17  8:02 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Amit Kucheria, Heiko Stuebner, open list:THERMAL, linux-kernel,
	open list:ARM/Rockchip SoC...,
	Zhang Rui, Chen-Yu Tsai, linux-arm-kernel

On Tue, Dec 17, 2019 at 4:01 PM Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:
>
>
> Hi Chen-Yu,
>
> On 17/12/2019 06:23, Chen-Yu Tsai wrote:
> > From: Chen-Yu Tsai <wens@csie.org>
> >
> > By default of-based thermal driver do not have hwmon entries registered.
> >
> > Do this explicitly so users can use standard hwmon interfaces and tools
> > to read the temperature.
> >
> > This is based on similar changes for bcm2835_thermal in commit
> > d56c19d07e0b ("thermal: bcm2835: enable hwmon explicitly").
>
> Thanks for submitting this patch, but it is duplicate with:
>
> https://lore.kernel.org/linux-arm-kernel/20191212061702.BFE2D6E85603@corona.crabdance.com/
>
> which I picked up.

No problem. Thanks for the pointer.

ChenYu

>   -- Daniel
>
>
> > Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> > ---
> >  drivers/thermal/rockchip_thermal.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
> > index 9ed8085bb792..d53ba7dabf16 100644
> > --- a/drivers/thermal/rockchip_thermal.c
> > +++ b/drivers/thermal/rockchip_thermal.c
> > @@ -19,6 +19,8 @@
> >  #include <linux/mfd/syscon.h>
> >  #include <linux/pinctrl/consumer.h>
> >
> > +#include "thermal_hwmon.h"
> > +
> >  /*
> >   * If the temperature over a period of time High,
> >   * the resulting TSHUT gave CRU module,let it reset the entire chip,
> > @@ -1210,7 +1212,11 @@ rockchip_thermal_register_sensor(struct platform_device *pdev,
> >               return error;
> >       }
> >
> > -     return 0;
> > +     /* thermal_zone doesn't enable hwmon as default, enable it here */
> > +     sensor->tzd->tzp->no_hwmon = false;
> > +     error = thermal_add_hwmon_sysfs(sensor->tzd);
> > +
> > +     return error;
> >  }
> >
> >  /**
> >
>
>
> --
>  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
>
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] thermal: rockchip: enable hwmon
  2019-12-17  5:23 Chen-Yu Tsai
@ 2019-12-17  8:01 ` Daniel Lezcano
  2019-12-17  8:02   ` Chen-Yu Tsai
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Lezcano @ 2019-12-17  8:01 UTC (permalink / raw)
  To: Chen-Yu Tsai, Zhang Rui, Amit Kucheria, Heiko Stuebner
  Cc: linux-rockchip, linux-kernel, linux-arm-kernel, linux-pm


Hi Chen-Yu,

On 17/12/2019 06:23, Chen-Yu Tsai wrote:
> From: Chen-Yu Tsai <wens@csie.org>
> 
> By default of-based thermal driver do not have hwmon entries registered.
> 
> Do this explicitly so users can use standard hwmon interfaces and tools
> to read the temperature.
> 
> This is based on similar changes for bcm2835_thermal in commit
> d56c19d07e0b ("thermal: bcm2835: enable hwmon explicitly").

Thanks for submitting this patch, but it is duplicate with:

https://lore.kernel.org/linux-arm-kernel/20191212061702.BFE2D6E85603@corona.crabdance.com/

which I picked up.

  -- Daniel


> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>  drivers/thermal/rockchip_thermal.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
> index 9ed8085bb792..d53ba7dabf16 100644
> --- a/drivers/thermal/rockchip_thermal.c
> +++ b/drivers/thermal/rockchip_thermal.c
> @@ -19,6 +19,8 @@
>  #include <linux/mfd/syscon.h>
>  #include <linux/pinctrl/consumer.h>
>  
> +#include "thermal_hwmon.h"
> +
>  /*
>   * If the temperature over a period of time High,
>   * the resulting TSHUT gave CRU module,let it reset the entire chip,
> @@ -1210,7 +1212,11 @@ rockchip_thermal_register_sensor(struct platform_device *pdev,
>  		return error;
>  	}
>  
> -	return 0;
> +	/* thermal_zone doesn't enable hwmon as default, enable it here */
> +	sensor->tzd->tzp->no_hwmon = false;
> +	error = thermal_add_hwmon_sysfs(sensor->tzd);
> +
> +	return error;
>  }
>  
>  /**
> 


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH] thermal: rockchip: enable hwmon
@ 2019-12-17  5:23 Chen-Yu Tsai
  2019-12-17  8:01 ` Daniel Lezcano
  0 siblings, 1 reply; 6+ messages in thread
From: Chen-Yu Tsai @ 2019-12-17  5:23 UTC (permalink / raw)
  To: Zhang Rui, Daniel Lezcano, Amit Kucheria, Heiko Stuebner
  Cc: linux-rockchip, Chen-Yu Tsai, linux-kernel, linux-arm-kernel, linux-pm

From: Chen-Yu Tsai <wens@csie.org>

By default of-based thermal driver do not have hwmon entries registered.

Do this explicitly so users can use standard hwmon interfaces and tools
to read the temperature.

This is based on similar changes for bcm2835_thermal in commit
d56c19d07e0b ("thermal: bcm2835: enable hwmon explicitly").

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/thermal/rockchip_thermal.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index 9ed8085bb792..d53ba7dabf16 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -19,6 +19,8 @@
 #include <linux/mfd/syscon.h>
 #include <linux/pinctrl/consumer.h>
 
+#include "thermal_hwmon.h"
+
 /*
  * If the temperature over a period of time High,
  * the resulting TSHUT gave CRU module,let it reset the entire chip,
@@ -1210,7 +1212,11 @@ rockchip_thermal_register_sensor(struct platform_device *pdev,
 		return error;
 	}
 
-	return 0;
+	/* thermal_zone doesn't enable hwmon as default, enable it here */
+	sensor->tzd->tzp->no_hwmon = false;
+	error = thermal_add_hwmon_sysfs(sensor->tzd);
+
+	return error;
 }
 
 /**
-- 
2.24.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-12-17  8:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18  5:24 [PATCH] thermal: rockchip: enable hwmon schaecsn
2019-12-02 14:52 ` Stefan Schaeckeler
2019-12-09 17:08   ` Daniel Lezcano
2019-12-17  5:23 Chen-Yu Tsai
2019-12-17  8:01 ` Daniel Lezcano
2019-12-17  8:02   ` Chen-Yu Tsai

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