Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions Documentation/devicetree/bindings/thermal/spacemit,k1-tsensor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/thermal/spacemit,k1-tsensor.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: SpacemiT K1 Thermal Sensor

description:
The SpacemiT K1 Thermal Sensor monitors the temperature of the SoC
using multiple internal sensors (e.g., soc, package, gpu, clusters).

maintainers:
- Shuwei Wu <shuwei.wu@mailbox.org>

$ref: thermal-sensor.yaml#

properties:
compatible:
const: spacemit,k1-tsensor

reg:
maxItems: 1

clocks:
items:
- description: Core clock for thermal sensor
- description: Bus clock for thermal sensor

clock-names:
items:
- const: core
- const: bus

interrupts:
maxItems: 1

resets:
items:
- description: Reset for the thermal sensor

"#thermal-sensor-cells":
const: 1
description:
The first cell indicates the sensor ID.
0 = soc
1 = package
2 = gpu
3 = cluster0
4 = cluster1

required:
- compatible
- reg
- clocks
- clock-names
- interrupts
- resets
- "#thermal-sensor-cells"

additionalProperties: false

examples:
- |
#include <dt-bindings/clock/spacemit,k1-syscon.h>

thermal@d4018000 {
compatible = "spacemit,k1-tsensor";
reg = <0xd4018000 0x100>;
clocks = <&syscon_apbc CLK_TSEN>,
<&syscon_apbc CLK_TSEN_BUS>;
clock-names = "core", "bus";
interrupts = <61>;
resets = <&syscon_apbc RESET_TSEN>;
#thermal-sensor-cells = <1>;
};
101 changes: 101 additions & 0 deletions arch/riscv/boot/dts/spacemit/k1.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,96 @@
};
};

thermal-zones {
soc-thermal {
polling-delay-passive = <0>;
polling-delay = <0>;
thermal-sensors = <&thermal 0>;

trips {
soc-crit {
temperature = <115000>;
hysteresis = <0>;
type = "critical";
};
};
};

package-thermal {
polling-delay-passive = <0>;
polling-delay = <0>;
thermal-sensors = <&thermal 1>;

trips {
package-crit {
temperature = <115000>;
hysteresis = <0>;
type = "critical";
};
};
};

gpu-thermal {
polling-delay-passive = <100>;
polling-delay = <0>;
thermal-sensors = <&thermal 2>;

trips {
gpu-alert {
temperature = <85000>;
hysteresis = <2000>;
type = "passive";
};

gpu-crit {
temperature = <115000>;
hysteresis = <0>;
type = "critical";
};
};
};

cluster0-thermal {
polling-delay-passive = <100>;
polling-delay = <0>;
thermal-sensors = <&thermal 3>;

trips {
cluster0-alert {
temperature = <85000>;
hysteresis = <2000>;
type = "passive";
};

cluster0-crit {
temperature = <115000>;
hysteresis = <0>;
type = "critical";
};
};
};

cluster1-thermal {
polling-delay-passive = <100>;
polling-delay = <0>;
thermal-sensors = <&thermal 4>;

trips {
cluster1-alert {
temperature = <85000>;
hysteresis = <2000>;
type = "passive";
};

cluster1-crit {
temperature = <115000>;
hysteresis = <0>;
type = "critical";
};
};
};
};

soc {
compatible = "simple-bus";
interrupt-parent = <&plic>;
Expand Down Expand Up @@ -494,6 +584,17 @@
#reset-cells = <1>;
};

thermal: thermal@d4018000 {
compatible = "spacemit,k1-tsensor";
reg = <0x0 0xd4018000 0x0 0x100>;
clocks = <&syscon_apbc CLK_TSEN>,
<&syscon_apbc CLK_TSEN_BUS>;
clock-names = "core", "bus";
interrupts = <61>;
resets = <&syscon_apbc RESET_TSEN>;
#thermal-sensor-cells = <1>;
};

i2c6: i2c@d4018800 {
compatible = "spacemit,k1-i2c";
reg = <0x0 0xd4018800 0x0 0x38>;
Expand Down
2 changes: 2 additions & 0 deletions drivers/thermal/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ endmenu

source "drivers/thermal/renesas/Kconfig"

source "drivers/thermal/spacemit/Kconfig"

source "drivers/thermal/tegra/Kconfig"

config GENERIC_ADC_THERMAL
Expand Down
1 change: 1 addition & 0 deletions drivers/thermal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ obj-y += mediatek/
obj-$(CONFIG_GENERIC_ADC_THERMAL) += thermal-generic-adc.o
obj-$(CONFIG_UNIPHIER_THERMAL) += uniphier_thermal.o
obj-$(CONFIG_AMLOGIC_THERMAL) += amlogic_thermal.o
obj-y += spacemit/
obj-$(CONFIG_SPRD_THERMAL) += sprd_thermal.o
obj-$(CONFIG_KHADAS_MCU_FAN_THERMAL) += khadas_mcu_fan.o
obj-$(CONFIG_LOONGSON2_THERMAL) += loongson2_thermal.o
Expand Down
19 changes: 19 additions & 0 deletions drivers/thermal/spacemit/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-License-Identifier: GPL-2.0-only
menu "SpacemiT thermal drivers"
depends on ARCH_SPACEMIT || COMPILE_TEST

config SPACEMIT_K1_TSENSOR
tristate "SpacemiT K1 thermal sensor driver"
depends on THERMAL_OF
help
This driver provides support for the thermal sensor
integrated in the SpacemiT K1 SoC.

The thermal sensor monitors temperatures for five thermal zones:
soc, package, gpu, cluster0, and cluster1. It supports reporting
temperature values and handling high/low threshold interrupts.

Say Y here if you want to enable thermal monitoring on SpacemiT K1.
If compiled as a module, it will be called k1_tsensor.

endmenu
3 changes: 3 additions & 0 deletions drivers/thermal/spacemit/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0-only

obj-$(CONFIG_SPACEMIT_K1_TSENSOR) += k1_tsensor.o
Loading
Loading