Skip to contentSkip to conversation

of: thermal: Introduce "hwmon" optional property

PATCH Superseded Michael Tatarinov 3 participants 5 messages Jul 10, 2017 – Dec 5, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 of: thermal: Introduce "hwmon" optional property

Introduce an optional property called, hwmon, which enable registration in hwmon subsystems.

Cc Zhang Rui <[email protected]>
Cc Eduardo Valentin <[email protected]>
---
 Documentation/devicetree/bindings/thermal/thermal.txt | 6 ++++++
 drivers/thermal/of-thermal.c                          | 3 +--
 2 files changed, 7 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/thermal/thermal.txt +6 -0
index 88b6ea1ad290..4e51fbd4efa2 100644
@@ -175,6 +175,10 @@ Optional property:
 			2000mW, while on a 10'' tablet is around
 			4500mW.
 
+- hwmon:		Register the thermal zone in hwmon subsystems
+  Type: boolean 	(requires CONFIG_THERMAL_HWMON).
+  Size: one cell
+
 Note: The delay properties are bound to the maximum dT/dt (temperature
 derivative over time) in two situations for a thermal zone:
 (i)  - when passive cooling is activated (polling-delay-passive); and
@@ -556,6 +560,8 @@ thermal-zones {
 
 		sustainable-power = <2500>;
 
+		hwmon;
+
 		trips {
 			/* Trips are based on resulting linear equation */
 			cpu_trip: cpu-trip {
drivers/thermal/of-thermal.c +1 -2
index d04ec3b9e5ff..ce580a57313b 100644
@@ -994,8 +994,7 @@ int __init of_parse_thermal_zones(void)
 			goto exit_free;
 		}
 
-		/* No hwmon because there might be hwmon drivers registering */
-		tzp->no_hwmon = true;
+		tzp->no_hwmon = !of_property_read_bool(child, "hwmon");
 
 		if (!of_property_read_u32(child, "sustainable-power", &prop))
 			tzp->sustainable_power = prop;
Signature · 1 line
2.9.4
#1 lore raw

Hello

Some clarifications for this patch.
I uses CONFIG_THERMAL_HWMON feature on Raspberry PI. It works ok with the downstream thermal driver because it uses thermal_zone_device_register(). After I switches to the upstream driver this feature doesn't work because it uses thermal_zone_of_sensor_register().
I would like to use this opportunity and in the future.

2017-07-10 15:51 GMT+04:00, Michael Tatarinov <[email protected]>:

Quoted 54 lines

Introduce an optional property called, hwmon, which enable registration in hwmon subsystems.

Cc Zhang Rui <[email protected]>
Cc Eduardo Valentin <[email protected]>
---
 Documentation/devicetree/bindings/thermal/thermal.txt | 6 ++++++
 drivers/thermal/of-thermal.c                          | 3 +--
 2 files changed, 7 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/thermal/thermal.txt +6 -0
index 88b6ea1ad290..4e51fbd4efa2 100644
@@ -175,6 +175,10 @@ Optional property:
 			2000mW, while on a 10'' tablet is around
 			4500mW.
 
+- hwmon:		Register the thermal zone in hwmon subsystems
+  Type: boolean 	(requires CONFIG_THERMAL_HWMON).
+  Size: one cell
+
 Note: The delay properties are bound to the maximum dT/dt (temperature
 derivative over time) in two situations for a thermal zone:
 (i)  - when passive cooling is activated (polling-delay-passive); and
@@ -556,6 +560,8 @@ thermal-zones {
 
 		sustainable-power = <2500>;
 
+		hwmon;
+
 		trips {
 			/* Trips are based on resulting linear equation */
 			cpu_trip: cpu-trip {
drivers/thermal/of-thermal.c +1 -3
index d04ec3b9e5ff..ce580a57313b 100644
@@ -994,8 +994,7 @@ int __init of_parse_thermal_zones(void)
 			goto exit_free;
 		}
 
-		/* No hwmon because there might be hwmon drivers registering */
-		tzp->no_hwmon = true;
+		tzp->no_hwmon = !of_property_read_bool(child, "hwmon");
 
 		if (!of_property_read_u32(child, "sustainable-power", &prop))
 			tzp->sustainable_power = prop;
--

2.9.4

#3 lore raw
In reply to Michael Tatarinov
Quoted 16 lines · Michael Tatarinov

Introduce an optional property called, hwmon, which enable registration in hwmon subsystems.

Cc Zhang Rui <[email protected]>
Cc Eduardo Valentin <[email protected]>
---
 Documentation/devicetree/bindings/thermal/thermal.txt | 6 ++++++
 drivers/thermal/of-thermal.c                          | 3 +--
 2 files changed, 7 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/thermal/thermal.txt +0 -0
index 88b6ea1ad290..4e51fbd4efa2 100644

Documentation/devicetree/bindings/thermal/thermal.txt Optional property: · line 181

Quoted 7 lines
Documentation/devicetree/bindings/thermal/thermal.txt +4 -0
@@ -175,6 +175,10 @@ Optional property:
 			2000mW, while on a 10'' tablet is around
 			4500mW.
 
+- hwmon:		Register the thermal zone in hwmon subsystems
+  Type: boolean 	(requires CONFIG_THERMAL_HWMON).
+  Size: one cell
+

That will probably be unacceptable since it is not a hardware description or configuration flag but an implementation problem.

What might be acceptable is to use a device property such as "linux,no-hwmon", set it in hwmon drivers prior to calling the registration function, then use device_property_present() in the thermal code to check it and assign the flag to no_hwmon. An alternative might be to add a "no_hwmon" parameter to the thermal registration function, but that would be much more invasive and, in my opinion, much less desirable.

Rui, Eduardo, any thoughts ?

Thanks,
Guenter

Quoted 26 lines
Documentation/devicetree/bindings/thermal/thermal.txt +2 -0
 Note: The delay properties are bound to the maximum dT/dt (temperature
 derivative over time) in two situations for a thermal zone:
 (i)  - when passive cooling is activated (polling-delay-passive); and
@@ -556,6 +560,8 @@ thermal-zones {
 
 		sustainable-power = <2500>;
 
+		hwmon;
+
 		trips {
 			/* Trips are based on resulting linear equation */
 			cpu_trip: cpu-trip {
drivers/thermal/of-thermal.c +1 -2
index d04ec3b9e5ff..ce580a57313b 100644
@@ -994,8 +994,7 @@ int __init of_parse_thermal_zones(void)
 			goto exit_free;
 		}
 
-		/* No hwmon because there might be hwmon drivers registering */
-		tzp->no_hwmon = true;
+		tzp->no_hwmon = !of_property_read_bool(child, "hwmon");
 
 		if (!of_property_read_u32(child, "sustainable-power", &prop))
 			tzp->sustainable_power = prop;
#4 lore raw

Hello
Thanks for you comments.

2017-08-31 19:08 GMT+04:00, Guenter Roeck <[email protected]>:

Quoted 21 lines · Michael Tatarinov
Quoted 20 lines

Introduce an optional property called, hwmon, which enable registration in hwmon subsystems.

Cc Zhang Rui <[email protected]>
Cc Eduardo Valentin <[email protected]>
---
 Documentation/devicetree/bindings/thermal/thermal.txt | 6 ++++++
 drivers/thermal/of-thermal.c                          | 3 +--
 2 files changed, 7 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/thermal/thermal.txt +0 -0
index 88b6ea1ad290..4e51fbd4efa2 100644
@@ -175,6 +175,10 @@ Optional property:
 			2000mW, while on a 10'' tablet is around
 			4500mW.
 
Quoted 7 lines

Documentation/devicetree/bindings/thermal/thermal.txt Optional property: · line 181

Quoted 4 lines
Documentation/devicetree/bindings/thermal/thermal.txt +4 -0
+- hwmon:		Register the thermal zone in hwmon subsystems
+  Type: boolean 	(requires CONFIG_THERMAL_HWMON).
+  Size: one cell
+

That will probably be unacceptable since it is not a hardware description or configuration flag but an implementation problem.

I didn't know it. I agree with change "hwmon" to "linux,hwmon".

Quoted 6 lines

What might be acceptable is to use a device property such as "linux,no-hwmon", set it in hwmon drivers prior to calling the registration function, then use device_property_present() in the thermal code to check it and assign the flag to no_hwmon. An alternative might be to add a "no_hwmon" parameter to the thermal registration function, but that would be much more invasive and, in my opinion, much less desirable.

I think it should be a thermal driver option. Comment says that the registration is disabled to prevent dual registration (native hwmon driver and imported thermal driver).

Quoted 32 lines

Rui, Eduardo, any thoughts ?

Thanks,
Guenter

Quoted 26 lines
Documentation/devicetree/bindings/thermal/thermal.txt +2 -0
 Note: The delay properties are bound to the maximum dT/dt (temperature
 derivative over time) in two situations for a thermal zone:
 (i)  - when passive cooling is activated (polling-delay-passive); and
@@ -556,6 +560,8 @@ thermal-zones {
 
 		sustainable-power = <2500>;
 
+		hwmon;
+
 		trips {
 			/* Trips are based on resulting linear equation */
 			cpu_trip: cpu-trip {
drivers/thermal/of-thermal.c +1 -2
index d04ec3b9e5ff..ce580a57313b 100644
@@ -994,8 +994,7 @@ int __init of_parse_thermal_zones(void)
 			goto exit_free;
 		}
 
-		/* No hwmon because there might be hwmon drivers registering */
-		tzp->no_hwmon = true;
+		tzp->no_hwmon = !of_property_read_bool(child, "hwmon");
 
 		if (!of_property_read_u32(child, "sustainable-power", &prop))
 			tzp->sustainable_power = prop;
#2 lore raw
In reply to Michael Tatarinov
Quoted 9 lines · Michael Tatarinov

Hello

Some clarifications for this patch.
I uses CONFIG_THERMAL_HWMON feature on Raspberry PI. It works ok with the downstream thermal driver because it uses thermal_zone_device_register(). After I switches to the upstream driver this feature doesn't work because it uses thermal_zone_of_sensor_register().
I would like to use this opportunity and in the future.

I would be OK with the linux,no-hwmon flag, but that needs to be acked by the DT folks.

Quoted 56 lines

2017-07-10 15:51 GMT+04:00, Michael Tatarinov <[email protected]>:

Quoted 54 lines

Introduce an optional property called, hwmon, which enable registration in hwmon subsystems.

Cc Zhang Rui <[email protected]>
Cc Eduardo Valentin <[email protected]>
---
 Documentation/devicetree/bindings/thermal/thermal.txt | 6 ++++++
 drivers/thermal/of-thermal.c                          | 3 +--
 2 files changed, 7 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/thermal/thermal.txt +6 -0
index 88b6ea1ad290..4e51fbd4efa2 100644
@@ -175,6 +175,10 @@ Optional property:
 			2000mW, while on a 10'' tablet is around
 			4500mW.
 
+- hwmon:		Register the thermal zone in hwmon subsystems
+  Type: boolean 	(requires CONFIG_THERMAL_HWMON).
+  Size: one cell
+
 Note: The delay properties are bound to the maximum dT/dt (temperature
 derivative over time) in two situations for a thermal zone:
 (i)  - when passive cooling is activated (polling-delay-passive); and
@@ -556,6 +560,8 @@ thermal-zones {
 
 		sustainable-power = <2500>;
 
+		hwmon;
+
 		trips {
 			/* Trips are based on resulting linear equation */
 			cpu_trip: cpu-trip {
drivers/thermal/of-thermal.c +1 -3
index d04ec3b9e5ff..ce580a57313b 100644
@@ -994,8 +994,7 @@ int __init of_parse_thermal_zones(void)
 			goto exit_free;
 		}
 
-		/* No hwmon because there might be hwmon drivers registering */
-		tzp->no_hwmon = true;
+		tzp->no_hwmon = !of_property_read_bool(child, "hwmon");
 
 		if (!of_property_read_u32(child, "sustainable-power", &prop))
 			tzp->sustainable_power = prop;
--

2.9.4