linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: brcmstb: enable hwmon
@ 2019-10-30 16:38 Chen-Yu Tsai
  2019-10-30 16:57 ` Florian Fainelli
  2019-10-31 13:08 ` Stefan Wahren
  0 siblings, 2 replies; 6+ messages in thread
From: Chen-Yu Tsai @ 2019-10-30 16:38 UTC (permalink / raw)
  To: Markus Mayer, Florian Fainelli, Zhang Rui, Eduardo Valentin,
	Daniel Lezcano, Amit Kucheria
  Cc: Chen-Yu Tsai, bcm-kernel-feedback-list, linux-pm,
	linux-arm-kernel, linux-kernel

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

By defaul 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>
---

This patch was only compile tested. A similar patch [1] was submitted to
the downstream kernel, which I did build and actually run on a Raspberry
Pi 4.

This one for mainline is much simpler, as it does not need to deal with
the error path or device removal, due to the use of devres.

 [1] https://github.com/raspberrypi/linux/pull/3307

---
 drivers/thermal/broadcom/brcmstb_thermal.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c
index 5825ac581f56..8353aaa4d624 100644
--- a/drivers/thermal/broadcom/brcmstb_thermal.c
+++ b/drivers/thermal/broadcom/brcmstb_thermal.c
@@ -21,6 +21,8 @@
 #include <linux/of_device.h>
 #include <linux/thermal.h>
 
+#include "../thermal_hwmon.h"
+
 #define AVS_TMON_STATUS			0x00
  #define AVS_TMON_STATUS_valid_msk	BIT(11)
  #define AVS_TMON_STATUS_data_msk	GENMASK(10, 1)
@@ -343,6 +345,12 @@ static int brcmstb_thermal_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	/* hwmon not enabled by default. Enable it here. */
+	thermal->tzp->no_hwmon = false;
+	ret = thermal_add_hwmon_sysfs(thermal);
+	if (ret)
+		return ret;
+
 	dev_info(&pdev->dev, "registered AVS TMON of-sensor driver\n");
 
 	return 0;
-- 
2.20.1


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

* Re: [PATCH] thermal: brcmstb: enable hwmon
  2019-10-30 16:38 [PATCH] thermal: brcmstb: enable hwmon Chen-Yu Tsai
@ 2019-10-30 16:57 ` Florian Fainelli
  2019-10-30 17:15   ` Florian Fainelli
  2019-10-31 13:08 ` Stefan Wahren
  1 sibling, 1 reply; 6+ messages in thread
From: Florian Fainelli @ 2019-10-30 16:57 UTC (permalink / raw)
  To: Chen-Yu Tsai, Markus Mayer, Florian Fainelli, Zhang Rui,
	Eduardo Valentin, Daniel Lezcano, Amit Kucheria
  Cc: Chen-Yu Tsai, bcm-kernel-feedback-list, linux-pm,
	linux-arm-kernel, linux-kernel

Hi Chen-Yu,

On 10/30/19 9:38 AM, Chen-Yu Tsai wrote:
> From: Chen-Yu Tsai <wens@csie.org>
> 
> By defaul 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>

Tested-by: Florian Fainelli <f.fainelli@gmail.com>

There a number of patches that I need to get upstream from our
downstream tree, because right now the temperatures reported are note
quite in the expected units..
-- 
Florian

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

* Re: [PATCH] thermal: brcmstb: enable hwmon
  2019-10-30 16:57 ` Florian Fainelli
@ 2019-10-30 17:15   ` Florian Fainelli
  0 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2019-10-30 17:15 UTC (permalink / raw)
  To: Chen-Yu Tsai, Markus Mayer, Florian Fainelli, Zhang Rui,
	Eduardo Valentin, Daniel Lezcano, Amit Kucheria
  Cc: Chen-Yu Tsai, bcm-kernel-feedback-list, linux-pm,
	linux-arm-kernel, linux-kernel

On 10/30/19 9:57 AM, Florian Fainelli wrote:
> Hi Chen-Yu,
> 
> On 10/30/19 9:38 AM, Chen-Yu Tsai wrote:
>> From: Chen-Yu Tsai <wens@csie.org>
>>
>> By defaul 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>
> 
> Tested-by: Florian Fainelli <f.fainelli@gmail.com>
> 
> There a number of patches that I need to get upstream from our
> downstream tree, because right now the temperatures reported are note
> quite in the expected units..

Oh yes, because we call the standard thermal framework helpers to
extract the coefficients, and we never made that a mandatory property,
so our firmware does not provide that information and the raw DAC code
is not properly converted, will fix that as well.
-- 
Florian

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

* Re: [PATCH] thermal: brcmstb: enable hwmon
  2019-10-30 16:38 [PATCH] thermal: brcmstb: enable hwmon Chen-Yu Tsai
  2019-10-30 16:57 ` Florian Fainelli
@ 2019-10-31 13:08 ` Stefan Wahren
  2019-11-01  3:01   ` Florian Fainelli
  2019-11-01  3:04   ` Chen-Yu Tsai
  1 sibling, 2 replies; 6+ messages in thread
From: Stefan Wahren @ 2019-10-31 13:08 UTC (permalink / raw)
  To: Chen-Yu Tsai, Markus Mayer, Florian Fainelli, Zhang Rui,
	Eduardo Valentin, Daniel Lezcano, Amit Kucheria
  Cc: Chen-Yu Tsai, bcm-kernel-feedback-list, linux-kernel,
	linux-arm-kernel, linux-pm

Hi Chen-Yu,

Am 30.10.19 um 17:38 schrieb Chen-Yu Tsai:
> From: Chen-Yu Tsai <wens@csie.org>
>
> By defaul 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>
> ---
>
> This patch was only compile tested. A similar patch [1] was submitted to
> the downstream kernel, which I did build and actually run on a Raspberry
> Pi 4.

just a note: from my understanding [2] the brcmstb_thermal isn't the
right driver for BCM2711. Please consider the current downstream
solution for BCM2711 support as a quick hack to avoid writing a new
thermal driver. But must confess that i didn't test Florian's recent
changes yet.

Regards
Stefan

[2] -
https://github.com/raspberrypi/linux/issues/3101#issuecomment-527554223

>
> This one for mainline is much simpler, as it does not need to deal with
> the error path or device removal, due to the use of devres.
>
>  [1] https://github.com/raspberrypi/linux/pull/3307
>
> ---
>  drivers/thermal/broadcom/brcmstb_thermal.c | 8 ++++++++
>  1 file changed, 8 insertions(+)


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

* Re: [PATCH] thermal: brcmstb: enable hwmon
  2019-10-31 13:08 ` Stefan Wahren
@ 2019-11-01  3:01   ` Florian Fainelli
  2019-11-01  3:04   ` Chen-Yu Tsai
  1 sibling, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2019-11-01  3:01 UTC (permalink / raw)
  To: Stefan Wahren, Chen-Yu Tsai, Markus Mayer, Florian Fainelli,
	Zhang Rui, Eduardo Valentin, Daniel Lezcano, Amit Kucheria
  Cc: Chen-Yu Tsai, bcm-kernel-feedback-list, linux-kernel,
	linux-arm-kernel, linux-pm

On 10/31/2019 6:08 AM, Stefan Wahren wrote:
> Hi Chen-Yu,
> 
> Am 30.10.19 um 17:38 schrieb Chen-Yu Tsai:
>> From: Chen-Yu Tsai <wens@csie.org>
>>
>> By defaul 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>
>> ---
>>
>> This patch was only compile tested. A similar patch [1] was submitted to
>> the downstream kernel, which I did build and actually run on a Raspberry
>> Pi 4.
> 
> just a note: from my understanding [2] the brcmstb_thermal isn't the
> right driver for BCM2711. Please consider the current downstream
> solution for BCM2711 support as a quick hack to avoid writing a new
> thermal driver. But must confess that i didn't test Florian's recent
> changes yet.

The brcmstb_thermal driver is for chips with an AVS_TMON whereas the
2711 does not have it AFAICT, even if the registers are there, the
hardware is not present (or so have I been told).

The AVS_RO register you are being pointed out may work, although the
data is over 10 bits (not 11) and the valid bit is 10 (not 11). It looks
like you may have to check bit 16 as well for a measurement being done
or not.
-- 
Florian

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

* Re: [PATCH] thermal: brcmstb: enable hwmon
  2019-10-31 13:08 ` Stefan Wahren
  2019-11-01  3:01   ` Florian Fainelli
@ 2019-11-01  3:04   ` Chen-Yu Tsai
  1 sibling, 0 replies; 6+ messages in thread
From: Chen-Yu Tsai @ 2019-11-01  3:04 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Chen-Yu Tsai, Markus Mayer, Florian Fainelli, Zhang Rui,
	Eduardo Valentin, Daniel Lezcano, Amit Kucheria,
	open list:BROADCOM BCM281XX...,
	linux-kernel, linux-arm-kernel, open list:THERMAL

On Thu, Oct 31, 2019 at 9:09 PM Stefan Wahren <wahrenst@gmx.net> wrote:
>
> Hi Chen-Yu,
>
> Am 30.10.19 um 17:38 schrieb Chen-Yu Tsai:
> > From: Chen-Yu Tsai <wens@csie.org>
> >
> > By defaul 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>
> > ---
> >
> > This patch was only compile tested. A similar patch [1] was submitted to
> > the downstream kernel, which I did build and actually run on a Raspberry
> > Pi 4.
>
> just a note: from my understanding [2] the brcmstb_thermal isn't the
> right driver for BCM2711. Please consider the current downstream
> solution for BCM2711 support as a quick hack to avoid writing a new
> thermal driver. But must confess that i didn't test Florian's recent
> changes yet.

Thanks for the tip. I only saw the thread after posting this patch.

ChenYu

> Regards
> Stefan
>
> [2] -
> https://github.com/raspberrypi/linux/issues/3101#issuecomment-527554223
>
> >
> > This one for mainline is much simpler, as it does not need to deal with
> > the error path or device removal, due to the use of devres.
> >
> >  [1] https://github.com/raspberrypi/linux/pull/3307
> >
> > ---
> >  drivers/thermal/broadcom/brcmstb_thermal.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
>

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

end of thread, other threads:[~2019-11-01  3:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 16:38 [PATCH] thermal: brcmstb: enable hwmon Chen-Yu Tsai
2019-10-30 16:57 ` Florian Fainelli
2019-10-30 17:15   ` Florian Fainelli
2019-10-31 13:08 ` Stefan Wahren
2019-11-01  3:01   ` Florian Fainelli
2019-11-01  3:04   ` 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).