2017-03-09 08:25:21

by Keerthy

[permalink] [raw]
Subject: [PATCH v2 0/8] thermal: ti-soc-thermal: Migrate slope/offset data to device tree

Currently the slope and offset values for calculating the
hot spot temperature of a particular thermal zone is part
of driver data. Pass them here instead and obtain the values
while of node parsing.

Tested for the slope and constant values on DRA7-EVM, OMAP3-BEAGLE.

Changes in v2:

* Added OMAP3 changes along with DRA7/OMAP4/OMAP5.

Keerthy (8):
arm: dts: omap3: Add cpu_thermal zone
ARM: DRA7: Thermal: Add slope and offset values
ARM: OMAP5: Thermal: Add slope and offset values
ARM: OMAP443x: Thermal: Add slope and offset values
ARM: OMAP4460: Thermal: Add slope and offset values
thermal: ti-soc-thermal: Fetch slope and offset from DT
thermal: ti-soc-thermal: Remove redundant constants
thermal: ti-soc-thermal: Remove redundant code

arch/arm/boot/dts/dra7.dtsi | 17 +++
arch/arm/boot/dts/omap3-cpu-thermal.dtsi | 20 +++
arch/arm/boot/dts/omap34xx.dtsi | 8 +-
arch/arm/boot/dts/omap36xx.dtsi | 8 +-
arch/arm/boot/dts/omap443x.dtsi | 4 +
arch/arm/boot/dts/omap4460.dtsi | 4 +
arch/arm/boot/dts/omap5.dtsi | 9 ++
.../thermal/ti-soc-thermal/dra752-thermal-data.c | 10 --
.../thermal/ti-soc-thermal/omap3-thermal-data.c | 4 -
.../thermal/ti-soc-thermal/omap4-thermal-data.c | 6 -
.../thermal/ti-soc-thermal/omap5-thermal-data.c | 4 -
drivers/thermal/ti-soc-thermal/ti-bandgap.h | 4 -
drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 158 +--------------------
drivers/thermal/ti-soc-thermal/ti-thermal.h | 16 ---
14 files changed, 71 insertions(+), 201 deletions(-)
create mode 100644 arch/arm/boot/dts/omap3-cpu-thermal.dtsi

--
1.9.1


2017-03-09 08:08:34

by Keerthy

[permalink] [raw]
Subject: [PATCH v2 7/8] thermal: ti-soc-thermal: Remove redundant constants

Now that slope and offset data are being passed from
device tree no need to populate in driver data.

Signed-off-by: Keerthy <[email protected]>
---
drivers/thermal/ti-soc-thermal/dra752-thermal-data.c | 10 ----------
drivers/thermal/ti-soc-thermal/omap3-thermal-data.c | 4 ----
drivers/thermal/ti-soc-thermal/omap4-thermal-data.c | 6 ------
drivers/thermal/ti-soc-thermal/omap5-thermal-data.c | 4 ----
drivers/thermal/ti-soc-thermal/ti-bandgap.h | 4 ----
drivers/thermal/ti-soc-thermal/ti-thermal.h | 16 ----------------
6 files changed, 44 deletions(-)

diff --git a/drivers/thermal/ti-soc-thermal/dra752-thermal-data.c b/drivers/thermal/ti-soc-thermal/dra752-thermal-data.c
index 118d7d8..4167373 100644
--- a/drivers/thermal/ti-soc-thermal/dra752-thermal-data.c
+++ b/drivers/thermal/ti-soc-thermal/dra752-thermal-data.c
@@ -410,8 +410,6 @@
.domain = "cpu",
.register_cooling = ti_thermal_register_cpu_cooling,
.unregister_cooling = ti_thermal_unregister_cpu_cooling,
- .slope = DRA752_GRADIENT_SLOPE,
- .constant = DRA752_GRADIENT_CONST,
.slope_pcb = DRA752_GRADIENT_SLOPE_W_PCB,
.constant_pcb = DRA752_GRADIENT_CONST_W_PCB,
},
@@ -419,8 +417,6 @@
.registers = &dra752_gpu_temp_sensor_registers,
.ts_data = &dra752_gpu_temp_sensor_data,
.domain = "gpu",
- .slope = DRA752_GRADIENT_SLOPE,
- .constant = DRA752_GRADIENT_CONST,
.slope_pcb = DRA752_GRADIENT_SLOPE_W_PCB,
.constant_pcb = DRA752_GRADIENT_CONST_W_PCB,
},
@@ -428,8 +424,6 @@
.registers = &dra752_core_temp_sensor_registers,
.ts_data = &dra752_core_temp_sensor_data,
.domain = "core",
- .slope = DRA752_GRADIENT_SLOPE,
- .constant = DRA752_GRADIENT_CONST,
.slope_pcb = DRA752_GRADIENT_SLOPE_W_PCB,
.constant_pcb = DRA752_GRADIENT_CONST_W_PCB,
},
@@ -437,8 +431,6 @@
.registers = &dra752_dspeve_temp_sensor_registers,
.ts_data = &dra752_dspeve_temp_sensor_data,
.domain = "dspeve",
- .slope = DRA752_GRADIENT_SLOPE,
- .constant = DRA752_GRADIENT_CONST,
.slope_pcb = DRA752_GRADIENT_SLOPE_W_PCB,
.constant_pcb = DRA752_GRADIENT_CONST_W_PCB,
},
@@ -446,8 +438,6 @@
.registers = &dra752_iva_temp_sensor_registers,
.ts_data = &dra752_iva_temp_sensor_data,
.domain = "iva",
- .slope = DRA752_GRADIENT_SLOPE,
- .constant = DRA752_GRADIENT_CONST,
.slope_pcb = DRA752_GRADIENT_SLOPE_W_PCB,
.constant_pcb = DRA752_GRADIENT_CONST_W_PCB,
},
diff --git a/drivers/thermal/ti-soc-thermal/omap3-thermal-data.c b/drivers/thermal/ti-soc-thermal/omap3-thermal-data.c
index 3ee3434..c6d2179 100644
--- a/drivers/thermal/ti-soc-thermal/omap3-thermal-data.c
+++ b/drivers/thermal/ti-soc-thermal/omap3-thermal-data.c
@@ -91,8 +91,6 @@
.registers = &omap34xx_mpu_temp_sensor_registers,
.ts_data = &omap34xx_mpu_temp_sensor_data,
.domain = "cpu",
- .slope = 0,
- .constant = 20000,
.slope_pcb = 0,
.constant_pcb = 20000,
.register_cooling = NULL,
@@ -164,8 +162,6 @@
.registers = &omap36xx_mpu_temp_sensor_registers,
.ts_data = &omap36xx_mpu_temp_sensor_data,
.domain = "cpu",
- .slope = 0,
- .constant = 20000,
.slope_pcb = 0,
.constant_pcb = 20000,
.register_cooling = NULL,
diff --git a/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c b/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c
index d255d33..fd11133 100644
--- a/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c
+++ b/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c
@@ -82,8 +82,6 @@
.registers = &omap4430_mpu_temp_sensor_registers,
.ts_data = &omap4430_mpu_temp_sensor_data,
.domain = "cpu",
- .slope = OMAP_GRADIENT_SLOPE_4430,
- .constant = OMAP_GRADIENT_CONST_4430,
.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_4430,
.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_4430,
.register_cooling = ti_thermal_register_cpu_cooling,
@@ -222,8 +220,6 @@
.registers = &omap4460_mpu_temp_sensor_registers,
.ts_data = &omap4460_mpu_temp_sensor_data,
.domain = "cpu",
- .slope = OMAP_GRADIENT_SLOPE_4460,
- .constant = OMAP_GRADIENT_CONST_4460,
.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_4460,
.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_4460,
.register_cooling = ti_thermal_register_cpu_cooling,
@@ -255,8 +251,6 @@
.registers = &omap4460_mpu_temp_sensor_registers,
.ts_data = &omap4460_mpu_temp_sensor_data,
.domain = "cpu",
- .slope = OMAP_GRADIENT_SLOPE_4470,
- .constant = OMAP_GRADIENT_CONST_4470,
.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_4470,
.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_4470,
.register_cooling = ti_thermal_register_cpu_cooling,
diff --git a/drivers/thermal/ti-soc-thermal/omap5-thermal-data.c b/drivers/thermal/ti-soc-thermal/omap5-thermal-data.c
index 79ff70c..cd9a304 100644
--- a/drivers/thermal/ti-soc-thermal/omap5-thermal-data.c
+++ b/drivers/thermal/ti-soc-thermal/omap5-thermal-data.c
@@ -336,8 +336,6 @@
.domain = "cpu",
.register_cooling = ti_thermal_register_cpu_cooling,
.unregister_cooling = ti_thermal_unregister_cpu_cooling,
- .slope = OMAP_GRADIENT_SLOPE_5430_CPU,
- .constant = OMAP_GRADIENT_CONST_5430_CPU,
.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_5430_CPU,
.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_5430_CPU,
},
@@ -345,8 +343,6 @@
.registers = &omap5430_gpu_temp_sensor_registers,
.ts_data = &omap5430_gpu_temp_sensor_data,
.domain = "gpu",
- .slope = OMAP_GRADIENT_SLOPE_5430_GPU,
- .constant = OMAP_GRADIENT_CONST_5430_GPU,
.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_5430_GPU,
.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_5430_GPU,
},
diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.h b/drivers/thermal/ti-soc-thermal/ti-bandgap.h
index fe0adb8..209c664 100644
--- a/drivers/thermal/ti-soc-thermal/ti-bandgap.h
+++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.h
@@ -254,8 +254,6 @@ struct ti_bandgap {
* @ts_data: pointer to struct with thresholds, limits of temperature sensor
* @registers: pointer to the list of register offsets and bitfields
* @domain: the name of the domain where the sensor is located
- * @slope: sensor gradient slope info for hotspot extrapolation equation
- * @constant: sensor gradient const info for hotspot extrapolation equation
* @slope_pcb: sensor gradient slope info for hotspot extrapolation equation
* with no external influence
* @constant_pcb: sensor gradient const info for hotspot extrapolation equation
@@ -274,8 +272,6 @@ struct ti_temp_sensor {
struct temp_sensor_registers *registers;
char *domain;
/* for hotspot extrapolation */
- const int slope;
- const int constant;
const int slope_pcb;
const int constant_pcb;
int (*register_cooling)(struct ti_bandgap *bgp, int id);
diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal.h b/drivers/thermal/ti-soc-thermal/ti-thermal.h
index f8b7ffe..8e85ca9 100644
--- a/drivers/thermal/ti-soc-thermal/ti-thermal.h
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal.h
@@ -25,22 +25,6 @@

#include "ti-bandgap.h"

-/* sensors gradient and offsets */
-#define OMAP_GRADIENT_SLOPE_4430 0
-#define OMAP_GRADIENT_CONST_4430 20000
-#define OMAP_GRADIENT_SLOPE_4460 348
-#define OMAP_GRADIENT_CONST_4460 -9301
-#define OMAP_GRADIENT_SLOPE_4470 308
-#define OMAP_GRADIENT_CONST_4470 -7896
-
-#define OMAP_GRADIENT_SLOPE_5430_CPU 65
-#define OMAP_GRADIENT_CONST_5430_CPU -1791
-#define OMAP_GRADIENT_SLOPE_5430_GPU 117
-#define OMAP_GRADIENT_CONST_5430_GPU -2992
-
-#define DRA752_GRADIENT_SLOPE 0
-#define DRA752_GRADIENT_CONST 2000
-
/* PCB sensor calculation constants */
#define OMAP_GRADIENT_SLOPE_W_PCB_4430 0
#define OMAP_GRADIENT_CONST_W_PCB_4430 20000
--
1.9.1

2017-03-09 08:08:33

by Keerthy

[permalink] [raw]
Subject: [PATCH v2 2/8] ARM: DRA7: Thermal: Add slope and offset values

Currently the slope and offset values for calculating the
hot spot temperature of a particular thermal zone is part
of driver data. Pass them here instead and obtain the values
while of node parsing.

Signed-off-by: Keerthy <[email protected]>
---
arch/arm/boot/dts/dra7.dtsi | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index 2c9e56f..10e09dc 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -1982,6 +1982,23 @@

&cpu_thermal {
polling-delay = <500>; /* milliseconds */
+ coefficients = <0 2000>;
+};
+
+&gpu_thermal {
+ coefficients = <0 2000>;
+};
+
+&core_thermal {
+ coefficients = <0 2000>;
+};
+
+&dspeve_thermal {
+ coefficients = <0 2000>;
+};
+
+&iva_thermal {
+ coefficients = <0 2000>;
};

/include/ "dra7xx-clocks.dtsi"
--
1.9.1

2017-03-09 08:08:51

by Keerthy

[permalink] [raw]
Subject: [PATCH v2 8/8] thermal: ti-soc-thermal: Remove redundant code

ti_thermal_expose_sensor always takes the
devm_thermal_zone_of_sensor_register call for registration
with the device tree nodes present for all the bandgap sensors
for omap3/4/5 and dra7 family. There are large chunks of unused
code. Removing all of them.

Signed-off-by: Keerthy <[email protected]>
---
drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 154 +--------------------
1 file changed, 3 insertions(+), 151 deletions(-)

diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
index 2054a5c..02790f6 100644
--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
@@ -126,119 +126,6 @@ static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
return __ti_thermal_get_temp(data, temp);
}

-/* Bind callback functions for thermal zone */
-static int ti_thermal_bind(struct thermal_zone_device *thermal,
- struct thermal_cooling_device *cdev)
-{
- struct ti_thermal_data *data = thermal->devdata;
- int id;
-
- if (!data || IS_ERR(data))
- return -ENODEV;
-
- /* check if this is the cooling device we registered */
- if (data->cool_dev != cdev)
- return 0;
-
- id = data->sensor_id;
-
- /* Simple thing, two trips, one passive another critical */
- return thermal_zone_bind_cooling_device(thermal, 0, cdev,
- /* bind with min and max states defined by cpu_cooling */
- THERMAL_NO_LIMIT,
- THERMAL_NO_LIMIT,
- THERMAL_WEIGHT_DEFAULT);
-}
-
-/* Unbind callback functions for thermal zone */
-static int ti_thermal_unbind(struct thermal_zone_device *thermal,
- struct thermal_cooling_device *cdev)
-{
- struct ti_thermal_data *data = thermal->devdata;
-
- if (!data || IS_ERR(data))
- return -ENODEV;
-
- /* check if this is the cooling device we registered */
- if (data->cool_dev != cdev)
- return 0;
-
- /* Simple thing, two trips, one passive another critical */
- return thermal_zone_unbind_cooling_device(thermal, 0, cdev);
-}
-
-/* Get mode callback functions for thermal zone */
-static int ti_thermal_get_mode(struct thermal_zone_device *thermal,
- enum thermal_device_mode *mode)
-{
- struct ti_thermal_data *data = thermal->devdata;
-
- if (data)
- *mode = data->mode;
-
- return 0;
-}
-
-/* Set mode callback functions for thermal zone */
-static int ti_thermal_set_mode(struct thermal_zone_device *thermal,
- enum thermal_device_mode mode)
-{
- struct ti_thermal_data *data = thermal->devdata;
- struct ti_bandgap *bgp;
-
- bgp = data->bgp;
-
- if (!data->ti_thermal) {
- dev_notice(&thermal->device, "thermal zone not registered\n");
- return 0;
- }
-
- mutex_lock(&data->ti_thermal->lock);
-
- if (mode == THERMAL_DEVICE_ENABLED)
- data->ti_thermal->polling_delay = FAST_TEMP_MONITORING_RATE;
- else
- data->ti_thermal->polling_delay = 0;
-
- mutex_unlock(&data->ti_thermal->lock);
-
- data->mode = mode;
- ti_bandgap_write_update_interval(bgp, data->sensor_id,
- data->ti_thermal->polling_delay);
- thermal_zone_device_update(data->ti_thermal, THERMAL_EVENT_UNSPECIFIED);
- dev_dbg(&thermal->device, "thermal polling set for duration=%d msec\n",
- data->ti_thermal->polling_delay);
-
- return 0;
-}
-
-/* Get trip type callback functions for thermal zone */
-static int ti_thermal_get_trip_type(struct thermal_zone_device *thermal,
- int trip, enum thermal_trip_type *type)
-{
- if (!ti_thermal_is_valid_trip(trip))
- return -EINVAL;
-
- if (trip + 1 == OMAP_TRIP_NUMBER)
- *type = THERMAL_TRIP_CRITICAL;
- else
- *type = THERMAL_TRIP_PASSIVE;
-
- return 0;
-}
-
-/* Get trip temperature callback functions for thermal zone */
-static int ti_thermal_get_trip_temp(struct thermal_zone_device *thermal,
- int trip, int *temp)
-{
- if (!ti_thermal_is_valid_trip(trip))
- return -EINVAL;
-
- *temp = ti_thermal_get_trip_value(trip);
-
- return 0;
-}
-
static int __ti_thermal_get_trend(void *p, int trip, enum thermal_trend *trend)
{
struct ti_thermal_data *data = p;
@@ -262,38 +149,11 @@ static int __ti_thermal_get_trend(void *p, int trip, enum thermal_trend *trend)
return 0;
}

-/* Get the temperature trend callback functions for thermal zone */
-static int ti_thermal_get_trend(struct thermal_zone_device *thermal,
- int trip, enum thermal_trend *trend)
-{
- return __ti_thermal_get_trend(thermal->devdata, trip, trend);
-}
-
-/* Get critical temperature callback functions for thermal zone */
-static int ti_thermal_get_crit_temp(struct thermal_zone_device *thermal,
- int *temp)
-{
- /* shutdown zone */
- return ti_thermal_get_trip_temp(thermal, OMAP_TRIP_NUMBER - 1, temp);
-}
-
static const struct thermal_zone_of_device_ops ti_of_thermal_ops = {
.get_temp = __ti_thermal_get_temp,
.get_trend = __ti_thermal_get_trend,
};

-static struct thermal_zone_device_ops ti_thermal_ops = {
- .get_temp = ti_thermal_get_temp,
- .get_trend = ti_thermal_get_trend,
- .bind = ti_thermal_bind,
- .unbind = ti_thermal_unbind,
- .get_mode = ti_thermal_get_mode,
- .set_mode = ti_thermal_set_mode,
- .get_trip_type = ti_thermal_get_trip_type,
- .get_trip_temp = ti_thermal_get_trip_temp,
- .get_crit_temp = ti_thermal_get_crit_temp,
-};
-
static struct ti_thermal_data
*ti_thermal_build_data(struct ti_bandgap *bgp, int id)
{
@@ -331,18 +191,10 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,
data->ti_thermal = devm_thermal_zone_of_sensor_register(bgp->dev, id,
data, &ti_of_thermal_ops);
if (IS_ERR(data->ti_thermal)) {
- /* Create thermal zone */
- data->ti_thermal = thermal_zone_device_register(domain,
- OMAP_TRIP_NUMBER, 0, data, &ti_thermal_ops,
- NULL, FAST_TEMP_MONITORING_RATE,
- FAST_TEMP_MONITORING_RATE);
- if (IS_ERR(data->ti_thermal)) {
- dev_err(bgp->dev, "thermal zone device is NULL\n");
- return PTR_ERR(data->ti_thermal);
- }
- data->ti_thermal->polling_delay = FAST_TEMP_MONITORING_RATE;
- data->our_zone = true;
+ dev_err(bgp->dev, "thermal zone device is NULL\n");
+ return PTR_ERR(data->ti_thermal);
}
+
ti_bandgap_set_sensor_data(bgp, id, data);
ti_bandgap_write_update_interval(bgp, data->sensor_id,
data->ti_thermal->polling_delay);
--
1.9.1

2017-03-09 08:08:31

by Keerthy

[permalink] [raw]
Subject: [PATCH v2 3/8] ARM: OMAP5: Thermal: Add slope and offset values

Currently the slope and offset values for calculating the
hot spot temperature of a particular thermal zone is part
of driver data. Pass them here instead and obtain the values
while of node parsing.

Signed-off-by: Keerthy <[email protected]>
---
arch/arm/boot/dts/omap5.dtsi | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 222155c..eaff2a5 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -1127,6 +1127,15 @@

&cpu_thermal {
polling-delay = <500>; /* milliseconds */
+ coefficients = <65 (-1791)>;
};

/include/ "omap54xx-clocks.dtsi"
+
+&gpu_thermal {
+ coefficients = <117 (-2992)>;
+};
+
+&core_thermal {
+ coefficients = <0 2000>;
+};
--
1.9.1

2017-03-09 08:08:28

by Keerthy

[permalink] [raw]
Subject: [PATCH v2 1/8] arm: dts: omap3: Add cpu_thermal zone

Add cpu_thermal zone.

Signed-off-by: Keerthy <[email protected]>
---
arch/arm/boot/dts/omap3-cpu-thermal.dtsi | 20 ++++++++++++++++++++
arch/arm/boot/dts/omap34xx.dtsi | 8 ++++++--
arch/arm/boot/dts/omap36xx.dtsi | 8 ++++++--
3 files changed, 32 insertions(+), 4 deletions(-)
create mode 100644 arch/arm/boot/dts/omap3-cpu-thermal.dtsi

diff --git a/arch/arm/boot/dts/omap3-cpu-thermal.dtsi b/arch/arm/boot/dts/omap3-cpu-thermal.dtsi
new file mode 100644
index 0000000..8dc3aa5
--- /dev/null
+++ b/arch/arm/boot/dts/omap3-cpu-thermal.dtsi
@@ -0,0 +1,20 @@
+/*
+ * Device Tree Source for OMAP3 SoC CPU thermal
+ *
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <dt-bindings/thermal/thermal.h>
+
+cpu_thermal: cpu_thermal {
+ polling-delay-passive = <250>; /* milliseconds */
+ polling-delay = <1000>; /* milliseconds */
+ coefficients = <0 20000>;
+
+ /* sensor ID */
+ thermal-sensors = <&bandgap 0>;
+};
diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi
index 834fdf1..ac4f879 100644
--- a/arch/arm/boot/dts/omap34xx.dtsi
+++ b/arch/arm/boot/dts/omap34xx.dtsi
@@ -14,7 +14,7 @@

/ {
cpus {
- cpu@0 {
+ cpu: cpu@0 {
/* OMAP343x/OMAP35xx variants OPP1-5 */
operating-points = <
/* kHz uV */
@@ -56,12 +56,16 @@
};
};

- bandgap@48002524 {
+ bandgap: bandgap@48002524 {
reg = <0x48002524 0x4>;
compatible = "ti,omap34xx-bandgap";
#thermal-sensor-cells = <0>;
};
};
+
+ thermal_zones: thermal-zones {
+ #include "omap3-cpu-thermal.dtsi"
+ };
};

&ssi {
diff --git a/arch/arm/boot/dts/omap36xx.dtsi b/arch/arm/boot/dts/omap36xx.dtsi
index d1a3e56..ade31d7 100644
--- a/arch/arm/boot/dts/omap36xx.dtsi
+++ b/arch/arm/boot/dts/omap36xx.dtsi
@@ -19,7 +19,7 @@

cpus {
/* OMAP3630/OMAP37xx 'standard device' variants OPP50 to OPP130 */
- cpu@0 {
+ cpu: cpu@0 {
operating-points = <
/* kHz uV */
300000 1012500
@@ -88,12 +88,16 @@
};
};

- bandgap@48002524 {
+ bandgap: bandgap@48002524 {
reg = <0x48002524 0x4>;
compatible = "ti,omap36xx-bandgap";
#thermal-sensor-cells = <0>;
};
};
+
+ thermal_zones: thermal-zones {
+ #include "omap3-cpu-thermal.dtsi"
+ };
};

/* OMAP3630 needs dss_96m_fck for VENC */
--
1.9.1

2017-03-09 08:09:51

by Keerthy

[permalink] [raw]
Subject: [PATCH v2 5/8] ARM: OMAP4460: Thermal: Add slope and offset values

Currently the slope and offset values for calculating the
hot spot temperature of a particular thermal zone is part
of driver data. Pass them here instead and obtain the values
while of node parsing.

Signed-off-by: Keerthy <[email protected]>
---
arch/arm/boot/dts/omap4460.dtsi | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/omap4460.dtsi b/arch/arm/boot/dts/omap4460.dtsi
index ef66e12..c43f2a2 100644
--- a/arch/arm/boot/dts/omap4460.dtsi
+++ b/arch/arm/boot/dts/omap4460.dtsi
@@ -90,4 +90,8 @@

};

+&cpu_thermal {
+ coefficients = <348 (-9301)>;
+};
+
/include/ "omap446x-clocks.dtsi"
--
1.9.1

2017-03-09 08:09:49

by Keerthy

[permalink] [raw]
Subject: [PATCH v2 6/8] thermal: ti-soc-thermal: Fetch slope and offset from DT

Currently slope and offset values for calculating the hot spot
temperature of a thermal zone is being taken directly from driver
data. So fetch them from device tree.

Signed-off-by: Keerthy <[email protected]>
---
drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
index 0586bd0..2054a5c 100644
--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
@@ -96,8 +96,8 @@ static inline int __ti_thermal_get_temp(void *devdata, int *temp)
return ret;

/* Default constants */
- slope = s->slope;
- constant = s->constant;
+ slope = thermal_zone_get_slope(data->ti_thermal);
+ constant = thermal_zone_get_offset(data->ti_thermal);

pcb_tz = data->pcb_tz;
/* In case pcb zone is available, use the extrapolation rule with it */
--
1.9.1

2017-03-09 08:25:57

by Keerthy

[permalink] [raw]
Subject: [PATCH v2 4/8] ARM: OMAP443x: Thermal: Add slope and offset values

Currently the slope and offset values for calculating the
hot spot temperature of a particular thermal zone is part
of driver data. Pass them here instead and obtain the values
while of node parsing.

Signed-off-by: Keerthy <[email protected]>
---
arch/arm/boot/dts/omap443x.dtsi | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/omap443x.dtsi b/arch/arm/boot/dts/omap443x.dtsi
index fc6a861..03c8ad9 100644
--- a/arch/arm/boot/dts/omap443x.dtsi
+++ b/arch/arm/boot/dts/omap443x.dtsi
@@ -71,4 +71,8 @@

};

+&cpu_thermal {
+ coefficients = <0 20000>;
+};
+
/include/ "omap443x-clocks.dtsi"
--
1.9.1

2017-03-22 03:43:52

by Keerthy

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] thermal: ti-soc-thermal: Migrate slope/offset data to device tree



On Thursday 09 March 2017 01:35 PM, Keerthy wrote:
> Currently the slope and offset values for calculating the
> hot spot temperature of a particular thermal zone is part
> of driver data. Pass them here instead and obtain the values
> while of node parsing.
>
> Tested for the slope and constant values on DRA7-EVM, OMAP3-BEAGLE.

Hi Eduardo,

If the series looks okay could you please pull this?

Regards,
Keerthy

>
> Changes in v2:
>
> * Added OMAP3 changes along with DRA7/OMAP4/OMAP5.
>
> Keerthy (8):
> arm: dts: omap3: Add cpu_thermal zone
> ARM: DRA7: Thermal: Add slope and offset values
> ARM: OMAP5: Thermal: Add slope and offset values
> ARM: OMAP443x: Thermal: Add slope and offset values
> ARM: OMAP4460: Thermal: Add slope and offset values
> thermal: ti-soc-thermal: Fetch slope and offset from DT
> thermal: ti-soc-thermal: Remove redundant constants
> thermal: ti-soc-thermal: Remove redundant code
>
> arch/arm/boot/dts/dra7.dtsi | 17 +++
> arch/arm/boot/dts/omap3-cpu-thermal.dtsi | 20 +++
> arch/arm/boot/dts/omap34xx.dtsi | 8 +-
> arch/arm/boot/dts/omap36xx.dtsi | 8 +-
> arch/arm/boot/dts/omap443x.dtsi | 4 +
> arch/arm/boot/dts/omap4460.dtsi | 4 +
> arch/arm/boot/dts/omap5.dtsi | 9 ++
> .../thermal/ti-soc-thermal/dra752-thermal-data.c | 10 --
> .../thermal/ti-soc-thermal/omap3-thermal-data.c | 4 -
> .../thermal/ti-soc-thermal/omap4-thermal-data.c | 6 -
> .../thermal/ti-soc-thermal/omap5-thermal-data.c | 4 -
> drivers/thermal/ti-soc-thermal/ti-bandgap.h | 4 -
> drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 158 +--------------------
> drivers/thermal/ti-soc-thermal/ti-thermal.h | 16 ---
> 14 files changed, 71 insertions(+), 201 deletions(-)
> create mode 100644 arch/arm/boot/dts/omap3-cpu-thermal.dtsi
>

2017-03-23 20:54:21

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] thermal: ti-soc-thermal: Migrate slope/offset data to device tree

* Keerthy <[email protected]> [170321 20:45]:
>
>
> On Thursday 09 March 2017 01:35 PM, Keerthy wrote:
> > Currently the slope and offset values for calculating the
> > hot spot temperature of a particular thermal zone is part
> > of driver data. Pass them here instead and obtain the values
> > while of node parsing.
> >
> > Tested for the slope and constant values on DRA7-EVM, OMAP3-BEAGLE.
>
> Hi Eduardo,
>
> If the series looks okay could you please pull this?

Also.. Are the dts changes safe for me to pick separately?

Regards,

Tony


> > Changes in v2:
> >
> > * Added OMAP3 changes along with DRA7/OMAP4/OMAP5.
> >
> > Keerthy (8):
> > arm: dts: omap3: Add cpu_thermal zone
> > ARM: DRA7: Thermal: Add slope and offset values
> > ARM: OMAP5: Thermal: Add slope and offset values
> > ARM: OMAP443x: Thermal: Add slope and offset values
> > ARM: OMAP4460: Thermal: Add slope and offset values
> > thermal: ti-soc-thermal: Fetch slope and offset from DT
> > thermal: ti-soc-thermal: Remove redundant constants
> > thermal: ti-soc-thermal: Remove redundant code
> >
> > arch/arm/boot/dts/dra7.dtsi | 17 +++
> > arch/arm/boot/dts/omap3-cpu-thermal.dtsi | 20 +++
> > arch/arm/boot/dts/omap34xx.dtsi | 8 +-
> > arch/arm/boot/dts/omap36xx.dtsi | 8 +-
> > arch/arm/boot/dts/omap443x.dtsi | 4 +
> > arch/arm/boot/dts/omap4460.dtsi | 4 +
> > arch/arm/boot/dts/omap5.dtsi | 9 ++
> > .../thermal/ti-soc-thermal/dra752-thermal-data.c | 10 --
> > .../thermal/ti-soc-thermal/omap3-thermal-data.c | 4 -
> > .../thermal/ti-soc-thermal/omap4-thermal-data.c | 6 -
> > .../thermal/ti-soc-thermal/omap5-thermal-data.c | 4 -
> > drivers/thermal/ti-soc-thermal/ti-bandgap.h | 4 -
> > drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 158 +--------------------
> > drivers/thermal/ti-soc-thermal/ti-thermal.h | 16 ---
> > 14 files changed, 71 insertions(+), 201 deletions(-)
> > create mode 100644 arch/arm/boot/dts/omap3-cpu-thermal.dtsi
> >

2017-03-24 03:27:42

by Keerthy

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] thermal: ti-soc-thermal: Migrate slope/offset data to device tree



On Friday 24 March 2017 02:22 AM, Tony Lindgren wrote:
> * Keerthy <[email protected]> [170321 20:45]:
>>
>>
>> On Thursday 09 March 2017 01:35 PM, Keerthy wrote:
>>> Currently the slope and offset values for calculating the
>>> hot spot temperature of a particular thermal zone is part
>>> of driver data. Pass them here instead and obtain the values
>>> while of node parsing.
>>>
>>> Tested for the slope and constant values on DRA7-EVM, OMAP3-BEAGLE.
>>
>> Hi Eduardo,
>>
>> If the series looks okay could you please pull this?
>
> Also.. Are the dts changes safe for me to pick separately?

Yes Tony they are safe to pulled separately.

>
> Regards,
>
> Tony
>
>
>>> Changes in v2:
>>>
>>> * Added OMAP3 changes along with DRA7/OMAP4/OMAP5.
>>>
>>> Keerthy (8):
>>> arm: dts: omap3: Add cpu_thermal zone
>>> ARM: DRA7: Thermal: Add slope and offset values
>>> ARM: OMAP5: Thermal: Add slope and offset values
>>> ARM: OMAP443x: Thermal: Add slope and offset values
>>> ARM: OMAP4460: Thermal: Add slope and offset values
>>> thermal: ti-soc-thermal: Fetch slope and offset from DT
>>> thermal: ti-soc-thermal: Remove redundant constants
>>> thermal: ti-soc-thermal: Remove redundant code
>>>
>>> arch/arm/boot/dts/dra7.dtsi | 17 +++
>>> arch/arm/boot/dts/omap3-cpu-thermal.dtsi | 20 +++
>>> arch/arm/boot/dts/omap34xx.dtsi | 8 +-
>>> arch/arm/boot/dts/omap36xx.dtsi | 8 +-
>>> arch/arm/boot/dts/omap443x.dtsi | 4 +
>>> arch/arm/boot/dts/omap4460.dtsi | 4 +
>>> arch/arm/boot/dts/omap5.dtsi | 9 ++
>>> .../thermal/ti-soc-thermal/dra752-thermal-data.c | 10 --
>>> .../thermal/ti-soc-thermal/omap3-thermal-data.c | 4 -
>>> .../thermal/ti-soc-thermal/omap4-thermal-data.c | 6 -
>>> .../thermal/ti-soc-thermal/omap5-thermal-data.c | 4 -
>>> drivers/thermal/ti-soc-thermal/ti-bandgap.h | 4 -
>>> drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 158 +--------------------
>>> drivers/thermal/ti-soc-thermal/ti-thermal.h | 16 ---
>>> 14 files changed, 71 insertions(+), 201 deletions(-)
>>> create mode 100644 arch/arm/boot/dts/omap3-cpu-thermal.dtsi
>>>

2017-03-24 14:26:43

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] thermal: ti-soc-thermal: Migrate slope/offset data to device tree

* Keerthy <[email protected]> [170323 20:29]:
>
>
> On Friday 24 March 2017 02:22 AM, Tony Lindgren wrote:
> > * Keerthy <[email protected]> [170321 20:45]:
> >>
> >>
> >> On Thursday 09 March 2017 01:35 PM, Keerthy wrote:
> >>> Currently the slope and offset values for calculating the
> >>> hot spot temperature of a particular thermal zone is part
> >>> of driver data. Pass them here instead and obtain the values
> >>> while of node parsing.
> >>>
> >>> Tested for the slope and constant values on DRA7-EVM, OMAP3-BEAGLE.
> >>
> >> Hi Eduardo,
> >>
> >> If the series looks okay could you please pull this?
> >
> > Also.. Are the dts changes safe for me to pick separately?
>
> Yes Tony they are safe to pulled separately.

OK applying patches 1 - 5 of this series into omap-for-v4.12/dt-v2.

Thanks,

Tony

2017-03-29 04:33:17

by Eduardo Valentin

[permalink] [raw]
Subject: Re: [PATCH v2 3/8] ARM: OMAP5: Thermal: Add slope and offset values

On Thu, Mar 09, 2017 at 01:35:57PM +0530, Keerthy wrote:
> Currently the slope and offset values for calculating the
> hot spot temperature of a particular thermal zone is part
> of driver data. Pass them here instead and obtain the values
> while of node parsing.


The patch is fine.. but

>
> Signed-off-by: Keerthy <[email protected]>
> ---
> arch/arm/boot/dts/omap5.dtsi | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
> index 222155c..eaff2a5 100644
> --- a/arch/arm/boot/dts/omap5.dtsi
> +++ b/arch/arm/boot/dts/omap5.dtsi
> @@ -1127,6 +1127,15 @@
>
> &cpu_thermal {
> polling-delay = <500>; /* milliseconds */
> + coefficients = <65 (-1791)>;

I suppose you tried this change with this patch:
https://patchwork.kernel.org/patch/9619577/
?

Otherwise, I do not see how your coeff would work, right?

> };
>
> /include/ "omap54xx-clocks.dtsi"
> +
> +&gpu_thermal {
> + coefficients = <117 (-2992)>;
> +};
> +
> +&core_thermal {
> + coefficients = <0 2000>;
> +};
> --
> 1.9.1
>

2017-03-29 04:38:09

by Eduardo Valentin

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] thermal: ti-soc-thermal: Migrate slope/offset data to device tree

Keerthy,

On Fri, Mar 24, 2017 at 07:26:10AM -0700, Tony Lindgren wrote:
> * Keerthy <[email protected]> [170323 20:29]:
> >
> >
> > On Friday 24 March 2017 02:22 AM, Tony Lindgren wrote:
> > > * Keerthy <[email protected]> [170321 20:45]:
> > >>
> > >>
> > >> On Thursday 09 March 2017 01:35 PM, Keerthy wrote:
> > >>> Currently the slope and offset values for calculating the
> > >>> hot spot temperature of a particular thermal zone is part
> > >>> of driver data. Pass them here instead and obtain the values
> > >>> while of node parsing.
> > >>>
> > >>> Tested for the slope and constant values on DRA7-EVM, OMAP3-BEAGLE.

Have you tried on boards that need negative coefficients?

https://patchwork.kernel.org/patch/9619577/

> > >>
> > >> Hi Eduardo,
> > >>
> > >> If the series looks okay could you please pull this?
> > >
> > > Also.. Are the dts changes safe for me to pick separately?
> >
> > Yes Tony they are safe to pulled separately.
>
> OK applying patches 1 - 5 of this series into omap-for-v4.12/dt-v2.

Keerthy,

The only thing I want you to confirm is if you are really getting the
negative coefficients, because currently of-thermal reads the array
using an OF helper that understands only unsigned. For this reason, I
will be queueing your patches only for next merge window, not as a fix,
not for rc's.


>
> Thanks,
>
> Tony

2017-03-30 03:28:37

by Keerthy

[permalink] [raw]
Subject: Re: [PATCH v2 3/8] ARM: OMAP5: Thermal: Add slope and offset values



On Wednesday 29 March 2017 10:03 AM, Eduardo Valentin wrote:
> On Thu, Mar 09, 2017 at 01:35:57PM +0530, Keerthy wrote:
>> Currently the slope and offset values for calculating the
>> hot spot temperature of a particular thermal zone is part
>> of driver data. Pass them here instead and obtain the values
>> while of node parsing.
>
>
> The patch is fine.. but
>
>>
>> Signed-off-by: Keerthy <[email protected]>
>> ---
>> arch/arm/boot/dts/omap5.dtsi | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
>> index 222155c..eaff2a5 100644
>> --- a/arch/arm/boot/dts/omap5.dtsi
>> +++ b/arch/arm/boot/dts/omap5.dtsi
>> @@ -1127,6 +1127,15 @@
>>
>> &cpu_thermal {
>> polling-delay = <500>; /* milliseconds */
>> + coefficients = <65 (-1791)>;
>
> I suppose you tried this change with this patch:
> https://patchwork.kernel.org/patch/9619577/
> ?
>
> Otherwise, I do not see how your coeff would work, right?

IIRC i did not have that patch.

But No issues there. I did try deliberately with negative values and i
retrieved the negative values in driver nicely.

Fox ex: -20 unsigned when retrieved in driver as an int coeff will give
me -20. I checked with multiple negative co-efficients and i retrieved
the passed negative co-efficients in driver from DT.

Regards,
Keerthy


>
>> };
>>
>> /include/ "omap54xx-clocks.dtsi"
>> +
>> +&gpu_thermal {
>> + coefficients = <117 (-2992)>;
>> +};
>> +
>> +&core_thermal {
>> + coefficients = <0 2000>;
>> +};
>> --
>> 1.9.1
>>

2017-03-30 03:30:07

by Keerthy

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] thermal: ti-soc-thermal: Migrate slope/offset data to device tree



On Wednesday 29 March 2017 10:07 AM, Eduardo Valentin wrote:
> Keerthy,
>
> On Fri, Mar 24, 2017 at 07:26:10AM -0700, Tony Lindgren wrote:
>> * Keerthy <[email protected]> [170323 20:29]:
>>>
>>>
>>> On Friday 24 March 2017 02:22 AM, Tony Lindgren wrote:
>>>> * Keerthy <[email protected]> [170321 20:45]:
>>>>>
>>>>>
>>>>> On Thursday 09 March 2017 01:35 PM, Keerthy wrote:
>>>>>> Currently the slope and offset values for calculating the
>>>>>> hot spot temperature of a particular thermal zone is part
>>>>>> of driver data. Pass them here instead and obtain the values
>>>>>> while of node parsing.
>>>>>>
>>>>>> Tested for the slope and constant values on DRA7-EVM, OMAP3-BEAGLE.
>
> Have you tried on boards that need negative coefficients?
>
> https://patchwork.kernel.org/patch/9619577/

Yes. I retrieved the negative values nicely in the driver passed via
Device Tree.

>
>>>>>
>>>>> Hi Eduardo,
>>>>>
>>>>> If the series looks okay could you please pull this?
>>>>
>>>> Also.. Are the dts changes safe for me to pick separately?
>>>
>>> Yes Tony they are safe to pulled separately.
>>
>> OK applying patches 1 - 5 of this series into omap-for-v4.12/dt-v2.
>
> Keerthy,
>
> The only thing I want you to confirm is if you are really getting the
> negative coefficients, because currently of-thermal reads the array
> using an OF helper that understands only unsigned. For this reason, I
> will be queueing your patches only for next merge window, not as a fix,
> not for rc's.

I am getting negative co-efficients.

>
>
>>
>> Thanks,
>>
>> Tony

2017-03-30 04:46:26

by Eduardo Valentin

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] thermal: ti-soc-thermal: Migrate slope/offset data to device tree

On Thu, Mar 30, 2017 at 08:59:31AM +0530, Keerthy wrote:
>
>
> On Wednesday 29 March 2017 10:07 AM, Eduardo Valentin wrote:
> > Keerthy,
> >
> > On Fri, Mar 24, 2017 at 07:26:10AM -0700, Tony Lindgren wrote:
> >> * Keerthy <[email protected]> [170323 20:29]:
> >>>
> >>>
> >>> On Friday 24 March 2017 02:22 AM, Tony Lindgren wrote:
> >>>> * Keerthy <[email protected]> [170321 20:45]:
> >>>>>
> >>>>>
> >>>>> On Thursday 09 March 2017 01:35 PM, Keerthy wrote:
> >>>>>> Currently the slope and offset values for calculating the
> >>>>>> hot spot temperature of a particular thermal zone is part
> >>>>>> of driver data. Pass them here instead and obtain the values
> >>>>>> while of node parsing.
> >>>>>>
> >>>>>> Tested for the slope and constant values on DRA7-EVM, OMAP3-BEAGLE.
> >
> > Have you tried on boards that need negative coefficients?
> >
> > https://patchwork.kernel.org/patch/9619577/
>
> Yes. I retrieved the negative values nicely in the driver passed via
> Device Tree.
>
> >
> >>>>>
> >>>>> Hi Eduardo,
> >>>>>
> >>>>> If the series looks okay could you please pull this?
> >>>>
> >>>> Also.. Are the dts changes safe for me to pick separately?
> >>>
> >>> Yes Tony they are safe to pulled separately.
> >>
> >> OK applying patches 1 - 5 of this series into omap-for-v4.12/dt-v2.
> >
> > Keerthy,
> >
> > The only thing I want you to confirm is if you are really getting the
> > negative coefficients, because currently of-thermal reads the array
> > using an OF helper that understands only unsigned. For this reason, I
> > will be queueing your patches only for next merge window, not as a fix,
> > not for rc's.
>
> I am getting negative co-efficients.

OK. That is odd. Might be simply we get still converted after simply
assigning the unsigned to the int in the thermal device data struct.
Anyways, still not for rc, given the amount of changes in the driver.

>
> >
> >
> >>
> >> Thanks,
> >>
> >> Tony