Skip to content

Commit

Permalink
Merge branches 'thermal-core', 'thermal-soc', 'thermal-intel' and 'id…
Browse files Browse the repository at this point in the history
…a-conversion' into next
  • Loading branch information
zhang-rui committed Feb 22, 2017
4 parents d9cc34a + ee73bcd + da8c1c4 + 2f96c03 commit 6fefe19
Show file tree
Hide file tree
Showing 22 changed files with 864 additions and 254 deletions.
7 changes: 7 additions & 0 deletions Documentation/devicetree/bindings/thermal/qoriq-thermal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Required properties:
calibration data, as specified by the SoC reference manual.
The first cell of each pair is the value to be written to TTCFGR,
and the second is the value to be written to TSCFGR.
- #thermal-sensor-cells : Must be 1. The sensor specifier is the monitoring
site ID, and represents the "n" in TRITSRn and TRATSRn.

Optional property:
- little-endian : If present, the TMU registers are little endian. If absent,
the default is big endian.

Example:

Expand Down Expand Up @@ -60,4 +66,5 @@ tmu@f0000 {

0x00030000 0x00000012
0x00030001 0x0000001d>;
#thermal-sensor-cells = <1>;
};
56 changes: 56 additions & 0 deletions Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
* DT bindings for Renesas R-Car Gen3 Thermal Sensor driver

On R-Car Gen3 SoCs, the thermal sensor controllers (TSC) control the thermal
sensors (THS) which are the analog circuits for measuring temperature (Tj)
inside the LSI.

Required properties:
- compatible : "renesas,<soctype>-thermal",
Examples with soctypes are:
- "renesas,r8a7795-thermal" (R-Car H3)
- "renesas,r8a7796-thermal" (R-Car M3-W)
- reg : Address ranges of the thermal registers. Each sensor
needs one address range. Sorting must be done in
increasing order according to datasheet, i.e.
TSC1, TSC2, ...
- clocks : Must contain a reference to the functional clock.
- #thermal-sensor-cells : must be <1>.

Optional properties:

- interrupts : interrupts routed to the TSC (3 for H3 and M3-W)
- power-domain : Must contain a reference to the power domain. This
property is mandatory if the thermal sensor instance
is part of a controllable power domain.

Example:

tsc: thermal@e6198000 {
compatible = "renesas,r8a7795-thermal";
reg = <0 0xe6198000 0 0x68>,
<0 0xe61a0000 0 0x5c>,
<0 0xe61a8000 0 0x5c>;
interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&cpg CPG_MOD 522>;
power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
#thermal-sensor-cells = <1>;
status = "okay";
};

thermal-zones {
sensor_thermal1: sensor-thermal1 {
polling-delay-passive = <250>;
polling-delay = <1000>;
thermal-sensors = <&tsc 0>;

trips {
sensor1_crit: sensor1-crit {
temperature = <90000>;
hysteresis = <2000>;
type = "critical";
};
};
};
};
116 changes: 116 additions & 0 deletions Documentation/devicetree/bindings/thermal/zx2967-thermal.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
* ZTE zx2967 family Thermal

Required Properties:
- compatible: should be one of the following.
* zte,zx296718-thermal
- reg: physical base address of the controller and length of memory mapped
region.
- clocks : Pairs of phandle and specifier referencing the controller's clocks.
- clock-names: "topcrm" for the topcrm clock.
"apb" for the apb clock.
- #thermal-sensor-cells: must be 0.

Please note: slope coefficient defined in thermal-zones section need to be
multiplied by 1000.

Example for tempsensor:

tempsensor: tempsensor@148a000 {
compatible = "zte,zx296718-thermal";
reg = <0x0148a000 0x20>;
clocks = <&topcrm TEMPSENSOR_GATE>, <&audiocrm AUDIO_TS_PCLK>;
clock-names = "topcrm", "apb";
#thermal-sensor-cells = <0>;
};

Example for cooling device:

cooling_dev: cooling_dev {
cluster0_cooling_dev: cluster0-cooling-dev {
#cooling-cells = <2>;
cpumask = <0xf>;
capacitance = <1500>;
};

cluster1_cooling_dev: cluster1-cooling-dev {
#cooling-cells = <2>;
cpumask = <0x30>;
capacitance = <2000>;
};
};

Example for thermal zones:

thermal-zones {
zx296718_thermal: zx296718_thermal {
polling-delay-passive = <500>;
polling-delay = <1000>;
sustainable-power = <6500>;

thermal-sensors = <&tempsensor 0>;
/*
* slope need to be multiplied by 1000.
*/
coefficients = <1951 (-922)>;

trips {
trip0: switch_on_temperature {
temperature = <90000>;
hysteresis = <2000>;
type = "passive";
};

trip1: desired_temperature {
temperature = <100000>;
hysteresis = <2000>;
type = "passive";
};

crit: critical_temperature {
temperature = <110000>;
hysteresis = <2000>;
type = "critical";
};
};

cooling-maps {
map0 {
trip = <&trip0>;
cooling-device = <&gpu 2 5>;
};

map1 {
trip = <&trip0>;
cooling-device = <&cluster0_cooling_dev 1 2>;
};

map2 {
trip = <&trip1>;
cooling-device = <&cluster0_cooling_dev 1 2>;
};

map3 {
trip = <&crit>;
cooling-device = <&cluster0_cooling_dev 1 2>;
};

map4 {
trip = <&trip0>;
cooling-device = <&cluster1_cooling_dev 1 2>;
contribution = <9000>;
};

map5 {
trip = <&trip1>;
cooling-device = <&cluster1_cooling_dev 1 2>;
contribution = <4096>;
};

map6 {
trip = <&crit>;
cooling-device = <&cluster1_cooling_dev 1 2>;
contribution = <4096>;
};
};
};
};
4 changes: 2 additions & 2 deletions arch/powerpc/boot/dts/fsl/t1023si-post.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,15 @@
0x00030001 0x0000000d
0x00030002 0x00000019
0x00030003 0x00000024>;
#thermal-sensor-cells = <0>;
#thermal-sensor-cells = <1>;
};

thermal-zones {
cpu_thermal: cpu-thermal {
polling-delay-passive = <1000>;
polling-delay = <5000>;

thermal-sensors = <&tmu>;
thermal-sensors = <&tmu 0>;

trips {
cpu_alert: cpu-alert {
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/boot/dts/fsl/t1040si-post.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -526,15 +526,15 @@

0x00030000 0x00000012
0x00030001 0x0000001d>;
#thermal-sensor-cells = <0>;
#thermal-sensor-cells = <1>;
};

thermal-zones {
cpu_thermal: cpu-thermal {
polling-delay-passive = <1000>;
polling-delay = <5000>;

thermal-sensors = <&tmu>;
thermal-sensors = <&tmu 2>;

trips {
cpu_alert: cpu-alert {
Expand Down
17 changes: 17 additions & 0 deletions drivers/thermal/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,15 @@ config RCAR_THERMAL
Enable this to plug the R-Car thermal sensor driver into the Linux
thermal framework.

config RCAR_GEN3_THERMAL
tristate "Renesas R-Car Gen3 thermal driver"
depends on ARCH_RENESAS || COMPILE_TEST
depends on HAS_IOMEM
depends on OF
help
Enable this to plug the R-Car Gen3 thermal sensor driver into the Linux
thermal framework.

config KIRKWOOD_THERMAL
tristate "Temperature sensor on Marvell Kirkwood SoCs"
depends on MACH_KIRKWOOD || COMPILE_TEST
Expand Down Expand Up @@ -436,4 +445,12 @@ depends on (ARCH_QCOM && OF) || COMPILE_TEST
source "drivers/thermal/qcom/Kconfig"
endmenu

config ZX2967_THERMAL
tristate "Thermal sensors on zx2967 SoC"
depends on ARCH_ZX || COMPILE_TEST
help
Enable the zx2967 thermal sensors driver, which supports
the primitive temperature sensor embedded in zx2967 SoCs.
This sensor generates the real time die temperature.

endif
2 changes: 2 additions & 0 deletions drivers/thermal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ obj-$(CONFIG_QCOM_SPMI_TEMP_ALARM) += qcom-spmi-temp-alarm.o
obj-$(CONFIG_SPEAR_THERMAL) += spear_thermal.o
obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o
obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o
obj-$(CONFIG_RCAR_GEN3_THERMAL) += rcar_gen3_thermal.o
obj-$(CONFIG_KIRKWOOD_THERMAL) += kirkwood_thermal.o
obj-y += samsung/
obj-$(CONFIG_DOVE_THERMAL) += dove_thermal.o
Expand All @@ -56,3 +57,4 @@ obj-$(CONFIG_TEGRA_SOCTHERM) += tegra/
obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o
obj-$(CONFIG_MTK_THERMAL) += mtk_thermal.o
obj-$(CONFIG_GENERIC_ADC_THERMAL) += thermal-generic-adc.o
obj-$(CONFIG_ZX2967_THERMAL) += zx2967_thermal.o
50 changes: 8 additions & 42 deletions drivers/thermal/clock_cooling.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,42 +65,7 @@ struct clock_cooling_device {
};
#define to_clock_cooling_device(x) \
container_of(x, struct clock_cooling_device, clk_rate_change_nb)
static DEFINE_IDR(clock_idr);
static DEFINE_MUTEX(cooling_clock_lock);

/**
* clock_cooling_get_idr - function to get an unique id.
* @id: int * value generated by this function.
*
* This function will populate @id with an unique
* id, using the idr API.
*
* Return: 0 on success, an error code on failure.
*/
static int clock_cooling_get_idr(int *id)
{
int ret;

mutex_lock(&cooling_clock_lock);
ret = idr_alloc(&clock_idr, NULL, 0, 0, GFP_KERNEL);
mutex_unlock(&cooling_clock_lock);
if (unlikely(ret < 0))
return ret;
*id = ret;

return 0;
}

/**
* release_idr - function to free the unique id.
* @id: int value representing the unique id.
*/
static void release_idr(int id)
{
mutex_lock(&cooling_clock_lock);
idr_remove(&clock_idr, id);
mutex_unlock(&cooling_clock_lock);
}
static DEFINE_IDA(clock_ida);

/* Below code defines functions to be used for clock as cooling device */

Expand Down Expand Up @@ -432,16 +397,17 @@ clock_cooling_register(struct device *dev, const char *clock_name)
if (IS_ERR(ccdev->clk))
return ERR_CAST(ccdev->clk);

ret = clock_cooling_get_idr(&ccdev->id);
if (ret)
return ERR_PTR(-EINVAL);
ret = ida_simple_get(&clock_ida, 0, 0, GFP_KERNEL);
if (ret < 0)
return ERR_PTR(ret);
ccdev->id = ret;

snprintf(dev_name, sizeof(dev_name), "thermal-clock-%d", ccdev->id);

cdev = thermal_cooling_device_register(dev_name, ccdev,
&clock_cooling_ops);
if (IS_ERR(cdev)) {
release_idr(ccdev->id);
ida_simple_remove(&clock_ida, ccdev->id);
return ERR_PTR(-EINVAL);
}
ccdev->cdev = cdev;
Expand All @@ -450,7 +416,7 @@ clock_cooling_register(struct device *dev, const char *clock_name)
/* Assuming someone has already filled the opp table for this device */
ret = dev_pm_opp_init_cpufreq_table(dev, &ccdev->freq_table);
if (ret) {
release_idr(ccdev->id);
ida_simple_remove(&clock_ida, ccdev->id);
return ERR_PTR(ret);
}
ccdev->clock_state = 0;
Expand Down Expand Up @@ -481,6 +447,6 @@ void clock_cooling_unregister(struct thermal_cooling_device *cdev)
dev_pm_opp_free_cpufreq_table(ccdev->dev, &ccdev->freq_table);

thermal_cooling_device_unregister(ccdev->cdev);
release_idr(ccdev->id);
ida_simple_remove(&clock_ida, ccdev->id);
}
EXPORT_SYMBOL_GPL(clock_cooling_unregister);
Loading

0 comments on commit 6fefe19

Please sign in to comment.