thermal: amlogic: Add hwmon support
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Sun, 15 Nov 2020 19:06:58 +0000 (20:06 +0100)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Mon, 16 Nov 2020 09:30:53 +0000 (10:30 +0100)
Many monitoring tools read the CPU temperature using the hwmon
interface. Expose the thermal sensors on Amlogic boards as hwmon
devices.

Without this lm_sensors' "sensors" tool does not find any temperature
sensors. Now it prints:
  cpu_thermal-virtual-0
  Adapter: Virtual device
  temp1:        +44.7 C  (crit = +110.0 C)

  ddr_thermal-virtual-0
  Adapter: Virtual device
  temp1:        +45.9 C  (crit = +110.0 C)

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20201115190658.631578-1-martin.blumenstingl@googlemail.com
drivers/thermal/amlogic_thermal.c

index ccb1fe1..dffe3ba 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/thermal.h>
 
 #include "thermal_core.h"
+#include "thermal_hwmon.h"
 
 #define TSENSOR_CFG_REG1                       0x4
        #define TSENSOR_CFG_REG1_RSET_VBG       BIT(12)
@@ -287,6 +288,9 @@ static int amlogic_thermal_probe(struct platform_device *pdev)
                return ret;
        }
 
+       if (devm_thermal_add_hwmon_sysfs(pdata->tzd))
+               dev_warn(&pdev->dev, "Failed to add hwmon sysfs attributes\n");
+
        ret = amlogic_thermal_initialize(pdata);
        if (ret)
                return ret;