Linux-Amlogic Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/2] make generic-adc-thermal less noisy
@ 2020-01-07 23:20 Martin Blumenstingl
  2020-01-07 23:20 ` [PATCH 1/2] thermal: generic-adc: silence "no lookup table" on deferred probe Martin Blumenstingl
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Martin Blumenstingl @ 2020-01-07 23:20 UTC (permalink / raw)
  To: rui.zhang, daniel.lezcano, amit.kucheria, linux-pm
  Cc: edubezval, linux-amlogic, Martin Blumenstingl, linux-kernel,
	jeff.dagenais

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


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

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

* [PATCH 1/2] thermal: generic-adc: silence "no lookup table" on deferred probe
  2020-01-07 23:20 [PATCH 0/2] make generic-adc-thermal less noisy Martin Blumenstingl
@ 2020-01-07 23:20 ` Martin Blumenstingl
  2020-01-07 23:20 ` [PATCH 2/2] thermal: generic-adc: silence info message for IIO_TEMP channels Martin Blumenstingl
  2020-01-09 22:43 ` [PATCH 0/2] make generic-adc-thermal less noisy Daniel Lezcano
  2 siblings, 0 replies; 4+ messages in thread
From: Martin Blumenstingl @ 2020-01-07 23:20 UTC (permalink / raw)
  To: rui.zhang, daniel.lezcano, amit.kucheria, linux-pm
  Cc: edubezval, linux-amlogic, Martin Blumenstingl, linux-kernel,
	jeff.dagenais

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 <martin.blumenstingl@googlemail.com>
---
 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


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

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

* [PATCH 2/2] thermal: generic-adc: silence info message for IIO_TEMP channels
  2020-01-07 23:20 [PATCH 0/2] make generic-adc-thermal less noisy Martin Blumenstingl
  2020-01-07 23:20 ` [PATCH 1/2] thermal: generic-adc: silence "no lookup table" on deferred probe Martin Blumenstingl
@ 2020-01-07 23:20 ` Martin Blumenstingl
  2020-01-09 22:43 ` [PATCH 0/2] make generic-adc-thermal less noisy Daniel Lezcano
  2 siblings, 0 replies; 4+ messages in thread
From: Martin Blumenstingl @ 2020-01-07 23:20 UTC (permalink / raw)
  To: rui.zhang, daniel.lezcano, amit.kucheria, linux-pm
  Cc: edubezval, linux-amlogic, Martin Blumenstingl, linux-kernel,
	jeff.dagenais

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 <martin.blumenstingl@googlemail.com>
---
 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


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

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

* Re: [PATCH 0/2] make generic-adc-thermal less noisy
  2020-01-07 23:20 [PATCH 0/2] make generic-adc-thermal less noisy Martin Blumenstingl
  2020-01-07 23:20 ` [PATCH 1/2] thermal: generic-adc: silence "no lookup table" on deferred probe Martin Blumenstingl
  2020-01-07 23:20 ` [PATCH 2/2] thermal: generic-adc: silence info message for IIO_TEMP channels Martin Blumenstingl
@ 2020-01-09 22:43 ` Daniel Lezcano
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Lezcano @ 2020-01-09 22:43 UTC (permalink / raw)
  To: Martin Blumenstingl, rui.zhang, amit.kucheria, linux-pm
  Cc: edubezval, linux-amlogic, linux-kernel, jeff.dagenais

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


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

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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07 23:20 [PATCH 0/2] make generic-adc-thermal less noisy Martin Blumenstingl
2020-01-07 23:20 ` [PATCH 1/2] thermal: generic-adc: silence "no lookup table" on deferred probe Martin Blumenstingl
2020-01-07 23:20 ` [PATCH 2/2] thermal: generic-adc: silence info message for IIO_TEMP channels Martin Blumenstingl
2020-01-09 22:43 ` [PATCH 0/2] make generic-adc-thermal less noisy Daniel Lezcano

Linux-Amlogic Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-amlogic/0 linux-amlogic/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-amlogic linux-amlogic/ https://lore.kernel.org/linux-amlogic \
		linux-amlogic@lists.infradead.org
	public-inbox-index linux-amlogic

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-amlogic


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git