]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
airoha: replace thermal patch with upstream version
authorChristian Marangi <ansuelsmth@gmail.com>
Sat, 5 Jul 2025 10:44:03 +0000 (12:44 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Tue, 2 Sep 2025 22:58:47 +0000 (00:58 +0200)
Replace thermal patch with upstream version. The thermal maintainer
reported that the sysfs entry are considered deprecated and that slope
and offset should be handled internally to the driver.

Link: https://github.com/openwrt/openwrt/pull/19816
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
target/linux/airoha/patches-6.6/049-01-v6.16-thermal-drivers-Add-support-for-Airoha-EN7581-therma.patch [moved from target/linux/airoha/patches-6.6/101-02-thermal-Add-support-for-Airoha-EN7581-thermal-sensor.patch with 84% similarity]
target/linux/airoha/patches-6.6/049-02-v6.16-thermal-drivers-airoha-Fix-spelling-mistake.patch [new file with mode: 0644]
target/linux/airoha/patches-6.6/101-01-thermal-of-Add-devm_thermal_of_zone_register_with_pa.patch [deleted file]

similarity index 84%
rename from target/linux/airoha/patches-6.6/101-02-thermal-Add-support-for-Airoha-EN7581-thermal-sensor.patch
rename to target/linux/airoha/patches-6.6/049-01-v6.16-thermal-drivers-Add-support-for-Airoha-EN7581-therma.patch
index ffacbba69374fbcc34f65c5a3249c2346b89b6e6..e168cda3249523f69212d373e3cd52320f11fd6a 100644 (file)
@@ -1,7 +1,7 @@
-From bc6a6a4ec6c28467683121cc165e5681b4acdf8d Mon Sep 17 00:00:00 2001
+From 42de37f40e1bc818df216dfa0918c114cfb5941d Mon Sep 17 00:00:00 2001
 From: Christian Marangi <ansuelsmth@gmail.com>
-Date: Tue, 27 Aug 2024 23:04:53 +0200
-Subject: [PATCH 3/3] thermal: Add support for Airoha EN7581 thermal sensor
+Date: Sun, 11 May 2025 20:49:55 +0200
+Subject: [PATCH] thermal/drivers: Add support for Airoha EN7581 thermal sensor
 
 Add support for Airoha EN7581 thermal sensor. This provide support for
 reading the CPU or SoC Package sensor and to setup trip points for hot
@@ -12,12 +12,20 @@ The thermal regs provide a way to read the ADC value from an external
 register placed in the Chip SCU regs. Monitor will read this value and
 fire an interrupt if the trip condition configured is reached.
 
+The Thermal Trip and Interrupt logic is conceptually similar to Mediatek
+LVTS Thermal but differ in register mapping and actual function/bug
+workaround. The implementation only share some register names but from
+functionality observation it's very different and used only for the
+basic function of periodically poll the temp and trip the interrupt.
+
 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
+Link: https://lore.kernel.org/r/20250511185003.3754495-2-ansuelsmth@gmail.com
+Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
 ---
  drivers/thermal/Kconfig          |   9 +
  drivers/thermal/Makefile         |   1 +
- drivers/thermal/airoha_thermal.c | 482 +++++++++++++++++++++++++++++++
- 3 files changed, 492 insertions(+)
+ drivers/thermal/airoha_thermal.c | 489 +++++++++++++++++++++++++++++++
+ 3 files changed, 499 insertions(+)
  create mode 100644 drivers/thermal/airoha_thermal.c
 
 --- a/drivers/thermal/Kconfig
@@ -50,7 +58,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
  obj-$(CONFIG_ROCKCHIP_THERMAL)        += rockchip_thermal.o
 --- /dev/null
 +++ b/drivers/thermal/airoha_thermal.c
-@@ -0,0 +1,482 @@
+@@ -0,0 +1,489 @@
 +// SPDX-License-Identifier: GPL-2.0-or-later
 +
 +#include <linux/module.h>
@@ -235,15 +243,17 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
 +#define EN7581_SCU_THERMAL_MUX_DIODE1         0x7
 +
 +/* Convert temp to raw value as read from ADC ((((temp / 100) - init) * slope) / 1000) + offset */
-+#define TEMP_TO_RAW(priv, tz, temp)           ((((((temp) / 100) - (priv)->init_temp) * \
-+                                                thermal_zone_get_slope(tz)) / 1000) + \
-+                                                thermal_zone_get_offset(tz))
++#define TEMP_TO_RAW(priv, temp)                       ((((((temp) / 100) - (priv)->init_temp) * \
++                                                (priv)->default_slope) / 1000) + \
++                                               (priv)->default_offset)
 +
 +/* Convert raw to temp                                ((((temp - offset) * 1000) / slope + init) * 100) */
-+#define RAW_TO_TEMP(priv, tz, raw)            (((((raw) - thermal_zone_get_offset(tz)) * 1000) / \
-+                                                thermal_zone_get_slope(tz) + \
++#define RAW_TO_TEMP(priv, raw)                        (((((raw) - (priv)->default_offset) * 1000) / \
++                                                (priv)->default_slope + \
 +                                                (priv)->init_temp) * 100)
 +
++#define AIROHA_MAX_SAMPLES                    6
++
 +struct airoha_thermal_priv {
 +      void __iomem *base;
 +      struct regmap *chip_scu;
@@ -251,6 +261,8 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
 +
 +      struct thermal_zone_device *tz;
 +      int init_temp;
++      int default_slope;
++      int default_offset;
 +};
 +
 +static int airoha_get_thermal_ADC(struct airoha_thermal_priv *priv)
@@ -280,28 +292,25 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
 +static int airoha_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
 +{
 +      struct airoha_thermal_priv *priv = thermal_zone_device_priv(tz);
-+      int min, max, avg_temp, temp_adc;
++      int min_value, max_value, avg_value, value;
 +      int i;
 +
-+      /* Get the starting temp */
-+      temp_adc = airoha_get_thermal_ADC(priv);
-+      min = temp_adc;
-+      max = temp_adc;
-+      avg_temp = temp_adc;
-+
-+      /* Make 5 more measurement and average the temp ADC difference */
-+      for (i = 0; i < 5; i++) {
-+              temp_adc = airoha_get_thermal_ADC(priv);
-+              avg_temp += temp_adc;
-+              if (temp_adc > max)
-+                      max = temp_adc;
-+              if (temp_adc < min)
-+                      min = temp_adc;
++      avg_value = 0;
++      min_value = INT_MAX;
++      max_value = INT_MIN;
++
++      for (i = 0; i < AIROHA_MAX_SAMPLES; i++) {
++              value = airoha_get_thermal_ADC(priv);
++              min_value = min(value, min_value);
++              max_value = max(value, max_value);
++              avg_value += value;
 +      }
-+      avg_temp = avg_temp - max - min;
-+      avg_temp /= 4;
 +
-+      *temp = RAW_TO_TEMP(priv, tz, avg_temp);
++      /* Drop min and max and average for the remaining sample */
++      avg_value -= (min_value + max_value);
++      avg_value /= AIROHA_MAX_SAMPLES - 2;
++
++      *temp = RAW_TO_TEMP(priv, avg_value);
 +      return 0;
 +}
 +
@@ -309,29 +318,35 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
 +                                  int high)
 +{
 +      struct airoha_thermal_priv *priv = thermal_zone_device_priv(tz);
++      bool enable_monitor = false;
 +
 +      if (high != INT_MAX) {
-+              /* Validate high and clamp them a sane value */
-+              if (high > RAW_TO_TEMP(priv, tz, FIELD_MAX(EN7581_DOUT_TADC_MASK)))
-+                      high = 110000;
++              /* Validate high and clamp it a supported value */
++              high = clamp_t(int, high, RAW_TO_TEMP(priv, 0),
++                             RAW_TO_TEMP(priv, FIELD_MAX(EN7581_DOUT_TADC_MASK)));
 +
 +              /* We offset the high temp of 1°C to trigger correct event */
-+              writel(TEMP_TO_RAW(priv, tz, high) >> 4,
++              writel(TEMP_TO_RAW(priv, high) >> 4,
 +                     priv->base + EN7581_TEMPOFFSETH);
++
++              enable_monitor = true;
 +      }
 +
 +      if (low != -INT_MAX) {
-+              /* Validate low and clamp them to a sane value */
-+              if (low < RAW_TO_TEMP(priv, tz, 0))
-+                      low = -33000;
++              /* Validate low and clamp it to a supported value */
++              low = clamp_t(int, high, RAW_TO_TEMP(priv, 0),
++                            RAW_TO_TEMP(priv, FIELD_MAX(EN7581_DOUT_TADC_MASK)));
 +
 +              /* We offset the low temp of 1°C to trigger correct event */
-+              writel(TEMP_TO_RAW(priv, tz, low) >> 4,
++              writel(TEMP_TO_RAW(priv, low) >> 4,
 +                     priv->base + EN7581_TEMPOFFSETL);
++
++              enable_monitor = true;
 +      }
 +
-+      /* Enable sensor 0 monitor */
-+      writel(EN7581_SENSE0_EN, priv->base + EN7581_TEMPMONCTL0);
++      /* Enable sensor 0 monitor after trip are set */
++      if (enable_monitor)
++              writel(EN7581_SENSE0_EN, priv->base + EN7581_TEMPMONCTL0);
 +
 +      return 0;
 +}
@@ -345,32 +360,35 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
 +{
 +      struct airoha_thermal_priv *priv = data;
 +      enum thermal_notify_event event;
++      bool update = false;
 +      u32 status;
 +
 +      status = readl(priv->base + EN7581_TEMPMONINTSTS);
 +      switch (status & (EN7581_HOFSINTSTS0 | EN7581_LOFSINTSTS0)) {
 +      case EN7581_HOFSINTSTS0:
 +              event = THERMAL_TRIP_VIOLATED;
++              update = true;
 +              break;
 +      case EN7581_LOFSINTSTS0:
 +              event = THERMAL_EVENT_UNSPECIFIED;
++              update = true;
 +              break;
 +      default:
-+              goto exit;
++              /* Should be impossible as we enable only these Interrupt */
++              break;
 +      }
 +
-+      thermal_zone_device_update(priv->tz, event);
-+
-+exit:
-+      /* reset interrupt */
++      /* Reset Interrupt */
 +      writel(status, priv->base + EN7581_TEMPMONINTSTS);
 +
++      if (update)
++              thermal_zone_device_update(priv->tz, event);
++
 +      return IRQ_HANDLED;
 +}
 +
 +static void airoha_thermal_setup_adc_val(struct device *dev,
-+                                       struct airoha_thermal_priv *priv,
-+                                       struct thermal_zone_params *tzp)
++                                       struct airoha_thermal_priv *priv)
 +{
 +      u32 efuse_calib_info, cpu_sensor;
 +
@@ -381,19 +399,19 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
 +
 +      efuse_calib_info = readl(priv->base + EN7581_EFUSE_TEMP_OFFSET_REG);
 +      if (efuse_calib_info) {
-+              tzp->offset = FIELD_GET(EN7581_EFUSE_TEMP_OFFSET, efuse_calib_info);
++              priv->default_offset = FIELD_GET(EN7581_EFUSE_TEMP_OFFSET, efuse_calib_info);
 +              /* Different slope are applied if the sensor is used for CPU or for package */
 +              cpu_sensor = readl(priv->base + EN7581_EFUSE_TEMP_CPU_SENSOR_REG);
 +              if (cpu_sensor) {
-+                      tzp->slope = EN7581_SLOPE_X100_DIO_DEFAULT;
++                      priv->default_slope = EN7581_SLOPE_X100_DIO_DEFAULT;
 +                      priv->init_temp = EN7581_INIT_TEMP_FTK_X10;
 +              } else {
-+                      tzp->slope = EN7581_SLOPE_X100_DIO_AVS;
++                      priv->default_slope = EN7581_SLOPE_X100_DIO_AVS;
 +                      priv->init_temp = EN7581_INIT_TEMP_CPK_X10;
 +              }
 +      } else {
-+              tzp->offset = airoha_get_thermal_ADC(priv);
-+              tzp->slope = EN7581_SLOPE_X100_DIO_DEFAULT;
++              priv->default_offset = airoha_get_thermal_ADC(priv);
++              priv->default_slope = EN7581_SLOPE_X100_DIO_DEFAULT;
 +              priv->init_temp = EN7581_INIT_TEMP_NONK_X10;
 +              dev_info(dev, "missing thermal calibrarion EFUSE, using non calibrated value\n");
 +      }
@@ -456,7 +474,6 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
 +
 +static int airoha_thermal_probe(struct platform_device *pdev)
 +{
-+      struct thermal_zone_params tzp = { };
 +      struct airoha_thermal_priv *priv;
 +      struct device_node *chip_scu_np;
 +      struct device *dev = &pdev->dev;
@@ -487,19 +504,17 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
 +
 +      ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
 +                                      airoha_thermal_irq, IRQF_ONESHOT,
-+                                      pdev->name, (void *)priv);
++                                      pdev->name, priv);
 +      if (ret) {
 +              dev_err(dev, "Can't get interrupt working.\n");
 +              return ret;
 +      }
 +
 +      airoha_thermal_setup_monitor(priv);
-+      airoha_thermal_setup_adc_val(dev, priv, &tzp);
++      airoha_thermal_setup_adc_val(dev, priv);
 +
 +      /* register of thermal sensor and get info from DT */
-+      priv->tz = devm_thermal_of_zone_register_with_params(dev, 0, priv,
-+                                                           &thdev_ops,
-+                                                           &tzp);
++      priv->tz = devm_thermal_of_zone_register(dev, 0, priv, &thdev_ops);
 +      if (IS_ERR(priv->tz)) {
 +              dev_err(dev, "register thermal zone sensor failed\n");
 +              return PTR_ERR(priv->tz);
diff --git a/target/linux/airoha/patches-6.6/049-02-v6.16-thermal-drivers-airoha-Fix-spelling-mistake.patch b/target/linux/airoha/patches-6.6/049-02-v6.16-thermal-drivers-airoha-Fix-spelling-mistake.patch
new file mode 100644 (file)
index 0000000..7b1b947
--- /dev/null
@@ -0,0 +1,44 @@
+From e23cba0ab49a9cf95e9bc3a86cfbf336b0e285f6 Mon Sep 17 00:00:00 2001
+From: Christian Marangi <ansuelsmth@gmail.com>
+Date: Wed, 14 May 2025 23:39:12 +0200
+Subject: [PATCH] thermal/drivers/airoha: Fix spelling mistake
+
+Fix various spelling mistake in airoha_thermal_setup_monitor() and
+define.
+
+Reported-by: Alok Tiwari <alok.a.tiwari@oracle.com>
+Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
+Link: https://lore.kernel.org/r/20250514213919.2321490-1-ansuelsmth@gmail.com
+Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
+---
+ drivers/thermal/airoha_thermal.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+--- a/drivers/thermal/airoha_thermal.c
++++ b/drivers/thermal/airoha_thermal.c
+@@ -155,7 +155,7 @@
+  * Can operate in:
+  * - 1 sample
+  * - 2 sample and make average of them
+- * - 4,6,10,16 sample, drop max and min and make avgerage of them
++ * - 4,6,10,16 sample, drop max and min and make average of them
+  */
+ #define   EN7581_MSRCTL_1SAMPLE                       0x0
+ #define   EN7581_MSRCTL_AVG2SAMPLE            0x1
+@@ -365,12 +365,12 @@ static void airoha_thermal_setup_monitor
+       /*
+        * Configure ADC valid reading addr
+        * The AHB temp monitor system doesn't have direct access to the
+-       * thermal sensor. It does instead work by providing all kind of
+-       * address to configure how to access and setup an ADC for the
++       * thermal sensor. It does instead work by providing various
++       * addresses to configure how to access and setup an ADC for the
+        * sensor. EN7581 supports only one sensor hence the
+        * implementation is greatly simplified but the AHB supports
+-       * up to 4 different sensor from the same ADC that can be
+-       * switched by tuning the ADC mux or wiriting address.
++       * up to 4 different sensors from the same ADC that can be
++       * switched by tuning the ADC mux or writing address.
+        *
+        * We set valid instead of volt as we don't enable valid/volt
+        * split reading and AHB read valid addr in such case.
diff --git a/target/linux/airoha/patches-6.6/101-01-thermal-of-Add-devm_thermal_of_zone_register_with_pa.patch b/target/linux/airoha/patches-6.6/101-01-thermal-of-Add-devm_thermal_of_zone_register_with_pa.patch
deleted file mode 100644 (file)
index d646e05..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-From 1f194995c3648e20da53137d4c9110b39e779f41 Mon Sep 17 00:00:00 2001
-From: Christian Marangi <ansuelsmth@gmail.com>
-Date: Fri, 18 Oct 2024 11:34:35 +0200
-Subject: [PATCH 2/3] thermal: of: Add
- devm_thermal_of_zone_register_with_params() variant
-
-Commit b1ae92dcfa8e ("thermal: core: Make struct thermal_zone_device
-definition internal") moved the thermal_zone_device struct from global
-thermal.h to internal thermal_core.h making the internal variables of
-the struct not accessible from the user drivers (without inclusing
-thermal_core.h).
-
-One case where the internal variables might be needed is for the
-thermal_zone_params in the context of OF probe.
-
-In such case a thermal driver might have default params that can only be
-parsed at runtime (example present in EFUSE or derived from other values)
-and wants to update the values in the thermal_zone_params for the
-thermal device. (to use the helper like get_slope() or get_offset())
-
-To account for this scenario, introduce a variant of
-devm_thermal_of_zone_register(),
-devm_thermal_of_zone_register_with_params(), that takes and additional
-variable and permits to register the thermal device with default
-thermal_zone_params.
-
-To follow OF implementation, these params are only treated as default
-params and are ignored if a related one is defined in DT. (example a
-slope or offset value defined in DT have priority to the default one
-passed in a thermal_device_params struct)
-
-This permits to support both implementation, use the helpers and expose
-these values in sysfs.
-
-Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
----
- drivers/thermal/thermal_of.c | 67 +++++++++++++++++++++++++++++-------
- include/linux/thermal.h      | 13 +++++++
- 2 files changed, 68 insertions(+), 12 deletions(-)
-
---- a/drivers/thermal/thermal_of.c
-+++ b/drivers/thermal/thermal_of.c
-@@ -246,7 +246,7 @@ static void thermal_of_parameters_init(s
- {
-       int coef[2];
-       int ncoef = ARRAY_SIZE(coef);
--      int prop, ret;
-+      int prop;
-       tzp->no_hwmon = true;
-@@ -258,14 +258,11 @@ static void thermal_of_parameters_init(s
-        * thermal zone. Thus, we are considering only the first two
-        * values as slope and offset.
-        */
--      ret = of_property_read_u32_array(np, "coefficients", coef, ncoef);
--      if (ret) {
--              coef[0] = 1;
--              coef[1] = 0;
-+      if (!of_property_read_u32_array(np, "coefficients", coef, ncoef)) {
-+              tzp->slope = coef[0];
-+              tzp->offset = coef[1];
-       }
--      tzp->slope = coef[0];
--      tzp->offset = coef[1];
- }
- static struct device_node *thermal_of_zone_get_by_name(struct thermal_zone_device *tz)
-@@ -459,10 +456,15 @@ static void thermal_of_zone_unregister(s
-  * zone properties and registers new thermal zone with those
-  * properties.
-  *
-+ * The passed thermal zone params are treated as default values and ignored if
-+ * the related property is found in DT. (DT params have priority to
-+ * default values)
-+ *
-  * @sensor: A device node pointer corresponding to the sensor in the device tree
-  * @id: An integer as sensor identifier
-  * @data: A private data to be stored in the thermal zone dedicated private area
-  * @ops: A set of thermal sensor ops
-+ * @tzp: a pointer to the default thermal zone params structure associated with the sensor
-  *
-  * Return: a valid thermal zone structure pointer on success.
-  *    - EINVAL: if the device tree thermal description is malformed
-@@ -470,11 +472,11 @@ static void thermal_of_zone_unregister(s
-  *    - Other negative errors are returned by the underlying called functions
-  */
- static struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data,
--                                                          const struct thermal_zone_device_ops *ops)
-+                                                          const struct thermal_zone_device_ops *ops,
-+                                                          struct thermal_zone_params *tzp)
- {
-       struct thermal_zone_device *tz;
-       struct thermal_trip *trips;
--      struct thermal_zone_params tzp = {};
-       struct thermal_zone_device_ops *of_ops;
-       struct device_node *np;
-       int delay, pdelay;
-@@ -509,7 +511,7 @@ static struct thermal_zone_device *therm
-               goto out_kfree_trips;
-       }
--      thermal_of_parameters_init(np, &tzp);
-+      thermal_of_parameters_init(np, tzp);
-       of_ops->bind = thermal_of_bind;
-       of_ops->unbind = thermal_of_unbind;
-@@ -517,7 +519,7 @@ static struct thermal_zone_device *therm
-       mask = GENMASK_ULL((ntrips) - 1, 0);
-       tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips,
--                                                   mask, data, of_ops, &tzp,
-+                                                   mask, data, of_ops, tzp,
-                                                    pdelay, delay);
-       if (IS_ERR(tz)) {
-               ret = PTR_ERR(tz);
-@@ -572,6 +574,7 @@ static int devm_thermal_of_zone_match(st
- struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int sensor_id, void *data,
-                                                         const struct thermal_zone_device_ops *ops)
- {
-+      struct thermal_zone_params tzp = { .slope = 1 };
-       struct thermal_zone_device **ptr, *tzd;
-       ptr = devres_alloc(devm_thermal_of_zone_release, sizeof(*ptr),
-@@ -579,7 +582,7 @@ struct thermal_zone_device *devm_thermal
-       if (!ptr)
-               return ERR_PTR(-ENOMEM);
--      tzd = thermal_of_zone_register(dev->of_node, sensor_id, data, ops);
-+      tzd = thermal_of_zone_register(dev->of_node, sensor_id, data, ops, &tzp);
-       if (IS_ERR(tzd)) {
-               devres_free(ptr);
-               return tzd;
-@@ -593,6 +596,46 @@ struct thermal_zone_device *devm_thermal
- EXPORT_SYMBOL_GPL(devm_thermal_of_zone_register);
- /**
-+ * devm_thermal_of_zone_register_with_params - register a thermal tied with the sensor life cycle
-+ *                                           with default params
-+ *
-+ * This function is the device version of the thermal_of_zone_register() function.
-+ *
-+ * @dev: a device structure pointer to sensor to be tied with the thermal zone OF life cycle
-+ * @sensor_id: the sensor identifier
-+ * @data: a pointer to a private data to be stored in the thermal zone 'devdata' field
-+ * @ops: a pointer to the ops structure associated with the sensor
-+ * @tzp: a pointer to the default thermal zone params structure associated with the sensor
-+ *
-+ * The thermal zone params are treated as default values and ignored if the related property is
-+ * found in DT. (DT params have priority to default values)
-+ */
-+struct thermal_zone_device *devm_thermal_of_zone_register_with_params(struct device *dev, int sensor_id,
-+                                                                    void *data,
-+                                                                    const struct thermal_zone_device_ops *ops,
-+                                                                    struct thermal_zone_params *tzp)
-+{
-+      struct thermal_zone_device **ptr, *tzd;
-+
-+      ptr = devres_alloc(devm_thermal_of_zone_release, sizeof(*ptr),
-+                         GFP_KERNEL);
-+      if (!ptr)
-+              return ERR_PTR(-ENOMEM);
-+
-+      tzd = thermal_of_zone_register(dev->of_node, sensor_id, data, ops, tzp);
-+      if (IS_ERR(tzd)) {
-+              devres_free(ptr);
-+              return tzd;
-+      }
-+
-+      *ptr = tzd;
-+      devres_add(dev, ptr);
-+
-+      return tzd;
-+}
-+EXPORT_SYMBOL_GPL(devm_thermal_of_zone_register_with_params);
-+
-+/**
-  * devm_thermal_of_zone_unregister - Resource managed version of
-  *                            thermal_of_zone_unregister().
-  * @dev: Device for which which resource was allocated.
---- a/include/linux/thermal.h
-+++ b/include/linux/thermal.h
-@@ -263,6 +263,10 @@ struct thermal_zone_params {
- #ifdef CONFIG_THERMAL_OF
- struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int id, void *data,
-                                                         const struct thermal_zone_device_ops *ops);
-+struct thermal_zone_device *devm_thermal_of_zone_register_with_params(struct device *dev, int id,
-+                                                                    void *data,
-+                                                                    const struct thermal_zone_device_ops *ops,
-+                                                                    struct thermal_zone_params *tzp);
- void devm_thermal_of_zone_unregister(struct device *dev, struct thermal_zone_device *tz);
-@@ -274,6 +278,15 @@ struct thermal_zone_device *devm_thermal
- {
-       return ERR_PTR(-ENOTSUPP);
- }
-+
-+static inline
-+struct thermal_zone_device *devm_thermal_of_zone_register_with_params(struct device *dev, int id,
-+                                                                    void *data,
-+                                                                    const struct thermal_zone_device_ops *ops,
-+                                                                    struct thermal_zone_params *tzp)
-+{
-+      return ERR_PTR(-ENOTSUPP);
-+}
- static inline void devm_thermal_of_zone_unregister(struct device *dev,
-                                                  struct thermal_zone_device *tz)