thermal/drivers/k3: Add hwmon support
authorMassimiliano Minella <massimiliano.minella@gmail.com>
Fri, 1 Apr 2022 15:13:51 +0000 (17:13 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Thu, 19 May 2022 10:11:51 +0000 (12:11 +0200)
Expose the thermal sensors on K3 AM654 as hwmon devices, so that
temperatures could be read using lm-sensors.

Signed-off-by: Massimiliano Minella <massimiliano.minella@gmail.com>
Link: https://lore.kernel.org/r/20220401151656.913166-1-massimiliano.minella@se.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
drivers/thermal/k3_bandgap.c

index 35f41e8a0b75930f9cacb3fa549df9b8e83e7502..5d0b3ffc6f46c65943373743e89567e2dcf7fb1f 100644 (file)
@@ -16,6 +16,8 @@
 #include <linux/thermal.h>
 #include <linux/types.h>
 
+#include "thermal_hwmon.h"
+
 #define K3_VTM_DEVINFO_PWR0_OFFSET             0x4
 #define K3_VTM_DEVINFO_PWR0_TEMPSENS_CT_MASK   0xf0
 #define K3_VTM_TMPSENS0_CTRL_OFFSET    0x80
@@ -219,6 +221,9 @@ static int k3_bandgap_probe(struct platform_device *pdev)
                        ret = PTR_ERR(data[id].tzd);
                        goto err_alloc;
                }
+
+               if (devm_thermal_add_hwmon_sysfs(data[id].tzd))
+                       dev_warn(dev, "Failed to add hwmon sysfs attributes\n");
        }
 
        platform_set_drvdata(pdev, bgp);