Skip to contentSkip to conversation

dt-bindings: thermal: Add support for Airoha EN7581 thermal sensor

PATCH Superseded Christian Marangi 2 participants 4 messages Oct 17, 2024 – Oct 18, 2024

Subsystems (2)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 dt-bindings: thermal: Add support for Airoha EN7581 thermal sensor

Add support for Airoha EN7581 thermal sensor and monitor. This is a simple sensor for the CPU or SoC Package that provide thermal sensor and trip point for hot low and critical condition to fire interrupt and react on the abnormal state.

---
Changes v2:
- Add Reviewed-by tag

 .../thermal/airoha,en7581-thermal.yaml        | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/airoha,en7581-thermal.yaml
Documentation/devicetree/bindings/thermal/airoha,en7581-thermal.yaml new file +48 -0
new file mode 100644
index 000000000000..ca0242ef0378
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/thermal/airoha,en7581-thermal.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Airoha EN7581 Thermal Sensor and Monitor
+
+maintainers:
+  - Christian Marangi <[email protected]>
+
+properties:
+  compatible:
+    const: airoha,en7581-thermal
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  airoha,chip-scu:
+    description: phandle to the chip SCU syscon
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  '#thermal-sensor-cells':
+    const: 0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - airoha,chip-scu
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    thermal-sensor@1efbd800 {
+        compatible = "airoha,en7581-thermal";
+        reg = <0x1efbd000 0xd5c>;
+        interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
+        airoha,chip-scu = <&chip_scu>;
+
+        #thermal-sensor-cells = <0>;
+    };
Signature · 1 line
2.45.2
#1 lore raw

PATCH v2 2/2 thermal: 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 and critical condition. An interrupt is fired to react on this and doesn't require passive poll to read the temperature.

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.

---
Changes v2:
- Add missing Makefile and Kconfig entry (somehow not included in v1)
- Sort include header
- Add missing bitfield.h

 drivers/thermal/Kconfig          |   9 +
 drivers/thermal/Makefile         |   1 +
 drivers/thermal/airoha_thermal.c | 493 +++++++++++++++++++++++++++++++
 3 files changed, 503 insertions(+)
 create mode 100644 drivers/thermal/airoha_thermal.c
drivers/thermal/Kconfig +9 -0
index 204ed89a3ec9..766ef6ae9a9e 100644
@@ -309,6 +309,15 @@ config QORIQ_THERMAL
 	  cpufreq is used as the cooling device to throttle CPUs when the
 	  passive trip is crossed.
 
+config AIROHA_THERMAL
+	tristate "Airoha thermal sensor driver"
+	depends on ARCH_AIROHA || COMPILE_TEST
+	depends on MFD_SYSCON
+	depends on OF
+	help
+	  Enable this to plug the Airoha thermal sensor driver into the Linux
+	  thermal framework.
+
 config SPEAR_THERMAL
 	tristate "SPEAr thermal sensor driver"
 	depends on PLAT_SPEAR || COMPILE_TEST
drivers/thermal/Makefile +1 -0
index 5cdf7d68687f..9b7431a371a9 100644
@@ -35,6 +35,7 @@ obj-$(CONFIG_K3_THERMAL)	+= k3_bandgap.o k3_j72xx_bandgap.o
 # platform thermal drivers
 obj-y				+= broadcom/
 obj-$(CONFIG_THERMAL_MMIO)		+= thermal_mmio.o
+obj-$(CONFIG_AIROHA_THERMAL)	+= airoha_thermal.o
 obj-$(CONFIG_SPEAR_THERMAL)	+= spear_thermal.o
 obj-$(CONFIG_SUN8I_THERMAL)     += sun8i_thermal.o
 obj-$(CONFIG_ROCKCHIP_THERMAL)	+= rockchip_thermal.o
drivers/thermal/airoha_thermal.c new file +493 -0

493 lines not on this page · raw message

Signature · 1 line
2.45.2
#2 lore raw

Re: [PATCH v2 2/2] thermal: Add support for Airoha EN7581 thermal sensor

kernel test robot noticed the following build errors:

Hi Christian,

kernel test robot noticed the following build errors:

[auto build test ERROR on rafael-pm/thermal]
[also build test ERROR on linus/master v6.12-rc3 next-20241017] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/thermal-Add-support-for-Airoha-EN7581-thermal-sensor/20241017-224102
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal
patch link:    https://lore.kernel.org/r/20241017143830.1656-2-ansuelsmth%40gmail.com
patch subject: [PATCH v2 2/2] thermal: Add support for Airoha EN7581 thermal sensor
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20241018/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241018/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/thermal/airoha_thermal.c: In function 'airoha_thermal_get_temp':

>> drivers/thermal/airoha_thermal.c:239:46: error: invalid use of undefined type 'struct thermal_zone_device'
     239 |         struct airoha_thermal_priv *priv = tz->devdata;
         |                                              ^~
   drivers/thermal/airoha_thermal.c: In function 'airoha_thermal_set_trips':
   drivers/thermal/airoha_thermal.c:268:46: error: invalid use of undefined type 'struct thermal_zone_device'
     268 |         struct airoha_thermal_priv *priv = tz->devdata;
         |                                              ^~
   drivers/thermal/airoha_thermal.c: In function 'airoha_thermal_probe':
   drivers/thermal/airoha_thermal.c:466:17: error: invalid use of undefined type 'struct thermal_zone_device'
     466 |         priv->tz->tzp->offset = priv->default_offset;
         |                 ^~
   drivers/thermal/airoha_thermal.c:467:17: error: invalid use of undefined type 'struct thermal_zone_device'
     467 |         priv->tz->tzp->slope = priv->default_slope;
         |                 ^~

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for GET_FREE_REGION Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

vim +239 drivers/thermal/airoha_thermal.c

236
237 static int airoha_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
238 {

 > 239		struct airoha_thermal_priv *priv = tz->devdata;

240 int min, max, avg_temp, temp_adc;
241 int i;
242
243 /* Get the starting temp */
244 temp_adc = airoha_get_thermal_ADC(priv);
245 min = temp_adc;
246 max = temp_adc;
247 avg_temp = temp_adc;
248
249 /* Make 5 more measurement and average the temp ADC difference */
250 for (i = 0; i < 5; i++) {
251 temp_adc = airoha_get_thermal_ADC(priv);
252 avg_temp += temp_adc;
253 if (temp_adc > max)
254 max = temp_adc;
255 if (temp_adc < min)
256 min = temp_adc;
257 }
258 avg_temp = avg_temp - max - min;
259 avg_temp /= 4;
260
261 *temp = RAW_TO_TEMP(priv, avg_temp);
262 return 0;
263 }
264

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#3 lore raw

Re: [PATCH v2 2/2] thermal: Add support for Airoha EN7581 thermal sensor

In reply to Christian Marangi
kernel test robot noticed the following build errors:

Hi Christian,

kernel test robot noticed the following build errors:

[auto build test ERROR on rafael-pm/thermal]
[also build test ERROR on linus/master v6.12-rc3 next-20241018] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/thermal-Add-support-for-Airoha-EN7581-thermal-sensor/20241017-224102
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal
patch link:    https://lore.kernel.org/r/20241017143830.1656-2-ansuelsmth%40gmail.com
patch subject: [PATCH v2 2/2] thermal: Add support for Airoha EN7581 thermal sensor
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20241018/[email protected]/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241018/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/thermal/airoha_thermal.c:239:39: error: incomplete definition of type 'struct thermal_zone_device'
     239 |         struct airoha_thermal_priv *priv = tz->devdata;
         |                                            ~~^
   include/linux/thermal.h:32:8: note: forward declaration of 'struct thermal_zone_device'
      32 | struct thermal_zone_device;
         |        ^
   drivers/thermal/airoha_thermal.c:268:39: error: incomplete definition of type 'struct thermal_zone_device'
     268 |         struct airoha_thermal_priv *priv = tz->devdata;
         |                                            ~~^
   include/linux/thermal.h:32:8: note: forward declaration of 'struct thermal_zone_device'
      32 | struct thermal_zone_device;
         |        ^
   drivers/thermal/airoha_thermal.c:466:10: error: incomplete definition of type 'struct thermal_zone_device'
     466 |         priv->tz->tzp->offset = priv->default_offset;
         |         ~~~~~~~~^
   include/linux/thermal.h:32:8: note: forward declaration of 'struct thermal_zone_device'
      32 | struct thermal_zone_device;
         |        ^
   drivers/thermal/airoha_thermal.c:467:10: error: incomplete definition of type 'struct thermal_zone_device'
     467 |         priv->tz->tzp->slope = priv->default_slope;
         |         ~~~~~~~~^
   include/linux/thermal.h:32:8: note: forward declaration of 'struct thermal_zone_device'
      32 | struct thermal_zone_device;
         |        ^

4 errors generated.

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for MODVERSIONS
Depends on [n]: MODULES [=y] && !COMPILE_TEST [=y]
Selected by [y]:
- RANDSTRUCT_FULL [=y] && (CC_HAS_RANDSTRUCT [=y] || GCC_PLUGINS [=n]) && MODULES [=y]

vim +239 drivers/thermal/airoha_thermal.c

236
237 static int airoha_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
238 {

 > 239		struct airoha_thermal_priv *priv = tz->devdata;

240 int min, max, avg_temp, temp_adc;
241 int i;
242
243 /* Get the starting temp */
244 temp_adc = airoha_get_thermal_ADC(priv);
245 min = temp_adc;
246 max = temp_adc;
247 avg_temp = temp_adc;
248
249 /* Make 5 more measurement and average the temp ADC difference */
250 for (i = 0; i < 5; i++) {
251 temp_adc = airoha_get_thermal_ADC(priv);
252 avg_temp += temp_adc;
253 if (temp_adc > max)
254 max = temp_adc;
255 if (temp_adc < min)
256 min = temp_adc;
257 }
258 avg_temp = avg_temp - max - min;
259 avg_temp /= 4;
260
261 *temp = RAW_TO_TEMP(priv, avg_temp);
262 return 0;
263 }
264

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki