2020-01-07 23:21:51

by Martin Blumenstingl

[permalink] [raw]
Subject: [PATCH 0/2] make generic-adc-thermal less noisy

I want to use generic-adc-thermal on the 32-bit Amlogic SoCs in the
future. These have a thermal sensors which can be read through the
SAR ADC (for which we have an IIO driver) on those SoCs.

While testing I found the generic-adc-thermal driver to be a bit
noisy when operating in well supported environment:
- the SoC temperature sensor on the 32-bit Amlogic SoCs is typically
loaded late because of it's dependencies (it needs data from the
eFuse and a syscon to calibrate). Yet I still got a message stating
there's no lookup table for the generic-adc-thermal defined (which
is expected and perfectly valid on these Amlogic SoCs, as the IIO
channel returns the temperature).
- the IIO channel is correctly defined with type IIO_TEMP, yet the
generic-adc-thermal driver still prints a message which first lead
me to believe that I passed an incorrect IIO channel (one that
returns a voltage).


Martin Blumenstingl (2):
thermal: generic-adc: silence "no lookup table" on deferred probe
thermal: generic-adc: silence info message for IIO_TEMP channels

drivers/thermal/thermal-generic-adc.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

--
2.24.1


2020-01-07 23:21:54

by Martin Blumenstingl

[permalink] [raw]
Subject: [PATCH 2/2] thermal: generic-adc: silence info message for IIO_TEMP channels

Since commit d36e2fa0253875 ("thermal: generic-adc: make lookup table
optional") "generic-adc-thermal" can be used with an IIO_TEMP channel.
In this case the following message is logged at probe time:
no lookup table, assuming DAC channel returns milliCelcius

Silence this info message if the channel type is known to be in
milli celsius. Keep this message when the channel type is unknown or not
of type temperature.

Signed-off-by: Martin Blumenstingl <[email protected]>
---
drivers/thermal/thermal-generic-adc.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal-generic-adc.c b/drivers/thermal/thermal-generic-adc.c
index 226e3c2b7469..73665c3ccfe0 100644
--- a/drivers/thermal/thermal-generic-adc.c
+++ b/drivers/thermal/thermal-generic-adc.c
@@ -76,13 +76,17 @@ static int gadc_thermal_read_linear_lookup_table(struct device *dev,
struct gadc_thermal_info *gti)
{
struct device_node *np = dev->of_node;
+ enum iio_chan_type chan_type;
int ntable;
int ret;

ntable = of_property_count_elems_of_size(np, "temperature-lookup-table",
sizeof(u32));
if (ntable <= 0) {
- dev_notice(dev, "no lookup table, assuming DAC channel returns milliCelcius\n");
+ ret = iio_get_channel_type(gti->channel, &chan_type);
+ if (ret || chan_type != IIO_TEMP)
+ dev_notice(dev,
+ "no lookup table, assuming DAC channel returns milliCelcius\n");
return 0;
}

--
2.24.1

2020-01-07 23:22:54

by Martin Blumenstingl

[permalink] [raw]
Subject: [PATCH 1/2] thermal: generic-adc: silence "no lookup table" on deferred probe

A "generic-adc-thermal" without "temperature-lookup-table" is perfectly
valid since commit d36e2fa0253875 ("thermal: generic-adc: make lookup
table optional"). On deferred probe the message "no lookup table,
assuming DAC channel returns milliCelcius" is still logged.
Prevent this message on deferred probe of the IIO channel by first
looking up the IIO channel.

Signed-off-by: Martin Blumenstingl <[email protected]>
---
drivers/thermal/thermal-generic-adc.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/thermal/thermal-generic-adc.c b/drivers/thermal/thermal-generic-adc.c
index ae5743c9a894..226e3c2b7469 100644
--- a/drivers/thermal/thermal-generic-adc.c
+++ b/drivers/thermal/thermal-generic-adc.c
@@ -124,13 +124,6 @@ static int gadc_thermal_probe(struct platform_device *pdev)
if (!gti)
return -ENOMEM;

- ret = gadc_thermal_read_linear_lookup_table(&pdev->dev, gti);
- if (ret < 0)
- return ret;
-
- gti->dev = &pdev->dev;
- platform_set_drvdata(pdev, gti);
-
gti->channel = devm_iio_channel_get(&pdev->dev, "sensor-channel");
if (IS_ERR(gti->channel)) {
ret = PTR_ERR(gti->channel);
@@ -139,6 +132,13 @@ static int gadc_thermal_probe(struct platform_device *pdev)
return ret;
}

+ ret = gadc_thermal_read_linear_lookup_table(&pdev->dev, gti);
+ if (ret < 0)
+ return ret;
+
+ gti->dev = &pdev->dev;
+ platform_set_drvdata(pdev, gti);
+
gti->tz_dev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, gti,
&gadc_thermal_ops);
if (IS_ERR(gti->tz_dev)) {
--
2.24.1

2020-01-09 22:45:46

by Daniel Lezcano

[permalink] [raw]
Subject: Re: [PATCH 0/2] make generic-adc-thermal less noisy

On 08/01/2020 00:20, Martin Blumenstingl wrote:
> I want to use generic-adc-thermal on the 32-bit Amlogic SoCs in the
> future. These have a thermal sensors which can be read through the
> SAR ADC (for which we have an IIO driver) on those SoCs.
>
> While testing I found the generic-adc-thermal driver to be a bit
> noisy when operating in well supported environment:
> - the SoC temperature sensor on the 32-bit Amlogic SoCs is typically
> loaded late because of it's dependencies (it needs data from the
> eFuse and a syscon to calibrate). Yet I still got a message stating
> there's no lookup table for the generic-adc-thermal defined (which
> is expected and perfectly valid on these Amlogic SoCs, as the IIO
> channel returns the temperature).
> - the IIO channel is correctly defined with type IIO_TEMP, yet the
> generic-adc-thermal driver still prints a message which first lead
> me to believe that I passed an incorrect IIO channel (one that
> returns a voltage).
>
>
> Martin Blumenstingl (2):
> thermal: generic-adc: silence "no lookup table" on deferred probe
> thermal: generic-adc: silence info message for IIO_TEMP channels
>
> drivers/thermal/thermal-generic-adc.c | 20 ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)

Applied, thanks

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