[PATCH] hwmon: (cros_ec) register thermal sensors to thermal framework

Sung-Chi, Li posted 1 patch 1 year, 1 month ago
There is a newer version of this series
drivers/hwmon/cros_ec_hwmon.c | 69 +++++++++++++++++++++++++++++++++--
1 file changed, 66 insertions(+), 3 deletions(-)
[PATCH] hwmon: (cros_ec) register thermal sensors to thermal framework
Posted by Sung-Chi, Li 1 year, 1 month ago
cros_ec hwmon driver probes available thermal sensors when probing the
driver.  Register these thermal sensors to the thermal framework, such
that thermal framework can adopt these sensors as well.

Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>
---
 drivers/hwmon/cros_ec_hwmon.c | 69 +++++++++++++++++++++++++++++++++--
 1 file changed, 66 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c
index 5514cf780b8b..4b1ea431e3d2 100644
--- a/drivers/hwmon/cros_ec_hwmon.c
+++ b/drivers/hwmon/cros_ec_hwmon.c
@@ -7,20 +7,31 @@
 
 #include <linux/device.h>
 #include <linux/hwmon.h>
+#include <linux/list.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_data/cros_ec_proto.h>
+#include <linux/thermal.h>
 #include <linux/types.h>
 #include <linux/units.h>
 
-#define DRV_NAME	"cros-ec-hwmon"
+#define DRV_NAME		"cros-ec-hwmon"
+#define THERMAL_VAL_OFFSET	200
 
 struct cros_ec_hwmon_priv {
 	struct cros_ec_device *cros_ec;
 	const char *temp_sensor_names[EC_TEMP_SENSOR_ENTRIES + EC_TEMP_SENSOR_B_ENTRIES];
 	u8 usable_fans;
+	struct list_head sensors;
+};
+
+struct cros_ec_sensor_data {
+	struct cros_ec_device *cros_ec;
+	struct thermal_zone_device *tz_dev;
+	int addr;
+	struct list_head node;
 };
 
 static int cros_ec_hwmon_read_fan_speed(struct cros_ec_device *cros_ec, u8 index, u16 *speed)
@@ -185,11 +196,32 @@ static const struct hwmon_chip_info cros_ec_hwmon_chip_info = {
 	.info = cros_ec_hwmon_info,
 };
 
-static void cros_ec_hwmon_probe_temp_sensors(struct device *dev, struct cros_ec_hwmon_priv *priv,
+static int cros_ec_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
+{
+	struct cros_ec_sensor_data *data = thermal_zone_device_priv(tz);
+	int ret;
+	u8 val;
+
+	ret = cros_ec_hwmon_read_temp(data->cros_ec, data->addr, &val);
+	if (ret)
+		return -ENODATA;
+	*temp = (val + THERMAL_VAL_OFFSET - 273) * 1000;
+	return 0;
+}
+
+static const struct thermal_zone_device_ops thermal_ops = {
+	.get_temp = cros_ec_thermal_get_temp,
+};
+
+static void cros_ec_hwmon_probe_temp_sensors(struct cros_ec_device *cros_ec,
+					     struct device *dev,
+					     struct cros_ec_hwmon_priv *priv,
+					     struct list_head *head,
 					     u8 thermal_version)
 {
 	struct ec_params_temp_sensor_get_info req = {};
 	struct ec_response_temp_sensor_get_info resp;
+	struct cros_ec_sensor_data *data;
 	size_t candidates, i, sensor_name_size;
 	int ret;
 	u8 temp;
@@ -216,6 +248,23 @@ static void cros_ec_hwmon_probe_temp_sensors(struct device *dev, struct cros_ec_
 		priv->temp_sensor_names[i] = devm_kasprintf(dev, GFP_KERNEL, "%.*s",
 							    (int)sensor_name_size,
 							    resp.sensor_name);
+
+		data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+		if (!data)
+			continue;
+
+		data->addr = i;
+		data->cros_ec = cros_ec;
+		data->tz_dev = devm_thermal_of_zone_register(
+			cros_ec->dev, i, data, &thermal_ops);
+		if (IS_ERR_VALUE(data->tz_dev)) {
+			dev_err(dev,
+				"failed to register %zu thermal sensor, err = %ld",
+				i, PTR_ERR(data->tz_dev));
+			continue;
+		}
+
+		list_add(&data->node, head);
 	}
 }
 
@@ -255,8 +304,10 @@ static int cros_ec_hwmon_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	priv->cros_ec = cros_ec;
+	INIT_LIST_HEAD(&priv->sensors);
 
-	cros_ec_hwmon_probe_temp_sensors(dev, priv, thermal_version);
+	cros_ec_hwmon_probe_temp_sensors(cros_ec, dev, priv, &priv->sensors,
+					 thermal_version);
 	cros_ec_hwmon_probe_fans(priv);
 
 	hwmon_dev = devm_hwmon_device_register_with_info(dev, "cros_ec", priv,
@@ -265,6 +316,17 @@ static int cros_ec_hwmon_probe(struct platform_device *pdev)
 	return PTR_ERR_OR_ZERO(hwmon_dev);
 }
 
+static void cros_ec_hwmon_remove(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct cros_ec_hwmon_priv *priv = dev_get_drvdata(dev);
+	struct cros_ec_sensor_data *iter;
+
+	list_for_each_entry(iter, &priv->sensors, node) {
+		devm_thermal_of_zone_unregister(dev, iter->tz_dev);
+	}
+}
+
 static const struct platform_device_id cros_ec_hwmon_id[] = {
 	{ DRV_NAME, 0 },
 	{}
@@ -273,6 +335,7 @@ static const struct platform_device_id cros_ec_hwmon_id[] = {
 static struct platform_driver cros_ec_hwmon_driver = {
 	.driver.name	= DRV_NAME,
 	.probe		= cros_ec_hwmon_probe,
+	.remove		= cros_ec_hwmon_remove,
 	.id_table	= cros_ec_hwmon_id,
 };
 module_platform_driver(cros_ec_hwmon_driver);
-- 
2.47.0.277.g8800431eea-goog
Re: [PATCH] hwmon: (cros_ec) register thermal sensors to thermal framework
Posted by Thomas Weißschuh 1 year, 1 month ago
Hi!

On 2024-11-11 15:49:04+0800, Sung-Chi, Li wrote:
> cros_ec hwmon driver probes available thermal sensors when probing the
> driver.  Register these thermal sensors to the thermal framework, such
> that thermal framework can adopt these sensors as well.
> 
> Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>
> ---
>  drivers/hwmon/cros_ec_hwmon.c | 69 +++++++++++++++++++++++++++++++++--
>  1 file changed, 66 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c
> index 5514cf780b8b..4b1ea431e3d2 100644
> --- a/drivers/hwmon/cros_ec_hwmon.c
> +++ b/drivers/hwmon/cros_ec_hwmon.c
> @@ -7,20 +7,31 @@
>  
>  #include <linux/device.h>
>  #include <linux/hwmon.h>
> +#include <linux/list.h>
>  #include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/platform_data/cros_ec_commands.h>
>  #include <linux/platform_data/cros_ec_proto.h>
> +#include <linux/thermal.h>
>  #include <linux/types.h>
>  #include <linux/units.h>
>  
> -#define DRV_NAME	"cros-ec-hwmon"
> +#define DRV_NAME		"cros-ec-hwmon"
> +#define THERMAL_VAL_OFFSET	200
>  
>  struct cros_ec_hwmon_priv {
>  	struct cros_ec_device *cros_ec;
>  	const char *temp_sensor_names[EC_TEMP_SENSOR_ENTRIES + EC_TEMP_SENSOR_B_ENTRIES];
>  	u8 usable_fans;
> +	struct list_head sensors;
> +};
> +
> +struct cros_ec_sensor_data {

cros_ec_hwmon_thermal_zone_data.

> +	struct cros_ec_device *cros_ec;
> +	struct thermal_zone_device *tz_dev;
> +	int addr;

This is not an address, but an index.

> +	struct list_head node;
>  };
>  
>  static int cros_ec_hwmon_read_fan_speed(struct cros_ec_device *cros_ec, u8 index, u16 *speed)
> @@ -185,11 +196,32 @@ static const struct hwmon_chip_info cros_ec_hwmon_chip_info = {
>  	.info = cros_ec_hwmon_info,
>  };
>  
> -static void cros_ec_hwmon_probe_temp_sensors(struct device *dev, struct cros_ec_hwmon_priv *priv,
> +static int cros_ec_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
> +{
> +	struct cros_ec_sensor_data *data = thermal_zone_device_priv(tz);
> +	int ret;
> +	u8 val;
> +
> +	ret = cros_ec_hwmon_read_temp(data->cros_ec, data->addr, &val);
> +	if (ret)
> +		return -ENODATA;
> +	*temp = (val + THERMAL_VAL_OFFSET - 273) * 1000;

Use cros_ec_hwmon_temp_to_millicelsius() and cros_ec_hwmon_is_error_temp().

> +	return 0;
> +}
> +
> +static const struct thermal_zone_device_ops thermal_ops = {
> +	.get_temp = cros_ec_thermal_get_temp,
> +};

Use the cros_ec_hwmon symbol prefix.

> +
> +static void cros_ec_hwmon_probe_temp_sensors(struct cros_ec_device *cros_ec,
> +					     struct device *dev,
> +					     struct cros_ec_hwmon_priv *priv,
> +					     struct list_head *head,
>  					     u8 thermal_version)
>  {
>  	struct ec_params_temp_sensor_get_info req = {};
>  	struct ec_response_temp_sensor_get_info resp;
> +	struct cros_ec_sensor_data *data;
>  	size_t candidates, i, sensor_name_size;
>  	int ret;
>  	u8 temp;
> @@ -216,6 +248,23 @@ static void cros_ec_hwmon_probe_temp_sensors(struct device *dev, struct cros_ec_
>  		priv->temp_sensor_names[i] = devm_kasprintf(dev, GFP_KERNEL, "%.*s",
>  							    (int)sensor_name_size,
>  							    resp.sensor_name);
> +
> +		data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> +		if (!data)
> +			continue;
> +
> +		data->addr = i;
> +		data->cros_ec = cros_ec;
> +		data->tz_dev = devm_thermal_of_zone_register(
> +			cros_ec->dev, i, data, &thermal_ops);

I'm a bit confused. The uses thermal configuration from OF,
but this driver has no specific OF support.
Can you provide a usage example in the commit message?

Does it not need a binding documentation update?

> +		if (IS_ERR_VALUE(data->tz_dev)) {
> +			dev_err(dev,
> +				"failed to register %zu thermal sensor, err = %ld",
> +				i, PTR_ERR(data->tz_dev));

Use %pe.

> +			continue;
> +		}
> +
> +		list_add(&data->node, head);
>  	}
>  }
>  
> @@ -255,8 +304,10 @@ static int cros_ec_hwmon_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	priv->cros_ec = cros_ec;
> +	INIT_LIST_HEAD(&priv->sensors);
>  
> -	cros_ec_hwmon_probe_temp_sensors(dev, priv, thermal_version);
> +	cros_ec_hwmon_probe_temp_sensors(cros_ec, dev, priv, &priv->sensors,
> +					 thermal_version);

cros_ec is already passed as priv->cros_ec.

>  	cros_ec_hwmon_probe_fans(priv);
>  
>  	hwmon_dev = devm_hwmon_device_register_with_info(dev, "cros_ec", priv,
> @@ -265,6 +316,17 @@ static int cros_ec_hwmon_probe(struct platform_device *pdev)
>  	return PTR_ERR_OR_ZERO(hwmon_dev);
>  }
>  
> +static void cros_ec_hwmon_remove(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct cros_ec_hwmon_priv *priv = dev_get_drvdata(dev);
> +	struct cros_ec_sensor_data *iter;
> +
> +	list_for_each_entry(iter, &priv->sensors, node) {
> +		devm_thermal_of_zone_unregister(dev, iter->tz_dev);

This shouldn't be needed, the zone will be unregistered automatically by
the devm framework.
This also means that .remove and priv->sensors can go away.

> +	}
> +}
> +
>  static const struct platform_device_id cros_ec_hwmon_id[] = {
>  	{ DRV_NAME, 0 },
>  	{}
> @@ -273,6 +335,7 @@ static const struct platform_device_id cros_ec_hwmon_id[] = {
>  static struct platform_driver cros_ec_hwmon_driver = {
>  	.driver.name	= DRV_NAME,
>  	.probe		= cros_ec_hwmon_probe,
> +	.remove		= cros_ec_hwmon_remove,
>  	.id_table	= cros_ec_hwmon_id,
>  };
>  module_platform_driver(cros_ec_hwmon_driver);
> -- 
> 2.47.0.277.g8800431eea-goog
>
[PATCH v3 1/2] hwmon: (cros_ec) register thermal sensors to thermal framework
Posted by Sung-Chi, Li 1 year, 1 month ago
cros_ec hwmon driver probes available thermal sensors when probing the
driver.  Register these thermal sensors to the thermal framework as well
via setting HWMON_C_REGISTER_TZ as a chip info, such that thermal
framework can adopt these sensors as well.

To make cros_ec registrable to thermal framework, the cros_ec dts need
the corresponding changes:

&cros_ec {
	#thermal-sensor-cells = <1>;
};

Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>
---
 Changes in v2:
   - Rename `cros_ec_sensor_data` to `cros_ec_hwmon_thermal_zone_data`.
   - Rename `addr` in struct `cros_ec_hwmon_thermal_zone_data` to `idx`.
   - Use `cros_ec_hwmon_temp_to_millicelsius` to do value conversion in
     `cros_ec_thermal_get_temp` function.
   - Rename `cros_ec_thermal_get_temp` to `cros_ec_hwmon_thermal_get_temp` to
     make `cros_ec_hwmon` a prefix.
   - Use `%pe` in `cros_ec_hwmon_probe_temp_sensors` when printing out
     `data->tz_dev` if failed register thermal device.
   - Remove `cros_ec_hwmon_remove`, and the `.remove` value in
     `cros_ec_hwmon_driver` since there is no need to call
     `devm_thermal_of_zone_unregister` for clean up.
   - Revert function signature of `cros_ec_hwmon_probe_temp_sensors` since all
     needed parameters are presented.
   - Revert include of `linux/list.h` because no list data structure is used.
---
 Changes in v3:
   - Revert all changes and just as add HWMON_C_REGISTER_TZ as a chip info.
   - Remove unneeded Change-Id tag in commit message.
---
 drivers/hwmon/cros_ec_hwmon.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c
index 5514cf780b8b..9991c3fa020a 100644
--- a/drivers/hwmon/cros_ec_hwmon.c
+++ b/drivers/hwmon/cros_ec_hwmon.c
@@ -141,6 +141,7 @@ static umode_t cros_ec_hwmon_is_visible(const void *data, enum hwmon_sensor_type
 }
 
 static const struct hwmon_channel_info * const cros_ec_hwmon_info[] = {
+	HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ),
 	HWMON_CHANNEL_INFO(fan,
 			   HWMON_F_INPUT | HWMON_F_FAULT,
 			   HWMON_F_INPUT | HWMON_F_FAULT,
-- 
2.47.0.338.g60cca15819-goog
Re: [PATCH v3 1/2] hwmon: (cros_ec) register thermal sensors to thermal framework
Posted by Guenter Roeck 1 year, 1 month ago
On Wed, Nov 13, 2024 at 10:39:51AM +0800, Sung-Chi, Li wrote:
> cros_ec hwmon driver probes available thermal sensors when probing the
> driver.  Register these thermal sensors to the thermal framework as well
> via setting HWMON_C_REGISTER_TZ as a chip info, such that thermal
> framework can adopt these sensors as well.
> 
> To make cros_ec registrable to thermal framework, the cros_ec dts need
> the corresponding changes:
> 
> &cros_ec {
> 	#thermal-sensor-cells = <1>;
> };
> 
> Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>

Applied.

Thanks,
Guenter
[PATCH v3 2/2] dt-bindings: mfd: Add properties for thermal sensor cells
Posted by Sung-Chi, Li 1 year, 1 month ago
The cros_ec supports reading thermal values from thermal sensors
connect to it. Add the property '#thermal-sensor-cells' bindings, such
that thermal framework can recognize cros_ec as a valid thermal device.

Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
---
 Changes in v2:
   - Add changes for DTS binding.
 Changes in v3:
   - Remove unneeded Change-Id tag in commit message.
---
 Documentation/devicetree/bindings/mfd/google,cros-ec.yaml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
index aac8819bd00b..c7d63e3aacd2 100644
--- a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
+++ b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
@@ -96,6 +96,9 @@ properties:
   '#gpio-cells':
     const: 2
 
+  '#thermal-sensor-cells':
+    const: 1
+
   gpio-controller: true
 
   typec:
-- 
2.47.0.338.g60cca15819-goog
Re: [PATCH v3 2/2] dt-bindings: mfd: Add properties for thermal sensor cells
Posted by Guenter Roeck 1 year, 1 month ago
On 11/12/24 18:39, Sung-Chi, Li wrote:
> The cros_ec supports reading thermal values from thermal sensors
> connect to it. Add the property '#thermal-sensor-cells' bindings, such
> that thermal framework can recognize cros_ec as a valid thermal device.
> 
> Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
> ---
>   Changes in v2:
>     - Add changes for DTS binding.
>   Changes in v3:
>     - Remove unneeded Change-Id tag in commit message.
> ---

I can't apply this one (not in hwmon space), so

Acked-by: Guenter Roeck <linux@roeck-us.net>

with the assumption that Lee will pick it up.

Thanks,
Guenter

>   Documentation/devicetree/bindings/mfd/google,cros-ec.yaml | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
> index aac8819bd00b..c7d63e3aacd2 100644
> --- a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
> +++ b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
> @@ -96,6 +96,9 @@ properties:
>     '#gpio-cells':
>       const: 2
>   
> +  '#thermal-sensor-cells':
> +    const: 1
> +
>     gpio-controller: true
>   
>     typec:
Re: [PATCH v3 2/2] dt-bindings: mfd: Add properties for thermal sensor cells
Posted by Krzysztof Kozlowski 1 year ago
On 13/11/2024 04:05, Guenter Roeck wrote:
> On 11/12/24 18:39, Sung-Chi, Li wrote:
>> The cros_ec supports reading thermal values from thermal sensors
>> connect to it. Add the property '#thermal-sensor-cells' bindings, such
>> that thermal framework can recognize cros_ec as a valid thermal device.
>>
>> Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>
>> Acked-by: Conor Dooley <conor.dooley@microchip.com>
>> ---
>>   Changes in v2:
>>     - Add changes for DTS binding.
>>   Changes in v3:
>>     - Remove unneeded Change-Id tag in commit message.
>> ---
> 
> I can't apply this one (not in hwmon space), so
> 
> Acked-by: Guenter Roeck <linux@roeck-us.net>
> 
> with the assumption that Lee will pick it up.

This was merged, while I was AFK, so the ship has sailed, but let me
state here objection for any future discussions:

NAK, this is not a thermal sensor. The commit msg explains what they
want to achieve, but that's not a valid reason to add property from
different class of devices.

This is some hardware/temperature monitoring device or power supply, not
part of SoC, not integrated into any SoC thermal zone. Calling it
thermal sensor is huge stretch and inappropriate hardware description
leading to next patches like calling it a SoC cooling device, instead of
simple power supply (for which we have bindings!).

Best regards,
Krzysztof
Re: [PATCH v3 2/2] dt-bindings: mfd: Add properties for thermal sensor cells
Posted by Guenter Roeck 1 year ago
On 11/25/24 00:52, Krzysztof Kozlowski wrote:
> On 13/11/2024 04:05, Guenter Roeck wrote:
>> On 11/12/24 18:39, Sung-Chi, Li wrote:
>>> The cros_ec supports reading thermal values from thermal sensors
>>> connect to it. Add the property '#thermal-sensor-cells' bindings, such
>>> that thermal framework can recognize cros_ec as a valid thermal device.
>>>
>>> Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>
>>> Acked-by: Conor Dooley <conor.dooley@microchip.com>
>>> ---
>>>    Changes in v2:
>>>      - Add changes for DTS binding.
>>>    Changes in v3:
>>>      - Remove unneeded Change-Id tag in commit message.
>>> ---
>>
>> I can't apply this one (not in hwmon space), so
>>
>> Acked-by: Guenter Roeck <linux@roeck-us.net>
>>
>> with the assumption that Lee will pick it up.
> 
> This was merged, while I was AFK, so the ship has sailed, but let me
> state here objection for any future discussions:
> 
> NAK, this is not a thermal sensor. The commit msg explains what they
> want to achieve, but that's not a valid reason to add property from
> different class of devices.
> 
> This is some hardware/temperature monitoring device or power supply, not
> part of SoC, not integrated into any SoC thermal zone. Calling it

I am confused. We have several thermal sensors registering as thermal
zone, and fan controllers registering themselves as thermal cooling devices.

Are you saying that this is all not permitted because they are not part
of a SoC ?

Guenter
Re: [PATCH v3 2/2] dt-bindings: mfd: Add properties for thermal sensor cells
Posted by Krzysztof Kozlowski 1 year ago
On 25/11/2024 16:13, Guenter Roeck wrote:
> On 11/25/24 00:52, Krzysztof Kozlowski wrote:
>> On 13/11/2024 04:05, Guenter Roeck wrote:
>>> On 11/12/24 18:39, Sung-Chi, Li wrote:
>>>> The cros_ec supports reading thermal values from thermal sensors
>>>> connect to it. Add the property '#thermal-sensor-cells' bindings, such
>>>> that thermal framework can recognize cros_ec as a valid thermal device.
>>>>
>>>> Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>
>>>> Acked-by: Conor Dooley <conor.dooley@microchip.com>
>>>> ---
>>>>    Changes in v2:
>>>>      - Add changes for DTS binding.
>>>>    Changes in v3:
>>>>      - Remove unneeded Change-Id tag in commit message.
>>>> ---
>>>
>>> I can't apply this one (not in hwmon space), so
>>>
>>> Acked-by: Guenter Roeck <linux@roeck-us.net>
>>>
>>> with the assumption that Lee will pick it up.
>>
>> This was merged, while I was AFK, so the ship has sailed, but let me
>> state here objection for any future discussions:
>>
>> NAK, this is not a thermal sensor. The commit msg explains what they
>> want to achieve, but that's not a valid reason to add property from
>> different class of devices.
>>
>> This is some hardware/temperature monitoring device or power supply, not
>> part of SoC, not integrated into any SoC thermal zone. Calling it
> 
> I am confused. We have several thermal sensors registering as thermal
> zone, and fan controllers registering themselves as thermal cooling devices.
> 
> Are you saying that this is all not permitted because they are not part
> of a SoC ?


These are fine, because they monitor or cool down the SoC.  Sensor can
be under the die.  Fan for battery or for battery charger also would be
fine, because it is a real cooling device.  It literally cools.

But treating battery charger as cooling device is not correct, IMHO.
Battery charger does not cool anything down and already we have there
properties for managing thermal and current aspects.

BTW, if power supply bindings miss some thermal aspects, then let's grow
the common binding first and agree on common aspects.


Best regards,
Krzysztof
Re: [PATCH v3 2/2] dt-bindings: mfd: Add properties for thermal sensor cells
Posted by Guenter Roeck 1 year ago
On 11/25/24 07:18, Krzysztof Kozlowski wrote:
> On 25/11/2024 16:13, Guenter Roeck wrote:
>> On 11/25/24 00:52, Krzysztof Kozlowski wrote:
>>> On 13/11/2024 04:05, Guenter Roeck wrote:
>>>> On 11/12/24 18:39, Sung-Chi, Li wrote:
>>>>> The cros_ec supports reading thermal values from thermal sensors
>>>>> connect to it. Add the property '#thermal-sensor-cells' bindings, such
>>>>> that thermal framework can recognize cros_ec as a valid thermal device.
>>>>>
>>>>> Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>
>>>>> Acked-by: Conor Dooley <conor.dooley@microchip.com>
>>>>> ---
>>>>>     Changes in v2:
>>>>>       - Add changes for DTS binding.
>>>>>     Changes in v3:
>>>>>       - Remove unneeded Change-Id tag in commit message.
>>>>> ---
>>>>
>>>> I can't apply this one (not in hwmon space), so
>>>>
>>>> Acked-by: Guenter Roeck <linux@roeck-us.net>
>>>>
>>>> with the assumption that Lee will pick it up.
>>>
>>> This was merged, while I was AFK, so the ship has sailed, but let me
>>> state here objection for any future discussions:
>>>
>>> NAK, this is not a thermal sensor. The commit msg explains what they
>>> want to achieve, but that's not a valid reason to add property from
>>> different class of devices.
>>>
>>> This is some hardware/temperature monitoring device or power supply, not
>>> part of SoC, not integrated into any SoC thermal zone. Calling it
>>
>> I am confused. We have several thermal sensors registering as thermal
>> zone, and fan controllers registering themselves as thermal cooling devices.
>>
>> Are you saying that this is all not permitted because they are not part
>> of a SoC ?
> 
> 
> These are fine, because they monitor or cool down the SoC.  Sensor can
> be under the die.  Fan for battery or for battery charger also would be
> fine, because it is a real cooling device.  It literally cools.
> 

Sorry, I don't get the distinction since you specifically refer to the SoC.
How about drive temperatures ? RAM temperatures ? Temperatures reported
by networking chips ? Power supply temperatures ? We have all those registering
thermal zones. The ASUS EC controller driver registers thermal zones
for its temperature sensors. Dell and HP drivers do the same.

> But treating battery charger as cooling device is not correct, IMHO.

Confused. The patch you object to isn't introducing a cooling device,
it is introducing #thermal-sensor-cells. The EC reports temperature
sensor results, and the driver wants to register those as thermal zones.
Yes, it may well be that one of those temperature sensors is close to
a battery charger, but I am not even sure if that is really the case.

> Battery charger does not cool anything down and already we have there
> properties for managing thermal and current aspects.
> 
Agreed, but unless I am missing something that isn't done here.

> BTW, if power supply bindings miss some thermal aspects, then let's grow
> the common binding first and agree on common aspects.
> 

I don't even know how the two patches are associated with power supplies
or battery chargers in the first place. All they try to do is to enable
adding the temperature sensor values reported by the EC in Chromebooks
to thermal zones. I don't recall any previous limitations on the ability
to register thermal sensors as thermal zone with the thermal subsystem,
and I am trying to understand what those limitations are.

So far my approach was "ok, someone wants to register a thermal sensor as
thermal zone - fine, let's do that. We have close to 50 thermal sensors on
a variety of devices - including but not limited to disk drives, memory,
Ethernet controllers, Ethernet PHYs, SFPs, RTCs, and ECs - registering
as thermal zones from hardware monitoring drivers. I don't recall anyone
ever saying "no, you can't do that".

I am trying to understand if some of those are inappropriate and, if so,
why that is the case.

Thanks,
Guenter
Re: [PATCH v3 2/2] dt-bindings: mfd: Add properties for thermal sensor cells
Posted by Krzysztof Kozlowski 1 year ago
On 25/11/2024 17:41, Guenter Roeck wrote:
>>>>>
>>>>> with the assumption that Lee will pick it up.
>>>>
>>>> This was merged, while I was AFK, so the ship has sailed, but let me
>>>> state here objection for any future discussions:
>>>>
>>>> NAK, this is not a thermal sensor. The commit msg explains what they
>>>> want to achieve, but that's not a valid reason to add property from
>>>> different class of devices.
>>>>
>>>> This is some hardware/temperature monitoring device or power supply, not
>>>> part of SoC, not integrated into any SoC thermal zone. Calling it
>>>
>>> I am confused. We have several thermal sensors registering as thermal
>>> zone, and fan controllers registering themselves as thermal cooling devices.
>>>
>>> Are you saying that this is all not permitted because they are not part
>>> of a SoC ?
>>
>>
>> These are fine, because they monitor or cool down the SoC.  Sensor can
>> be under the die.  Fan for battery or for battery charger also would be
>> fine, because it is a real cooling device.  It literally cools.
>>
> 
> Sorry, I don't get the distinction since you specifically refer to the SoC.
> How about drive temperatures ? RAM temperatures ? Temperatures reported

Several of them are part of the SoC, like DDR. But even if they are not,
I agree they could be a thermal sensor, but I would stop before calling
them thermal zones and this patchset leads to such calling.

> by networking chips ? Power supply temperatures ? We have all those registering
> thermal zones. The ASUS EC controller driver registers thermal zones
> for its temperature sensors. Dell and HP drivers do the same.

Maybe we need to clarify that thermal sensors and zones are not specific
to SoCs?

For now all bindings say:
"thermal-sensor: device that measures temperature, has SoC-specific
bindings"


> 
>> But treating battery charger as cooling device is not correct, IMHO.
> 
> Confused. The patch you object to isn't introducing a cooling device,
> it is introducing #thermal-sensor-cells. The EC reports temperature


The next patchset is. This is one of the problems with series from
Sung-Chi, Li - they add hardware description piece by piece, to match
the driver needs, while we expect to see complete hardware picture.

In the complete picture (f:lschyi@chromium.org in lore) you would see
the battery being called a cooling sensor with explanation:

"The cros_ec supports limiting the input current to act as a passive
thermal cooling device. Add the property '#cooling-cells' bindings, such
that thermal framework can recognize cros_ec as a valid thermal cooling
device."



> sensor results, and the driver wants to register those as thermal zones.
> Yes, it may well be that one of those temperature sensors is close to
> a battery charger, but I am not even sure if that is really the case.

Hm, my impression based on very limited commit msg was that it is about
battery.

Probably I don't understand how the hardware looks here, but sorry,
commit msgs and bindings descriptions are for a reason - to help me
understanding it.

> 
>> Battery charger does not cool anything down and already we have there
>> properties for managing thermal and current aspects.
>>
> Agreed, but unless I am missing something that isn't done here.

Yep, I connected two separate patchsets, because they form greater work
of making power supply a cooling device, AFAIU.

> 
>> BTW, if power supply bindings miss some thermal aspects, then let's grow
>> the common binding first and agree on common aspects.
>>
> 
> I don't even know how the two patches are associated with power supplies
> or battery chargers in the first place. All they try to do is to enable
> adding the temperature sensor values reported by the EC in Chromebooks
> to thermal zones. I don't recall any previous limitations on the ability
> to register thermal sensors as thermal zone with the thermal subsystem,
> and I am trying to understand what those limitations are.
> 
> So far my approach was "ok, someone wants to register a thermal sensor as
> thermal zone - fine, let's do that. We have close to 50 thermal sensors on
> a variety of devices - including but not limited to disk drives, memory,
> Ethernet controllers, Ethernet PHYs, SFPs, RTCs, and ECs - registering
> as thermal zones from hardware monitoring drivers. I don't recall anyone
> ever saying "no, you can't do that".
> 
> I am trying to understand if some of those are inappropriate and, if so,
> why that is the case.


Probably would be nice to drop remaining references to SoC from thermal
bindings and just interpret thermal zones as system-wide.

I retract than my objects against sensor cells, but I keep my objection
of changing these bindings piece by piece. This should be one complete
work for bindings so we see what this hardware is supposed to do.

Best regards,
Krzysztof
Re: [PATCH v3 2/2] dt-bindings: mfd: Add properties for thermal sensor cells
Posted by Krzysztof Kozlowski 1 year ago
On 25/11/2024 09:52, Krzysztof Kozlowski wrote:
> On 13/11/2024 04:05, Guenter Roeck wrote:
>> On 11/12/24 18:39, Sung-Chi, Li wrote:
>>> The cros_ec supports reading thermal values from thermal sensors
>>> connect to it. Add the property '#thermal-sensor-cells' bindings, such
>>> that thermal framework can recognize cros_ec as a valid thermal device.
>>>
>>> Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>
>>> Acked-by: Conor Dooley <conor.dooley@microchip.com>
>>> ---
>>>   Changes in v2:
>>>     - Add changes for DTS binding.
>>>   Changes in v3:
>>>     - Remove unneeded Change-Id tag in commit message.
>>> ---
>>
>> I can't apply this one (not in hwmon space), so
>>
>> Acked-by: Guenter Roeck <linux@roeck-us.net>
>>
>> with the assumption that Lee will pick it up.
> 
> This was merged, while I was AFK, so the ship has sailed, but let me
> state here objection for any future discussions:
> 
> NAK, this is not a thermal sensor. The commit msg explains what they
> want to achieve, but that's not a valid reason to add property from
> different class of devices.
> 
> This is some hardware/temperature monitoring device or power supply, not
> part of SoC, not integrated into any SoC thermal zone. Calling it
> thermal sensor is huge stretch and inappropriate hardware description
> leading to next patches like calling it a SoC cooling device, instead of
> simple power supply (for which we have bindings!).
Ah, wait, this was not merged, so I can actually NAK it.

BTW, all your patches are incorrectly ordered - bindings are always
before the users. You cannot merge user of a binding without or before
the binding.

Best regards,
Krzysztof
[PATCH v2] hwmon: (cros_ec) register thermal sensors to thermal framework
Posted by Sung-Chi 1 year, 1 month ago
From: "Sung-Chi, Li" <lschyi@chromium.org>

cros_ec hwmon driver probes available thermal sensors when probing the
driver.  Register these thermal sensors to the thermal framework, such
that thermal framework can adopt these sensors as well.

To make cros_ec registrable to thermal framework, the cros_ec dts need
the corresponding changes:

&cros_ec {
	#thermal-sensor-cells = <1>;
};

Change-Id: I29b638427c715cb44391496881fc61ad53abccaf
Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>
---
 Changes in v2:
   - Rename `cros_ec_sensor_data` to `cros_ec_hwmon_thermal_zone_data`.
   - Rename `addr` in struct `cros_ec_hwmon_thermal_zone_data` to `idx`.
   - Use `cros_ec_hwmon_temp_to_millicelsius` to do value conversion in 
     `cros_ec_thermal_get_temp` function.
   - Rename `cros_ec_thermal_get_temp` to `cros_ec_hwmon_thermal_get_temp` to
     make `cros_ec_hwmon` a prefix.
   - Use `%pe` in `cros_ec_hwmon_probe_temp_sensors` when printing out
     `data->tz_dev` if failed register thermal device.
   - Remove `cros_ec_hwmon_remove`, and the `.remove` value in
     `cros_ec_hwmon_driver` since there is no need to call
     `devm_thermal_of_zone_unregister` for clean up.
   - Revert function signature of `cros_ec_hwmon_probe_temp_sensors` since all
     needed parameters are presented.
   - Revert include of `linux/list.h` because no list data structure is used.
---
 drivers/hwmon/cros_ec_hwmon.c | 41 +++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c
index 5514cf780b8b..81e563e0455f 100644
--- a/drivers/hwmon/cros_ec_hwmon.c
+++ b/drivers/hwmon/cros_ec_hwmon.c
@@ -12,6 +12,7 @@
 #include <linux/platform_device.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_data/cros_ec_proto.h>
+#include <linux/thermal.h>
 #include <linux/types.h>
 #include <linux/units.h>
 
@@ -23,6 +24,12 @@ struct cros_ec_hwmon_priv {
 	u8 usable_fans;
 };
 
+struct cros_ec_hwmon_thermal_zone_data {
+	struct cros_ec_device *cros_ec;
+	struct thermal_zone_device *tz_dev;
+	int idx;
+};
+
 static int cros_ec_hwmon_read_fan_speed(struct cros_ec_device *cros_ec, u8 index, u16 *speed)
 {
 	int ret;
@@ -185,11 +192,30 @@ static const struct hwmon_chip_info cros_ec_hwmon_chip_info = {
 	.info = cros_ec_hwmon_info,
 };
 
+static int cros_ec_hwmon_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
+{
+	struct cros_ec_hwmon_thermal_zone_data *data =
+		thermal_zone_device_priv(tz);
+	int ret;
+	u8 val;
+
+	ret = cros_ec_hwmon_read_temp(data->cros_ec, data->idx, &val);
+	if (ret || cros_ec_hwmon_is_error_temp(temp))
+		return -ENODATA;
+	*temp = cros_ec_hwmon_temp_to_millicelsius(val);
+	return 0;
+}
+
+static const struct thermal_zone_device_ops thermal_ops = {
+	.get_temp = cros_ec_hwmon_thermal_get_temp,
+};
+
 static void cros_ec_hwmon_probe_temp_sensors(struct device *dev, struct cros_ec_hwmon_priv *priv,
 					     u8 thermal_version)
 {
 	struct ec_params_temp_sensor_get_info req = {};
 	struct ec_response_temp_sensor_get_info resp;
+	struct cros_ec_hwmon_thermal_zone_data *data;
 	size_t candidates, i, sensor_name_size;
 	int ret;
 	u8 temp;
@@ -216,6 +242,21 @@ static void cros_ec_hwmon_probe_temp_sensors(struct device *dev, struct cros_ec_
 		priv->temp_sensor_names[i] = devm_kasprintf(dev, GFP_KERNEL, "%.*s",
 							    (int)sensor_name_size,
 							    resp.sensor_name);
+
+		data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+		if (!data)
+			continue;
+
+		data->idx = i;
+		data->cros_ec = priv->cros_ec;
+		data->tz_dev = devm_thermal_of_zone_register(
+			priv->cros_ec->dev, i, data, &thermal_ops);
+		if (IS_ERR_VALUE(data->tz_dev)) {
+			dev_err(dev,
+				"failed to register %zu thermal sensor, err = %pe",
+				i, data->tz_dev);
+			continue;
+		}
 	}
 }
 
-- 
2.47.0.277.g8800431eea-goog
Re: [PATCH v2] hwmon: (cros_ec) register thermal sensors to thermal framework
Posted by Guenter Roeck 1 year, 1 month ago
On 11/11/24 01:50, Sung-Chi wrote:
> From: "Sung-Chi, Li" <lschyi@chromium.org>
> 
> cros_ec hwmon driver probes available thermal sensors when probing the
> driver.  Register these thermal sensors to the thermal framework, such
> that thermal framework can adopt these sensors as well.
> 
> To make cros_ec registrable to thermal framework, the cros_ec dts need
> the corresponding changes:
> 
> &cros_ec {
> 	#thermal-sensor-cells = <1>;
> };
> 
> Change-Id: I29b638427c715cb44391496881fc61ad53abccaf

Drop.

> Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>

Detailed explanation will be needed: Why not use HWMON_C_REGISTER_TZ ?
Unless I am missing something, this code just duplicates code from the hwmon core.

Please do not send follow-up patch series as response to previous ones.

Guenter
Re: [PATCH v2] hwmon: (cros_ec) register thermal sensors to thermal framework
Posted by Sung-Chi, Li 1 year, 1 month ago
On Mon, Nov 11, 2024 at 09:01:33AM -0800, Guenter Roeck wrote:
> On 11/11/24 01:50, Sung-Chi wrote:
> > From: "Sung-Chi, Li" <lschyi@chromium.org>
> > 
> > cros_ec hwmon driver probes available thermal sensors when probing the
> > driver.  Register these thermal sensors to the thermal framework, such
> > that thermal framework can adopt these sensors as well.
> > 
> > To make cros_ec registrable to thermal framework, the cros_ec dts need
> > the corresponding changes:
> > 
> > &cros_ec {
> > 	#thermal-sensor-cells = <1>;
> > };
> > 
> > Change-Id: I29b638427c715cb44391496881fc61ad53abccaf
> 
> Drop.
> 
> > Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>
> 
> Detailed explanation will be needed: Why not use HWMON_C_REGISTER_TZ ?
> Unless I am missing something, this code just duplicates code from the hwmon core.
> 
> Please do not send follow-up patch series as response to previous ones.
> 
> Guenter
> 

Hi, thank you for pointing out using HWMON_C_REGISTER_TZ. After checking how
HWMON_C_REGSITER_TZ works, I think I only need to add one line into the
cros_ec_hwmon_info, and almost all concerns Thomas pointed out in latest reply
would be resolved automatically (because there would be only one line of change,
and that change is just a hwmon configuration, so should be a valid way of
combining with the thermal system).

Thank all for reviewing and giving inputs, and I will soon send out the one
line patch.

Best,
Sung-Chi, Li
Re: [PATCH v2] hwmon: (cros_ec) register thermal sensors to thermal framework
Posted by Thomas Weißschuh 1 year, 1 month ago
On 2024-11-11 17:50:30+0800, Sung-Chi wrote:
> From: "Sung-Chi, Li" <lschyi@chromium.org>
> 
> cros_ec hwmon driver probes available thermal sensors when probing the
> driver.  Register these thermal sensors to the thermal framework, such
> that thermal framework can adopt these sensors as well.

The driver also supports fan readings. These could also be wired up as
cooling devices.

> To make cros_ec registrable to thermal framework, the cros_ec dts need
> the corresponding changes:
> 
> &cros_ec {
> 	#thermal-sensor-cells = <1>;
> };

If this is the only thing that is meant to be configured I'm wondering
why the OF variant is needed in the first place.
Why not register a non-OF thermal device?

Please send the next revision also to the maintainers of the THERMAL
subsystem so we can figure out the most correct way forward.

> Change-Id: I29b638427c715cb44391496881fc61ad53abccaf
> Signed-off-by: Sung-Chi, Li <lschyi@chromium.org>
> ---
>  Changes in v2:
>    - Rename `cros_ec_sensor_data` to `cros_ec_hwmon_thermal_zone_data`.
>    - Rename `addr` in struct `cros_ec_hwmon_thermal_zone_data` to `idx`.
>    - Use `cros_ec_hwmon_temp_to_millicelsius` to do value conversion in 
>      `cros_ec_thermal_get_temp` function.
>    - Rename `cros_ec_thermal_get_temp` to `cros_ec_hwmon_thermal_get_temp` to
>      make `cros_ec_hwmon` a prefix.
>    - Use `%pe` in `cros_ec_hwmon_probe_temp_sensors` when printing out
>      `data->tz_dev` if failed register thermal device.
>    - Remove `cros_ec_hwmon_remove`, and the `.remove` value in
>      `cros_ec_hwmon_driver` since there is no need to call
>      `devm_thermal_of_zone_unregister` for clean up.
>    - Revert function signature of `cros_ec_hwmon_probe_temp_sensors` since all
>      needed parameters are presented.
>    - Revert include of `linux/list.h` because no list data structure is used.
> ---
>  drivers/hwmon/cros_ec_hwmon.c | 41 +++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
> 
> diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c
> index 5514cf780b8b..81e563e0455f 100644
> --- a/drivers/hwmon/cros_ec_hwmon.c
> +++ b/drivers/hwmon/cros_ec_hwmon.c
> @@ -12,6 +12,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/platform_data/cros_ec_commands.h>
>  #include <linux/platform_data/cros_ec_proto.h>
> +#include <linux/thermal.h>
>  #include <linux/types.h>
>  #include <linux/units.h>
>  
> @@ -23,6 +24,12 @@ struct cros_ec_hwmon_priv {
>  	u8 usable_fans;
>  };
>  
> +struct cros_ec_hwmon_thermal_zone_data {
> +	struct cros_ec_device *cros_ec;
> +	struct thermal_zone_device *tz_dev;
> +	int idx;
> +};
> +
>  static int cros_ec_hwmon_read_fan_speed(struct cros_ec_device *cros_ec, u8 index, u16 *speed)
>  {
>  	int ret;
> @@ -185,11 +192,30 @@ static const struct hwmon_chip_info cros_ec_hwmon_chip_info = {
>  	.info = cros_ec_hwmon_info,
>  };
>  
> +static int cros_ec_hwmon_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
> +{
> +	struct cros_ec_hwmon_thermal_zone_data *data =
> +		thermal_zone_device_priv(tz);
> +	int ret;
> +	u8 val;
> +
> +	ret = cros_ec_hwmon_read_temp(data->cros_ec, data->idx, &val);
> +	if (ret || cros_ec_hwmon_is_error_temp(temp))
> +		return -ENODATA;
> +	*temp = cros_ec_hwmon_temp_to_millicelsius(val);
> +	return 0;
> +}
> +
> +static const struct thermal_zone_device_ops thermal_ops = {

Symbol still needs namespacing.

> +	.get_temp = cros_ec_hwmon_thermal_get_temp,
> +};
> +
>  static void cros_ec_hwmon_probe_temp_sensors(struct device *dev, struct cros_ec_hwmon_priv *priv,
>  					     u8 thermal_version)
>  {
>  	struct ec_params_temp_sensor_get_info req = {};
>  	struct ec_response_temp_sensor_get_info resp;
> +	struct cros_ec_hwmon_thermal_zone_data *data;
>  	size_t candidates, i, sensor_name_size;
>  	int ret;
>  	u8 temp;
> @@ -216,6 +242,21 @@ static void cros_ec_hwmon_probe_temp_sensors(struct device *dev, struct cros_ec_
>  		priv->temp_sensor_names[i] = devm_kasprintf(dev, GFP_KERNEL, "%.*s",
>  							    (int)sensor_name_size,
>  							    resp.sensor_name);
> +
> +		data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> +		if (!data)
> +			continue;
> +
> +		data->idx = i;
> +		data->cros_ec = priv->cros_ec;
> +		data->tz_dev = devm_thermal_of_zone_register(
> +			priv->cros_ec->dev, i, data, &thermal_ops);

Doesn't this also automatically create new hwmon device off of the
thermal device? That shouldn't happen.

In general I'm not sure how the hwmon and thermal subsystems are meant
to interact. Is one recommended over the other?
Should the driver become a first-class thermal driver and use the
automatic hwmon functionality?

> +		if (IS_ERR_VALUE(data->tz_dev)) {
> +			dev_err(dev,
> +				"failed to register %zu thermal sensor, err = %pe",
> +				i, data->tz_dev);

If !CONFIG_OF || !CONFIG_THERMAL this will always log an error.
EOPNOTSUP should not trigger that logging.

> +			continue;
> +		}
>  	}
>  }
>  
> -- 
> 2.47.0.277.g8800431eea-goog
>
[PATCH v2 2/2] dt-bindings: mfd: Add properties for thermal sensor cells
Posted by Sung-Chi 1 year, 1 month ago
The cros_ec supports reading thermal values from thermal sensors
connect to it. Add the property '#thermal-sensor-cells' bindings, such
that thermal framework can recognize cros_ec as a valid thermal device.

Change-Id: I95a22c0f1a69de547fede5f0f9c43cbd60820789
Signed-off-by: Sung-Chi <lschyi@chromium.org>
---
 Changes in v2:
   - Add changes for DTS binding.
---
 Documentation/devicetree/bindings/mfd/google,cros-ec.yaml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
index aac8819bd00b..c7d63e3aacd2 100644
--- a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
+++ b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
@@ -96,6 +96,9 @@ properties:
   '#gpio-cells':
     const: 2
 
+  '#thermal-sensor-cells':
+    const: 1
+
   gpio-controller: true
 
   typec:
-- 
2.47.0.277.g8800431eea-goog
Re: [PATCH v2 2/2] dt-bindings: mfd: Add properties for thermal sensor cells
Posted by Conor Dooley 1 year, 1 month ago
On Mon, Nov 11, 2024 at 05:50:31PM +0800, Sung-Chi wrote:
> The cros_ec supports reading thermal values from thermal sensors
> connect to it. Add the property '#thermal-sensor-cells' bindings, such
> that thermal framework can recognize cros_ec as a valid thermal device.
> 
> Change-Id: I95a22c0f1a69de547fede5f0f9c43cbd60820789
  ^^^^^^^^^
With this removed,
Acked-by: Conor Dooley <conor.dooley@microchip.com>

Cheers,
Conor.