All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/21] thermal: exynos: Thermal code rework to use device tree
@ 2014-10-09 16:38 ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

1. Introduction

Following patches aim to clean up the current implementation of the thermal
framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration
(of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which
is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal 
subsystem.

2. Patch-set structure

This series starts with extending current of-thermal.c implementation with
exporting information about trip points and support for setting emulated 
temperature. Those changes were necessary to reuse this code in Exynos.

Then the cpu_cooling functionality has been preserved to allow cooling
devices by reducing operating frequency. Definition of trip points and
cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to
the Exynos thermal subsystem was performed. Now device tree is used for
configuration.

Patch series end with removing exynos5250/exynos3250 TMU compatibles.
Both SoCs have thermal management unit (TMU) compatible with the one first 
introduced at Exynos4412.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c 
file, was removed since, as of 3.17-rc6, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those
SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality
has been preserved in the code, but not tested on the hardware. I would
be grateful for help in testing.

5. Prerequisites:

This work requires following patches developed by Bartlomiej Zolnierkiewicz:

5.1. [PATCH v3] ARM: dts: add CPU nodes for Exynos4 SoCs
http://article.gmane.org/gmane.linux.kernel.samsung-soc/37946/match=patch+v3+arm+dts+add+cpu+nodes+exynos4+socs

5.2. First thermal clean up patch set (from patch 1 to 33):

[PATCH 00/33] thermal: exynos: convert the driver to use per-SoC type operations
http://article.gmane.org/gmane.linux.kernel.samsung-soc/37642/match=patch+00+33+thermal+exynos+convert+driver+use+per+soc+type+operations


Lukasz Majewski (21):
  thermal: of: Extend of-thermal.c to provide number of trip points
  thermal: of: Extend of-thermal.c to provide check if trip point is
    enabled
  thermal: of: Extend of-thermal.c to provide number of non critical
    trip points
  thermal: of: Extend current of-thermal.c code to allow setting
    emulated temp
  thermal: exynos: cosmetic: Correct comment format
  thermal: exynos: Provide thermal_exynos.h file to be included in
    device tree files
  thermal: dts: trats: Enable TMU on the Exynos4210 trats device
  thermal: dts: exynos: Adding LD010 regulator node necessary for TMU on
    Odroid U3 board
  thermal: dts: Provide bindings and enable TMU at Exynos4x12 devices
  thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu
    cooling functionality
  thermal: cpu_cooling: Modify exynos thermal code to use device tree
    for cpu cooling configuration
  thermal: exynos: dts: Add default definition for the TMU sensor
  thermal: dts: Default trip points definition for Exynos5420 SoCs
  thermal: exynos: dts: Define default thermal-zones for Exynos4
  thermal: dts: exynos: Trip points and sensor configuration data for
    Exynos5440
  thermal: exynos: dts: Provide device tree bindings identical to one in
    exynos_tmu_data.c
  thermal: samsung: core: Exynos TMU rework to use device tree for
    configuration
  thermal: exynos: Remove exynos_thermal_common.[c|h] files
  thermal: exynos: Remove exynos_tmu_data.c file
  thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412
  thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412

 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi        |  52 +++
 arch/arm/boot/dts/exynos4.dtsi                    |   5 +
 arch/arm/boot/dts/exynos4210-trats.dts            |  19 +
 arch/arm/boot/dts/exynos4210.dtsi                 |  28 +-
 arch/arm/boot/dts/exynos4212.dtsi                 |   5 +-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi   |  27 ++
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi |  24 ++
 arch/arm/boot/dts/exynos4412.dtsi                 |   5 +-
 arch/arm/boot/dts/exynos4x12.dtsi                 |  13 +
 arch/arm/boot/dts/exynos5250.dtsi                 |  29 +-
 arch/arm/boot/dts/exynos5420-trip-points.dtsi     |  35 ++
 arch/arm/boot/dts/exynos5420.dtsi                 |  33 ++
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi |  25 ++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi     |  25 ++
 arch/arm/boot/dts/exynos5440.dtsi                 |  18 +
 drivers/cpufreq/exynos-cpufreq.c                  |  23 +-
 drivers/thermal/of-thermal.c                      |  52 ++-
 drivers/thermal/samsung/Makefile                  |   2 -
 drivers/thermal/samsung/exynos_thermal_common.c   | 430 ----------------------
 drivers/thermal/samsung/exynos_thermal_common.h   | 106 ------
 drivers/thermal/samsung/exynos_tmu.c              | 283 +++++++-------
 drivers/thermal/samsung/exynos_tmu.h              |  79 +---
 drivers/thermal/samsung/exynos_tmu_data.c         | 264 -------------
 drivers/thermal/thermal_core.h                    |  15 +
 include/dt-bindings/thermal/thermal_exynos.h      |  40 ++
 include/linux/thermal.h                           |   6 +-
 26 files changed, 623 insertions(+), 1020 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 00/21] thermal: exynos: Thermal code rework to use device tree
@ 2014-10-09 16:38 ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

1. Introduction

Following patches aim to clean up the current implementation of the thermal
framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration
(of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which
is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal 
subsystem.

2. Patch-set structure

This series starts with extending current of-thermal.c implementation with
exporting information about trip points and support for setting emulated 
temperature. Those changes were necessary to reuse this code in Exynos.

Then the cpu_cooling functionality has been preserved to allow cooling
devices by reducing operating frequency. Definition of trip points and
cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to
the Exynos thermal subsystem was performed. Now device tree is used for
configuration.

Patch series end with removing exynos5250/exynos3250 TMU compatibles.
Both SoCs have thermal management unit (TMU) compatible with the one first 
introduced at Exynos4412.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c 
file, was removed since, as of 3.17-rc6, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those
SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality
has been preserved in the code, but not tested on the hardware. I would
be grateful for help in testing.

5. Prerequisites:

This work requires following patches developed by Bartlomiej Zolnierkiewicz:

5.1. [PATCH v3] ARM: dts: add CPU nodes for Exynos4 SoCs
http://article.gmane.org/gmane.linux.kernel.samsung-soc/37946/match=patch+v3+arm+dts+add+cpu+nodes+exynos4+socs

5.2. First thermal clean up patch set (from patch 1 to 33):

[PATCH 00/33] thermal: exynos: convert the driver to use per-SoC type operations
http://article.gmane.org/gmane.linux.kernel.samsung-soc/37642/match=patch+00+33+thermal+exynos+convert+driver+use+per+soc+type+operations


Lukasz Majewski (21):
  thermal: of: Extend of-thermal.c to provide number of trip points
  thermal: of: Extend of-thermal.c to provide check if trip point is
    enabled
  thermal: of: Extend of-thermal.c to provide number of non critical
    trip points
  thermal: of: Extend current of-thermal.c code to allow setting
    emulated temp
  thermal: exynos: cosmetic: Correct comment format
  thermal: exynos: Provide thermal_exynos.h file to be included in
    device tree files
  thermal: dts: trats: Enable TMU on the Exynos4210 trats device
  thermal: dts: exynos: Adding LD010 regulator node necessary for TMU on
    Odroid U3 board
  thermal: dts: Provide bindings and enable TMU at Exynos4x12 devices
  thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu
    cooling functionality
  thermal: cpu_cooling: Modify exynos thermal code to use device tree
    for cpu cooling configuration
  thermal: exynos: dts: Add default definition for the TMU sensor
  thermal: dts: Default trip points definition for Exynos5420 SoCs
  thermal: exynos: dts: Define default thermal-zones for Exynos4
  thermal: dts: exynos: Trip points and sensor configuration data for
    Exynos5440
  thermal: exynos: dts: Provide device tree bindings identical to one in
    exynos_tmu_data.c
  thermal: samsung: core: Exynos TMU rework to use device tree for
    configuration
  thermal: exynos: Remove exynos_thermal_common.[c|h] files
  thermal: exynos: Remove exynos_tmu_data.c file
  thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412
  thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412

 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi        |  52 +++
 arch/arm/boot/dts/exynos4.dtsi                    |   5 +
 arch/arm/boot/dts/exynos4210-trats.dts            |  19 +
 arch/arm/boot/dts/exynos4210.dtsi                 |  28 +-
 arch/arm/boot/dts/exynos4212.dtsi                 |   5 +-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi   |  27 ++
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi |  24 ++
 arch/arm/boot/dts/exynos4412.dtsi                 |   5 +-
 arch/arm/boot/dts/exynos4x12.dtsi                 |  13 +
 arch/arm/boot/dts/exynos5250.dtsi                 |  29 +-
 arch/arm/boot/dts/exynos5420-trip-points.dtsi     |  35 ++
 arch/arm/boot/dts/exynos5420.dtsi                 |  33 ++
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi |  25 ++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi     |  25 ++
 arch/arm/boot/dts/exynos5440.dtsi                 |  18 +
 drivers/cpufreq/exynos-cpufreq.c                  |  23 +-
 drivers/thermal/of-thermal.c                      |  52 ++-
 drivers/thermal/samsung/Makefile                  |   2 -
 drivers/thermal/samsung/exynos_thermal_common.c   | 430 ----------------------
 drivers/thermal/samsung/exynos_thermal_common.h   | 106 ------
 drivers/thermal/samsung/exynos_tmu.c              | 283 +++++++-------
 drivers/thermal/samsung/exynos_tmu.h              |  79 +---
 drivers/thermal/samsung/exynos_tmu_data.c         | 264 -------------
 drivers/thermal/thermal_core.h                    |  15 +
 include/dt-bindings/thermal/thermal_exynos.h      |  40 ++
 include/linux/thermal.h                           |   6 +-
 26 files changed, 623 insertions(+), 1020 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

-- 
2.0.0.rc2

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 01/21] thermal: of: Extend of-thermal.c to provide number of trip points
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This patch extends the of-thermal.c to provide information about number of
available trip points.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/of-thermal.c   | 6 ++++++
 drivers/thermal/thermal_core.h | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index f8eb625..b2390d9 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -113,6 +113,12 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
 	return data->get_temp(data->sensor_data, temp);
 }
 
+int of_thermal_get_ntrips(struct thermal_zone_device *tz)
+{
+	struct __thermal_zone *data = tz->devdata;
+	return data->ntrips;
+}
+
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 				enum thermal_trend *trend)
 {
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 3db339f..587ca5c 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -81,9 +81,14 @@ static inline void thermal_gov_user_space_unregister(void) {}
 #ifdef CONFIG_THERMAL_OF
 int of_parse_thermal_zones(void);
 void of_thermal_destroy_zones(void);
+int of_thermal_get_ntrips(struct thermal_zone_device *);
 #else
 static inline int of_parse_thermal_zones(void) { return 0; }
 static inline void of_thermal_destroy_zones(void) { }
+static inline int of_thermal_get_ntrips(struct thermal_zone_device *)
+{
+	return 0;
+}
 #endif
 
 #endif /* __THERMAL_CORE_H__ */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 01/21] thermal: of: Extend of-thermal.c to provide number of trip points
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

This patch extends the of-thermal.c to provide information about number of
available trip points.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/of-thermal.c   | 6 ++++++
 drivers/thermal/thermal_core.h | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index f8eb625..b2390d9 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -113,6 +113,12 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
 	return data->get_temp(data->sensor_data, temp);
 }
 
+int of_thermal_get_ntrips(struct thermal_zone_device *tz)
+{
+	struct __thermal_zone *data = tz->devdata;
+	return data->ntrips;
+}
+
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 				enum thermal_trend *trend)
 {
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 3db339f..587ca5c 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -81,9 +81,14 @@ static inline void thermal_gov_user_space_unregister(void) {}
 #ifdef CONFIG_THERMAL_OF
 int of_parse_thermal_zones(void);
 void of_thermal_destroy_zones(void);
+int of_thermal_get_ntrips(struct thermal_zone_device *);
 #else
 static inline int of_parse_thermal_zones(void) { return 0; }
 static inline void of_thermal_destroy_zones(void) { }
+static inline int of_thermal_get_ntrips(struct thermal_zone_device *)
+{
+	return 0;
+}
 #endif
 
 #endif /* __THERMAL_CORE_H__ */
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 02/21] thermal: of: Extend of-thermal.c to provide check if trip point is enabled
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This patch extends the of-thermal.c to provide check if trip point is
enabled.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/of-thermal.c   | 9 +++++++++
 drivers/thermal/thermal_core.h | 5 +++++
 2 files changed, 14 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index b2390d9..23c8d6c 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -119,6 +119,15 @@ int of_thermal_get_ntrips(struct thermal_zone_device *tz)
 	return data->ntrips;
 }
 
+int of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	if (trip >= data->ntrips || trip < 0)
+		return 0;
+	return 1;
+}
+
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 				enum thermal_trend *trend)
 {
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 587ca5c..ed8ff05 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -82,6 +82,7 @@ static inline void thermal_gov_user_space_unregister(void) {}
 int of_parse_thermal_zones(void);
 void of_thermal_destroy_zones(void);
 int of_thermal_get_ntrips(struct thermal_zone_device *);
+int of_thermal_is_trip_en(struct thermal_zone_device *, int);
 #else
 static inline int of_parse_thermal_zones(void) { return 0; }
 static inline void of_thermal_destroy_zones(void) { }
@@ -89,6 +90,10 @@ static inline int of_thermal_get_ntrips(struct thermal_zone_device *)
 {
 	return 0;
 }
+int of_thermal_is_trip_en(struct thermal_zone_device *, int)
+{
+	return 0;
+}
 #endif
 
 #endif /* __THERMAL_CORE_H__ */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 02/21] thermal: of: Extend of-thermal.c to provide check if trip point is enabled
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

This patch extends the of-thermal.c to provide check if trip point is
enabled.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/of-thermal.c   | 9 +++++++++
 drivers/thermal/thermal_core.h | 5 +++++
 2 files changed, 14 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index b2390d9..23c8d6c 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -119,6 +119,15 @@ int of_thermal_get_ntrips(struct thermal_zone_device *tz)
 	return data->ntrips;
 }
 
+int of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	if (trip >= data->ntrips || trip < 0)
+		return 0;
+	return 1;
+}
+
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 				enum thermal_trend *trend)
 {
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 587ca5c..ed8ff05 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -82,6 +82,7 @@ static inline void thermal_gov_user_space_unregister(void) {}
 int of_parse_thermal_zones(void);
 void of_thermal_destroy_zones(void);
 int of_thermal_get_ntrips(struct thermal_zone_device *);
+int of_thermal_is_trip_en(struct thermal_zone_device *, int);
 #else
 static inline int of_parse_thermal_zones(void) { return 0; }
 static inline void of_thermal_destroy_zones(void) { }
@@ -89,6 +90,10 @@ static inline int of_thermal_get_ntrips(struct thermal_zone_device *)
 {
 	return 0;
 }
+int of_thermal_is_trip_en(struct thermal_zone_device *, int)
+{
+	return 0;
+}
 #endif
 
 #endif /* __THERMAL_CORE_H__ */
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This patch extends the of-thermal.c to provide information about number of
available non critical (i.e. non HW) trip points in the system.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/of-thermal.c   | 12 ++++++++++++
 drivers/thermal/thermal_core.h |  5 +++++
 2 files changed, 17 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 23c8d6c..cd74e64 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)
 	return 1;
 }
 
+int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *tz)
+{
+	struct __thermal_zone *data = tz->devdata;
+	int i;
+
+	for (i = 0; i < data->ntrips; i++)
+		if (data->trips[i].type != THERMAL_TRIP_CRITICAL)
+			continue;
+
+	return --i;
+}
+
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 				enum thermal_trend *trend)
 {
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index ed8ff05..334a7be 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
 void of_thermal_destroy_zones(void);
 int of_thermal_get_ntrips(struct thermal_zone_device *);
 int of_thermal_is_trip_en(struct thermal_zone_device *, int);
+int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *);
 #else
 static inline int of_parse_thermal_zones(void) { return 0; }
 static inline void of_thermal_destroy_zones(void) { }
@@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct thermal_zone_device *, int)
 {
 	return 0;
 }
+int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *)
+{
+	return 0;
+}
 #endif
 
 #endif /* __THERMAL_CORE_H__ */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

This patch extends the of-thermal.c to provide information about number of
available non critical (i.e. non HW) trip points in the system.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/of-thermal.c   | 12 ++++++++++++
 drivers/thermal/thermal_core.h |  5 +++++
 2 files changed, 17 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 23c8d6c..cd74e64 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)
 	return 1;
 }
 
+int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *tz)
+{
+	struct __thermal_zone *data = tz->devdata;
+	int i;
+
+	for (i = 0; i < data->ntrips; i++)
+		if (data->trips[i].type != THERMAL_TRIP_CRITICAL)
+			continue;
+
+	return --i;
+}
+
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 				enum thermal_trend *trend)
 {
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index ed8ff05..334a7be 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
 void of_thermal_destroy_zones(void);
 int of_thermal_get_ntrips(struct thermal_zone_device *);
 int of_thermal_is_trip_en(struct thermal_zone_device *, int);
+int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *);
 #else
 static inline int of_parse_thermal_zones(void) { return 0; }
 static inline void of_thermal_destroy_zones(void) { }
@@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct thermal_zone_device *, int)
 {
 	return 0;
 }
+int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *)
+{
+	return 0;
+}
 #endif
 
 #endif /* __THERMAL_CORE_H__ */
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 04/21] thermal: of: Extend current of-thermal.c code to allow setting emulated temp
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Before this change it was only possible to set get_temp() and get_trend()
methods to be used in the common code handling passing parameters via
device tree to "cpu-thermal" CPU thermal zone device.

Now it is possible to also set emulated value of temperature for debug
purposes.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/of-thermal.c | 25 ++++++++++++++++++++++---
 include/linux/thermal.h      |  6 ++++--
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index cd74e64..f206375 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -98,10 +98,22 @@ struct __thermal_zone {
 	void *sensor_data;
 	int (*get_temp)(void *, long *);
 	int (*get_trend)(void *, long *);
+	int (*set_emul_temp)(void *, unsigned long);
 };
 
 /***   DT thermal zone device callbacks   ***/
 
+static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
+				    unsigned long temp)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	if (!data->set_emul_temp)
+		return -EINVAL;
+
+	return data->set_emul_temp(data->sensor_data, temp);
+}
+
 static int of_thermal_get_temp(struct thermal_zone_device *tz,
 			       unsigned long *temp)
 {
@@ -352,7 +364,8 @@ static struct thermal_zone_device *
 thermal_zone_of_add_sensor(struct device_node *zone,
 			   struct device_node *sensor, void *data,
 			   int (*get_temp)(void *, long *),
-			   int (*get_trend)(void *, long *))
+			   int (*get_trend)(void *, long *),
+			   int (*set_emul_temp)(void *, unsigned long))
 {
 	struct thermal_zone_device *tzd;
 	struct __thermal_zone *tz;
@@ -366,10 +379,12 @@ thermal_zone_of_add_sensor(struct device_node *zone,
 	mutex_lock(&tzd->lock);
 	tz->get_temp = get_temp;
 	tz->get_trend = get_trend;
+	tz->set_emul_temp = set_emul_temp;
 	tz->sensor_data = data;
 
 	tzd->ops->get_temp = of_thermal_get_temp;
 	tzd->ops->get_trend = of_thermal_get_trend;
+	tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
 	mutex_unlock(&tzd->lock);
 
 	return tzd;
@@ -411,7 +426,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
 struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
 				void *data, int (*get_temp)(void *, long *),
-				int (*get_trend)(void *, long *))
+				int (*get_trend)(void *, long *),
+				int (*set_emul_temp)(void *, unsigned long))
 {
 	struct device_node *np, *child, *sensor_np;
 
@@ -453,7 +469,8 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
 			return thermal_zone_of_add_sensor(child, sensor_np,
 							  data,
 							  get_temp,
-							  get_trend);
+							  get_trend,
+							  set_emul_temp);
 		}
 	}
 	of_node_put(np);
@@ -494,9 +511,11 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 	mutex_lock(&tzd->lock);
 	tzd->ops->get_temp = NULL;
 	tzd->ops->get_trend = NULL;
+	tzd->ops->set_emul_temp = NULL;
 
 	tz->get_temp = NULL;
 	tz->get_trend = NULL;
+	tz->set_emul_temp = NULL;
 	tz->sensor_data = NULL;
 	mutex_unlock(&tzd->lock);
 }
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 0305cde..36010e9 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -290,14 +290,16 @@ struct thermal_genl_event {
 struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id,
 				void *data, int (*get_temp)(void *, long *),
-				int (*get_trend)(void *, long *));
+				int (*get_trend)(void *, long *),
+				int (*set_emul_temp)(void *, unsigned long));
 void thermal_zone_of_sensor_unregister(struct device *dev,
 				       struct thermal_zone_device *tz);
 #else
 static inline struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id,
 				void *data, int (*get_temp)(void *, long *),
-				int (*get_trend)(void *, long *))
+				int (*get_trend)(void *, long *),
+				int (*set_emul_temp)(void *, unsigned long))
 {
 	return NULL;
 }
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 04/21] thermal: of: Extend current of-thermal.c code to allow setting emulated temp
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

Before this change it was only possible to set get_temp() and get_trend()
methods to be used in the common code handling passing parameters via
device tree to "cpu-thermal" CPU thermal zone device.

Now it is possible to also set emulated value of temperature for debug
purposes.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/of-thermal.c | 25 ++++++++++++++++++++++---
 include/linux/thermal.h      |  6 ++++--
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index cd74e64..f206375 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -98,10 +98,22 @@ struct __thermal_zone {
 	void *sensor_data;
 	int (*get_temp)(void *, long *);
 	int (*get_trend)(void *, long *);
+	int (*set_emul_temp)(void *, unsigned long);
 };
 
 /***   DT thermal zone device callbacks   ***/
 
+static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
+				    unsigned long temp)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	if (!data->set_emul_temp)
+		return -EINVAL;
+
+	return data->set_emul_temp(data->sensor_data, temp);
+}
+
 static int of_thermal_get_temp(struct thermal_zone_device *tz,
 			       unsigned long *temp)
 {
@@ -352,7 +364,8 @@ static struct thermal_zone_device *
 thermal_zone_of_add_sensor(struct device_node *zone,
 			   struct device_node *sensor, void *data,
 			   int (*get_temp)(void *, long *),
-			   int (*get_trend)(void *, long *))
+			   int (*get_trend)(void *, long *),
+			   int (*set_emul_temp)(void *, unsigned long))
 {
 	struct thermal_zone_device *tzd;
 	struct __thermal_zone *tz;
@@ -366,10 +379,12 @@ thermal_zone_of_add_sensor(struct device_node *zone,
 	mutex_lock(&tzd->lock);
 	tz->get_temp = get_temp;
 	tz->get_trend = get_trend;
+	tz->set_emul_temp = set_emul_temp;
 	tz->sensor_data = data;
 
 	tzd->ops->get_temp = of_thermal_get_temp;
 	tzd->ops->get_trend = of_thermal_get_trend;
+	tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
 	mutex_unlock(&tzd->lock);
 
 	return tzd;
@@ -411,7 +426,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
 struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
 				void *data, int (*get_temp)(void *, long *),
-				int (*get_trend)(void *, long *))
+				int (*get_trend)(void *, long *),
+				int (*set_emul_temp)(void *, unsigned long))
 {
 	struct device_node *np, *child, *sensor_np;
 
@@ -453,7 +469,8 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
 			return thermal_zone_of_add_sensor(child, sensor_np,
 							  data,
 							  get_temp,
-							  get_trend);
+							  get_trend,
+							  set_emul_temp);
 		}
 	}
 	of_node_put(np);
@@ -494,9 +511,11 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 	mutex_lock(&tzd->lock);
 	tzd->ops->get_temp = NULL;
 	tzd->ops->get_trend = NULL;
+	tzd->ops->set_emul_temp = NULL;
 
 	tz->get_temp = NULL;
 	tz->get_trend = NULL;
+	tz->set_emul_temp = NULL;
 	tz->sensor_data = NULL;
 	mutex_unlock(&tzd->lock);
 }
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 0305cde..36010e9 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -290,14 +290,16 @@ struct thermal_genl_event {
 struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id,
 				void *data, int (*get_temp)(void *, long *),
-				int (*get_trend)(void *, long *));
+				int (*get_trend)(void *, long *),
+				int (*set_emul_temp)(void *, unsigned long));
 void thermal_zone_of_sensor_unregister(struct device *dev,
 				       struct thermal_zone_device *tz);
 #else
 static inline struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id,
 				void *data, int (*get_temp)(void *, long *),
-				int (*get_trend)(void *, long *))
+				int (*get_trend)(void *, long *),
+				int (*set_emul_temp)(void *, unsigned long))
 {
 	return NULL;
 }
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 05/21] thermal: exynos: cosmetic: Correct comment format
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/samsung/exynos_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 9e7f720..fa29b95 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -606,7 +606,7 @@ out:
 #define exynos5440_tmu_set_emulation NULL
 static int exynos_tmu_set_emulation(void *drv_data,	unsigned long temp)
 	{ return -EINVAL; }
-#endif/*CONFIG_THERMAL_EMULATION*/
+#endif /* CONFIG_THERMAL_EMULATION */
 
 static int exynos4210_tmu_read(struct exynos_tmu_data *data)
 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 05/21] thermal: exynos: cosmetic: Correct comment format
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/samsung/exynos_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 9e7f720..fa29b95 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -606,7 +606,7 @@ out:
 #define exynos5440_tmu_set_emulation NULL
 static int exynos_tmu_set_emulation(void *drv_data,	unsigned long temp)
 	{ return -EINVAL; }
-#endif/*CONFIG_THERMAL_EMULATION*/
+#endif /* CONFIG_THERMAL_EMULATION */
 
 static int exynos4210_tmu_read(struct exynos_tmu_data *data)
 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 06/21] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This patch is a preparatory patch for being able to read Exynos thermal
configuration from the device tree.

The DTC is not able to interpret enums properly and hence it is necessary
to #define those values explicitly.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/samsung/exynos_tmu.c         |  2 +-
 drivers/thermal/samsung/exynos_tmu.h         | 23 +++-------------
 include/dt-bindings/thermal/thermal_exynos.h | 40 ++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 21 deletions(-)
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index fa29b95..2f55daa 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -159,7 +159,7 @@ struct exynos_tmu_data {
 	void __iomem *base;
 	void __iomem *base_second;
 	int irq;
-	enum soc_type soc;
+	int soc;
 	struct work_struct irq_work;
 	struct mutex lock;
 	struct clk *clk, *clk_sec;
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index da3009b..a089391 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -26,24 +26,7 @@
 
 #include "exynos_thermal_common.h"
 
-enum calibration_type {
-	TYPE_ONE_POINT_TRIMMING,
-	TYPE_ONE_POINT_TRIMMING_25,
-	TYPE_ONE_POINT_TRIMMING_85,
-	TYPE_TWO_POINT_TRIMMING,
-	TYPE_NONE,
-};
-
-enum soc_type {
-	SOC_ARCH_EXYNOS3250 = 1,
-	SOC_ARCH_EXYNOS4210,
-	SOC_ARCH_EXYNOS4412,
-	SOC_ARCH_EXYNOS5250,
-	SOC_ARCH_EXYNOS5260,
-	SOC_ARCH_EXYNOS5420,
-	SOC_ARCH_EXYNOS5420_TRIMINFO,
-	SOC_ARCH_EXYNOS5440,
-};
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
@@ -115,8 +98,8 @@ struct exynos_tmu_platform_data {
 	u8 second_point_trim;
 	u8 default_temp_offset;
 
-	enum calibration_type cal_type;
-	enum soc_type type;
+	u32 cal_type;
+	u32 type;
 	struct freq_clip_table freq_tab[4];
 	unsigned int freq_tab_count;
 };
diff --git a/include/dt-bindings/thermal/thermal_exynos.h b/include/dt-bindings/thermal/thermal_exynos.h
new file mode 100644
index 0000000..5d91d64
--- /dev/null
+++ b/include/dt-bindings/thermal/thermal_exynos.h
@@ -0,0 +1,40 @@
+/*
+ * thermal_exynos.h - Samsung EXYNOS TMU device tree definitions
+ *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _EXYNOS_THERMAL_TMU_DT_H
+#define _EXYNOS_THERMAL_TMU_DT_H
+
+#define TYPE_ONE_POINT_TRIMMING 0
+#define TYPE_ONE_POINT_TRIMMING_25 1
+#define TYPE_ONE_POINT_TRIMMING_85 2
+#define TYPE_TWO_POINT_TRIMMING 3
+#define TYPE_NONE 4
+
+#define SOC_ARCH_EXYNOS3250 1
+#define SOC_ARCH_EXYNOS4210 2
+#define SOC_ARCH_EXYNOS4412 3
+#define SOC_ARCH_EXYNOS5250 4
+#define SOC_ARCH_EXYNOS5260 5
+#define SOC_ARCH_EXYNOS5420_TRIMINFO 6
+#define SOC_ARCH_EXYNOS5420 7
+#define SOC_ARCH_EXYNOS5440 8
+
+#endif /* _EXYNOS_THERMAL_TMU_DT_H */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 06/21] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

This patch is a preparatory patch for being able to read Exynos thermal
configuration from the device tree.

The DTC is not able to interpret enums properly and hence it is necessary
to #define those values explicitly.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/samsung/exynos_tmu.c         |  2 +-
 drivers/thermal/samsung/exynos_tmu.h         | 23 +++-------------
 include/dt-bindings/thermal/thermal_exynos.h | 40 ++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 21 deletions(-)
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index fa29b95..2f55daa 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -159,7 +159,7 @@ struct exynos_tmu_data {
 	void __iomem *base;
 	void __iomem *base_second;
 	int irq;
-	enum soc_type soc;
+	int soc;
 	struct work_struct irq_work;
 	struct mutex lock;
 	struct clk *clk, *clk_sec;
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index da3009b..a089391 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -26,24 +26,7 @@
 
 #include "exynos_thermal_common.h"
 
-enum calibration_type {
-	TYPE_ONE_POINT_TRIMMING,
-	TYPE_ONE_POINT_TRIMMING_25,
-	TYPE_ONE_POINT_TRIMMING_85,
-	TYPE_TWO_POINT_TRIMMING,
-	TYPE_NONE,
-};
-
-enum soc_type {
-	SOC_ARCH_EXYNOS3250 = 1,
-	SOC_ARCH_EXYNOS4210,
-	SOC_ARCH_EXYNOS4412,
-	SOC_ARCH_EXYNOS5250,
-	SOC_ARCH_EXYNOS5260,
-	SOC_ARCH_EXYNOS5420,
-	SOC_ARCH_EXYNOS5420_TRIMINFO,
-	SOC_ARCH_EXYNOS5440,
-};
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
@@ -115,8 +98,8 @@ struct exynos_tmu_platform_data {
 	u8 second_point_trim;
 	u8 default_temp_offset;
 
-	enum calibration_type cal_type;
-	enum soc_type type;
+	u32 cal_type;
+	u32 type;
 	struct freq_clip_table freq_tab[4];
 	unsigned int freq_tab_count;
 };
diff --git a/include/dt-bindings/thermal/thermal_exynos.h b/include/dt-bindings/thermal/thermal_exynos.h
new file mode 100644
index 0000000..5d91d64
--- /dev/null
+++ b/include/dt-bindings/thermal/thermal_exynos.h
@@ -0,0 +1,40 @@
+/*
+ * thermal_exynos.h - Samsung EXYNOS TMU device tree definitions
+ *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _EXYNOS_THERMAL_TMU_DT_H
+#define _EXYNOS_THERMAL_TMU_DT_H
+
+#define TYPE_ONE_POINT_TRIMMING 0
+#define TYPE_ONE_POINT_TRIMMING_25 1
+#define TYPE_ONE_POINT_TRIMMING_85 2
+#define TYPE_TWO_POINT_TRIMMING 3
+#define TYPE_NONE 4
+
+#define SOC_ARCH_EXYNOS3250 1
+#define SOC_ARCH_EXYNOS4210 2
+#define SOC_ARCH_EXYNOS4412 3
+#define SOC_ARCH_EXYNOS5250 4
+#define SOC_ARCH_EXYNOS5260 5
+#define SOC_ARCH_EXYNOS5420_TRIMINFO 6
+#define SOC_ARCH_EXYNOS5420 7
+#define SOC_ARCH_EXYNOS5440 8
+
+#endif /* _EXYNOS_THERMAL_TMU_DT_H */
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 07/21] thermal: dts: trats: Enable TMU on the Exynos4210 trats device
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

The thermal IP block (Thermal Management Unit) called TMU has been enabled
in this device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4210-trats.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index f516da9..b59019c 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -424,6 +424,10 @@
 		status = "okay";
 	};
 
+	tmu@100C0000 {
+		status = "okay";
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 07/21] thermal: dts: trats: Enable TMU on the Exynos4210 trats device
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

The thermal IP block (Thermal Management Unit) called TMU has been enabled
in this device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4210-trats.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index f516da9..b59019c 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -424,6 +424,10 @@
 		status = "okay";
 	};
 
+	tmu at 100C0000 {
+		status = "okay";
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 08/21] thermal: dts: exynos: Adding LD010 regulator node necessary for TMU on Odroid U3 board
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index adadaf9..5364f1a 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -209,6 +209,13 @@
 					regulator-always-on;
 				};
 
+				ldo10_reg: LDO10 {
+					regulator-name = "VDD18_MIPIHSI_1.8V";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <1800000>;
+					regulator-always-on;
+				};
+
 				ldo11_reg: LDO11 {
 					regulator-name = "VDD18_ABB1_1.8V";
 					regulator-min-microvolt = <1800000>;
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 08/21] thermal: dts: exynos: Adding LD010 regulator node necessary for TMU on Odroid U3 board
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index adadaf9..5364f1a 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -209,6 +209,13 @@
 					regulator-always-on;
 				};
 
+				ldo10_reg: LDO10 {
+					regulator-name = "VDD18_MIPIHSI_1.8V";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <1800000>;
+					regulator-always-on;
+				};
+
 				ldo11_reg: LDO11 {
 					regulator-name = "VDD18_ABB1_1.8V";
 					regulator-min-microvolt = <1800000>;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 09/21] thermal: dts: Provide bindings and enable TMU at Exynos4x12 devices
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This commit adds necessary bindings for enabling TMU IP block on the
Exynos4412 Odroid U3 device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi |  5 +++++
 arch/arm/boot/dts/exynos4x12.dtsi               | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 5364f1a..5d4ecc3 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -374,6 +374,11 @@
 	ehci: ehci@12580000 {
 		status = "okay";
 	};
+
+	tmu@100C0000 {
+		vtmu-supply = <&ldo10_reg>;
+		status = "okay";
+	};
 };
 
 &pinctrl_1 {
diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi
index 861bb91..c12890c 100644
--- a/arch/arm/boot/dts/exynos4x12.dtsi
+++ b/arch/arm/boot/dts/exynos4x12.dtsi
@@ -271,4 +271,14 @@
 		compatible = "samsung,exynos4x12-usb2-phy";
 		samsung,sysreg-phandle = <&sys_reg>;
 	};
+
+	tmu@100C0000 {
+		compatible = "samsung,exynos4412-tmu";
+		interrupt-parent = <&combiner>;
+		reg = <0x100C0000 0x100>;
+		interrupts = <2 4>;
+		clocks = <&clock 383>;
+		clock-names = "tmu_apbif";
+		status = "disabled";
+	};
 };
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 09/21] thermal: dts: Provide bindings and enable TMU at Exynos4x12 devices
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

This commit adds necessary bindings for enabling TMU IP block on the
Exynos4412 Odroid U3 device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi |  5 +++++
 arch/arm/boot/dts/exynos4x12.dtsi               | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 5364f1a..5d4ecc3 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -374,6 +374,11 @@
 	ehci: ehci at 12580000 {
 		status = "okay";
 	};
+
+	tmu at 100C0000 {
+		vtmu-supply = <&ldo10_reg>;
+		status = "okay";
+	};
 };
 
 &pinctrl_1 {
diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi
index 861bb91..c12890c 100644
--- a/arch/arm/boot/dts/exynos4x12.dtsi
+++ b/arch/arm/boot/dts/exynos4x12.dtsi
@@ -271,4 +271,14 @@
 		compatible = "samsung,exynos4x12-usb2-phy";
 		samsung,sysreg-phandle = <&sys_reg>;
 	};
+
+	tmu at 100C0000 {
+		compatible = "samsung,exynos4412-tmu";
+		interrupt-parent = <&combiner>;
+		reg = <0x100C0000 0x100>;
+		interrupts = <2 4>;
+		clocks = <&clock 383>;
+		clock-names = "tmu_apbif";
+		status = "disabled";
+	};
 };
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 10/21] thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu cooling functionality
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Presented patch aims to move data necessary for correct CPU cooling device
configuration from exynos_tmu_data.c to device tree.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4210-trats.dts          | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4210.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos4212.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4412.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos5250.dtsi               | 20 +++++++++++++++++++-
 6 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index b59019c..d9dd9a7 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -428,6 +428,21 @@
 		status = "okay";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				    /* Corresponds to 800MHz at freq_table */
+				    cooling-device = <&cpu0 2 2>;
+				};
+				map1 {
+				   /* Corresponds to 200MHz at freq_table */
+				   cooling-device = <&cpu0 4 4>;
+			       };
+		       };
+		};
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index 477d455..10e8915 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -45,10 +45,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@0 {
+		cpu0: cpu@0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0x900>;
+			cooling-min-level = <4>;
+			cooling-max-level = <2>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@1 {
diff --git a/arch/arm/boot/dts/exynos4212.dtsi b/arch/arm/boot/dts/exynos4212.dtsi
index 484a2da..6405954 100644
--- a/arch/arm/boot/dts/exynos4212.dtsi
+++ b/arch/arm/boot/dts/exynos4212.dtsi
@@ -26,10 +26,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@0 {
+		cpu0: cpu@0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@1 {
diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 5d4ecc3..28e7a4c 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -379,6 +379,21 @@
 		vtmu-supply = <&ldo10_reg>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				    /* Corresponds to 800MHz at freq_table */
+				    cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				   /* Corresponds to 200MHz at freq_table */
+				   cooling-device = <&cpu0 13 13>;
+			       };
+		       };
+		};
+	};
 };
 
 &pinctrl_1 {
diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
index 529fd13..9ed8925 100644
--- a/arch/arm/boot/dts/exynos4412.dtsi
+++ b/arch/arm/boot/dts/exynos4412.dtsi
@@ -26,10 +26,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@0 {
+		cpu0: cpu@0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@1 {
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index 492e1ef..c322fb9 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -58,11 +58,14 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@0 {
+		cpu0: cpu@0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a15";
 			reg = <0>;
 			clock-frequency = <1700000000>;
+			cooling-min-level = <15>;
+			cooling-max-level = <9>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 		cpu@1 {
 			device_type = "cpu";
@@ -241,6 +244,21 @@
 		clock-names = "tmu_apbif";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				    /* Corresponds to 800MHz at freq_table */
+				    cooling-device = <&cpu0 9 9>;
+				};
+				map1 {
+				   /* Corresponds to 200MHz at freq_table */
+				   cooling-device = <&cpu0 15 15>;
+			       };
+		       };
+		};
+	};
+
 	serial@12C00000 {
 		clocks = <&clock CLK_UART0>, <&clock CLK_SCLK_UART0>;
 		clock-names = "uart", "clk_uart_baud0";
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 10/21] thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu cooling functionality
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

Presented patch aims to move data necessary for correct CPU cooling device
configuration from exynos_tmu_data.c to device tree.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4210-trats.dts          | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4210.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos4212.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4412.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos5250.dtsi               | 20 +++++++++++++++++++-
 6 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index b59019c..d9dd9a7 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -428,6 +428,21 @@
 		status = "okay";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				    /* Corresponds to 800MHz at freq_table */
+				    cooling-device = <&cpu0 2 2>;
+				};
+				map1 {
+				   /* Corresponds to 200MHz at freq_table */
+				   cooling-device = <&cpu0 4 4>;
+			       };
+		       };
+		};
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index 477d455..10e8915 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -45,10 +45,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu at 0 {
+		cpu0: cpu at 0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0x900>;
+			cooling-min-level = <4>;
+			cooling-max-level = <2>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu at 1 {
diff --git a/arch/arm/boot/dts/exynos4212.dtsi b/arch/arm/boot/dts/exynos4212.dtsi
index 484a2da..6405954 100644
--- a/arch/arm/boot/dts/exynos4212.dtsi
+++ b/arch/arm/boot/dts/exynos4212.dtsi
@@ -26,10 +26,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu at 0 {
+		cpu0: cpu at 0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu at 1 {
diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 5d4ecc3..28e7a4c 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -379,6 +379,21 @@
 		vtmu-supply = <&ldo10_reg>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				    /* Corresponds to 800MHz at freq_table */
+				    cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				   /* Corresponds to 200MHz at freq_table */
+				   cooling-device = <&cpu0 13 13>;
+			       };
+		       };
+		};
+	};
 };
 
 &pinctrl_1 {
diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
index 529fd13..9ed8925 100644
--- a/arch/arm/boot/dts/exynos4412.dtsi
+++ b/arch/arm/boot/dts/exynos4412.dtsi
@@ -26,10 +26,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu at 0 {
+		cpu0: cpu at 0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu at 1 {
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index 492e1ef..c322fb9 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -58,11 +58,14 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu at 0 {
+		cpu0: cpu at 0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a15";
 			reg = <0>;
 			clock-frequency = <1700000000>;
+			cooling-min-level = <15>;
+			cooling-max-level = <9>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 		cpu at 1 {
 			device_type = "cpu";
@@ -241,6 +244,21 @@
 		clock-names = "tmu_apbif";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				    /* Corresponds to 800MHz at freq_table */
+				    cooling-device = <&cpu0 9 9>;
+				};
+				map1 {
+				   /* Corresponds to 200MHz at freq_table */
+				   cooling-device = <&cpu0 15 15>;
+			       };
+		       };
+		};
+	};
+
 	serial at 12C00000 {
 		clocks = <&clock CLK_UART0>, <&clock CLK_SCLK_UART0>;
 		clock-names = "uart", "clk_uart_baud0";
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 11/21] thermal: cpu_cooling: Modify exynos thermal code to use device tree for cpu cooling configuration
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Up till now exynos_tmu_data.c was used for storing CPU cooling configuration
data. Now the Exynos thermal core code uses device tree to get this data.
For this purpose generic thermal code for configuring CPU cooling was
used.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/cpufreq/exynos-cpufreq.c                |  23 ++++-
 drivers/thermal/samsung/exynos_thermal_common.c | 122 ++++++++++++++----------
 drivers/thermal/samsung/exynos_tmu.c            |   7 --
 drivers/thermal/samsung/exynos_tmu.h            |   5 -
 drivers/thermal/samsung/exynos_tmu_data.c       |  42 +-------
 5 files changed, 94 insertions(+), 105 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 1e0ec57..fdedb8d 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -18,10 +18,13 @@
 #include <linux/cpufreq.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/cpu_cooling.h>
+#include <linux/cpu.h>
 
 #include "exynos-cpufreq.h"
 
 static struct exynos_dvfs_info *exynos_info;
+static struct thermal_cooling_device *cdev;
 static struct regulator *arm_regulator;
 static unsigned int locking_frequency;
 
@@ -156,6 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
+	struct device_node *np;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -198,9 +202,24 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	/* Done here as we want to capture boot frequency */
 	locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;
 
-	if (!cpufreq_register_driver(&exynos_driver))
-		return 0;
+	if (cpufreq_register_driver(&exynos_driver))
+		goto err;
 
+	np = of_find_node_by_path("/cpus/cpu@0");
+	if (!np) {
+		pr_err("failed to find cpu0 node\n");
+		return -ENOENT;
+	}
+	if (of_find_property(np, "#cooling-cells", NULL)) {
+		cdev = of_cpufreq_cooling_register(np, cpu_present_mask);
+		if (IS_ERR(cdev))
+			pr_err("running cpufreq without cooling device: %ld\n",
+			       PTR_ERR(cdev));
+	}
+	of_node_put(np);
+
+	return 0;
+ err:
 	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
 	regulator_put(arm_regulator);
 err_vdd_arm:
diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 3f5ad25..c306de5 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -133,47 +133,62 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
 static int exynos_bind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size, level;
-	struct freq_clip_table *tab_ptr, *clip_data;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
+	struct of_phandle_args cooling_spec;
+	unsigned long max, state = 0;
+	int ret = 0, i = 0;
 
-	tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data;
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_ptr == NULL || tab_size == 0)
+	/*
+	 * Below code is necessary to skip binding when cpufreq's
+	 * frequency table is not yet initialized.
+	 */
+	cdev->ops->get_max_state(cdev, &state);
+	if (!state && !th_zone->cool_dev_size) {
+		th_zone->cool_dev_size = 1;
+		th_zone->cool_dev[0] = cdev;
+		th_zone->bind = false;
 		return 0;
+	}
 
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
 
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
+	child = of_get_child_by_name(np, "cooling-maps");
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		clip_data = (struct freq_clip_table *)&(tab_ptr[i]);
-		level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max);
-		if (level == THERMAL_CSTATE_INVALID)
-			return 0;
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-								level, 0)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = true;
-			break;
-		default:
+	for_each_child_of_node(child, gchild) {
+		ret = of_parse_phandle_with_args(gchild, "cooling-device",
+						 "#cooling-cells",
+						 0, &cooling_spec);
+		if (ret < 0) {
+			pr_err("missing cooling_device property\n");
+			goto end;
+		}
+
+		if (cooling_spec.args_count < 2) {
 			ret = -EINVAL;
+			goto end;
 		}
+
+		max = cooling_spec.args[0];
+		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
+						     max, 0)) {
+			dev_err(data->dev,
+				"thermal error unbinding cdev inst=%d\n", i);
+
+			ret = -EINVAL;
+			goto end;
+		}
+		i++;
 	}
+	th_zone->bind = true;
+end:
+	of_node_put(child);
+	of_node_put(np);
 
 	return ret;
 }
@@ -182,16 +197,12 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 static int exynos_unbind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size;
+	int ret = 0, i;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
 
-	if (th_zone->bind == false)
-		return 0;
-
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_size == 0)
+	if (th_zone->bind == false || !th_zone->cool_dev_size)
 		return 0;
 
 	/* find the cooling device registered*/
@@ -203,23 +214,30 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
 	if (i == th_zone->cool_dev_size)
 		return 0;
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_unbind_cooling_device(thermal, i,
-								cdev)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = false;
-			break;
-		default:
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
+
+	child = of_get_child_by_name(np, "cooling-maps");
+
+	i = 0;
+	for_each_child_of_node(child, gchild) {
+		if (thermal_zone_unbind_cooling_device(thermal, i,
+						       cdev)) {
+			dev_err(data->dev,
+				"error unbinding cdev inst=%d\n", i);
 			ret = -EINVAL;
+			goto end;
 		}
+		i++;
 	}
+	th_zone->bind = false;
+end:
+	of_node_put(child);
+	of_node_put(np);
+
 	return ret;
 }
 
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 2f55daa..1d6b1cb 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -937,13 +937,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 
 	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
 
-	sensor_conf->cooling_data.freq_clip_count = pdata->freq_tab_count;
-	for (i = 0; i < pdata->freq_tab_count; i++) {
-		sensor_conf->cooling_data.freq_data[i].freq_clip_max =
-					pdata->freq_tab[i].freq_clip_max;
-		sensor_conf->cooling_data.freq_data[i].temp_level =
-					pdata->freq_tab[i].temp_level;
-	}
 	sensor_conf->dev = &pdev->dev;
 	/* Register the sensor with thermal management interface */
 	ret = exynos_register_thermal(sensor_conf);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index a089391..1e87f0f 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -73,9 +73,6 @@
  * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
- * @freq_clip_table: Table representing frequency reduction percentage.
- * @freq_tab_count: Count of the above table as frequency reduction may
- *	applicable to only some of the trigger levels.
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
@@ -100,8 +97,6 @@ struct exynos_tmu_platform_data {
 
 	u32 cal_type;
 	u32 type;
-	struct freq_clip_table freq_tab[4];
-	unsigned int freq_tab_count;
 };
 
 /**
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
index b239100..a993f3d 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -47,15 +47,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 		.first_point_trim = 25,
 		.second_point_trim = 85,
 		.default_temp_offset = 50,
-		.freq_tab[0] = {
-			.freq_clip_max = 800 * 1000,
-			.temp_level = 85,
-			},
-		.freq_tab[1] = {
-			.freq_clip_max = 200 * 1000,
-			.temp_level = 100,
-		},
-		.freq_tab_count = 2,
 		.type = SOC_ARCH_EXYNOS4210,
 		},
 	},
@@ -87,16 +78,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 800 * 1000, \
-		.temp_level = 70, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 400 * 1000, \
-		.temp_level = 95, \
-	}, \
-	.freq_tab_count = 2
+	.default_temp_offset = 50
 
 struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 	.tmu_data = {
@@ -133,16 +115,7 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 1400 * 1000, \
-		.temp_level = 70, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 400 * 1000, \
-		.temp_level = 95, \
-	}, \
-	.freq_tab_count = 2
+	.default_temp_offset = 50
 
 struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
 	.tmu_data = {
@@ -189,16 +162,7 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 800 * 1000, \
-		.temp_level = 85, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 200 * 1000, \
-		.temp_level = 103, \
-	}, \
-	.freq_tab_count = 2, \
+	.default_temp_offset = 50,
 
 #define EXYNOS5260_TMU_DATA \
 	__EXYNOS5260_TMU_DATA \
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 11/21] thermal: cpu_cooling: Modify exynos thermal code to use device tree for cpu cooling configuration
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

Up till now exynos_tmu_data.c was used for storing CPU cooling configuration
data. Now the Exynos thermal core code uses device tree to get this data.
For this purpose generic thermal code for configuring CPU cooling was
used.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/cpufreq/exynos-cpufreq.c                |  23 ++++-
 drivers/thermal/samsung/exynos_thermal_common.c | 122 ++++++++++++++----------
 drivers/thermal/samsung/exynos_tmu.c            |   7 --
 drivers/thermal/samsung/exynos_tmu.h            |   5 -
 drivers/thermal/samsung/exynos_tmu_data.c       |  42 +-------
 5 files changed, 94 insertions(+), 105 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 1e0ec57..fdedb8d 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -18,10 +18,13 @@
 #include <linux/cpufreq.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/cpu_cooling.h>
+#include <linux/cpu.h>
 
 #include "exynos-cpufreq.h"
 
 static struct exynos_dvfs_info *exynos_info;
+static struct thermal_cooling_device *cdev;
 static struct regulator *arm_regulator;
 static unsigned int locking_frequency;
 
@@ -156,6 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
+	struct device_node *np;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -198,9 +202,24 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	/* Done here as we want to capture boot frequency */
 	locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;
 
-	if (!cpufreq_register_driver(&exynos_driver))
-		return 0;
+	if (cpufreq_register_driver(&exynos_driver))
+		goto err;
 
+	np = of_find_node_by_path("/cpus/cpu at 0");
+	if (!np) {
+		pr_err("failed to find cpu0 node\n");
+		return -ENOENT;
+	}
+	if (of_find_property(np, "#cooling-cells", NULL)) {
+		cdev = of_cpufreq_cooling_register(np, cpu_present_mask);
+		if (IS_ERR(cdev))
+			pr_err("running cpufreq without cooling device: %ld\n",
+			       PTR_ERR(cdev));
+	}
+	of_node_put(np);
+
+	return 0;
+ err:
 	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
 	regulator_put(arm_regulator);
 err_vdd_arm:
diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 3f5ad25..c306de5 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -133,47 +133,62 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
 static int exynos_bind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size, level;
-	struct freq_clip_table *tab_ptr, *clip_data;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
+	struct of_phandle_args cooling_spec;
+	unsigned long max, state = 0;
+	int ret = 0, i = 0;
 
-	tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data;
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_ptr == NULL || tab_size == 0)
+	/*
+	 * Below code is necessary to skip binding when cpufreq's
+	 * frequency table is not yet initialized.
+	 */
+	cdev->ops->get_max_state(cdev, &state);
+	if (!state && !th_zone->cool_dev_size) {
+		th_zone->cool_dev_size = 1;
+		th_zone->cool_dev[0] = cdev;
+		th_zone->bind = false;
 		return 0;
+	}
 
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
 
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
+	child = of_get_child_by_name(np, "cooling-maps");
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		clip_data = (struct freq_clip_table *)&(tab_ptr[i]);
-		level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max);
-		if (level == THERMAL_CSTATE_INVALID)
-			return 0;
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-								level, 0)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = true;
-			break;
-		default:
+	for_each_child_of_node(child, gchild) {
+		ret = of_parse_phandle_with_args(gchild, "cooling-device",
+						 "#cooling-cells",
+						 0, &cooling_spec);
+		if (ret < 0) {
+			pr_err("missing cooling_device property\n");
+			goto end;
+		}
+
+		if (cooling_spec.args_count < 2) {
 			ret = -EINVAL;
+			goto end;
 		}
+
+		max = cooling_spec.args[0];
+		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
+						     max, 0)) {
+			dev_err(data->dev,
+				"thermal error unbinding cdev inst=%d\n", i);
+
+			ret = -EINVAL;
+			goto end;
+		}
+		i++;
 	}
+	th_zone->bind = true;
+end:
+	of_node_put(child);
+	of_node_put(np);
 
 	return ret;
 }
@@ -182,16 +197,12 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 static int exynos_unbind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size;
+	int ret = 0, i;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
 
-	if (th_zone->bind == false)
-		return 0;
-
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_size == 0)
+	if (th_zone->bind == false || !th_zone->cool_dev_size)
 		return 0;
 
 	/* find the cooling device registered*/
@@ -203,23 +214,30 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
 	if (i == th_zone->cool_dev_size)
 		return 0;
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_unbind_cooling_device(thermal, i,
-								cdev)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = false;
-			break;
-		default:
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
+
+	child = of_get_child_by_name(np, "cooling-maps");
+
+	i = 0;
+	for_each_child_of_node(child, gchild) {
+		if (thermal_zone_unbind_cooling_device(thermal, i,
+						       cdev)) {
+			dev_err(data->dev,
+				"error unbinding cdev inst=%d\n", i);
 			ret = -EINVAL;
+			goto end;
 		}
+		i++;
 	}
+	th_zone->bind = false;
+end:
+	of_node_put(child);
+	of_node_put(np);
+
 	return ret;
 }
 
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 2f55daa..1d6b1cb 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -937,13 +937,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 
 	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
 
-	sensor_conf->cooling_data.freq_clip_count = pdata->freq_tab_count;
-	for (i = 0; i < pdata->freq_tab_count; i++) {
-		sensor_conf->cooling_data.freq_data[i].freq_clip_max =
-					pdata->freq_tab[i].freq_clip_max;
-		sensor_conf->cooling_data.freq_data[i].temp_level =
-					pdata->freq_tab[i].temp_level;
-	}
 	sensor_conf->dev = &pdev->dev;
 	/* Register the sensor with thermal management interface */
 	ret = exynos_register_thermal(sensor_conf);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index a089391..1e87f0f 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -73,9 +73,6 @@
  * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
- * @freq_clip_table: Table representing frequency reduction percentage.
- * @freq_tab_count: Count of the above table as frequency reduction may
- *	applicable to only some of the trigger levels.
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
@@ -100,8 +97,6 @@ struct exynos_tmu_platform_data {
 
 	u32 cal_type;
 	u32 type;
-	struct freq_clip_table freq_tab[4];
-	unsigned int freq_tab_count;
 };
 
 /**
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
index b239100..a993f3d 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -47,15 +47,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 		.first_point_trim = 25,
 		.second_point_trim = 85,
 		.default_temp_offset = 50,
-		.freq_tab[0] = {
-			.freq_clip_max = 800 * 1000,
-			.temp_level = 85,
-			},
-		.freq_tab[1] = {
-			.freq_clip_max = 200 * 1000,
-			.temp_level = 100,
-		},
-		.freq_tab_count = 2,
 		.type = SOC_ARCH_EXYNOS4210,
 		},
 	},
@@ -87,16 +78,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 800 * 1000, \
-		.temp_level = 70, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 400 * 1000, \
-		.temp_level = 95, \
-	}, \
-	.freq_tab_count = 2
+	.default_temp_offset = 50
 
 struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 	.tmu_data = {
@@ -133,16 +115,7 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 1400 * 1000, \
-		.temp_level = 70, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 400 * 1000, \
-		.temp_level = 95, \
-	}, \
-	.freq_tab_count = 2
+	.default_temp_offset = 50
 
 struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
 	.tmu_data = {
@@ -189,16 +162,7 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 800 * 1000, \
-		.temp_level = 85, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 200 * 1000, \
-		.temp_level = 103, \
-	}, \
-	.freq_tab_count = 2, \
+	.default_temp_offset = 50,
 
 #define EXYNOS5260_TMU_DATA \
 	__EXYNOS5260_TMU_DATA \
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 12/21] thermal: exynos: dts: Add default definition for the TMU sensor
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Exynos 4 and 5 family of SoCs uses almost identical TMU sensor to measure the
on chip temperature. Hence it is possible to group TMU configuration parameters
in one dts include file.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi | 24 +++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi

diff --git a/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
new file mode 100644
index 0000000..ee6d8bb
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
@@ -0,0 +1,24 @@
+/*
+ * Device tree sources for Exynos4412 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+gain = <8>;
+reference_voltage = <16>;
+noise_cancel_mode = <4>;
+efuse_value = <55>;
+min_efuse_value = <40>;
+max_efuse_value = <100>;
+first_point_trim = <25>;
+second_point_trim = <85>;
+default_temp_offset = <50>;
+cal_type = <TYPE_ONE_POINT_TRIMMING>;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 12/21] thermal: exynos: dts: Add default definition for the TMU sensor
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

Exynos 4 and 5 family of SoCs uses almost identical TMU sensor to measure the
on chip temperature. Hence it is possible to group TMU configuration parameters
in one dts include file.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi | 24 +++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi

diff --git a/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
new file mode 100644
index 0000000..ee6d8bb
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
@@ -0,0 +1,24 @@
+/*
+ * Device tree sources for Exynos4412 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+gain = <8>;
+reference_voltage = <16>;
+noise_cancel_mode = <4>;
+efuse_value = <55>;
+min_efuse_value = <40>;
+max_efuse_value = <100>;
+first_point_trim = <25>;
+second_point_trim = <85>;
+default_temp_offset = <50>;
+cal_type = <TYPE_ONE_POINT_TRIMMING>;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 13/21] thermal: dts: Default trip points definition for Exynos5420 SoCs
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This code groups in one place default settings of trip points. It is used
in SoCs with multiple instances of TMU sensor.

Separate device tree file prevents from multiple copying of the same data.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos5420-trip-points.dtsi | 35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi

diff --git a/arch/arm/boot/dts/exynos5420-trip-points.dtsi b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
new file mode 100644
index 0000000..09d6c56
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
@@ -0,0 +1,35 @@
+/*
+ * Device tree sources for default Exynos 5420 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <85000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-1 {
+		temperature = <103000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-2 {
+		temperature = <110000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1200000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 13/21] thermal: dts: Default trip points definition for Exynos5420 SoCs
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

This code groups in one place default settings of trip points. It is used
in SoCs with multiple instances of TMU sensor.

Separate device tree file prevents from multiple copying of the same data.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos5420-trip-points.dtsi | 35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi

diff --git a/arch/arm/boot/dts/exynos5420-trip-points.dtsi b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
new file mode 100644
index 0000000..09d6c56
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
@@ -0,0 +1,35 @@
+/*
+ * Device tree sources for default Exynos 5420 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <85000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-1 {
+		temperature = <103000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-2 {
+		temperature = <110000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1200000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 14/21] thermal: exynos: dts: Define default thermal-zones for Exynos4
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Trip points corresponding to the one defined in the exynos_tmu_data.c
for Exynos4 have been included.
This thermal-zones attribute is afterwards reused for Exynos4210, Exynos4412
and Exynos5250.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi | 52 ++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi

diff --git a/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
new file mode 100644
index 0000000..506600a
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
@@ -0,0 +1,52 @@
+/*
+ * Device tree sources for Exynos4 thermal zone
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal.h>
+
+/ {
+  thermal-zones {
+	cpu_thermal: cpu-thermal {
+		thermal-sensors = <&tmu 0>;
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		trips {
+			cpu_alert0: cpu-alert-0 {
+				temperature = <70000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert1: cpu-alert-1 {
+				temperature = <95000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert2: cpu-alert-2 {
+				temperature = <110000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_crit0: cpu-crit-0 {
+				temperature = <120000>; /* millicelsius */
+				hysteresis = <0>; /* millicelsius */
+				type = "critical";
+			};
+		};
+		cooling-maps {
+			map0 {
+			    trip = <&cpu_alert0>;
+			};
+			map1 {
+			    trip = <&cpu_alert1>;
+			};
+		};
+	};
+  };
+};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 14/21] thermal: exynos: dts: Define default thermal-zones for Exynos4
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

Trip points corresponding to the one defined in the exynos_tmu_data.c
for Exynos4 have been included.
This thermal-zones attribute is afterwards reused for Exynos4210, Exynos4412
and Exynos5250.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi | 52 ++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi

diff --git a/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
new file mode 100644
index 0000000..506600a
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
@@ -0,0 +1,52 @@
+/*
+ * Device tree sources for Exynos4 thermal zone
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal.h>
+
+/ {
+  thermal-zones {
+	cpu_thermal: cpu-thermal {
+		thermal-sensors = <&tmu 0>;
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		trips {
+			cpu_alert0: cpu-alert-0 {
+				temperature = <70000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert1: cpu-alert-1 {
+				temperature = <95000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert2: cpu-alert-2 {
+				temperature = <110000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_crit0: cpu-crit-0 {
+				temperature = <120000>; /* millicelsius */
+				hysteresis = <0>; /* millicelsius */
+				type = "critical";
+			};
+		};
+		cooling-maps {
+			map0 {
+			    trip = <&cpu_alert0>;
+			};
+			map1 {
+			    trip = <&cpu_alert1>;
+			};
+		};
+	};
+  };
+};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 15/21] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This commit provides information about Exynos5440 device configuration.
Previously this information was available in exynos_tmu_data.c file.
Now it is available in the device tree.
Such approach allows reusing some common code for thermal.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi | 25 +++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi     | 25 +++++++++++++++++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi

diff --git a/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
new file mode 100644
index 0000000..336cb12
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
@@ -0,0 +1,25 @@
+/*
+ * Device tree sources for Exynos5440 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+gain = <5>;
+reference_voltage = <16>;
+noise_cancel_mode = <4>;
+efuse_value = <0x5d2d>;
+min_efuse_value = <16>;
+max_efuse_value = <76>;
+first_point_trim = <25>;
+second_point_trim = <70>;
+default_temp_offset = <25>;
+cal_type = <TYPE_ONE_POINT_TRIMMING>;
+type = <SOC_ARCH_EXYNOS5440>;
diff --git a/arch/arm/boot/dts/exynos5440-trip-points.dtsi b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
new file mode 100644
index 0000000..48adfa8
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
@@ -0,0 +1,25 @@
+/*
+ * Device tree sources for default Exynos5440 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <100000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1050000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 15/21] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

This commit provides information about Exynos5440 device configuration.
Previously this information was available in exynos_tmu_data.c file.
Now it is available in the device tree.
Such approach allows reusing some common code for thermal.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi | 25 +++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi     | 25 +++++++++++++++++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi

diff --git a/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
new file mode 100644
index 0000000..336cb12
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
@@ -0,0 +1,25 @@
+/*
+ * Device tree sources for Exynos5440 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+gain = <5>;
+reference_voltage = <16>;
+noise_cancel_mode = <4>;
+efuse_value = <0x5d2d>;
+min_efuse_value = <16>;
+max_efuse_value = <76>;
+first_point_trim = <25>;
+second_point_trim = <70>;
+default_temp_offset = <25>;
+cal_type = <TYPE_ONE_POINT_TRIMMING>;
+type = <SOC_ARCH_EXYNOS5440>;
diff --git a/arch/arm/boot/dts/exynos5440-trip-points.dtsi b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
new file mode 100644
index 0000000..48adfa8
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
@@ -0,0 +1,25 @@
+/*
+ * Device tree sources for default Exynos5440 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <100000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1050000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 16/21] thermal: exynos: dts: Provide device tree bindings identical to one in exynos_tmu_data.c
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Presented device tree bindings provide data already hardcoded in the
exynos_tmu_data.c file.
After this commit, it should be possible to reuse common thermal core
framework in Exynos SoCs.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4.dtsi    |  5 +++++
 arch/arm/boot/dts/exynos4210.dtsi | 23 ++++++++++++++++++++++-
 arch/arm/boot/dts/exynos4x12.dtsi |  3 +++
 arch/arm/boot/dts/exynos5250.dtsi |  7 +++++--
 arch/arm/boot/dts/exynos5420.dtsi | 33 +++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440.dtsi | 18 ++++++++++++++++++
 6 files changed, 86 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index e0278ec..1735bb3 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -21,6 +21,7 @@
 
 #include <dt-bindings/clock/exynos4.h>
 #include <dt-bindings/clock/exynos-audss-clk.h>
+#include <dt-bindings/thermal/thermal_exynos.h>
 #include "skeleton.dtsi"
 
 / {
@@ -645,4 +646,8 @@
 		samsung,sysreg = <&sys_reg>;
 		status = "disabled";
 	};
+
+	tmu: tmu@100C0000 {
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+	};
 };
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index 10e8915..1c52681 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -21,6 +21,8 @@
 
 #include "exynos4.dtsi"
 #include "exynos4210-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 / {
 	compatible = "samsung,exynos4210", "samsung,exynos4";
@@ -146,16 +148,35 @@
 		reg = <0x03860000 0x1000>;
 	};
 
-	tmu@100C0000 {
+	tmu: tmu@100C0000 {
 		compatible = "samsung,exynos4210-tmu";
 		interrupt-parent = <&combiner>;
 		reg = <0x100C0000 0x100>;
 		interrupts = <2 4>;
 		clocks = <&clock CLK_TMU_APBIF>;
 		clock-names = "tmu_apbif";
+		gain = <15>;
+		reference_voltage = <7>;
+		type = <SOC_ARCH_EXYNOS4210>;
 		status = "disabled";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			trips {
+			      cpu_alert0: cpu-alert-0 {
+				      temperature = <85000>; /* millicelsius */
+			      };
+			      cpu_alert1: cpu-alert-1 {
+				      temperature = <100000>; /* millicelsius */
+			      };
+			      cpu_alert2: cpu-alert-2 {
+				      temperature = <110000>; /* millicelsius */
+			      };
+			};
+		};
+	};
+
 	g2d@12800000 {
 		compatible = "samsung,s5pv210-g2d";
 		reg = <0x12800000 0x1000>;
diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi
index c12890c..a7dda7e 100644
--- a/arch/arm/boot/dts/exynos4x12.dtsi
+++ b/arch/arm/boot/dts/exynos4x12.dtsi
@@ -19,6 +19,8 @@
 
 #include "exynos4.dtsi"
 #include "exynos4x12-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 / {
 	aliases {
@@ -279,6 +281,7 @@
 		interrupts = <2 4>;
 		clocks = <&clock 383>;
 		clock-names = "tmu_apbif";
+		type = <SOC_ARCH_EXYNOS4412>;
 		status = "disabled";
 	};
 };
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index c322fb9..e71ec78 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -20,8 +20,9 @@
 #include <dt-bindings/clock/exynos5250.h>
 #include "exynos5.dtsi"
 #include "exynos5250-pinctrl.dtsi"
-
+#include "exynos4-cpu-thermal.dtsi"
 #include <dt-bindings/clock/exynos-audss-clk.h>
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 / {
 	compatible = "samsung,exynos5250", "samsung,exynos5";
@@ -236,12 +237,14 @@
 		status = "disabled";
 	};
 
-	tmu@10060000 {
+	tmu: tmu@10060000 {
 		compatible = "samsung,exynos5250-tmu";
 		reg = <0x10060000 0x100>;
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		type = <SOC_ARCH_EXYNOS5250>;
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	thermal-zones {
diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
index bfe056d..4bebc6f 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -756,6 +756,8 @@
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420>;
 	};
 
 	tmu_cpu1: tmu@10064000 {
@@ -764,6 +766,8 @@
 		interrupts = <0 183 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420>;
 	};
 
 	tmu_cpu2: tmu@10068000 {
@@ -772,6 +776,8 @@
 		interrupts = <0 184 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
 	};
 
 	tmu_cpu3: tmu@1006c000 {
@@ -780,6 +786,8 @@
 		interrupts = <0 185 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU_GPU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
 	};
 
 	tmu_gpu: tmu@100a0000 {
@@ -788,6 +796,31 @@
 		interrupts = <0 215 0>;
 		clocks = <&clock CLK_TMU_GPU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmu_cpu0>;
+			#include "exynos5420-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmu_cpu1>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmu_cpu2>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu3_thermal: cpu3-thermal {
+		       thermal-sensors = <&tmu_cpu3>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		gpu_thermal: gpu-thermal {
+		       thermal-sensors = <&tmu_gpu>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
 	};
 
         watchdog: watchdog@101D0000 {
diff --git a/arch/arm/boot/dts/exynos5440.dtsi b/arch/arm/boot/dts/exynos5440.dtsi
index 8f3373c..59d9416 100644
--- a/arch/arm/boot/dts/exynos5440.dtsi
+++ b/arch/arm/boot/dts/exynos5440.dtsi
@@ -219,6 +219,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_1: tmuctrl@16011C {
@@ -227,6 +228,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_2: tmuctrl@160120 {
@@ -235,6 +237,22 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmuctrl_0>;
+			#include "exynos5440-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmuctrl_1>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmuctrl_2>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
 	};
 
 	sata@210000 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 16/21] thermal: exynos: dts: Provide device tree bindings identical to one in exynos_tmu_data.c
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

Presented device tree bindings provide data already hardcoded in the
exynos_tmu_data.c file.
After this commit, it should be possible to reuse common thermal core
framework in Exynos SoCs.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4.dtsi    |  5 +++++
 arch/arm/boot/dts/exynos4210.dtsi | 23 ++++++++++++++++++++++-
 arch/arm/boot/dts/exynos4x12.dtsi |  3 +++
 arch/arm/boot/dts/exynos5250.dtsi |  7 +++++--
 arch/arm/boot/dts/exynos5420.dtsi | 33 +++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440.dtsi | 18 ++++++++++++++++++
 6 files changed, 86 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index e0278ec..1735bb3 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -21,6 +21,7 @@
 
 #include <dt-bindings/clock/exynos4.h>
 #include <dt-bindings/clock/exynos-audss-clk.h>
+#include <dt-bindings/thermal/thermal_exynos.h>
 #include "skeleton.dtsi"
 
 / {
@@ -645,4 +646,8 @@
 		samsung,sysreg = <&sys_reg>;
 		status = "disabled";
 	};
+
+	tmu: tmu at 100C0000 {
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+	};
 };
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index 10e8915..1c52681 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -21,6 +21,8 @@
 
 #include "exynos4.dtsi"
 #include "exynos4210-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 / {
 	compatible = "samsung,exynos4210", "samsung,exynos4";
@@ -146,16 +148,35 @@
 		reg = <0x03860000 0x1000>;
 	};
 
-	tmu at 100C0000 {
+	tmu: tmu at 100C0000 {
 		compatible = "samsung,exynos4210-tmu";
 		interrupt-parent = <&combiner>;
 		reg = <0x100C0000 0x100>;
 		interrupts = <2 4>;
 		clocks = <&clock CLK_TMU_APBIF>;
 		clock-names = "tmu_apbif";
+		gain = <15>;
+		reference_voltage = <7>;
+		type = <SOC_ARCH_EXYNOS4210>;
 		status = "disabled";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			trips {
+			      cpu_alert0: cpu-alert-0 {
+				      temperature = <85000>; /* millicelsius */
+			      };
+			      cpu_alert1: cpu-alert-1 {
+				      temperature = <100000>; /* millicelsius */
+			      };
+			      cpu_alert2: cpu-alert-2 {
+				      temperature = <110000>; /* millicelsius */
+			      };
+			};
+		};
+	};
+
 	g2d at 12800000 {
 		compatible = "samsung,s5pv210-g2d";
 		reg = <0x12800000 0x1000>;
diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi
index c12890c..a7dda7e 100644
--- a/arch/arm/boot/dts/exynos4x12.dtsi
+++ b/arch/arm/boot/dts/exynos4x12.dtsi
@@ -19,6 +19,8 @@
 
 #include "exynos4.dtsi"
 #include "exynos4x12-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 / {
 	aliases {
@@ -279,6 +281,7 @@
 		interrupts = <2 4>;
 		clocks = <&clock 383>;
 		clock-names = "tmu_apbif";
+		type = <SOC_ARCH_EXYNOS4412>;
 		status = "disabled";
 	};
 };
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index c322fb9..e71ec78 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -20,8 +20,9 @@
 #include <dt-bindings/clock/exynos5250.h>
 #include "exynos5.dtsi"
 #include "exynos5250-pinctrl.dtsi"
-
+#include "exynos4-cpu-thermal.dtsi"
 #include <dt-bindings/clock/exynos-audss-clk.h>
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 / {
 	compatible = "samsung,exynos5250", "samsung,exynos5";
@@ -236,12 +237,14 @@
 		status = "disabled";
 	};
 
-	tmu at 10060000 {
+	tmu: tmu at 10060000 {
 		compatible = "samsung,exynos5250-tmu";
 		reg = <0x10060000 0x100>;
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		type = <SOC_ARCH_EXYNOS5250>;
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	thermal-zones {
diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
index bfe056d..4bebc6f 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -756,6 +756,8 @@
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420>;
 	};
 
 	tmu_cpu1: tmu at 10064000 {
@@ -764,6 +766,8 @@
 		interrupts = <0 183 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420>;
 	};
 
 	tmu_cpu2: tmu at 10068000 {
@@ -772,6 +776,8 @@
 		interrupts = <0 184 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
 	};
 
 	tmu_cpu3: tmu at 1006c000 {
@@ -780,6 +786,8 @@
 		interrupts = <0 185 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU_GPU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
 	};
 
 	tmu_gpu: tmu at 100a0000 {
@@ -788,6 +796,31 @@
 		interrupts = <0 215 0>;
 		clocks = <&clock CLK_TMU_GPU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmu_cpu0>;
+			#include "exynos5420-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmu_cpu1>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmu_cpu2>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu3_thermal: cpu3-thermal {
+		       thermal-sensors = <&tmu_cpu3>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		gpu_thermal: gpu-thermal {
+		       thermal-sensors = <&tmu_gpu>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
 	};
 
         watchdog: watchdog at 101D0000 {
diff --git a/arch/arm/boot/dts/exynos5440.dtsi b/arch/arm/boot/dts/exynos5440.dtsi
index 8f3373c..59d9416 100644
--- a/arch/arm/boot/dts/exynos5440.dtsi
+++ b/arch/arm/boot/dts/exynos5440.dtsi
@@ -219,6 +219,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_1: tmuctrl at 16011C {
@@ -227,6 +228,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_2: tmuctrl at 160120 {
@@ -235,6 +237,22 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmuctrl_0>;
+			#include "exynos5440-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmuctrl_1>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmuctrl_2>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
 	};
 
 	sata at 210000 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 17/21] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This patch brings support for providing configuration via device tree.
Previously, data hardcoded in the exynos_tmu_data.c file was used, which is
not scalable and error prone.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/samsung/Makefile     |   2 -
 drivers/thermal/samsung/exynos_tmu.c | 266 ++++++++++++++++++++---------------
 drivers/thermal/samsung/exynos_tmu.h |  51 -------
 3 files changed, 154 insertions(+), 165 deletions(-)

diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile
index c09d830..1e47d0d 100644
--- a/drivers/thermal/samsung/Makefile
+++ b/drivers/thermal/samsung/Makefile
@@ -3,5 +3,3 @@
 #
 obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_thermal.o
 exynos_thermal-y				:= exynos_tmu.o
-exynos_thermal-y				+= exynos_tmu_data.o
-exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+= exynos_thermal_common.o
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 1d6b1cb..e26042a 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -1,6 +1,10 @@
 /*
  * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
  *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
  *  Copyright (C) 2011 Samsung Electronics
  *  Donggeun Kim <dg77.kim@samsung.com>
  *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
@@ -31,8 +35,8 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 
-#include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
+#include "../thermal_core.h"
 
 /* Exynos generic registers */
 #define EXYNOS_TMU_REG_TRIMINFO		0x0
@@ -130,6 +134,7 @@
 #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
 #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
 
+#define MCELSIUS	1000
 /**
  * struct exynos_tmu_data : A structure to hold the private data of the TMU
 	driver
@@ -165,7 +170,8 @@ struct exynos_tmu_data {
 	struct clk *clk, *clk_sec;
 	u8 temp_error1, temp_error2;
 	struct regulator *regulator;
-	struct thermal_sensor_conf *reg_conf;
+	struct thermal_zone_device *tzd;
+
 	int (*tmu_initialize)(struct platform_device *pdev);
 	void (*tmu_control)(struct platform_device *pdev, bool on);
 	int (*tmu_read)(struct exynos_tmu_data *data);
@@ -174,6 +180,33 @@ struct exynos_tmu_data {
 	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
 };
 
+static void exynos_report_trigger(struct exynos_tmu_data *p)
+{
+	char data[10], *envp[] = { data, NULL };
+	struct thermal_zone_device *tz = p->tzd;
+	unsigned long temp;
+	unsigned int i;
+
+	if (!p) {
+		pr_err("Wrong temperature configuration data\n");
+		return;
+	}
+
+	thermal_zone_device_update(tz);
+
+	mutex_lock(&tz->lock);
+	/* Find the level for which trip happened */
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		tz->ops->get_trip_temp(tz, i, &temp);
+		if (tz->last_temperature < temp)
+			break;
+	}
+
+	snprintf(data, sizeof(data), "%u", i);
+	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
+	mutex_unlock(&tz->lock);
+}
+
 /*
  * TMU treats temperature as a mapped temperature code.
  * The temperature is converted differently depending on the calibration type.
@@ -249,16 +282,22 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
 
 static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling)
 {
-	struct exynos_tmu_platform_data *pdata = data->pdata;
-	int i;
+	struct thermal_zone_device *tz = data->tzd;
+	unsigned long temp, temp_hist;
+	int i, ret;
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
-		u8 temp = pdata->trigger_levels[i];
+	for (i = 0; i < of_thermal_get_non_crit_ntrips(tz); i++) {
+		ret = tz->ops->get_trip_temp(tz, i, &temp);
+		if (ret)
+			return 0;
 
-		if (falling)
-			temp -= pdata->threshold_falling;
-		else
+		temp /= MCELSIUS;
+		if (falling) {
+			tz->ops->get_trip_hyst(tz, i, &temp_hist);
+			temp -= (temp_hist / MCELSIUS);
+		} else {
 			threshold &= ~(0xff << 8 * i);
+		}
 
 		threshold |= temp_to_code(data, temp) << 8 * i;
 	}
@@ -320,9 +359,10 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 static int exynos4210_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
-	unsigned int status;
+	struct thermal_zone_device *tz = data->tzd;
 	int ret = 0, threshold_code, i;
+	unsigned long reference, temp;
+	unsigned int status;
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -333,12 +373,21 @@ static int exynos4210_tmu_initialize(struct platform_device *pdev)
 	sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));
 
 	/* Write temperature code for threshold */
-	threshold_code = temp_to_code(data, pdata->threshold);
+	tz->ops->get_trip_temp(tz, 0, &reference);
+	reference /= MCELSIUS;
+	threshold_code = temp_to_code(data, reference);
+	if (threshold_code < 0) {
+		ret = threshold_code;
+		goto out;
+	}
 	writeb(threshold_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
-		writeb(pdata->trigger_levels[i], data->base +
+	for (i = 0; i < of_thermal_get_non_crit_ntrips(tz); i++) {
+		tz->ops->get_trip_temp(tz, i, &temp);
+		temp /= MCELSIUS;
+		writeb(temp - reference, data->base +
 		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
+	}
 
 	writel(EXYNOS4210_TMU_TRIG_LEVEL_MASK,
 	       data->base + EXYNOS_TMU_REG_INTCLEAR);
@@ -349,9 +398,9 @@ out:
 static int exynos4412_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
 	unsigned int status, trim_info, con, ctrl, rising_threshold;
 	int ret = 0, threshold_code, i;
+	unsigned long crit_temp = 0;
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -401,9 +450,9 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
 		       data->base + EXYNOS_TMU_REG_INTCLEAR);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
+	i = of_thermal_get_non_crit_ntrips(data->tzd);
+	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp)) {
+		threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
 		/* 1-4 level to be assigned in th0 reg */
 		rising_threshold &= ~(0xff << 8 * i);
 		rising_threshold |= threshold_code << 8 * i;
@@ -419,9 +468,9 @@ out:
 static int exynos5440_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
 	unsigned int trim_info = 0, con, rising_threshold;
-	int ret = 0, threshold_code, i;
+	int ret = 0, threshold_code;
+	unsigned long crit_temp = 0;
 
 	/*
 	 * For exynos5440 soc triminfo value is swapped between TMU0 and
@@ -452,9 +501,8 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 	       data->base + EXYNOS5440_TMU_S0_7_IRQ);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
+	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp)) {
+		threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
 		/* 5th level to be assigned in th2 reg */
 		rising_threshold =
 			threshold_code << EXYNOS5440_TMU_TH_RISE4_SHIFT;
@@ -472,7 +520,7 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
@@ -480,10 +528,11 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS_TMU_INTEN_RISE0_SHIFT;
+			of_thermal_is_trip_en(tz, 3) << EXYNOS_TMU_INTEN_RISE3_SHIFT |
+			of_thermal_is_trip_en(tz, 2) << EXYNOS_TMU_INTEN_RISE2_SHIFT |
+			of_thermal_is_trip_en(tz, 1) << EXYNOS_TMU_INTEN_RISE1_SHIFT |
+			of_thermal_is_trip_en(tz, 0) << EXYNOS_TMU_INTEN_RISE0_SHIFT;
+
 		if (data->soc != SOC_ARCH_EXYNOS4210)
 			interrupt_en |=
 				interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
@@ -498,7 +547,7 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS5440_TMU_S0_7_CTRL));
@@ -506,10 +555,10 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
+			of_thermal_is_trip_en(tz, 3) << EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
+			of_thermal_is_trip_en(tz, 2) << EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
+			of_thermal_is_trip_en(tz, 1) << EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
+			of_thermal_is_trip_en(tz, 0) << EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
 		interrupt_en |= interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
 	} else {
 		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
@@ -519,19 +568,21 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL);
 }
 
-static int exynos_tmu_read(struct exynos_tmu_data *data)
+int exynos_get_temp(void *p, long *temp)
 {
-	int ret;
+	struct exynos_tmu_data *data = p;
+	if (!data)
+		return -EINVAL;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
-	ret = data->tmu_read(data);
-	if (ret >= 0)
-		ret = code_to_temp(data, ret);
+
+	*temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS;
+
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
 
-	return ret;
+	return 0;
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
@@ -643,7 +694,7 @@ static void exynos_tmu_work(struct work_struct *work)
 	if (!IS_ERR(data->clk_sec))
 		clk_disable(data->clk_sec);
 
-	exynos_report_trigger(data->reg_conf);
+	exynos_report_trigger(data);
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 	/* TODO: take action based on particular interrupt */
@@ -694,55 +745,63 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 static const struct of_device_id exynos_tmu_match[] = {
 	{
 		.compatible = "samsung,exynos3250-tmu",
-		.data = &exynos3250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4210-tmu",
-		.data = &exynos4210_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4412-tmu",
-		.data = &exynos4412_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5250-tmu",
-		.data = &exynos5250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5260-tmu",
-		.data = &exynos5260_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu-ext-triminfo",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5440-tmu",
-		.data = &exynos5440_default_tmu_data,
 	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 
-static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
-			struct platform_device *pdev, int id)
+static int exynos_of_sensor_conf(struct device_node *np,
+				 struct exynos_tmu_platform_data *pdata)
 {
-	struct  exynos_tmu_init_data *data_table;
-	struct exynos_tmu_platform_data *tmu_data;
-	const struct of_device_id *match;
-
-	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
-	if (!match)
-		return NULL;
-	data_table = (struct exynos_tmu_init_data *) match->data;
-	if (!data_table || id >= data_table->tmu_count)
-		return NULL;
-	tmu_data = data_table->tmu_data;
-	return (struct exynos_tmu_platform_data *) (tmu_data + id);
+	u32 value;
+	int ret;
+
+	of_node_get(np);
+
+	ret = of_property_read_u32(np, "gain", &value);
+	pdata->gain = (u8) value;
+	of_property_read_u32(np, "reference_voltage", &value);
+	pdata->reference_voltage = (u8) value;
+	of_property_read_u32(np, "noise_cancel_mode", &value);
+	pdata->noise_cancel_mode = (u8) value;;
+
+	of_property_read_u32(np, "efuse_value", &pdata->efuse_value);
+	of_property_read_u32(np, "min_efuse_value", &pdata->min_efuse_value);
+	of_property_read_u32(np, "max_efuse_value", &pdata->max_efuse_value);
+
+	of_property_read_u32(np, "first_point_trim", &value);
+	pdata->first_point_trim = (u8) value;
+	of_property_read_u32(np, "second_point_trim", &value);
+	pdata->second_point_trim = (u8) value;
+	of_property_read_u32(np, "default_temp_offset", &value);
+	pdata->default_temp_offset = (u8) value;
+
+	of_property_read_u32(np, "cal_type", &pdata->cal_type);
+	of_property_read_u32(np, "type", &pdata->type);
+
+	of_node_put(np);
+	return 0;
 }
 
 static int exynos_map_dt_data(struct platform_device *pdev)
@@ -792,12 +851,13 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 		return -EADDRNOTAVAIL;
 	}
 
-	pdata = exynos_get_driver_data(pdev, data->id);
-	if (!pdata) {
-		dev_err(&pdev->dev, "No platform init data supplied.\n");
-		return -ENODEV;
-	}
+	pdata = devm_kzalloc(&pdev->dev,
+			     sizeof(struct exynos_tmu_platform_data),
+			     GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
 
+	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
 	data->pdata = pdata;
 	data->soc = pdata->type;
 
@@ -857,10 +917,9 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 
 static int exynos_tmu_probe(struct platform_device *pdev)
 {
-	struct exynos_tmu_data *data;
 	struct exynos_tmu_platform_data *pdata;
-	struct thermal_sensor_conf *sensor_conf;
-	int ret, i;
+	struct exynos_tmu_data *data;
+	int ret;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
 					GFP_KERNEL);
@@ -870,9 +929,16 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, data);
 	mutex_init(&data->lock);
 
+	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
+						    exynos_get_temp, NULL,
+						    exynos_tmu_set_emulation);
+	if (IS_ERR(data->tzd)) {
+		pr_err("thermal: tz: %p ERROR\n", data->tzd);
+		return PTR_ERR(data->tzd);
+	}
 	ret = exynos_map_dt_data(pdev);
 	if (ret)
-		return ret;
+		goto err_sensor;
 
 	pdata = data->pdata;
 
@@ -881,20 +947,22 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
 	if (IS_ERR(data->clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
-		return  PTR_ERR(data->clk);
+		ret = PTR_ERR(data->clk);
+		goto err_sensor;
 	}
 
 	data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
 	if (IS_ERR(data->clk_sec)) {
 		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
 			dev_err(&pdev->dev, "Failed to get triminfo clock\n");
-			return PTR_ERR(data->clk_sec);
+			ret = PTR_ERR(data->clk_sec);
+			goto err_sensor;
 		}
 	} else {
 		ret = clk_prepare(data->clk_sec);
 		if (ret) {
 			dev_err(&pdev->dev, "Failed to get clock\n");
-			return ret;
+			goto err_sensor;
 		}
 	}
 
@@ -910,42 +978,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	exynos_tmu_control(pdev, true);
-
-	/* Allocate a structure to register with the exynos core thermal */
-	sensor_conf = devm_kzalloc(&pdev->dev,
-				sizeof(struct thermal_sensor_conf), GFP_KERNEL);
-	if (!sensor_conf) {
-		ret = -ENOMEM;
-		goto err_clk;
-	}
-	sprintf(sensor_conf->name, "therm_zone%d", data->id);
-	sensor_conf->read_temperature = (int (*)(void *))exynos_tmu_read;
-	sensor_conf->write_emul_temp =
-		(int (*)(void *, unsigned long))exynos_tmu_set_emulation;
-	sensor_conf->driver_data = data;
-	sensor_conf->trip_data.trip_count = pdata->trigger_enable[0] +
-			pdata->trigger_enable[1] + pdata->trigger_enable[2]+
-			pdata->trigger_enable[3];
-
-	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
-		sensor_conf->trip_data.trip_val[i] =
-			pdata->threshold + pdata->trigger_levels[i];
-		sensor_conf->trip_data.trip_type[i] =
-					pdata->trigger_type[i];
-	}
-
-	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
-
-	sensor_conf->dev = &pdev->dev;
-	/* Register the sensor with thermal management interface */
-	ret = exynos_register_thermal(sensor_conf);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to register thermal interface\n");
-		goto err_clk;
-	}
-	data->reg_conf = sensor_conf;
-
 	ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
 		IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
 	if (ret) {
@@ -953,21 +985,31 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
+	ret = exynos_tmu_initialize(pdev);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to initialize TMU\n");
+		goto err_clk;
+	}
+	exynos_tmu_control(pdev, true);
 	return 0;
+
 err_clk:
 	clk_unprepare(data->clk);
 err_clk_sec:
 	if (!IS_ERR(data->clk_sec))
 		clk_unprepare(data->clk_sec);
+err_sensor:
+	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
+
 	return ret;
 }
 
 static int exynos_tmu_remove(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	struct thermal_zone_device *tzd = data->tzd;
 
-	exynos_unregister_thermal(data->reg_conf);
-
+	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
 	exynos_tmu_control(pdev, false);
 
 	clk_unprepare(data->clk);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 1e87f0f..6f176ef 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -24,40 +24,10 @@
 #define _EXYNOS_TMU_H
 #include <linux/cpu_cooling.h>
 
-#include "exynos_thermal_common.h"
-
 #include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
- * @threshold: basic temperature for generating interrupt
- *	       25 <= threshold <= 125 [unit: degree Celsius]
- * @threshold_falling: differntial value for setting threshold
- *		       of temperature falling interrupt.
- * @trigger_levels: array for each interrupt levels
- *	[unit: degree Celsius]
- *	0: temperature for trigger_level0 interrupt
- *	   condition for trigger_level0 interrupt:
- *		current temperature > threshold + trigger_levels[0]
- *	1: temperature for trigger_level1 interrupt
- *	   condition for trigger_level1 interrupt:
- *		current temperature > threshold + trigger_levels[1]
- *	2: temperature for trigger_level2 interrupt
- *	   condition for trigger_level2 interrupt:
- *		current temperature > threshold + trigger_levels[2]
- *	3: temperature for trigger_level3 interrupt
- *	   condition for trigger_level3 interrupt:
- *		current temperature > threshold + trigger_levels[3]
- * @trigger_type: defines the type of trigger. Possible values are,
- *	THROTTLE_ACTIVE trigger type
- *	THROTTLE_PASSIVE trigger type
- *	SW_TRIP trigger type
- *	HW_TRIP
- * @trigger_enable[]: array to denote which trigger levels are enabled.
- *	1 = enable trigger_level[] interrupt,
- *	0 = disable trigger_level[] interrupt
- * @max_trigger_level: max trigger level supported by the TMU
- * @non_hw_trigger_levels: number of defined non-hardware trigger levels
  * @gain: gain of amplifier in the positive-TC generator block
  *	0 < gain <= 15
  * @reference_voltage: reference voltage of amplifier
@@ -69,21 +39,12 @@
  * @efuse_value: platform defined fuse value
  * @min_efuse_value: minimum valid trimming data
  * @max_efuse_value: maximum valid trimming data
- * @first_point_trim: temp value of the first point trimming
- * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
 struct exynos_tmu_platform_data {
-	u8 threshold;
-	u8 threshold_falling;
-	u8 trigger_levels[MAX_TRIP_COUNT];
-	enum trigger_type trigger_type[MAX_TRIP_COUNT];
-	bool trigger_enable[MAX_TRIP_COUNT];
-	u8 max_trigger_level;
-	u8 non_hw_trigger_levels;
 	u8 gain;
 	u8 reference_voltage;
 	u8 noise_cancel_mode;
@@ -99,18 +60,6 @@ struct exynos_tmu_platform_data {
 	u32 type;
 };
 
-/**
- * struct exynos_tmu_init_data
- * @tmu_count: number of TMU instances.
- * @tmu_data: platform data of all TMU instances.
- * This structure is required to store data for multi-instance exynos tmu
- * driver.
- */
-struct exynos_tmu_init_data {
-	int tmu_count;
-	struct exynos_tmu_platform_data tmu_data[];
-};
-
 extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
 extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
 extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 17/21] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

This patch brings support for providing configuration via device tree.
Previously, data hardcoded in the exynos_tmu_data.c file was used, which is
not scalable and error prone.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/samsung/Makefile     |   2 -
 drivers/thermal/samsung/exynos_tmu.c | 266 ++++++++++++++++++++---------------
 drivers/thermal/samsung/exynos_tmu.h |  51 -------
 3 files changed, 154 insertions(+), 165 deletions(-)

diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile
index c09d830..1e47d0d 100644
--- a/drivers/thermal/samsung/Makefile
+++ b/drivers/thermal/samsung/Makefile
@@ -3,5 +3,3 @@
 #
 obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_thermal.o
 exynos_thermal-y				:= exynos_tmu.o
-exynos_thermal-y				+= exynos_tmu_data.o
-exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+= exynos_thermal_common.o
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 1d6b1cb..e26042a 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -1,6 +1,10 @@
 /*
  * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
  *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
  *  Copyright (C) 2011 Samsung Electronics
  *  Donggeun Kim <dg77.kim@samsung.com>
  *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
@@ -31,8 +35,8 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 
-#include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
+#include "../thermal_core.h"
 
 /* Exynos generic registers */
 #define EXYNOS_TMU_REG_TRIMINFO		0x0
@@ -130,6 +134,7 @@
 #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
 #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
 
+#define MCELSIUS	1000
 /**
  * struct exynos_tmu_data : A structure to hold the private data of the TMU
 	driver
@@ -165,7 +170,8 @@ struct exynos_tmu_data {
 	struct clk *clk, *clk_sec;
 	u8 temp_error1, temp_error2;
 	struct regulator *regulator;
-	struct thermal_sensor_conf *reg_conf;
+	struct thermal_zone_device *tzd;
+
 	int (*tmu_initialize)(struct platform_device *pdev);
 	void (*tmu_control)(struct platform_device *pdev, bool on);
 	int (*tmu_read)(struct exynos_tmu_data *data);
@@ -174,6 +180,33 @@ struct exynos_tmu_data {
 	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
 };
 
+static void exynos_report_trigger(struct exynos_tmu_data *p)
+{
+	char data[10], *envp[] = { data, NULL };
+	struct thermal_zone_device *tz = p->tzd;
+	unsigned long temp;
+	unsigned int i;
+
+	if (!p) {
+		pr_err("Wrong temperature configuration data\n");
+		return;
+	}
+
+	thermal_zone_device_update(tz);
+
+	mutex_lock(&tz->lock);
+	/* Find the level for which trip happened */
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		tz->ops->get_trip_temp(tz, i, &temp);
+		if (tz->last_temperature < temp)
+			break;
+	}
+
+	snprintf(data, sizeof(data), "%u", i);
+	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
+	mutex_unlock(&tz->lock);
+}
+
 /*
  * TMU treats temperature as a mapped temperature code.
  * The temperature is converted differently depending on the calibration type.
@@ -249,16 +282,22 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
 
 static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling)
 {
-	struct exynos_tmu_platform_data *pdata = data->pdata;
-	int i;
+	struct thermal_zone_device *tz = data->tzd;
+	unsigned long temp, temp_hist;
+	int i, ret;
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
-		u8 temp = pdata->trigger_levels[i];
+	for (i = 0; i < of_thermal_get_non_crit_ntrips(tz); i++) {
+		ret = tz->ops->get_trip_temp(tz, i, &temp);
+		if (ret)
+			return 0;
 
-		if (falling)
-			temp -= pdata->threshold_falling;
-		else
+		temp /= MCELSIUS;
+		if (falling) {
+			tz->ops->get_trip_hyst(tz, i, &temp_hist);
+			temp -= (temp_hist / MCELSIUS);
+		} else {
 			threshold &= ~(0xff << 8 * i);
+		}
 
 		threshold |= temp_to_code(data, temp) << 8 * i;
 	}
@@ -320,9 +359,10 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 static int exynos4210_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
-	unsigned int status;
+	struct thermal_zone_device *tz = data->tzd;
 	int ret = 0, threshold_code, i;
+	unsigned long reference, temp;
+	unsigned int status;
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -333,12 +373,21 @@ static int exynos4210_tmu_initialize(struct platform_device *pdev)
 	sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));
 
 	/* Write temperature code for threshold */
-	threshold_code = temp_to_code(data, pdata->threshold);
+	tz->ops->get_trip_temp(tz, 0, &reference);
+	reference /= MCELSIUS;
+	threshold_code = temp_to_code(data, reference);
+	if (threshold_code < 0) {
+		ret = threshold_code;
+		goto out;
+	}
 	writeb(threshold_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
-		writeb(pdata->trigger_levels[i], data->base +
+	for (i = 0; i < of_thermal_get_non_crit_ntrips(tz); i++) {
+		tz->ops->get_trip_temp(tz, i, &temp);
+		temp /= MCELSIUS;
+		writeb(temp - reference, data->base +
 		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
+	}
 
 	writel(EXYNOS4210_TMU_TRIG_LEVEL_MASK,
 	       data->base + EXYNOS_TMU_REG_INTCLEAR);
@@ -349,9 +398,9 @@ out:
 static int exynos4412_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
 	unsigned int status, trim_info, con, ctrl, rising_threshold;
 	int ret = 0, threshold_code, i;
+	unsigned long crit_temp = 0;
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -401,9 +450,9 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
 		       data->base + EXYNOS_TMU_REG_INTCLEAR);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
+	i = of_thermal_get_non_crit_ntrips(data->tzd);
+	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp)) {
+		threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
 		/* 1-4 level to be assigned in th0 reg */
 		rising_threshold &= ~(0xff << 8 * i);
 		rising_threshold |= threshold_code << 8 * i;
@@ -419,9 +468,9 @@ out:
 static int exynos5440_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
 	unsigned int trim_info = 0, con, rising_threshold;
-	int ret = 0, threshold_code, i;
+	int ret = 0, threshold_code;
+	unsigned long crit_temp = 0;
 
 	/*
 	 * For exynos5440 soc triminfo value is swapped between TMU0 and
@@ -452,9 +501,8 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 	       data->base + EXYNOS5440_TMU_S0_7_IRQ);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
+	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp)) {
+		threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
 		/* 5th level to be assigned in th2 reg */
 		rising_threshold =
 			threshold_code << EXYNOS5440_TMU_TH_RISE4_SHIFT;
@@ -472,7 +520,7 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
@@ -480,10 +528,11 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS_TMU_INTEN_RISE0_SHIFT;
+			of_thermal_is_trip_en(tz, 3) << EXYNOS_TMU_INTEN_RISE3_SHIFT |
+			of_thermal_is_trip_en(tz, 2) << EXYNOS_TMU_INTEN_RISE2_SHIFT |
+			of_thermal_is_trip_en(tz, 1) << EXYNOS_TMU_INTEN_RISE1_SHIFT |
+			of_thermal_is_trip_en(tz, 0) << EXYNOS_TMU_INTEN_RISE0_SHIFT;
+
 		if (data->soc != SOC_ARCH_EXYNOS4210)
 			interrupt_en |=
 				interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
@@ -498,7 +547,7 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS5440_TMU_S0_7_CTRL));
@@ -506,10 +555,10 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
+			of_thermal_is_trip_en(tz, 3) << EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
+			of_thermal_is_trip_en(tz, 2) << EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
+			of_thermal_is_trip_en(tz, 1) << EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
+			of_thermal_is_trip_en(tz, 0) << EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
 		interrupt_en |= interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
 	} else {
 		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
@@ -519,19 +568,21 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL);
 }
 
-static int exynos_tmu_read(struct exynos_tmu_data *data)
+int exynos_get_temp(void *p, long *temp)
 {
-	int ret;
+	struct exynos_tmu_data *data = p;
+	if (!data)
+		return -EINVAL;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
-	ret = data->tmu_read(data);
-	if (ret >= 0)
-		ret = code_to_temp(data, ret);
+
+	*temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS;
+
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
 
-	return ret;
+	return 0;
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
@@ -643,7 +694,7 @@ static void exynos_tmu_work(struct work_struct *work)
 	if (!IS_ERR(data->clk_sec))
 		clk_disable(data->clk_sec);
 
-	exynos_report_trigger(data->reg_conf);
+	exynos_report_trigger(data);
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 	/* TODO: take action based on particular interrupt */
@@ -694,55 +745,63 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 static const struct of_device_id exynos_tmu_match[] = {
 	{
 		.compatible = "samsung,exynos3250-tmu",
-		.data = &exynos3250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4210-tmu",
-		.data = &exynos4210_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4412-tmu",
-		.data = &exynos4412_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5250-tmu",
-		.data = &exynos5250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5260-tmu",
-		.data = &exynos5260_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu-ext-triminfo",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5440-tmu",
-		.data = &exynos5440_default_tmu_data,
 	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 
-static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
-			struct platform_device *pdev, int id)
+static int exynos_of_sensor_conf(struct device_node *np,
+				 struct exynos_tmu_platform_data *pdata)
 {
-	struct  exynos_tmu_init_data *data_table;
-	struct exynos_tmu_platform_data *tmu_data;
-	const struct of_device_id *match;
-
-	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
-	if (!match)
-		return NULL;
-	data_table = (struct exynos_tmu_init_data *) match->data;
-	if (!data_table || id >= data_table->tmu_count)
-		return NULL;
-	tmu_data = data_table->tmu_data;
-	return (struct exynos_tmu_platform_data *) (tmu_data + id);
+	u32 value;
+	int ret;
+
+	of_node_get(np);
+
+	ret = of_property_read_u32(np, "gain", &value);
+	pdata->gain = (u8) value;
+	of_property_read_u32(np, "reference_voltage", &value);
+	pdata->reference_voltage = (u8) value;
+	of_property_read_u32(np, "noise_cancel_mode", &value);
+	pdata->noise_cancel_mode = (u8) value;;
+
+	of_property_read_u32(np, "efuse_value", &pdata->efuse_value);
+	of_property_read_u32(np, "min_efuse_value", &pdata->min_efuse_value);
+	of_property_read_u32(np, "max_efuse_value", &pdata->max_efuse_value);
+
+	of_property_read_u32(np, "first_point_trim", &value);
+	pdata->first_point_trim = (u8) value;
+	of_property_read_u32(np, "second_point_trim", &value);
+	pdata->second_point_trim = (u8) value;
+	of_property_read_u32(np, "default_temp_offset", &value);
+	pdata->default_temp_offset = (u8) value;
+
+	of_property_read_u32(np, "cal_type", &pdata->cal_type);
+	of_property_read_u32(np, "type", &pdata->type);
+
+	of_node_put(np);
+	return 0;
 }
 
 static int exynos_map_dt_data(struct platform_device *pdev)
@@ -792,12 +851,13 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 		return -EADDRNOTAVAIL;
 	}
 
-	pdata = exynos_get_driver_data(pdev, data->id);
-	if (!pdata) {
-		dev_err(&pdev->dev, "No platform init data supplied.\n");
-		return -ENODEV;
-	}
+	pdata = devm_kzalloc(&pdev->dev,
+			     sizeof(struct exynos_tmu_platform_data),
+			     GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
 
+	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
 	data->pdata = pdata;
 	data->soc = pdata->type;
 
@@ -857,10 +917,9 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 
 static int exynos_tmu_probe(struct platform_device *pdev)
 {
-	struct exynos_tmu_data *data;
 	struct exynos_tmu_platform_data *pdata;
-	struct thermal_sensor_conf *sensor_conf;
-	int ret, i;
+	struct exynos_tmu_data *data;
+	int ret;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
 					GFP_KERNEL);
@@ -870,9 +929,16 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, data);
 	mutex_init(&data->lock);
 
+	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
+						    exynos_get_temp, NULL,
+						    exynos_tmu_set_emulation);
+	if (IS_ERR(data->tzd)) {
+		pr_err("thermal: tz: %p ERROR\n", data->tzd);
+		return PTR_ERR(data->tzd);
+	}
 	ret = exynos_map_dt_data(pdev);
 	if (ret)
-		return ret;
+		goto err_sensor;
 
 	pdata = data->pdata;
 
@@ -881,20 +947,22 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
 	if (IS_ERR(data->clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
-		return  PTR_ERR(data->clk);
+		ret = PTR_ERR(data->clk);
+		goto err_sensor;
 	}
 
 	data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
 	if (IS_ERR(data->clk_sec)) {
 		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
 			dev_err(&pdev->dev, "Failed to get triminfo clock\n");
-			return PTR_ERR(data->clk_sec);
+			ret = PTR_ERR(data->clk_sec);
+			goto err_sensor;
 		}
 	} else {
 		ret = clk_prepare(data->clk_sec);
 		if (ret) {
 			dev_err(&pdev->dev, "Failed to get clock\n");
-			return ret;
+			goto err_sensor;
 		}
 	}
 
@@ -910,42 +978,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	exynos_tmu_control(pdev, true);
-
-	/* Allocate a structure to register with the exynos core thermal */
-	sensor_conf = devm_kzalloc(&pdev->dev,
-				sizeof(struct thermal_sensor_conf), GFP_KERNEL);
-	if (!sensor_conf) {
-		ret = -ENOMEM;
-		goto err_clk;
-	}
-	sprintf(sensor_conf->name, "therm_zone%d", data->id);
-	sensor_conf->read_temperature = (int (*)(void *))exynos_tmu_read;
-	sensor_conf->write_emul_temp =
-		(int (*)(void *, unsigned long))exynos_tmu_set_emulation;
-	sensor_conf->driver_data = data;
-	sensor_conf->trip_data.trip_count = pdata->trigger_enable[0] +
-			pdata->trigger_enable[1] + pdata->trigger_enable[2]+
-			pdata->trigger_enable[3];
-
-	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
-		sensor_conf->trip_data.trip_val[i] =
-			pdata->threshold + pdata->trigger_levels[i];
-		sensor_conf->trip_data.trip_type[i] =
-					pdata->trigger_type[i];
-	}
-
-	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
-
-	sensor_conf->dev = &pdev->dev;
-	/* Register the sensor with thermal management interface */
-	ret = exynos_register_thermal(sensor_conf);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to register thermal interface\n");
-		goto err_clk;
-	}
-	data->reg_conf = sensor_conf;
-
 	ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
 		IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
 	if (ret) {
@@ -953,21 +985,31 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
+	ret = exynos_tmu_initialize(pdev);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to initialize TMU\n");
+		goto err_clk;
+	}
+	exynos_tmu_control(pdev, true);
 	return 0;
+
 err_clk:
 	clk_unprepare(data->clk);
 err_clk_sec:
 	if (!IS_ERR(data->clk_sec))
 		clk_unprepare(data->clk_sec);
+err_sensor:
+	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
+
 	return ret;
 }
 
 static int exynos_tmu_remove(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	struct thermal_zone_device *tzd = data->tzd;
 
-	exynos_unregister_thermal(data->reg_conf);
-
+	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
 	exynos_tmu_control(pdev, false);
 
 	clk_unprepare(data->clk);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 1e87f0f..6f176ef 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -24,40 +24,10 @@
 #define _EXYNOS_TMU_H
 #include <linux/cpu_cooling.h>
 
-#include "exynos_thermal_common.h"
-
 #include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
- * @threshold: basic temperature for generating interrupt
- *	       25 <= threshold <= 125 [unit: degree Celsius]
- * @threshold_falling: differntial value for setting threshold
- *		       of temperature falling interrupt.
- * @trigger_levels: array for each interrupt levels
- *	[unit: degree Celsius]
- *	0: temperature for trigger_level0 interrupt
- *	   condition for trigger_level0 interrupt:
- *		current temperature > threshold + trigger_levels[0]
- *	1: temperature for trigger_level1 interrupt
- *	   condition for trigger_level1 interrupt:
- *		current temperature > threshold + trigger_levels[1]
- *	2: temperature for trigger_level2 interrupt
- *	   condition for trigger_level2 interrupt:
- *		current temperature > threshold + trigger_levels[2]
- *	3: temperature for trigger_level3 interrupt
- *	   condition for trigger_level3 interrupt:
- *		current temperature > threshold + trigger_levels[3]
- * @trigger_type: defines the type of trigger. Possible values are,
- *	THROTTLE_ACTIVE trigger type
- *	THROTTLE_PASSIVE trigger type
- *	SW_TRIP trigger type
- *	HW_TRIP
- * @trigger_enable[]: array to denote which trigger levels are enabled.
- *	1 = enable trigger_level[] interrupt,
- *	0 = disable trigger_level[] interrupt
- * @max_trigger_level: max trigger level supported by the TMU
- * @non_hw_trigger_levels: number of defined non-hardware trigger levels
  * @gain: gain of amplifier in the positive-TC generator block
  *	0 < gain <= 15
  * @reference_voltage: reference voltage of amplifier
@@ -69,21 +39,12 @@
  * @efuse_value: platform defined fuse value
  * @min_efuse_value: minimum valid trimming data
  * @max_efuse_value: maximum valid trimming data
- * @first_point_trim: temp value of the first point trimming
- * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
 struct exynos_tmu_platform_data {
-	u8 threshold;
-	u8 threshold_falling;
-	u8 trigger_levels[MAX_TRIP_COUNT];
-	enum trigger_type trigger_type[MAX_TRIP_COUNT];
-	bool trigger_enable[MAX_TRIP_COUNT];
-	u8 max_trigger_level;
-	u8 non_hw_trigger_levels;
 	u8 gain;
 	u8 reference_voltage;
 	u8 noise_cancel_mode;
@@ -99,18 +60,6 @@ struct exynos_tmu_platform_data {
 	u32 type;
 };
 
-/**
- * struct exynos_tmu_init_data
- * @tmu_count: number of TMU instances.
- * @tmu_data: platform data of all TMU instances.
- * This structure is required to store data for multi-instance exynos tmu
- * driver.
- */
-struct exynos_tmu_init_data {
-	int tmu_count;
-	struct exynos_tmu_platform_data tmu_data[];
-};
-
 extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
 extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
 extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 18/21] thermal: exynos: Remove exynos_thermal_common.[c|h] files
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

After defining all necessary Exynos data in the device tree
those files can be removed.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/samsung/exynos_thermal_common.c | 448 ------------------------
 drivers/thermal/samsung/exynos_thermal_common.h | 106 ------
 2 files changed, 554 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
deleted file mode 100644
index c306de5..0000000
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ /dev/null
@@ -1,448 +0,0 @@
-/*
- * exynos_thermal_common.c - Samsung EXYNOS common thermal file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include <linux/cpu_cooling.h>
-#include <linux/err.h>
-#include <linux/slab.h>
-#include <linux/thermal.h>
-
-#include "exynos_thermal_common.h"
-
-struct exynos_thermal_zone {
-	enum thermal_device_mode mode;
-	struct thermal_zone_device *therm_dev;
-	struct thermal_cooling_device *cool_dev[MAX_COOLING_DEVICE];
-	unsigned int cool_dev_size;
-	struct platform_device *exynos4_dev;
-	struct thermal_sensor_conf *sensor_conf;
-	bool bind;
-};
-
-/* Get mode callback functions for thermal zone */
-static int exynos_get_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode *mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (th_zone)
-		*mode = th_zone->mode;
-	return 0;
-}
-
-/* Set mode callback functions for thermal zone */
-static int exynos_set_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (!th_zone) {
-		dev_err(&thermal->device,
-			"thermal zone not registered\n");
-		return 0;
-	}
-
-	mutex_lock(&thermal->lock);
-
-	if (mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling)
-		thermal->polling_delay = IDLE_INTERVAL;
-	else
-		thermal->polling_delay = 0;
-
-	mutex_unlock(&thermal->lock);
-
-	th_zone->mode = mode;
-	thermal_zone_device_update(thermal);
-	dev_dbg(th_zone->sensor_conf->dev,
-		"thermal polling set for duration=%d msec\n",
-		thermal->polling_delay);
-	return 0;
-}
-
-
-/* Get trip type callback functions for thermal zone */
-static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
-				 enum thermal_trip_type *type)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	int trip_type;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	trip_type = th_zone->sensor_conf->trip_data.trip_type[trip];
-
-	if (trip_type == SW_TRIP)
-		*type = THERMAL_TRIP_CRITICAL;
-	else if (trip_type == THROTTLE_ACTIVE)
-		*type = THERMAL_TRIP_ACTIVE;
-	else if (trip_type == THROTTLE_PASSIVE)
-		*type = THERMAL_TRIP_PASSIVE;
-	else
-		return -EINVAL;
-
-	return 0;
-}
-
-/* Get trip temperature callback functions for thermal zone */
-static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	*temp = th_zone->sensor_conf->trip_data.trip_val[trip];
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-
-	return 0;
-}
-
-/* Get critical temperature callback functions for thermal zone */
-static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	/* Get the temp of highest trip*/
-	return exynos_get_trip_temp(thermal, max_trip - 1, temp);
-}
-
-/* Bind callback functions for thermal zone */
-static int exynos_bind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-	struct of_phandle_args cooling_spec;
-	unsigned long max, state = 0;
-	int ret = 0, i = 0;
-
-	/*
-	 * Below code is necessary to skip binding when cpufreq's
-	 * frequency table is not yet initialized.
-	 */
-	cdev->ops->get_max_state(cdev, &state);
-	if (!state && !th_zone->cool_dev_size) {
-		th_zone->cool_dev_size = 1;
-		th_zone->cool_dev[0] = cdev;
-		th_zone->bind = false;
-		return 0;
-	}
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	for_each_child_of_node(child, gchild) {
-		ret = of_parse_phandle_with_args(gchild, "cooling-device",
-						 "#cooling-cells",
-						 0, &cooling_spec);
-		if (ret < 0) {
-			pr_err("missing cooling_device property\n");
-			goto end;
-		}
-
-		if (cooling_spec.args_count < 2) {
-			ret = -EINVAL;
-			goto end;
-		}
-
-		max = cooling_spec.args[0];
-		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-						     max, 0)) {
-			dev_err(data->dev,
-				"thermal error unbinding cdev inst=%d\n", i);
-
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = true;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Unbind callback functions for thermal zone */
-static int exynos_unbind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	int ret = 0, i;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-
-	if (th_zone->bind == false || !th_zone->cool_dev_size)
-		return 0;
-
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
-
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	i = 0;
-	for_each_child_of_node(child, gchild) {
-		if (thermal_zone_unbind_cooling_device(thermal, i,
-						       cdev)) {
-			dev_err(data->dev,
-				"error unbinding cdev inst=%d\n", i);
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = false;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_get_temp(struct thermal_zone_device *thermal,
-			unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	void *data;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	*temp = th_zone->sensor_conf->read_temperature(data);
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-	return 0;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
-						unsigned long temp)
-{
-	void *data;
-	int ret = -EINVAL;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	if (th_zone->sensor_conf->write_emul_temp)
-		ret = th_zone->sensor_conf->write_emul_temp(data, temp);
-	return ret;
-}
-
-/* Get the temperature trend */
-static int exynos_get_trend(struct thermal_zone_device *thermal,
-			int trip, enum thermal_trend *trend)
-{
-	int ret;
-	unsigned long trip_temp;
-
-	ret = exynos_get_trip_temp(thermal, trip, &trip_temp);
-	if (ret < 0)
-		return ret;
-
-	if (thermal->temperature >= trip_temp)
-		*trend = THERMAL_TREND_RAISE_FULL;
-	else
-		*trend = THERMAL_TREND_DROP_FULL;
-
-	return 0;
-}
-/* Operation callback functions for thermal zone */
-static struct thermal_zone_device_ops exynos_dev_ops = {
-	.bind = exynos_bind,
-	.unbind = exynos_unbind,
-	.get_temp = exynos_get_temp,
-	.set_emul_temp = exynos_set_emul_temp,
-	.get_trend = exynos_get_trend,
-	.get_mode = exynos_get_mode,
-	.set_mode = exynos_set_mode,
-	.get_trip_type = exynos_get_trip_type,
-	.get_trip_temp = exynos_get_trip_temp,
-	.get_crit_temp = exynos_get_crit_temp,
-};
-
-/*
- * This function may be called from interrupt based temperature sensor
- * when threshold is changed.
- */
-void exynos_report_trigger(struct thermal_sensor_conf *conf)
-{
-	unsigned int i;
-	char data[10];
-	char *envp[] = { data, NULL };
-	struct exynos_thermal_zone *th_zone;
-
-	if (!conf || !conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = conf->pzone_data;
-
-	if (th_zone->bind == false) {
-		for (i = 0; i < th_zone->cool_dev_size; i++) {
-			if (!th_zone->cool_dev[i])
-				continue;
-			exynos_bind(th_zone->therm_dev,
-					th_zone->cool_dev[i]);
-		}
-	}
-
-	thermal_zone_device_update(th_zone->therm_dev);
-
-	mutex_lock(&th_zone->therm_dev->lock);
-	/* Find the level for which trip happened */
-	for (i = 0; i < th_zone->sensor_conf->trip_data.trip_count; i++) {
-		if (th_zone->therm_dev->last_temperature <
-			th_zone->sensor_conf->trip_data.trip_val[i] * MCELSIUS)
-			break;
-	}
-
-	if (th_zone->mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling) {
-		if (i > 0)
-			th_zone->therm_dev->polling_delay = ACTIVE_INTERVAL;
-		else
-			th_zone->therm_dev->polling_delay = IDLE_INTERVAL;
-	}
-
-	snprintf(data, sizeof(data), "%u", i);
-	kobject_uevent_env(&th_zone->therm_dev->device.kobj, KOBJ_CHANGE, envp);
-	mutex_unlock(&th_zone->therm_dev->lock);
-}
-
-/* Register with the in-kernel thermal management */
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int ret;
-	struct cpumask mask_val;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->read_temperature) {
-		pr_err("Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-
-	th_zone = devm_kzalloc(sensor_conf->dev,
-				sizeof(struct exynos_thermal_zone), GFP_KERNEL);
-	if (!th_zone)
-		return -ENOMEM;
-
-	th_zone->sensor_conf = sensor_conf;
-	/*
-	 * TODO: 1) Handle multiple cooling devices in a thermal zone
-	 *	 2) Add a flag/name in cooling info to map to specific
-	 *	 sensor
-	 */
-	if (sensor_conf->cooling_data.freq_clip_count > 0) {
-		cpumask_set_cpu(0, &mask_val);
-		th_zone->cool_dev[th_zone->cool_dev_size] =
-					cpufreq_cooling_register(&mask_val);
-		if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
-			dev_err(sensor_conf->dev,
-				"Failed to register cpufreq cooling device\n");
-			ret = -EINVAL;
-			goto err_unregister;
-		}
-		th_zone->cool_dev_size++;
-	}
-
-	th_zone->therm_dev = thermal_zone_device_register(
-			sensor_conf->name, sensor_conf->trip_data.trip_count,
-			0, th_zone, &exynos_dev_ops, NULL, 0,
-			sensor_conf->trip_data.trigger_falling ? 0 :
-			IDLE_INTERVAL);
-
-	if (IS_ERR(th_zone->therm_dev)) {
-		dev_err(sensor_conf->dev,
-			"Failed to register thermal zone device\n");
-		ret = PTR_ERR(th_zone->therm_dev);
-		goto err_unregister;
-	}
-	th_zone->mode = THERMAL_DEVICE_ENABLED;
-	sensor_conf->pzone_data = th_zone;
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Thermal zone(%s) registered\n", sensor_conf->name);
-
-	return 0;
-
-err_unregister:
-	exynos_unregister_thermal(sensor_conf);
-	return ret;
-}
-
-/* Un-Register with the in-kernel thermal management */
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int i;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = sensor_conf->pzone_data;
-
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
-
-	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-	}
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Kernel Thermal management unregistered\n");
-}
diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h
deleted file mode 100644
index cd44719..0000000
--- a/drivers/thermal/samsung/exynos_thermal_common.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * exynos_thermal_common.h - Samsung EXYNOS common header file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#ifndef _EXYNOS_THERMAL_COMMON_H
-#define _EXYNOS_THERMAL_COMMON_H
-
-/* In-kernel thermal framework related macros & definations */
-#define SENSOR_NAME_LEN	16
-#define MAX_TRIP_COUNT	8
-#define MAX_COOLING_DEVICE 4
-
-#define ACTIVE_INTERVAL 500
-#define IDLE_INTERVAL 10000
-#define MCELSIUS	1000
-
-/* CPU Zone information */
-#define PANIC_ZONE      4
-#define WARN_ZONE       3
-#define MONITOR_ZONE    2
-#define SAFE_ZONE       1
-
-#define GET_ZONE(trip) (trip + 2)
-#define GET_TRIP(zone) (zone - 2)
-
-enum trigger_type {
-	THROTTLE_ACTIVE = 1,
-	THROTTLE_PASSIVE,
-	SW_TRIP,
-	HW_TRIP,
-};
-
-/**
- * struct freq_clip_table
- * @freq_clip_max: maximum frequency allowed for this cooling state.
- * @temp_level: Temperature level at which the temperature clipping will
- *	happen.
- * @mask_val: cpumask of the allowed cpu's where the clipping will take place.
- *
- * This structure is required to be filled and passed to the
- * cpufreq_cooling_unregister function.
- */
-struct freq_clip_table {
-	unsigned int freq_clip_max;
-	unsigned int temp_level;
-	const struct cpumask *mask_val;
-};
-
-struct	thermal_trip_point_conf {
-	int trip_val[MAX_TRIP_COUNT];
-	int trip_type[MAX_TRIP_COUNT];
-	int trip_count;
-	unsigned char trigger_falling;
-};
-
-struct	thermal_cooling_conf {
-	struct freq_clip_table freq_data[MAX_TRIP_COUNT];
-	int freq_clip_count;
-};
-
-struct thermal_sensor_conf {
-	char name[SENSOR_NAME_LEN];
-	int (*read_temperature)(void *data);
-	int (*write_emul_temp)(void *drv_data, unsigned long temp);
-	struct thermal_trip_point_conf trip_data;
-	struct thermal_cooling_conf cooling_data;
-	void *driver_data;
-	void *pzone_data;
-	struct device *dev;
-};
-
-/*Functions used exynos based thermal sensor driver*/
-#ifdef CONFIG_EXYNOS_THERMAL_CORE
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf);
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf);
-void exynos_report_trigger(struct thermal_sensor_conf *sensor_conf);
-#else
-static inline void
-exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf) { return; }
-
-static inline int
-exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) { return 0; }
-
-static inline void
-exynos_report_trigger(struct thermal_sensor_conf *sensor_conf) { return; }
-
-#endif /* CONFIG_EXYNOS_THERMAL_CORE */
-#endif /* _EXYNOS_THERMAL_COMMON_H */
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 18/21] thermal: exynos: Remove exynos_thermal_common.[c|h] files
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

After defining all necessary Exynos data in the device tree
those files can be removed.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/samsung/exynos_thermal_common.c | 448 ------------------------
 drivers/thermal/samsung/exynos_thermal_common.h | 106 ------
 2 files changed, 554 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
deleted file mode 100644
index c306de5..0000000
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ /dev/null
@@ -1,448 +0,0 @@
-/*
- * exynos_thermal_common.c - Samsung EXYNOS common thermal file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include <linux/cpu_cooling.h>
-#include <linux/err.h>
-#include <linux/slab.h>
-#include <linux/thermal.h>
-
-#include "exynos_thermal_common.h"
-
-struct exynos_thermal_zone {
-	enum thermal_device_mode mode;
-	struct thermal_zone_device *therm_dev;
-	struct thermal_cooling_device *cool_dev[MAX_COOLING_DEVICE];
-	unsigned int cool_dev_size;
-	struct platform_device *exynos4_dev;
-	struct thermal_sensor_conf *sensor_conf;
-	bool bind;
-};
-
-/* Get mode callback functions for thermal zone */
-static int exynos_get_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode *mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (th_zone)
-		*mode = th_zone->mode;
-	return 0;
-}
-
-/* Set mode callback functions for thermal zone */
-static int exynos_set_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (!th_zone) {
-		dev_err(&thermal->device,
-			"thermal zone not registered\n");
-		return 0;
-	}
-
-	mutex_lock(&thermal->lock);
-
-	if (mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling)
-		thermal->polling_delay = IDLE_INTERVAL;
-	else
-		thermal->polling_delay = 0;
-
-	mutex_unlock(&thermal->lock);
-
-	th_zone->mode = mode;
-	thermal_zone_device_update(thermal);
-	dev_dbg(th_zone->sensor_conf->dev,
-		"thermal polling set for duration=%d msec\n",
-		thermal->polling_delay);
-	return 0;
-}
-
-
-/* Get trip type callback functions for thermal zone */
-static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
-				 enum thermal_trip_type *type)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	int trip_type;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	trip_type = th_zone->sensor_conf->trip_data.trip_type[trip];
-
-	if (trip_type == SW_TRIP)
-		*type = THERMAL_TRIP_CRITICAL;
-	else if (trip_type == THROTTLE_ACTIVE)
-		*type = THERMAL_TRIP_ACTIVE;
-	else if (trip_type == THROTTLE_PASSIVE)
-		*type = THERMAL_TRIP_PASSIVE;
-	else
-		return -EINVAL;
-
-	return 0;
-}
-
-/* Get trip temperature callback functions for thermal zone */
-static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	*temp = th_zone->sensor_conf->trip_data.trip_val[trip];
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-
-	return 0;
-}
-
-/* Get critical temperature callback functions for thermal zone */
-static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	/* Get the temp of highest trip*/
-	return exynos_get_trip_temp(thermal, max_trip - 1, temp);
-}
-
-/* Bind callback functions for thermal zone */
-static int exynos_bind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-	struct of_phandle_args cooling_spec;
-	unsigned long max, state = 0;
-	int ret = 0, i = 0;
-
-	/*
-	 * Below code is necessary to skip binding when cpufreq's
-	 * frequency table is not yet initialized.
-	 */
-	cdev->ops->get_max_state(cdev, &state);
-	if (!state && !th_zone->cool_dev_size) {
-		th_zone->cool_dev_size = 1;
-		th_zone->cool_dev[0] = cdev;
-		th_zone->bind = false;
-		return 0;
-	}
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	for_each_child_of_node(child, gchild) {
-		ret = of_parse_phandle_with_args(gchild, "cooling-device",
-						 "#cooling-cells",
-						 0, &cooling_spec);
-		if (ret < 0) {
-			pr_err("missing cooling_device property\n");
-			goto end;
-		}
-
-		if (cooling_spec.args_count < 2) {
-			ret = -EINVAL;
-			goto end;
-		}
-
-		max = cooling_spec.args[0];
-		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-						     max, 0)) {
-			dev_err(data->dev,
-				"thermal error unbinding cdev inst=%d\n", i);
-
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = true;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Unbind callback functions for thermal zone */
-static int exynos_unbind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	int ret = 0, i;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-
-	if (th_zone->bind == false || !th_zone->cool_dev_size)
-		return 0;
-
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
-
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	i = 0;
-	for_each_child_of_node(child, gchild) {
-		if (thermal_zone_unbind_cooling_device(thermal, i,
-						       cdev)) {
-			dev_err(data->dev,
-				"error unbinding cdev inst=%d\n", i);
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = false;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_get_temp(struct thermal_zone_device *thermal,
-			unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	void *data;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	*temp = th_zone->sensor_conf->read_temperature(data);
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-	return 0;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
-						unsigned long temp)
-{
-	void *data;
-	int ret = -EINVAL;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	if (th_zone->sensor_conf->write_emul_temp)
-		ret = th_zone->sensor_conf->write_emul_temp(data, temp);
-	return ret;
-}
-
-/* Get the temperature trend */
-static int exynos_get_trend(struct thermal_zone_device *thermal,
-			int trip, enum thermal_trend *trend)
-{
-	int ret;
-	unsigned long trip_temp;
-
-	ret = exynos_get_trip_temp(thermal, trip, &trip_temp);
-	if (ret < 0)
-		return ret;
-
-	if (thermal->temperature >= trip_temp)
-		*trend = THERMAL_TREND_RAISE_FULL;
-	else
-		*trend = THERMAL_TREND_DROP_FULL;
-
-	return 0;
-}
-/* Operation callback functions for thermal zone */
-static struct thermal_zone_device_ops exynos_dev_ops = {
-	.bind = exynos_bind,
-	.unbind = exynos_unbind,
-	.get_temp = exynos_get_temp,
-	.set_emul_temp = exynos_set_emul_temp,
-	.get_trend = exynos_get_trend,
-	.get_mode = exynos_get_mode,
-	.set_mode = exynos_set_mode,
-	.get_trip_type = exynos_get_trip_type,
-	.get_trip_temp = exynos_get_trip_temp,
-	.get_crit_temp = exynos_get_crit_temp,
-};
-
-/*
- * This function may be called from interrupt based temperature sensor
- * when threshold is changed.
- */
-void exynos_report_trigger(struct thermal_sensor_conf *conf)
-{
-	unsigned int i;
-	char data[10];
-	char *envp[] = { data, NULL };
-	struct exynos_thermal_zone *th_zone;
-
-	if (!conf || !conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = conf->pzone_data;
-
-	if (th_zone->bind == false) {
-		for (i = 0; i < th_zone->cool_dev_size; i++) {
-			if (!th_zone->cool_dev[i])
-				continue;
-			exynos_bind(th_zone->therm_dev,
-					th_zone->cool_dev[i]);
-		}
-	}
-
-	thermal_zone_device_update(th_zone->therm_dev);
-
-	mutex_lock(&th_zone->therm_dev->lock);
-	/* Find the level for which trip happened */
-	for (i = 0; i < th_zone->sensor_conf->trip_data.trip_count; i++) {
-		if (th_zone->therm_dev->last_temperature <
-			th_zone->sensor_conf->trip_data.trip_val[i] * MCELSIUS)
-			break;
-	}
-
-	if (th_zone->mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling) {
-		if (i > 0)
-			th_zone->therm_dev->polling_delay = ACTIVE_INTERVAL;
-		else
-			th_zone->therm_dev->polling_delay = IDLE_INTERVAL;
-	}
-
-	snprintf(data, sizeof(data), "%u", i);
-	kobject_uevent_env(&th_zone->therm_dev->device.kobj, KOBJ_CHANGE, envp);
-	mutex_unlock(&th_zone->therm_dev->lock);
-}
-
-/* Register with the in-kernel thermal management */
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int ret;
-	struct cpumask mask_val;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->read_temperature) {
-		pr_err("Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-
-	th_zone = devm_kzalloc(sensor_conf->dev,
-				sizeof(struct exynos_thermal_zone), GFP_KERNEL);
-	if (!th_zone)
-		return -ENOMEM;
-
-	th_zone->sensor_conf = sensor_conf;
-	/*
-	 * TODO: 1) Handle multiple cooling devices in a thermal zone
-	 *	 2) Add a flag/name in cooling info to map to specific
-	 *	 sensor
-	 */
-	if (sensor_conf->cooling_data.freq_clip_count > 0) {
-		cpumask_set_cpu(0, &mask_val);
-		th_zone->cool_dev[th_zone->cool_dev_size] =
-					cpufreq_cooling_register(&mask_val);
-		if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
-			dev_err(sensor_conf->dev,
-				"Failed to register cpufreq cooling device\n");
-			ret = -EINVAL;
-			goto err_unregister;
-		}
-		th_zone->cool_dev_size++;
-	}
-
-	th_zone->therm_dev = thermal_zone_device_register(
-			sensor_conf->name, sensor_conf->trip_data.trip_count,
-			0, th_zone, &exynos_dev_ops, NULL, 0,
-			sensor_conf->trip_data.trigger_falling ? 0 :
-			IDLE_INTERVAL);
-
-	if (IS_ERR(th_zone->therm_dev)) {
-		dev_err(sensor_conf->dev,
-			"Failed to register thermal zone device\n");
-		ret = PTR_ERR(th_zone->therm_dev);
-		goto err_unregister;
-	}
-	th_zone->mode = THERMAL_DEVICE_ENABLED;
-	sensor_conf->pzone_data = th_zone;
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Thermal zone(%s) registered\n", sensor_conf->name);
-
-	return 0;
-
-err_unregister:
-	exynos_unregister_thermal(sensor_conf);
-	return ret;
-}
-
-/* Un-Register with the in-kernel thermal management */
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int i;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = sensor_conf->pzone_data;
-
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
-
-	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-	}
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Kernel Thermal management unregistered\n");
-}
diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h
deleted file mode 100644
index cd44719..0000000
--- a/drivers/thermal/samsung/exynos_thermal_common.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * exynos_thermal_common.h - Samsung EXYNOS common header file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#ifndef _EXYNOS_THERMAL_COMMON_H
-#define _EXYNOS_THERMAL_COMMON_H
-
-/* In-kernel thermal framework related macros & definations */
-#define SENSOR_NAME_LEN	16
-#define MAX_TRIP_COUNT	8
-#define MAX_COOLING_DEVICE 4
-
-#define ACTIVE_INTERVAL 500
-#define IDLE_INTERVAL 10000
-#define MCELSIUS	1000
-
-/* CPU Zone information */
-#define PANIC_ZONE      4
-#define WARN_ZONE       3
-#define MONITOR_ZONE    2
-#define SAFE_ZONE       1
-
-#define GET_ZONE(trip) (trip + 2)
-#define GET_TRIP(zone) (zone - 2)
-
-enum trigger_type {
-	THROTTLE_ACTIVE = 1,
-	THROTTLE_PASSIVE,
-	SW_TRIP,
-	HW_TRIP,
-};
-
-/**
- * struct freq_clip_table
- * @freq_clip_max: maximum frequency allowed for this cooling state.
- * @temp_level: Temperature level at which the temperature clipping will
- *	happen.
- * @mask_val: cpumask of the allowed cpu's where the clipping will take place.
- *
- * This structure is required to be filled and passed to the
- * cpufreq_cooling_unregister function.
- */
-struct freq_clip_table {
-	unsigned int freq_clip_max;
-	unsigned int temp_level;
-	const struct cpumask *mask_val;
-};
-
-struct	thermal_trip_point_conf {
-	int trip_val[MAX_TRIP_COUNT];
-	int trip_type[MAX_TRIP_COUNT];
-	int trip_count;
-	unsigned char trigger_falling;
-};
-
-struct	thermal_cooling_conf {
-	struct freq_clip_table freq_data[MAX_TRIP_COUNT];
-	int freq_clip_count;
-};
-
-struct thermal_sensor_conf {
-	char name[SENSOR_NAME_LEN];
-	int (*read_temperature)(void *data);
-	int (*write_emul_temp)(void *drv_data, unsigned long temp);
-	struct thermal_trip_point_conf trip_data;
-	struct thermal_cooling_conf cooling_data;
-	void *driver_data;
-	void *pzone_data;
-	struct device *dev;
-};
-
-/*Functions used exynos based thermal sensor driver*/
-#ifdef CONFIG_EXYNOS_THERMAL_CORE
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf);
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf);
-void exynos_report_trigger(struct thermal_sensor_conf *sensor_conf);
-#else
-static inline void
-exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf) { return; }
-
-static inline int
-exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) { return 0; }
-
-static inline void
-exynos_report_trigger(struct thermal_sensor_conf *sensor_conf) { return; }
-
-#endif /* CONFIG_EXYNOS_THERMAL_CORE */
-#endif /* _EXYNOS_THERMAL_COMMON_H */
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 19/21] thermal: exynos: Remove exynos_tmu_data.c file
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Data already present in the exynos_tmu_data.c file has been moved to the
appropriate device tree files.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/samsung/exynos_tmu_data.c | 228 ------------------------------
 1 file changed, 228 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c

diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
deleted file mode 100644
index a993f3d..0000000
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * exynos_tmu_data.c - Samsung EXYNOS tmu data file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include "exynos_thermal_common.h"
-#include "exynos_tmu.h"
-
-struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
-	.tmu_data = {
-		{
-		.threshold = 80,
-		.trigger_levels[0] = 5,
-		.trigger_levels[1] = 20,
-		.trigger_levels[2] = 30,
-		.trigger_enable[0] = true,
-		.trigger_enable[1] = true,
-		.trigger_enable[2] = true,
-		.trigger_enable[3] = false,
-		.trigger_type[0] = THROTTLE_ACTIVE,
-		.trigger_type[1] = THROTTLE_ACTIVE,
-		.trigger_type[2] = SW_TRIP,
-		.max_trigger_level = 4,
-		.non_hw_trigger_levels = 3,
-		.gain = 15,
-		.reference_voltage = 7,
-		.cal_type = TYPE_ONE_POINT_TRIMMING,
-		.min_efuse_value = 40,
-		.max_efuse_value = 100,
-		.first_point_trim = 25,
-		.second_point_trim = 85,
-		.default_temp_offset = 50,
-		.type = SOC_ARCH_EXYNOS4210,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS3250_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_TWO_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS3250_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS3250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS4412_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS4412,
-		},
-	},
-	.tmu_count = 1,
-};
-
-struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS5250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define __EXYNOS5260_TMU_DATA	\
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 85, \
-	.trigger_levels[1] = 103, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50,
-
-#define EXYNOS5260_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5260
-
-struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5420_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420
-
-#define EXYNOS5420_TMU_DATA_SHARED \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420_TRIMINFO
-
-struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5440_TMU_DATA \
-	.trigger_levels[0] = 100, \
-	.trigger_levels[4] = 105, \
-	.trigger_enable[0] = 1, \
-	.trigger_type[0] = SW_TRIP, \
-	.trigger_type[4] = HW_TRIP, \
-	.max_trigger_level = 5, \
-	.non_hw_trigger_levels = 1, \
-	.gain = 5, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 0x5b2d, \
-	.min_efuse_value = 16, \
-	.max_efuse_value = 76, \
-	.first_point_trim = 25, \
-	.second_point_trim = 70, \
-	.default_temp_offset = 25, \
-	.type = SOC_ARCH_EXYNOS5440
-
-struct exynos_tmu_init_data const exynos5440_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-	},
-	.tmu_count = 3,
-};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 19/21] thermal: exynos: Remove exynos_tmu_data.c file
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

Data already present in the exynos_tmu_data.c file has been moved to the
appropriate device tree files.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/samsung/exynos_tmu_data.c | 228 ------------------------------
 1 file changed, 228 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c

diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
deleted file mode 100644
index a993f3d..0000000
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * exynos_tmu_data.c - Samsung EXYNOS tmu data file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include "exynos_thermal_common.h"
-#include "exynos_tmu.h"
-
-struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
-	.tmu_data = {
-		{
-		.threshold = 80,
-		.trigger_levels[0] = 5,
-		.trigger_levels[1] = 20,
-		.trigger_levels[2] = 30,
-		.trigger_enable[0] = true,
-		.trigger_enable[1] = true,
-		.trigger_enable[2] = true,
-		.trigger_enable[3] = false,
-		.trigger_type[0] = THROTTLE_ACTIVE,
-		.trigger_type[1] = THROTTLE_ACTIVE,
-		.trigger_type[2] = SW_TRIP,
-		.max_trigger_level = 4,
-		.non_hw_trigger_levels = 3,
-		.gain = 15,
-		.reference_voltage = 7,
-		.cal_type = TYPE_ONE_POINT_TRIMMING,
-		.min_efuse_value = 40,
-		.max_efuse_value = 100,
-		.first_point_trim = 25,
-		.second_point_trim = 85,
-		.default_temp_offset = 50,
-		.type = SOC_ARCH_EXYNOS4210,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS3250_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_TWO_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS3250_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS3250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS4412_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS4412,
-		},
-	},
-	.tmu_count = 1,
-};
-
-struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS5250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define __EXYNOS5260_TMU_DATA	\
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 85, \
-	.trigger_levels[1] = 103, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50,
-
-#define EXYNOS5260_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5260
-
-struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5420_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420
-
-#define EXYNOS5420_TMU_DATA_SHARED \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420_TRIMINFO
-
-struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5440_TMU_DATA \
-	.trigger_levels[0] = 100, \
-	.trigger_levels[4] = 105, \
-	.trigger_enable[0] = 1, \
-	.trigger_type[0] = SW_TRIP, \
-	.trigger_type[4] = HW_TRIP, \
-	.max_trigger_level = 5, \
-	.non_hw_trigger_levels = 1, \
-	.gain = 5, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 0x5b2d, \
-	.min_efuse_value = 16, \
-	.max_efuse_value = 76, \
-	.first_point_trim = 25, \
-	.second_point_trim = 70, \
-	.default_temp_offset = 25, \
-	.type = SOC_ARCH_EXYNOS5440
-
-struct exynos_tmu_init_data const exynos5440_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-	},
-	.tmu_count = 3,
-};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 20/21] thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Since both SoCs have the same TMU IP block embedded on them, it is
not necessary to maintain separate compatible entry.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos5250.dtsi    | 2 +-
 drivers/thermal/samsung/exynos_tmu.c | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index e71ec78..3426bab 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -238,7 +238,7 @@
 	};
 
 	tmu: tmu@10060000 {
-		compatible = "samsung,exynos5250-tmu";
+		compatible = "samsung,exynos4412-tmu";
 		reg = <0x10060000 0x100>;
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index e26042a..f1e8c9b 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -753,9 +753,6 @@ static const struct of_device_id exynos_tmu_match[] = {
 		.compatible = "samsung,exynos4412-tmu",
 	},
 	{
-		.compatible = "samsung,exynos5250-tmu",
-	},
-	{
 		.compatible = "samsung,exynos5260-tmu",
 	},
 	{
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 20/21] thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

Since both SoCs have the same TMU IP block embedded on them, it is
not necessary to maintain separate compatible entry.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos5250.dtsi    | 2 +-
 drivers/thermal/samsung/exynos_tmu.c | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index e71ec78..3426bab 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -238,7 +238,7 @@
 	};
 
 	tmu: tmu at 10060000 {
-		compatible = "samsung,exynos5250-tmu";
+		compatible = "samsung,exynos4412-tmu";
 		reg = <0x10060000 0x100>;
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index e26042a..f1e8c9b 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -753,9 +753,6 @@ static const struct of_device_id exynos_tmu_match[] = {
 		.compatible = "samsung,exynos4412-tmu",
 	},
 	{
-		.compatible = "samsung,exynos5250-tmu",
-	},
-	{
 		.compatible = "samsung,exynos5260-tmu",
 	},
 	{
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 21/21] thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-09 16:38   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-samsung-soc, linux-arm-kernel, Linux PM list, Kukjin Kim,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Since both SoCs have the same TMU IP block embedded on them, it is
not necessary to maintain separate compatible entry.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/samsung/exynos_tmu.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index f1e8c9b..7818e2f 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -744,9 +744,6 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 
 static const struct of_device_id exynos_tmu_match[] = {
 	{
-		.compatible = "samsung,exynos3250-tmu",
-	},
-	{
 		.compatible = "samsung,exynos4210-tmu",
 	},
 	{
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH 21/21] thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412
@ 2014-10-09 16:38   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-09 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

Since both SoCs have the same TMU IP block embedded on them, it is
not necessary to maintain separate compatible entry.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/samsung/exynos_tmu.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index f1e8c9b..7818e2f 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -744,9 +744,6 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 
 static const struct of_device_id exynos_tmu_match[] = {
 	{
-		.compatible = "samsung,exynos3250-tmu",
-	},
-	{
 		.compatible = "samsung,exynos4210-tmu",
 	},
 	{
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* Re: [PATCH 21/21] thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412
  2014-10-09 16:38   ` Lukasz Majewski
@ 2014-10-09 23:34     ` Chanwoo Choi
  -1 siblings, 0 replies; 288+ messages in thread
From: Chanwoo Choi @ 2014-10-09 23:34 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Zhang Rui, linux-samsung-soc, linux-arm-kernel,
	Linux PM list, Kukjin Kim, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Kyungmin Park

On 10/10/2014 01:38 AM, Lukasz Majewski wrote:
> Since both SoCs have the same TMU IP block embedded on them, it is
> not necessary to maintain separate compatible entry.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/thermal/samsung/exynos_tmu.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index f1e8c9b..7818e2f 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -744,9 +744,6 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
>  
>  static const struct of_device_id exynos_tmu_match[] = {
>  	{
> -		.compatible = "samsung,exynos3250-tmu",
> -	},
> -	{

If you want to remove compatible string for Exynos3250,
you have to modify it on exynos3250.dtsi.

Thanks,
Chanwoo Choi

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 21/21] thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412
@ 2014-10-09 23:34     ` Chanwoo Choi
  0 siblings, 0 replies; 288+ messages in thread
From: Chanwoo Choi @ 2014-10-09 23:34 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/10/2014 01:38 AM, Lukasz Majewski wrote:
> Since both SoCs have the same TMU IP block embedded on them, it is
> not necessary to maintain separate compatible entry.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/thermal/samsung/exynos_tmu.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index f1e8c9b..7818e2f 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -744,9 +744,6 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
>  
>  static const struct of_device_id exynos_tmu_match[] = {
>  	{
> -		.compatible = "samsung,exynos3250-tmu",
> -	},
> -	{

If you want to remove compatible string for Exynos3250,
you have to modify it on exynos3250.dtsi.

Thanks,
Chanwoo Choi

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 21/21] thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412
  2014-10-09 23:34     ` Chanwoo Choi
@ 2014-10-10  8:51       ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-10  8:51 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Eduardo Valentin, Zhang Rui, linux-samsung-soc, linux-arm-kernel,
	Linux PM list, Kukjin Kim, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Kyungmin Park

Hi Chanwoo,

> On 10/10/2014 01:38 AM, Lukasz Majewski wrote:
> > Since both SoCs have the same TMU IP block embedded on them, it is
> > not necessary to maintain separate compatible entry.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  drivers/thermal/samsung/exynos_tmu.c | 3 ---
> >  1 file changed, 3 deletions(-)
> > 
> > diff --git a/drivers/thermal/samsung/exynos_tmu.c
> > b/drivers/thermal/samsung/exynos_tmu.c index f1e8c9b..7818e2f 100644
> > --- a/drivers/thermal/samsung/exynos_tmu.c
> > +++ b/drivers/thermal/samsung/exynos_tmu.c
> > @@ -744,9 +744,6 @@ static irqreturn_t exynos_tmu_irq(int irq, void
> > *id) 
> >  static const struct of_device_id exynos_tmu_match[] = {
> >  	{
> > -		.compatible = "samsung,exynos3250-tmu",
> > -	},
> > -	{
> 
> If you want to remove compatible string for Exynos3250,
> you have to modify it on exynos3250.dtsi.
> 

Thanks for pointing this out. I've overlooked this dtsi file.

> Thanks,
> Chanwoo Choi



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 21/21] thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412
@ 2014-10-10  8:51       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-10  8:51 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Chanwoo,

> On 10/10/2014 01:38 AM, Lukasz Majewski wrote:
> > Since both SoCs have the same TMU IP block embedded on them, it is
> > not necessary to maintain separate compatible entry.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  drivers/thermal/samsung/exynos_tmu.c | 3 ---
> >  1 file changed, 3 deletions(-)
> > 
> > diff --git a/drivers/thermal/samsung/exynos_tmu.c
> > b/drivers/thermal/samsung/exynos_tmu.c index f1e8c9b..7818e2f 100644
> > --- a/drivers/thermal/samsung/exynos_tmu.c
> > +++ b/drivers/thermal/samsung/exynos_tmu.c
> > @@ -744,9 +744,6 @@ static irqreturn_t exynos_tmu_irq(int irq, void
> > *id) 
> >  static const struct of_device_id exynos_tmu_match[] = {
> >  	{
> > -		.compatible = "samsung,exynos3250-tmu",
> > -	},
> > -	{
> 
> If you want to remove compatible string for Exynos3250,
> you have to modify it on exynos3250.dtsi.
> 

Thanks for pointing this out. I've overlooked this dtsi file.

> Thanks,
> Chanwoo Choi



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 00/21] thermal: exynos: Thermal code rework to use device tree
  2014-10-09 16:38 ` Lukasz Majewski
@ 2014-10-23  8:50   ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-23  8:50 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Lukasz Majewski, linux-samsung-soc, linux-arm-kernel,
	Linux PM list, Kukjin Kim, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Kyungmin Park,
	Chanwoo Choi

Hi Lukasz,

> 1. Introduction
> 
> Following patches aim to clean up the current implementation of the
> thermal framework on Exynos devices.
> 
> The main goal was to use a generic code for reading thermal
> configuration (of-thermal.c). Due to that redundant
> exynos_thermal_common.[h|c] files were removed.
> 
> Around 400 lines of code (LOC) were removed directly by this patch,
> which is around 20% of the Exynos thermal code base.
> 
> This work should NOT bring any functional changes to Exynos thermal 
> subsystem.
> 
> 2. Patch-set structure
> 
> This series starts with extending current of-thermal.c implementation
> with exporting information about trip points and support for setting
> emulated temperature. Those changes were necessary to reuse this code
> in Exynos.
> 
> Then the cpu_cooling functionality has been preserved to allow cooling
> devices by reducing operating frequency. Definition of trip points and
> cpufreq's cooling properties were moved to device tree.
> 
> Then the rework of the way in which configuration data is provided to
> the Exynos thermal subsystem was performed. Now device tree is used
> for configuration.
> 
> Patch series end with removing exynos5250/exynos3250 TMU compatibles.
> Both SoCs have thermal management unit (TMU) compatible with the one
> first introduced at Exynos4412.
> 
> 3. Dead code removal
> 
> Thermal support for some SoCs, previously available in the
> exynos_tmu_data.c file, was removed since, as of 3.17-rc6, they
> didn't have TMU bindings.
> 
> Moreover, support for cpu_cooling devices was preserved only on those
> SoCs which had available and working cpufreq driver.
> 
> 4. Testing
> 
> Test devices:
> - Exynos4210 - Trats (TMU zone + cpu_cooling)
> - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> - Exynos5420 - Arndale-octa (only TMU zones)
> 
> Unfortunately, I don't posses Exynos5440 for testing. Its
> functionality has been preserved in the code, but not tested on the
> hardware. I would be grateful for help in testing.
> 
> 5. Prerequisites:
> 
> This work requires following patches developed by Bartlomiej
> Zolnierkiewicz:
> 
> 5.1. [PATCH v3] ARM: dts: add CPU nodes for Exynos4 SoCs
> http://article.gmane.org/gmane.linux.kernel.samsung-soc/37946/match=patch+v3+arm+dts+add+cpu+nodes+exynos4+socs
> 
> 5.2. First thermal clean up patch set (from patch 1 to 33):
> 
> [PATCH 00/33] thermal: exynos: convert the driver to use per-SoC type
> operations
> http://article.gmane.org/gmane.linux.kernel.samsung-soc/37642/match=patch+00+33+thermal+exynos+convert+driver+use+per+soc+type+operations
> 

Any comments on this patch set (despite the ones from Chanwoo)?

I'm especially wondering if changes introduced to of-thermal.c file are
appropriate for mainline.

> 
> Lukasz Majewski (21):
>   thermal: of: Extend of-thermal.c to provide number of trip points
>   thermal: of: Extend of-thermal.c to provide check if trip point is
>     enabled
>   thermal: of: Extend of-thermal.c to provide number of non critical
>     trip points
>   thermal: of: Extend current of-thermal.c code to allow setting
>     emulated temp
>   thermal: exynos: cosmetic: Correct comment format
>   thermal: exynos: Provide thermal_exynos.h file to be included in
>     device tree files
>   thermal: dts: trats: Enable TMU on the Exynos4210 trats device
>   thermal: dts: exynos: Adding LD010 regulator node necessary for TMU
> on Odroid U3 board
>   thermal: dts: Provide bindings and enable TMU at Exynos4x12 devices
>   thermal: cpu_cooling: dts: Define device tree bindings for Exynos
> cpu cooling functionality
>   thermal: cpu_cooling: Modify exynos thermal code to use device tree
>     for cpu cooling configuration
>   thermal: exynos: dts: Add default definition for the TMU sensor
>   thermal: dts: Default trip points definition for Exynos5420 SoCs
>   thermal: exynos: dts: Define default thermal-zones for Exynos4
>   thermal: dts: exynos: Trip points and sensor configuration data for
>     Exynos5440
>   thermal: exynos: dts: Provide device tree bindings identical to one
> in exynos_tmu_data.c
>   thermal: samsung: core: Exynos TMU rework to use device tree for
>     configuration
>   thermal: exynos: Remove exynos_thermal_common.[c|h] files
>   thermal: exynos: Remove exynos_tmu_data.c file
>   thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412
>   thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412
> 
>  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi        |  52 +++
>  arch/arm/boot/dts/exynos4.dtsi                    |   5 +
>  arch/arm/boot/dts/exynos4210-trats.dts            |  19 +
>  arch/arm/boot/dts/exynos4210.dtsi                 |  28 +-
>  arch/arm/boot/dts/exynos4212.dtsi                 |   5 +-
>  arch/arm/boot/dts/exynos4412-odroid-common.dtsi   |  27 ++
>  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi |  24 ++
>  arch/arm/boot/dts/exynos4412.dtsi                 |   5 +-
>  arch/arm/boot/dts/exynos4x12.dtsi                 |  13 +
>  arch/arm/boot/dts/exynos5250.dtsi                 |  29 +-
>  arch/arm/boot/dts/exynos5420-trip-points.dtsi     |  35 ++
>  arch/arm/boot/dts/exynos5420.dtsi                 |  33 ++
>  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi |  25 ++
>  arch/arm/boot/dts/exynos5440-trip-points.dtsi     |  25 ++
>  arch/arm/boot/dts/exynos5440.dtsi                 |  18 +
>  drivers/cpufreq/exynos-cpufreq.c                  |  23 +-
>  drivers/thermal/of-thermal.c                      |  52 ++-
>  drivers/thermal/samsung/Makefile                  |   2 -
>  drivers/thermal/samsung/exynos_thermal_common.c   | 430
> ----------------------
> drivers/thermal/samsung/exynos_thermal_common.h   | 106 ------
> drivers/thermal/samsung/exynos_tmu.c              | 283
> +++++++------- drivers/thermal/samsung/exynos_tmu.h              |
> 79 +--- drivers/thermal/samsung/exynos_tmu_data.c         | 264
> ------------- drivers/thermal/thermal_core.h                    |  15
> + include/dt-bindings/thermal/thermal_exynos.h      |  40 ++
> include/linux/thermal.h                           |   6 +- 26 files
> changed, 623 insertions(+), 1020 deletions(-) create mode 100644
> arch/arm/boot/dts/exynos4-cpu-thermal.dtsi create mode 100644
> arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi create mode 100644
> arch/arm/boot/dts/exynos5420-trip-points.dtsi create mode 100644
> arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi create mode 100644
> arch/arm/boot/dts/exynos5440-trip-points.dtsi delete mode 100644
> drivers/thermal/samsung/exynos_thermal_common.c delete mode 100644
> drivers/thermal/samsung/exynos_thermal_common.h delete mode 100644
> drivers/thermal/samsung/exynos_tmu_data.c create mode 100644
> include/dt-bindings/thermal/thermal_exynos.h
> 


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 00/21] thermal: exynos: Thermal code rework to use device tree
@ 2014-10-23  8:50   ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-10-23  8:50 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Lukasz,

> 1. Introduction
> 
> Following patches aim to clean up the current implementation of the
> thermal framework on Exynos devices.
> 
> The main goal was to use a generic code for reading thermal
> configuration (of-thermal.c). Due to that redundant
> exynos_thermal_common.[h|c] files were removed.
> 
> Around 400 lines of code (LOC) were removed directly by this patch,
> which is around 20% of the Exynos thermal code base.
> 
> This work should NOT bring any functional changes to Exynos thermal 
> subsystem.
> 
> 2. Patch-set structure
> 
> This series starts with extending current of-thermal.c implementation
> with exporting information about trip points and support for setting
> emulated temperature. Those changes were necessary to reuse this code
> in Exynos.
> 
> Then the cpu_cooling functionality has been preserved to allow cooling
> devices by reducing operating frequency. Definition of trip points and
> cpufreq's cooling properties were moved to device tree.
> 
> Then the rework of the way in which configuration data is provided to
> the Exynos thermal subsystem was performed. Now device tree is used
> for configuration.
> 
> Patch series end with removing exynos5250/exynos3250 TMU compatibles.
> Both SoCs have thermal management unit (TMU) compatible with the one
> first introduced at Exynos4412.
> 
> 3. Dead code removal
> 
> Thermal support for some SoCs, previously available in the
> exynos_tmu_data.c file, was removed since, as of 3.17-rc6, they
> didn't have TMU bindings.
> 
> Moreover, support for cpu_cooling devices was preserved only on those
> SoCs which had available and working cpufreq driver.
> 
> 4. Testing
> 
> Test devices:
> - Exynos4210 - Trats (TMU zone + cpu_cooling)
> - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> - Exynos5420 - Arndale-octa (only TMU zones)
> 
> Unfortunately, I don't posses Exynos5440 for testing. Its
> functionality has been preserved in the code, but not tested on the
> hardware. I would be grateful for help in testing.
> 
> 5. Prerequisites:
> 
> This work requires following patches developed by Bartlomiej
> Zolnierkiewicz:
> 
> 5.1. [PATCH v3] ARM: dts: add CPU nodes for Exynos4 SoCs
> http://article.gmane.org/gmane.linux.kernel.samsung-soc/37946/match=patch+v3+arm+dts+add+cpu+nodes+exynos4+socs
> 
> 5.2. First thermal clean up patch set (from patch 1 to 33):
> 
> [PATCH 00/33] thermal: exynos: convert the driver to use per-SoC type
> operations
> http://article.gmane.org/gmane.linux.kernel.samsung-soc/37642/match=patch+00+33+thermal+exynos+convert+driver+use+per+soc+type+operations
> 

Any comments on this patch set (despite the ones from Chanwoo)?

I'm especially wondering if changes introduced to of-thermal.c file are
appropriate for mainline.

> 
> Lukasz Majewski (21):
>   thermal: of: Extend of-thermal.c to provide number of trip points
>   thermal: of: Extend of-thermal.c to provide check if trip point is
>     enabled
>   thermal: of: Extend of-thermal.c to provide number of non critical
>     trip points
>   thermal: of: Extend current of-thermal.c code to allow setting
>     emulated temp
>   thermal: exynos: cosmetic: Correct comment format
>   thermal: exynos: Provide thermal_exynos.h file to be included in
>     device tree files
>   thermal: dts: trats: Enable TMU on the Exynos4210 trats device
>   thermal: dts: exynos: Adding LD010 regulator node necessary for TMU
> on Odroid U3 board
>   thermal: dts: Provide bindings and enable TMU at Exynos4x12 devices
>   thermal: cpu_cooling: dts: Define device tree bindings for Exynos
> cpu cooling functionality
>   thermal: cpu_cooling: Modify exynos thermal code to use device tree
>     for cpu cooling configuration
>   thermal: exynos: dts: Add default definition for the TMU sensor
>   thermal: dts: Default trip points definition for Exynos5420 SoCs
>   thermal: exynos: dts: Define default thermal-zones for Exynos4
>   thermal: dts: exynos: Trip points and sensor configuration data for
>     Exynos5440
>   thermal: exynos: dts: Provide device tree bindings identical to one
> in exynos_tmu_data.c
>   thermal: samsung: core: Exynos TMU rework to use device tree for
>     configuration
>   thermal: exynos: Remove exynos_thermal_common.[c|h] files
>   thermal: exynos: Remove exynos_tmu_data.c file
>   thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412
>   thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412
> 
>  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi        |  52 +++
>  arch/arm/boot/dts/exynos4.dtsi                    |   5 +
>  arch/arm/boot/dts/exynos4210-trats.dts            |  19 +
>  arch/arm/boot/dts/exynos4210.dtsi                 |  28 +-
>  arch/arm/boot/dts/exynos4212.dtsi                 |   5 +-
>  arch/arm/boot/dts/exynos4412-odroid-common.dtsi   |  27 ++
>  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi |  24 ++
>  arch/arm/boot/dts/exynos4412.dtsi                 |   5 +-
>  arch/arm/boot/dts/exynos4x12.dtsi                 |  13 +
>  arch/arm/boot/dts/exynos5250.dtsi                 |  29 +-
>  arch/arm/boot/dts/exynos5420-trip-points.dtsi     |  35 ++
>  arch/arm/boot/dts/exynos5420.dtsi                 |  33 ++
>  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi |  25 ++
>  arch/arm/boot/dts/exynos5440-trip-points.dtsi     |  25 ++
>  arch/arm/boot/dts/exynos5440.dtsi                 |  18 +
>  drivers/cpufreq/exynos-cpufreq.c                  |  23 +-
>  drivers/thermal/of-thermal.c                      |  52 ++-
>  drivers/thermal/samsung/Makefile                  |   2 -
>  drivers/thermal/samsung/exynos_thermal_common.c   | 430
> ----------------------
> drivers/thermal/samsung/exynos_thermal_common.h   | 106 ------
> drivers/thermal/samsung/exynos_tmu.c              | 283
> +++++++------- drivers/thermal/samsung/exynos_tmu.h              |
> 79 +--- drivers/thermal/samsung/exynos_tmu_data.c         | 264
> ------------- drivers/thermal/thermal_core.h                    |  15
> + include/dt-bindings/thermal/thermal_exynos.h      |  40 ++
> include/linux/thermal.h                           |   6 +- 26 files
> changed, 623 insertions(+), 1020 deletions(-) create mode 100644
> arch/arm/boot/dts/exynos4-cpu-thermal.dtsi create mode 100644
> arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi create mode 100644
> arch/arm/boot/dts/exynos5420-trip-points.dtsi create mode 100644
> arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi create mode 100644
> arch/arm/boot/dts/exynos5440-trip-points.dtsi delete mode 100644
> drivers/thermal/samsung/exynos_thermal_common.c delete mode 100644
> drivers/thermal/samsung/exynos_thermal_common.h delete mode 100644
> drivers/thermal/samsung/exynos_tmu_data.c create mode 100644
> include/dt-bindings/thermal/thermal_exynos.h
> 


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 01/21] thermal: of: Extend of-thermal.c to provide number of trip points
  2014-10-09 16:38   ` Lukasz Majewski
@ 2014-11-07  1:34     ` Eduardo Valentin
  -1 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-07  1:34 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, linux-samsung-soc, linux-arm-kernel, Linux PM list,
	Kukjin Kim, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 1839 bytes --]

Hello Lukasz,

On Thu, Oct 09, 2014 at 06:38:37PM +0200, Lukasz Majewski wrote:
> This patch extends the of-thermal.c to provide information about number of
> available trip points.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/thermal/of-thermal.c   | 6 ++++++
>  drivers/thermal/thermal_core.h | 5 +++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index f8eb625..b2390d9 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -113,6 +113,12 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
>  	return data->get_temp(data->sensor_data, temp);
>  }
>  
> +int of_thermal_get_ntrips(struct thermal_zone_device *tz)
> +{
> +	struct __thermal_zone *data = tz->devdata;
> +	return data->ntrips;
> +}

I am not against this addition. I just request you to document it
accordingly.

> +
>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
>  				enum thermal_trend *trend)
>  {
> diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> index 3db339f..587ca5c 100644
> --- a/drivers/thermal/thermal_core.h
> +++ b/drivers/thermal/thermal_core.h
> @@ -81,9 +81,14 @@ static inline void thermal_gov_user_space_unregister(void) {}
>  #ifdef CONFIG_THERMAL_OF
>  int of_parse_thermal_zones(void);
>  void of_thermal_destroy_zones(void);
> +int of_thermal_get_ntrips(struct thermal_zone_device *);
>  #else
>  static inline int of_parse_thermal_zones(void) { return 0; }
>  static inline void of_thermal_destroy_zones(void) { }
> +static inline int of_thermal_get_ntrips(struct thermal_zone_device *)
> +{
> +	return 0;
> +}
>  #endif
>  
>  #endif /* __THERMAL_CORE_H__ */
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 01/21] thermal: of: Extend of-thermal.c to provide number of trip points
@ 2014-11-07  1:34     ` Eduardo Valentin
  0 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-07  1:34 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Lukasz,

On Thu, Oct 09, 2014 at 06:38:37PM +0200, Lukasz Majewski wrote:
> This patch extends the of-thermal.c to provide information about number of
> available trip points.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/thermal/of-thermal.c   | 6 ++++++
>  drivers/thermal/thermal_core.h | 5 +++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index f8eb625..b2390d9 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -113,6 +113,12 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
>  	return data->get_temp(data->sensor_data, temp);
>  }
>  
> +int of_thermal_get_ntrips(struct thermal_zone_device *tz)
> +{
> +	struct __thermal_zone *data = tz->devdata;
> +	return data->ntrips;
> +}

I am not against this addition. I just request you to document it
accordingly.

> +
>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
>  				enum thermal_trend *trend)
>  {
> diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> index 3db339f..587ca5c 100644
> --- a/drivers/thermal/thermal_core.h
> +++ b/drivers/thermal/thermal_core.h
> @@ -81,9 +81,14 @@ static inline void thermal_gov_user_space_unregister(void) {}
>  #ifdef CONFIG_THERMAL_OF
>  int of_parse_thermal_zones(void);
>  void of_thermal_destroy_zones(void);
> +int of_thermal_get_ntrips(struct thermal_zone_device *);
>  #else
>  static inline int of_parse_thermal_zones(void) { return 0; }
>  static inline void of_thermal_destroy_zones(void) { }
> +static inline int of_thermal_get_ntrips(struct thermal_zone_device *)
> +{
> +	return 0;
> +}
>  #endif
>  
>  #endif /* __THERMAL_CORE_H__ */
> -- 
> 2.0.0.rc2
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141106/41acfa02/attachment.sig>

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 02/21] thermal: of: Extend of-thermal.c to provide check if trip point is enabled
  2014-10-09 16:38   ` Lukasz Majewski
@ 2014-11-07  1:37     ` Eduardo Valentin
  -1 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-07  1:37 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, linux-samsung-soc, linux-arm-kernel, Linux PM list,
	Kukjin Kim, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 2131 bytes --]

Hello Lukasz,

On Thu, Oct 09, 2014 at 06:38:38PM +0200, Lukasz Majewski wrote:
> This patch extends the of-thermal.c to provide check if trip point is
> enabled.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/thermal/of-thermal.c   | 9 +++++++++
>  drivers/thermal/thermal_core.h | 5 +++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index b2390d9..23c8d6c 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -119,6 +119,15 @@ int of_thermal_get_ntrips(struct thermal_zone_device *tz)
>  	return data->ntrips;
>  }
>  
> +int of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)
> +{
> +	struct __thermal_zone *data = tz->devdata;
> +
> +	if (trip >= data->ntrips || trip < 0)
> +		return 0;
> +	return 1;

might be worth using 'true' and 'false', just for the sake of code
readability.

> +}
> +


I am not against this addition. I just request you to document it
accordingly.


>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
>  				enum thermal_trend *trend)
>  {
> diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> index 587ca5c..ed8ff05 100644
> --- a/drivers/thermal/thermal_core.h
> +++ b/drivers/thermal/thermal_core.h
> @@ -82,6 +82,7 @@ static inline void thermal_gov_user_space_unregister(void) {}
>  int of_parse_thermal_zones(void);
>  void of_thermal_destroy_zones(void);
>  int of_thermal_get_ntrips(struct thermal_zone_device *);
> +int of_thermal_is_trip_en(struct thermal_zone_device *, int);
>  #else
>  static inline int of_parse_thermal_zones(void) { return 0; }
>  static inline void of_thermal_destroy_zones(void) { }
> @@ -89,6 +90,10 @@ static inline int of_thermal_get_ntrips(struct thermal_zone_device *)
>  {
>  	return 0;
>  }
> +int of_thermal_is_trip_en(struct thermal_zone_device *, int)
this is supposed to be static inline.

> +{
> +	return 0;
> +}
>  #endif
>  
>  #endif /* __THERMAL_CORE_H__ */
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 02/21] thermal: of: Extend of-thermal.c to provide check if trip point is enabled
@ 2014-11-07  1:37     ` Eduardo Valentin
  0 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-07  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Lukasz,

On Thu, Oct 09, 2014 at 06:38:38PM +0200, Lukasz Majewski wrote:
> This patch extends the of-thermal.c to provide check if trip point is
> enabled.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/thermal/of-thermal.c   | 9 +++++++++
>  drivers/thermal/thermal_core.h | 5 +++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index b2390d9..23c8d6c 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -119,6 +119,15 @@ int of_thermal_get_ntrips(struct thermal_zone_device *tz)
>  	return data->ntrips;
>  }
>  
> +int of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)
> +{
> +	struct __thermal_zone *data = tz->devdata;
> +
> +	if (trip >= data->ntrips || trip < 0)
> +		return 0;
> +	return 1;

might be worth using 'true' and 'false', just for the sake of code
readability.

> +}
> +


I am not against this addition. I just request you to document it
accordingly.


>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
>  				enum thermal_trend *trend)
>  {
> diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> index 587ca5c..ed8ff05 100644
> --- a/drivers/thermal/thermal_core.h
> +++ b/drivers/thermal/thermal_core.h
> @@ -82,6 +82,7 @@ static inline void thermal_gov_user_space_unregister(void) {}
>  int of_parse_thermal_zones(void);
>  void of_thermal_destroy_zones(void);
>  int of_thermal_get_ntrips(struct thermal_zone_device *);
> +int of_thermal_is_trip_en(struct thermal_zone_device *, int);
>  #else
>  static inline int of_parse_thermal_zones(void) { return 0; }
>  static inline void of_thermal_destroy_zones(void) { }
> @@ -89,6 +90,10 @@ static inline int of_thermal_get_ntrips(struct thermal_zone_device *)
>  {
>  	return 0;
>  }
> +int of_thermal_is_trip_en(struct thermal_zone_device *, int)
this is supposed to be static inline.

> +{
> +	return 0;
> +}
>  #endif
>  
>  #endif /* __THERMAL_CORE_H__ */
> -- 
> 2.0.0.rc2
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141106/fcbfbbba/attachment-0001.sig>

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
  2014-10-09 16:38   ` Lukasz Majewski
@ 2014-11-07  1:41     ` Eduardo Valentin
  -1 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-07  1:41 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, linux-samsung-soc, linux-arm-kernel, Linux PM list,
	Kukjin Kim, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 2404 bytes --]

On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski wrote:
> This patch extends the of-thermal.c to provide information about number of
> available non critical (i.e. non HW) trip points in the system.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/thermal/of-thermal.c   | 12 ++++++++++++
>  drivers/thermal/thermal_core.h |  5 +++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index 23c8d6c..cd74e64 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)
>  	return 1;
>  }
>  
> +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *tz)
> +{
> +	struct __thermal_zone *data = tz->devdata;
> +	int i;
> +
> +	for (i = 0; i < data->ntrips; i++)
> +		if (data->trips[i].type != THERMAL_TRIP_CRITICAL)
> +			continue;
> +
> +	return --i;
> +}
> +



I am not against this addition. But looks like we start to spread some
specific APIs that may not be used to other drivers. Maybe having a
single API to provide a read-only copy the list / array of trips might
be a better approach. I will think of a better way.

I also request you to document it accordingly.


>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
>  				enum thermal_trend *trend)
>  {
> diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> index ed8ff05..334a7be 100644
> --- a/drivers/thermal/thermal_core.h
> +++ b/drivers/thermal/thermal_core.h
> @@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
>  void of_thermal_destroy_zones(void);
>  int of_thermal_get_ntrips(struct thermal_zone_device *);
>  int of_thermal_is_trip_en(struct thermal_zone_device *, int);
> +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *);
>  #else
>  static inline int of_parse_thermal_zones(void) { return 0; }
>  static inline void of_thermal_destroy_zones(void) { }
> @@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct thermal_zone_device *, int)
>  {
>  	return 0;
>  }
> +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *)
here, it is supposed to be static inline.

> +{
> +	return 0;
> +}
>  #endif
>  
>  #endif /* __THERMAL_CORE_H__ */
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
@ 2014-11-07  1:41     ` Eduardo Valentin
  0 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-07  1:41 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski wrote:
> This patch extends the of-thermal.c to provide information about number of
> available non critical (i.e. non HW) trip points in the system.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/thermal/of-thermal.c   | 12 ++++++++++++
>  drivers/thermal/thermal_core.h |  5 +++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index 23c8d6c..cd74e64 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)
>  	return 1;
>  }
>  
> +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *tz)
> +{
> +	struct __thermal_zone *data = tz->devdata;
> +	int i;
> +
> +	for (i = 0; i < data->ntrips; i++)
> +		if (data->trips[i].type != THERMAL_TRIP_CRITICAL)
> +			continue;
> +
> +	return --i;
> +}
> +



I am not against this addition. But looks like we start to spread some
specific APIs that may not be used to other drivers. Maybe having a
single API to provide a read-only copy the list / array of trips might
be a better approach. I will think of a better way.

I also request you to document it accordingly.


>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
>  				enum thermal_trend *trend)
>  {
> diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> index ed8ff05..334a7be 100644
> --- a/drivers/thermal/thermal_core.h
> +++ b/drivers/thermal/thermal_core.h
> @@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
>  void of_thermal_destroy_zones(void);
>  int of_thermal_get_ntrips(struct thermal_zone_device *);
>  int of_thermal_is_trip_en(struct thermal_zone_device *, int);
> +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *);
>  #else
>  static inline int of_parse_thermal_zones(void) { return 0; }
>  static inline void of_thermal_destroy_zones(void) { }
> @@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct thermal_zone_device *, int)
>  {
>  	return 0;
>  }
> +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *)
here, it is supposed to be static inline.

> +{
> +	return 0;
> +}
>  #endif
>  
>  #endif /* __THERMAL_CORE_H__ */
> -- 
> 2.0.0.rc2
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141106/34013c3e/attachment.sig>

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 04/21] thermal: of: Extend current of-thermal.c code to allow setting emulated temp
  2014-10-09 16:38   ` Lukasz Majewski
@ 2014-11-07  1:44     ` Eduardo Valentin
  -1 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-07  1:44 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, linux-samsung-soc, linux-arm-kernel, Linux PM list,
	Kukjin Kim, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 4751 bytes --]

Hello,

On Thu, Oct 09, 2014 at 06:38:40PM +0200, Lukasz Majewski wrote:
> Before this change it was only possible to set get_temp() and get_trend()
> methods to be used in the common code handling passing parameters via
> device tree to "cpu-thermal" CPU thermal zone device.
> 
> Now it is possible to also set emulated value of temperature for debug
> purposes.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/thermal/of-thermal.c | 25 ++++++++++++++++++++++---
>  include/linux/thermal.h      |  6 ++++--
>  2 files changed, 26 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index cd74e64..f206375 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -98,10 +98,22 @@ struct __thermal_zone {
>  	void *sensor_data;
>  	int (*get_temp)(void *, long *);
>  	int (*get_trend)(void *, long *);
> +	int (*set_emul_temp)(void *, unsigned long);
>  };
>  
>  /***   DT thermal zone device callbacks   ***/
>  
> +static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
> +				    unsigned long temp)
> +{
> +	struct __thermal_zone *data = tz->devdata;
> +
> +	if (!data->set_emul_temp)
> +		return -EINVAL;
> +
> +	return data->set_emul_temp(data->sensor_data, temp);
> +}
> +
>  static int of_thermal_get_temp(struct thermal_zone_device *tz,
>  			       unsigned long *temp)
>  {
> @@ -352,7 +364,8 @@ static struct thermal_zone_device *
>  thermal_zone_of_add_sensor(struct device_node *zone,
>  			   struct device_node *sensor, void *data,
>  			   int (*get_temp)(void *, long *),
> -			   int (*get_trend)(void *, long *))
> +			   int (*get_trend)(void *, long *),
> +			   int (*set_emul_temp)(void *, unsigned long))

Thanks for improving the API. However, looking at what is above, it
starts to be pretty ugly. And for sure, this is not the last callback to
be added. I believe it is time to add a .ops in the of-thermal. While in
here, do you mind adding the .ops in a separated patch, then add the
.set_emul_temp in the .ops field?

>  {
>  	struct thermal_zone_device *tzd;
>  	struct __thermal_zone *tz;
> @@ -366,10 +379,12 @@ thermal_zone_of_add_sensor(struct device_node *zone,
>  	mutex_lock(&tzd->lock);
>  	tz->get_temp = get_temp;
>  	tz->get_trend = get_trend;
> +	tz->set_emul_temp = set_emul_temp;
>  	tz->sensor_data = data;
>  
>  	tzd->ops->get_temp = of_thermal_get_temp;
>  	tzd->ops->get_trend = of_thermal_get_trend;
> +	tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
>  	mutex_unlock(&tzd->lock);
>  
>  	return tzd;
> @@ -411,7 +426,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
>  struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
>  				void *data, int (*get_temp)(void *, long *),
> -				int (*get_trend)(void *, long *))
> +				int (*get_trend)(void *, long *),
> +				int (*set_emul_temp)(void *, unsigned long))
>  {
>  	struct device_node *np, *child, *sensor_np;
>  
> @@ -453,7 +469,8 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
>  			return thermal_zone_of_add_sensor(child, sensor_np,
>  							  data,
>  							  get_temp,
> -							  get_trend);
> +							  get_trend,
> +							  set_emul_temp);
>  		}
>  	}
>  	of_node_put(np);
> @@ -494,9 +511,11 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
>  	mutex_lock(&tzd->lock);
>  	tzd->ops->get_temp = NULL;
>  	tzd->ops->get_trend = NULL;
> +	tzd->ops->set_emul_temp = NULL;
>  
>  	tz->get_temp = NULL;
>  	tz->get_trend = NULL;
> +	tz->set_emul_temp = NULL;
>  	tz->sensor_data = NULL;
>  	mutex_unlock(&tzd->lock);
>  }
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 0305cde..36010e9 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -290,14 +290,16 @@ struct thermal_genl_event {
>  struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int id,
>  				void *data, int (*get_temp)(void *, long *),
> -				int (*get_trend)(void *, long *));
> +				int (*get_trend)(void *, long *),
> +				int (*set_emul_temp)(void *, unsigned long));
>  void thermal_zone_of_sensor_unregister(struct device *dev,
>  				       struct thermal_zone_device *tz);
>  #else
>  static inline struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int id,
>  				void *data, int (*get_temp)(void *, long *),
> -				int (*get_trend)(void *, long *))
> +				int (*get_trend)(void *, long *),
> +				int (*set_emul_temp)(void *, unsigned long))
>  {
>  	return NULL;
>  }
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 04/21] thermal: of: Extend current of-thermal.c code to allow setting emulated temp
@ 2014-11-07  1:44     ` Eduardo Valentin
  0 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-07  1:44 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

On Thu, Oct 09, 2014 at 06:38:40PM +0200, Lukasz Majewski wrote:
> Before this change it was only possible to set get_temp() and get_trend()
> methods to be used in the common code handling passing parameters via
> device tree to "cpu-thermal" CPU thermal zone device.
> 
> Now it is possible to also set emulated value of temperature for debug
> purposes.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/thermal/of-thermal.c | 25 ++++++++++++++++++++++---
>  include/linux/thermal.h      |  6 ++++--
>  2 files changed, 26 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index cd74e64..f206375 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -98,10 +98,22 @@ struct __thermal_zone {
>  	void *sensor_data;
>  	int (*get_temp)(void *, long *);
>  	int (*get_trend)(void *, long *);
> +	int (*set_emul_temp)(void *, unsigned long);
>  };
>  
>  /***   DT thermal zone device callbacks   ***/
>  
> +static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
> +				    unsigned long temp)
> +{
> +	struct __thermal_zone *data = tz->devdata;
> +
> +	if (!data->set_emul_temp)
> +		return -EINVAL;
> +
> +	return data->set_emul_temp(data->sensor_data, temp);
> +}
> +
>  static int of_thermal_get_temp(struct thermal_zone_device *tz,
>  			       unsigned long *temp)
>  {
> @@ -352,7 +364,8 @@ static struct thermal_zone_device *
>  thermal_zone_of_add_sensor(struct device_node *zone,
>  			   struct device_node *sensor, void *data,
>  			   int (*get_temp)(void *, long *),
> -			   int (*get_trend)(void *, long *))
> +			   int (*get_trend)(void *, long *),
> +			   int (*set_emul_temp)(void *, unsigned long))

Thanks for improving the API. However, looking at what is above, it
starts to be pretty ugly. And for sure, this is not the last callback to
be added. I believe it is time to add a .ops in the of-thermal. While in
here, do you mind adding the .ops in a separated patch, then add the
.set_emul_temp in the .ops field?

>  {
>  	struct thermal_zone_device *tzd;
>  	struct __thermal_zone *tz;
> @@ -366,10 +379,12 @@ thermal_zone_of_add_sensor(struct device_node *zone,
>  	mutex_lock(&tzd->lock);
>  	tz->get_temp = get_temp;
>  	tz->get_trend = get_trend;
> +	tz->set_emul_temp = set_emul_temp;
>  	tz->sensor_data = data;
>  
>  	tzd->ops->get_temp = of_thermal_get_temp;
>  	tzd->ops->get_trend = of_thermal_get_trend;
> +	tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
>  	mutex_unlock(&tzd->lock);
>  
>  	return tzd;
> @@ -411,7 +426,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
>  struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
>  				void *data, int (*get_temp)(void *, long *),
> -				int (*get_trend)(void *, long *))
> +				int (*get_trend)(void *, long *),
> +				int (*set_emul_temp)(void *, unsigned long))
>  {
>  	struct device_node *np, *child, *sensor_np;
>  
> @@ -453,7 +469,8 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
>  			return thermal_zone_of_add_sensor(child, sensor_np,
>  							  data,
>  							  get_temp,
> -							  get_trend);
> +							  get_trend,
> +							  set_emul_temp);
>  		}
>  	}
>  	of_node_put(np);
> @@ -494,9 +511,11 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
>  	mutex_lock(&tzd->lock);
>  	tzd->ops->get_temp = NULL;
>  	tzd->ops->get_trend = NULL;
> +	tzd->ops->set_emul_temp = NULL;
>  
>  	tz->get_temp = NULL;
>  	tz->get_trend = NULL;
> +	tz->set_emul_temp = NULL;
>  	tz->sensor_data = NULL;
>  	mutex_unlock(&tzd->lock);
>  }
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 0305cde..36010e9 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -290,14 +290,16 @@ struct thermal_genl_event {
>  struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int id,
>  				void *data, int (*get_temp)(void *, long *),
> -				int (*get_trend)(void *, long *));
> +				int (*get_trend)(void *, long *),
> +				int (*set_emul_temp)(void *, unsigned long));
>  void thermal_zone_of_sensor_unregister(struct device *dev,
>  				       struct thermal_zone_device *tz);
>  #else
>  static inline struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int id,
>  				void *data, int (*get_temp)(void *, long *),
> -				int (*get_trend)(void *, long *))
> +				int (*get_trend)(void *, long *),
> +				int (*set_emul_temp)(void *, unsigned long))
>  {
>  	return NULL;
>  }
> -- 
> 2.0.0.rc2
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141106/f8997fc6/attachment.sig>

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 01/21] thermal: of: Extend of-thermal.c to provide number of trip points
  2014-11-07  1:34     ` Eduardo Valentin
@ 2014-11-07  9:14       ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-07  9:14 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, linux-samsung-soc, linux-arm-kernel, Linux PM list,
	Kukjin Kim, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Kyungmin Park, Chanwoo Choi

Hi Eduardo,

> Hello Lukasz,
> 
> On Thu, Oct 09, 2014 at 06:38:37PM +0200, Lukasz Majewski wrote:
> > This patch extends the of-thermal.c to provide information about
> > number of available trip points.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  drivers/thermal/of-thermal.c   | 6 ++++++
> >  drivers/thermal/thermal_core.h | 5 +++++
> >  2 files changed, 11 insertions(+)
> > 
> > diff --git a/drivers/thermal/of-thermal.c
> > b/drivers/thermal/of-thermal.c index f8eb625..b2390d9 100644
> > --- a/drivers/thermal/of-thermal.c
> > +++ b/drivers/thermal/of-thermal.c
> > @@ -113,6 +113,12 @@ static int of_thermal_get_temp(struct
> > thermal_zone_device *tz, return data->get_temp(data->sensor_data,
> > temp); }
> >  
> > +int of_thermal_get_ntrips(struct thermal_zone_device *tz)
> > +{
> > +	struct __thermal_zone *data = tz->devdata;
> > +	return data->ntrips;
> > +}
> 
> I am not against this addition. I just request you to document it
> accordingly.

OK, no problem.

> 
> > +
> >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > int trip, enum thermal_trend *trend)
> >  {
> > diff --git a/drivers/thermal/thermal_core.h
> > b/drivers/thermal/thermal_core.h index 3db339f..587ca5c 100644
> > --- a/drivers/thermal/thermal_core.h
> > +++ b/drivers/thermal/thermal_core.h
> > @@ -81,9 +81,14 @@ static inline void
> > thermal_gov_user_space_unregister(void) {} #ifdef CONFIG_THERMAL_OF
> >  int of_parse_thermal_zones(void);
> >  void of_thermal_destroy_zones(void);
> > +int of_thermal_get_ntrips(struct thermal_zone_device *);
> >  #else
> >  static inline int of_parse_thermal_zones(void) { return 0; }
> >  static inline void of_thermal_destroy_zones(void) { }
> > +static inline int of_thermal_get_ntrips(struct thermal_zone_device
> > *) +{
> > +	return 0;
> > +}
> >  #endif
> >  
> >  #endif /* __THERMAL_CORE_H__ */
> > -- 
> > 2.0.0.rc2
> > 


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 01/21] thermal: of: Extend of-thermal.c to provide number of trip points
@ 2014-11-07  9:14       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-07  9:14 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Eduardo,

> Hello Lukasz,
> 
> On Thu, Oct 09, 2014 at 06:38:37PM +0200, Lukasz Majewski wrote:
> > This patch extends the of-thermal.c to provide information about
> > number of available trip points.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  drivers/thermal/of-thermal.c   | 6 ++++++
> >  drivers/thermal/thermal_core.h | 5 +++++
> >  2 files changed, 11 insertions(+)
> > 
> > diff --git a/drivers/thermal/of-thermal.c
> > b/drivers/thermal/of-thermal.c index f8eb625..b2390d9 100644
> > --- a/drivers/thermal/of-thermal.c
> > +++ b/drivers/thermal/of-thermal.c
> > @@ -113,6 +113,12 @@ static int of_thermal_get_temp(struct
> > thermal_zone_device *tz, return data->get_temp(data->sensor_data,
> > temp); }
> >  
> > +int of_thermal_get_ntrips(struct thermal_zone_device *tz)
> > +{
> > +	struct __thermal_zone *data = tz->devdata;
> > +	return data->ntrips;
> > +}
> 
> I am not against this addition. I just request you to document it
> accordingly.

OK, no problem.

> 
> > +
> >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > int trip, enum thermal_trend *trend)
> >  {
> > diff --git a/drivers/thermal/thermal_core.h
> > b/drivers/thermal/thermal_core.h index 3db339f..587ca5c 100644
> > --- a/drivers/thermal/thermal_core.h
> > +++ b/drivers/thermal/thermal_core.h
> > @@ -81,9 +81,14 @@ static inline void
> > thermal_gov_user_space_unregister(void) {} #ifdef CONFIG_THERMAL_OF
> >  int of_parse_thermal_zones(void);
> >  void of_thermal_destroy_zones(void);
> > +int of_thermal_get_ntrips(struct thermal_zone_device *);
> >  #else
> >  static inline int of_parse_thermal_zones(void) { return 0; }
> >  static inline void of_thermal_destroy_zones(void) { }
> > +static inline int of_thermal_get_ntrips(struct thermal_zone_device
> > *) +{
> > +	return 0;
> > +}
> >  #endif
> >  
> >  #endif /* __THERMAL_CORE_H__ */
> > -- 
> > 2.0.0.rc2
> > 


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 02/21] thermal: of: Extend of-thermal.c to provide check if trip point is enabled
  2014-11-07  1:37     ` Eduardo Valentin
@ 2014-11-07  9:15       ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-07  9:15 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, linux-samsung-soc, linux-arm-kernel, Linux PM list,
	Kukjin Kim, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Kyungmin Park, Chanwoo Choi

Hi Eduardo,

> Hello Lukasz,
> 
> On Thu, Oct 09, 2014 at 06:38:38PM +0200, Lukasz Majewski wrote:
> > This patch extends the of-thermal.c to provide check if trip point
> > is enabled.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  drivers/thermal/of-thermal.c   | 9 +++++++++
> >  drivers/thermal/thermal_core.h | 5 +++++
> >  2 files changed, 14 insertions(+)
> > 
> > diff --git a/drivers/thermal/of-thermal.c
> > b/drivers/thermal/of-thermal.c index b2390d9..23c8d6c 100644
> > --- a/drivers/thermal/of-thermal.c
> > +++ b/drivers/thermal/of-thermal.c
> > @@ -119,6 +119,15 @@ int of_thermal_get_ntrips(struct
> > thermal_zone_device *tz) return data->ntrips;
> >  }
> >  
> > +int of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)
> > +{
> > +	struct __thermal_zone *data = tz->devdata;
> > +
> > +	if (trip >= data->ntrips || trip < 0)
> > +		return 0;
> > +	return 1;
> 
> might be worth using 'true' and 'false', just for the sake of code
> readability.
> 
> > +}
> > +
> 
> 
> I am not against this addition. I just request you to document it
> accordingly.
> 
> 
> >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > int trip, enum thermal_trend *trend)
> >  {
> > diff --git a/drivers/thermal/thermal_core.h
> > b/drivers/thermal/thermal_core.h index 587ca5c..ed8ff05 100644
> > --- a/drivers/thermal/thermal_core.h
> > +++ b/drivers/thermal/thermal_core.h
> > @@ -82,6 +82,7 @@ static inline void
> > thermal_gov_user_space_unregister(void) {} int
> > of_parse_thermal_zones(void); void of_thermal_destroy_zones(void);
> >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > +int of_thermal_is_trip_en(struct thermal_zone_device *, int);
> >  #else
> >  static inline int of_parse_thermal_zones(void) { return 0; }
> >  static inline void of_thermal_destroy_zones(void) { }
> > @@ -89,6 +90,10 @@ static inline int of_thermal_get_ntrips(struct
> > thermal_zone_device *) {
> >  	return 0;
> >  }
> > +int of_thermal_is_trip_en(struct thermal_zone_device *, int)
> this is supposed to be static inline.
> 
> > +{
> > +	return 0;
> > +}
> >  #endif
> >  
> >  #endif /* __THERMAL_CORE_H__ */
> > -- 
> > 2.0.0.rc2
> > 

I will prepare proper description for the code.

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 02/21] thermal: of: Extend of-thermal.c to provide check if trip point is enabled
@ 2014-11-07  9:15       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-07  9:15 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Eduardo,

> Hello Lukasz,
> 
> On Thu, Oct 09, 2014 at 06:38:38PM +0200, Lukasz Majewski wrote:
> > This patch extends the of-thermal.c to provide check if trip point
> > is enabled.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  drivers/thermal/of-thermal.c   | 9 +++++++++
> >  drivers/thermal/thermal_core.h | 5 +++++
> >  2 files changed, 14 insertions(+)
> > 
> > diff --git a/drivers/thermal/of-thermal.c
> > b/drivers/thermal/of-thermal.c index b2390d9..23c8d6c 100644
> > --- a/drivers/thermal/of-thermal.c
> > +++ b/drivers/thermal/of-thermal.c
> > @@ -119,6 +119,15 @@ int of_thermal_get_ntrips(struct
> > thermal_zone_device *tz) return data->ntrips;
> >  }
> >  
> > +int of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)
> > +{
> > +	struct __thermal_zone *data = tz->devdata;
> > +
> > +	if (trip >= data->ntrips || trip < 0)
> > +		return 0;
> > +	return 1;
> 
> might be worth using 'true' and 'false', just for the sake of code
> readability.
> 
> > +}
> > +
> 
> 
> I am not against this addition. I just request you to document it
> accordingly.
> 
> 
> >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > int trip, enum thermal_trend *trend)
> >  {
> > diff --git a/drivers/thermal/thermal_core.h
> > b/drivers/thermal/thermal_core.h index 587ca5c..ed8ff05 100644
> > --- a/drivers/thermal/thermal_core.h
> > +++ b/drivers/thermal/thermal_core.h
> > @@ -82,6 +82,7 @@ static inline void
> > thermal_gov_user_space_unregister(void) {} int
> > of_parse_thermal_zones(void); void of_thermal_destroy_zones(void);
> >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > +int of_thermal_is_trip_en(struct thermal_zone_device *, int);
> >  #else
> >  static inline int of_parse_thermal_zones(void) { return 0; }
> >  static inline void of_thermal_destroy_zones(void) { }
> > @@ -89,6 +90,10 @@ static inline int of_thermal_get_ntrips(struct
> > thermal_zone_device *) {
> >  	return 0;
> >  }
> > +int of_thermal_is_trip_en(struct thermal_zone_device *, int)
> this is supposed to be static inline.
> 
> > +{
> > +	return 0;
> > +}
> >  #endif
> >  
> >  #endif /* __THERMAL_CORE_H__ */
> > -- 
> > 2.0.0.rc2
> > 

I will prepare proper description for the code.

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
  2014-11-07  1:41     ` Eduardo Valentin
@ 2014-11-07 10:05       ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-07 10:05 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kukjin Kim, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Linux PM list, Kyungmin Park, Chanwoo Choi, Amit Daniel Kachhap,
	linux-samsung-soc, Zhang Rui, linux-arm-kernel

Hi Eduardo,

> On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski wrote:
> > This patch extends the of-thermal.c to provide information about
> > number of available non critical (i.e. non HW) trip points in the
> > system.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  drivers/thermal/of-thermal.c   | 12 ++++++++++++
> >  drivers/thermal/thermal_core.h |  5 +++++
> >  2 files changed, 17 insertions(+)
> > 
> > diff --git a/drivers/thermal/of-thermal.c
> > b/drivers/thermal/of-thermal.c index 23c8d6c..cd74e64 100644
> > --- a/drivers/thermal/of-thermal.c
> > +++ b/drivers/thermal/of-thermal.c
> > @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct
> > thermal_zone_device *tz, int trip) return 1;
> >  }
> >  
> > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *tz)
> > +{
> > +	struct __thermal_zone *data = tz->devdata;
> > +	int i;
> > +
> > +	for (i = 0; i < data->ntrips; i++)
> > +		if (data->trips[i].type != THERMAL_TRIP_CRITICAL)
> > +			continue;
> > +
> > +	return --i;
> > +}
> > +
> 
> 
> 
> I am not against this addition. But looks like we start to spread some
> specific APIs that may not be used to other drivers.

Why do you think that this is a specific API? In the thermal OF we can
define trip point as "active", "passive", "hot" and "critical".

With the first three we can handle them and properly react. For the last
one SoC's PMU will power down the board.

Do you know if any board (e.g. from TI) is NOT supposed to shut down
when "critical" temperature is passed?

The real problem here is the accessibility to __thermal_trip and
__thermal_bind arrays.

Use case:
In the Exynos driver we do need to initialize TMU registers with
threshold temperatures.
The temperature is read via tz->ops->get_trip_temp() [1] (from
of-thermal.c).
Unfortunately, the current API is not exporting the number of
non-critical trip points to know how many times call [1].
Of course we could by hand instantiate [1] n times, but this looks for
me a bit clumsy.

Additionally, we now have implicit assumption about the order of defined
temperatures for trip points, but I think this is not a big issue.

> Maybe having a
> single API to provide a read-only copy the list / array of trips might
> be a better approach. I will think of a better way.

Definitely. Exporting available trip points is crucial.

> 
> I also request you to document it accordingly.

Ok, I will do that.

> 
> 
> >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > int trip, enum thermal_trend *trend)
> >  {
> > diff --git a/drivers/thermal/thermal_core.h
> > b/drivers/thermal/thermal_core.h index ed8ff05..334a7be 100644
> > --- a/drivers/thermal/thermal_core.h
> > +++ b/drivers/thermal/thermal_core.h
> > @@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
> >  void of_thermal_destroy_zones(void);
> >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> >  int of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *);
> >  #else
> >  static inline int of_parse_thermal_zones(void) { return 0; }
> >  static inline void of_thermal_destroy_zones(void) { }
> > @@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct
> > thermal_zone_device *, int) {
> >  	return 0;
> >  }
> > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *)
> here, it is supposed to be static inline.
> 
> > +{
> > +	return 0;
> > +}
> >  #endif
> >  
> >  #endif /* __THERMAL_CORE_H__ */
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
@ 2014-11-07 10:05       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-07 10:05 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Eduardo,

> On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski wrote:
> > This patch extends the of-thermal.c to provide information about
> > number of available non critical (i.e. non HW) trip points in the
> > system.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  drivers/thermal/of-thermal.c   | 12 ++++++++++++
> >  drivers/thermal/thermal_core.h |  5 +++++
> >  2 files changed, 17 insertions(+)
> > 
> > diff --git a/drivers/thermal/of-thermal.c
> > b/drivers/thermal/of-thermal.c index 23c8d6c..cd74e64 100644
> > --- a/drivers/thermal/of-thermal.c
> > +++ b/drivers/thermal/of-thermal.c
> > @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct
> > thermal_zone_device *tz, int trip) return 1;
> >  }
> >  
> > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *tz)
> > +{
> > +	struct __thermal_zone *data = tz->devdata;
> > +	int i;
> > +
> > +	for (i = 0; i < data->ntrips; i++)
> > +		if (data->trips[i].type != THERMAL_TRIP_CRITICAL)
> > +			continue;
> > +
> > +	return --i;
> > +}
> > +
> 
> 
> 
> I am not against this addition. But looks like we start to spread some
> specific APIs that may not be used to other drivers.

Why do you think that this is a specific API? In the thermal OF we can
define trip point as "active", "passive", "hot" and "critical".

With the first three we can handle them and properly react. For the last
one SoC's PMU will power down the board.

Do you know if any board (e.g. from TI) is NOT supposed to shut down
when "critical" temperature is passed?

The real problem here is the accessibility to __thermal_trip and
__thermal_bind arrays.

Use case:
In the Exynos driver we do need to initialize TMU registers with
threshold temperatures.
The temperature is read via tz->ops->get_trip_temp() [1] (from
of-thermal.c).
Unfortunately, the current API is not exporting the number of
non-critical trip points to know how many times call [1].
Of course we could by hand instantiate [1] n times, but this looks for
me a bit clumsy.

Additionally, we now have implicit assumption about the order of defined
temperatures for trip points, but I think this is not a big issue.

> Maybe having a
> single API to provide a read-only copy the list / array of trips might
> be a better approach. I will think of a better way.

Definitely. Exporting available trip points is crucial.

> 
> I also request you to document it accordingly.

Ok, I will do that.

> 
> 
> >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > int trip, enum thermal_trend *trend)
> >  {
> > diff --git a/drivers/thermal/thermal_core.h
> > b/drivers/thermal/thermal_core.h index ed8ff05..334a7be 100644
> > --- a/drivers/thermal/thermal_core.h
> > +++ b/drivers/thermal/thermal_core.h
> > @@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
> >  void of_thermal_destroy_zones(void);
> >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> >  int of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *);
> >  #else
> >  static inline int of_parse_thermal_zones(void) { return 0; }
> >  static inline void of_thermal_destroy_zones(void) { }
> > @@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct
> > thermal_zone_device *, int) {
> >  	return 0;
> >  }
> > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *)
> here, it is supposed to be static inline.
> 
> > +{
> > +	return 0;
> > +}
> >  #endif
> >  
> >  #endif /* __THERMAL_CORE_H__ */
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 04/21] thermal: of: Extend current of-thermal.c code to allow setting emulated temp
  2014-11-07  1:44     ` Eduardo Valentin
@ 2014-11-07 11:20       ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-07 11:20 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, linux-samsung-soc, linux-arm-kernel, Linux PM list,
	Kukjin Kim, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Kyungmin Park, Chanwoo Choi

Hi Eduardo,

> Hello,
> 
> On Thu, Oct 09, 2014 at 06:38:40PM +0200, Lukasz Majewski wrote:
> > Before this change it was only possible to set get_temp() and
> > get_trend() methods to be used in the common code handling passing
> > parameters via device tree to "cpu-thermal" CPU thermal zone device.
> > 
> > Now it is possible to also set emulated value of temperature for
> > debug purposes.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  drivers/thermal/of-thermal.c | 25 ++++++++++++++++++++++---
> >  include/linux/thermal.h      |  6 ++++--
> >  2 files changed, 26 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/thermal/of-thermal.c
> > b/drivers/thermal/of-thermal.c index cd74e64..f206375 100644
> > --- a/drivers/thermal/of-thermal.c
> > +++ b/drivers/thermal/of-thermal.c
> > @@ -98,10 +98,22 @@ struct __thermal_zone {
> >  	void *sensor_data;
> >  	int (*get_temp)(void *, long *);
> >  	int (*get_trend)(void *, long *);
> > +	int (*set_emul_temp)(void *, unsigned long);
> >  };
> >  
> >  /***   DT thermal zone device callbacks   ***/
> >  
> > +static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
> > +				    unsigned long temp)
> > +{
> > +	struct __thermal_zone *data = tz->devdata;
> > +
> > +	if (!data->set_emul_temp)
> > +		return -EINVAL;
> > +
> > +	return data->set_emul_temp(data->sensor_data, temp);
> > +}
> > +
> >  static int of_thermal_get_temp(struct thermal_zone_device *tz,
> >  			       unsigned long *temp)
> >  {
> > @@ -352,7 +364,8 @@ static struct thermal_zone_device *
> >  thermal_zone_of_add_sensor(struct device_node *zone,
> >  			   struct device_node *sensor, void *data,
> >  			   int (*get_temp)(void *, long *),
> > -			   int (*get_trend)(void *, long *))
> > +			   int (*get_trend)(void *, long *),
> > +			   int (*set_emul_temp)(void *, unsigned
> > long))
> 
> Thanks for improving the API. However, looking at what is above, it
> starts to be pretty ugly. And for sure, this is not the last callback
> to be added.

Presumably there would be some more callbacks.

> I believe it is time to add a .ops in the of-thermal.
> While in here, do you mind adding the .ops in a separated patch, then
> add the .set_emul_temp in the .ops field?

I will add an option to pass .ops with thermal_zone_of_add_sensor().

I'm only concerned a bit about testing other users of of-thermal. 
I have only beaglebone black (BBB) for testing, which on-soc bandgap
thermal sensor is very inaccurate and hence not supported even at BBB
github linux kernel repository (v3.14).

Because of above I would need your support for testing.

> 
> >  {
> >  	struct thermal_zone_device *tzd;
> >  	struct __thermal_zone *tz;
> > @@ -366,10 +379,12 @@ thermal_zone_of_add_sensor(struct device_node
> > *zone, mutex_lock(&tzd->lock);
> >  	tz->get_temp = get_temp;
> >  	tz->get_trend = get_trend;
> > +	tz->set_emul_temp = set_emul_temp;
> >  	tz->sensor_data = data;
> >  
> >  	tzd->ops->get_temp = of_thermal_get_temp;
> >  	tzd->ops->get_trend = of_thermal_get_trend;
> > +	tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
> >  	mutex_unlock(&tzd->lock);
> >  
> >  	return tzd;
> > @@ -411,7 +426,8 @@ thermal_zone_of_add_sensor(struct device_node
> > *zone, struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
> >  				void *data, int (*get_temp)(void
> > *, long *),
> > -				int (*get_trend)(void *, long *))
> > +				int (*get_trend)(void *, long *),
> > +				int (*set_emul_temp)(void *,
> > unsigned long)) {
> >  	struct device_node *np, *child, *sensor_np;
> >  
> > @@ -453,7 +469,8 @@ thermal_zone_of_sensor_register(struct device
> > *dev, int sensor_id, return thermal_zone_of_add_sensor(child,
> > sensor_np, data,
> >  							  get_temp,
> > -
> > get_trend);
> > +
> > get_trend,
> > +
> > set_emul_temp); }
> >  	}
> >  	of_node_put(np);
> > @@ -494,9 +511,11 @@ void thermal_zone_of_sensor_unregister(struct
> > device *dev, mutex_lock(&tzd->lock);
> >  	tzd->ops->get_temp = NULL;
> >  	tzd->ops->get_trend = NULL;
> > +	tzd->ops->set_emul_temp = NULL;
> >  
> >  	tz->get_temp = NULL;
> >  	tz->get_trend = NULL;
> > +	tz->set_emul_temp = NULL;
> >  	tz->sensor_data = NULL;
> >  	mutex_unlock(&tzd->lock);
> >  }
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index 0305cde..36010e9 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -290,14 +290,16 @@ struct thermal_genl_event {
> >  struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int id,
> >  				void *data, int (*get_temp)(void
> > *, long *),
> > -				int (*get_trend)(void *, long *));
> > +				int (*get_trend)(void *, long *),
> > +				int (*set_emul_temp)(void *,
> > unsigned long)); void thermal_zone_of_sensor_unregister(struct
> > device *dev, struct thermal_zone_device *tz);
> >  #else
> >  static inline struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int id,
> >  				void *data, int (*get_temp)(void
> > *, long *),
> > -				int (*get_trend)(void *, long *))
> > +				int (*get_trend)(void *, long *),
> > +				int (*set_emul_temp)(void *,
> > unsigned long)) {
> >  	return NULL;
> >  }
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 04/21] thermal: of: Extend current of-thermal.c code to allow setting emulated temp
@ 2014-11-07 11:20       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-07 11:20 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Eduardo,

> Hello,
> 
> On Thu, Oct 09, 2014 at 06:38:40PM +0200, Lukasz Majewski wrote:
> > Before this change it was only possible to set get_temp() and
> > get_trend() methods to be used in the common code handling passing
> > parameters via device tree to "cpu-thermal" CPU thermal zone device.
> > 
> > Now it is possible to also set emulated value of temperature for
> > debug purposes.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  drivers/thermal/of-thermal.c | 25 ++++++++++++++++++++++---
> >  include/linux/thermal.h      |  6 ++++--
> >  2 files changed, 26 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/thermal/of-thermal.c
> > b/drivers/thermal/of-thermal.c index cd74e64..f206375 100644
> > --- a/drivers/thermal/of-thermal.c
> > +++ b/drivers/thermal/of-thermal.c
> > @@ -98,10 +98,22 @@ struct __thermal_zone {
> >  	void *sensor_data;
> >  	int (*get_temp)(void *, long *);
> >  	int (*get_trend)(void *, long *);
> > +	int (*set_emul_temp)(void *, unsigned long);
> >  };
> >  
> >  /***   DT thermal zone device callbacks   ***/
> >  
> > +static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
> > +				    unsigned long temp)
> > +{
> > +	struct __thermal_zone *data = tz->devdata;
> > +
> > +	if (!data->set_emul_temp)
> > +		return -EINVAL;
> > +
> > +	return data->set_emul_temp(data->sensor_data, temp);
> > +}
> > +
> >  static int of_thermal_get_temp(struct thermal_zone_device *tz,
> >  			       unsigned long *temp)
> >  {
> > @@ -352,7 +364,8 @@ static struct thermal_zone_device *
> >  thermal_zone_of_add_sensor(struct device_node *zone,
> >  			   struct device_node *sensor, void *data,
> >  			   int (*get_temp)(void *, long *),
> > -			   int (*get_trend)(void *, long *))
> > +			   int (*get_trend)(void *, long *),
> > +			   int (*set_emul_temp)(void *, unsigned
> > long))
> 
> Thanks for improving the API. However, looking at what is above, it
> starts to be pretty ugly. And for sure, this is not the last callback
> to be added.

Presumably there would be some more callbacks.

> I believe it is time to add a .ops in the of-thermal.
> While in here, do you mind adding the .ops in a separated patch, then
> add the .set_emul_temp in the .ops field?

I will add an option to pass .ops with thermal_zone_of_add_sensor().

I'm only concerned a bit about testing other users of of-thermal. 
I have only beaglebone black (BBB) for testing, which on-soc bandgap
thermal sensor is very inaccurate and hence not supported even at BBB
github linux kernel repository (v3.14).

Because of above I would need your support for testing.

> 
> >  {
> >  	struct thermal_zone_device *tzd;
> >  	struct __thermal_zone *tz;
> > @@ -366,10 +379,12 @@ thermal_zone_of_add_sensor(struct device_node
> > *zone, mutex_lock(&tzd->lock);
> >  	tz->get_temp = get_temp;
> >  	tz->get_trend = get_trend;
> > +	tz->set_emul_temp = set_emul_temp;
> >  	tz->sensor_data = data;
> >  
> >  	tzd->ops->get_temp = of_thermal_get_temp;
> >  	tzd->ops->get_trend = of_thermal_get_trend;
> > +	tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
> >  	mutex_unlock(&tzd->lock);
> >  
> >  	return tzd;
> > @@ -411,7 +426,8 @@ thermal_zone_of_add_sensor(struct device_node
> > *zone, struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
> >  				void *data, int (*get_temp)(void
> > *, long *),
> > -				int (*get_trend)(void *, long *))
> > +				int (*get_trend)(void *, long *),
> > +				int (*set_emul_temp)(void *,
> > unsigned long)) {
> >  	struct device_node *np, *child, *sensor_np;
> >  
> > @@ -453,7 +469,8 @@ thermal_zone_of_sensor_register(struct device
> > *dev, int sensor_id, return thermal_zone_of_add_sensor(child,
> > sensor_np, data,
> >  							  get_temp,
> > -
> > get_trend);
> > +
> > get_trend,
> > +
> > set_emul_temp); }
> >  	}
> >  	of_node_put(np);
> > @@ -494,9 +511,11 @@ void thermal_zone_of_sensor_unregister(struct
> > device *dev, mutex_lock(&tzd->lock);
> >  	tzd->ops->get_temp = NULL;
> >  	tzd->ops->get_trend = NULL;
> > +	tzd->ops->set_emul_temp = NULL;
> >  
> >  	tz->get_temp = NULL;
> >  	tz->get_trend = NULL;
> > +	tz->set_emul_temp = NULL;
> >  	tz->sensor_data = NULL;
> >  	mutex_unlock(&tzd->lock);
> >  }
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index 0305cde..36010e9 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -290,14 +290,16 @@ struct thermal_genl_event {
> >  struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int id,
> >  				void *data, int (*get_temp)(void
> > *, long *),
> > -				int (*get_trend)(void *, long *));
> > +				int (*get_trend)(void *, long *),
> > +				int (*set_emul_temp)(void *,
> > unsigned long)); void thermal_zone_of_sensor_unregister(struct
> > device *dev, struct thermal_zone_device *tz);
> >  #else
> >  static inline struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int id,
> >  				void *data, int (*get_temp)(void
> > *, long *),
> > -				int (*get_trend)(void *, long *))
> > +				int (*get_trend)(void *, long *),
> > +				int (*set_emul_temp)(void *,
> > unsigned long)) {
> >  	return NULL;
> >  }
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
  2014-11-07 10:05       ` Lukasz Majewski
@ 2014-11-07 16:06         ` Eduardo Valentin
  -1 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-07 16:06 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kukjin Kim, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Linux PM list, Kyungmin Park, Chanwoo Choi, Amit Daniel Kachhap,
	linux-samsung-soc, Zhang Rui, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 4798 bytes --]


Hello Lukasz,

On Fri, Nov 07, 2014 at 11:05:51AM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski wrote:
> > > This patch extends the of-thermal.c to provide information about
> > > number of available non critical (i.e. non HW) trip points in the
> > > system.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > >  drivers/thermal/of-thermal.c   | 12 ++++++++++++
> > >  drivers/thermal/thermal_core.h |  5 +++++
> > >  2 files changed, 17 insertions(+)
> > > 
> > > diff --git a/drivers/thermal/of-thermal.c
> > > b/drivers/thermal/of-thermal.c index 23c8d6c..cd74e64 100644
> > > --- a/drivers/thermal/of-thermal.c
> > > +++ b/drivers/thermal/of-thermal.c
> > > @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct
> > > thermal_zone_device *tz, int trip) return 1;
> > >  }
> > >  
> > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *tz)
> > > +{
> > > +	struct __thermal_zone *data = tz->devdata;
> > > +	int i;
> > > +
> > > +	for (i = 0; i < data->ntrips; i++)
> > > +		if (data->trips[i].type != THERMAL_TRIP_CRITICAL)
> > > +			continue;
> > > +
> > > +	return --i;
> > > +}
> > > +
> > 
> > 
> > 
> > I am not against this addition. But looks like we start to spread some
> > specific APIs that may not be used to other drivers.
> 
> Why do you think that this is a specific API? In the thermal OF we can
> define trip point as "active", "passive", "hot" and "critical".
> 
> With the first three we can handle them and properly react. For the last
> one SoC's PMU will power down the board.
> 
> Do you know if any board (e.g. from TI) is NOT supposed to shut down
> when "critical" temperature is passed?
> 

So, my point is not really about the usage of trip points. It is just
that the of-thermal  API will grow with in a wide way with specific
functions to check some property on the trip point array. And not all
drivers may be using these function, e.g. the above proposal.

> The real problem here is the accessibility to __thermal_trip and
> __thermal_bind arrays.
> 
> Use case:
> In the Exynos driver we do need to initialize TMU registers with
> threshold temperatures.
> The temperature is read via tz->ops->get_trip_temp() [1] (from
> of-thermal.c).
> Unfortunately, the current API is not exporting the number of
> non-critical trip points to know how many times call [1].
> Of course we could by hand instantiate [1] n times, but this looks for
> me a bit clumsy.


I understand your use case. My point was simply that this use case may
be specific to your driver (or few drivers).
> 
> Additionally, we now have implicit assumption about the order of defined
> temperatures for trip points, but I think this is not a big issue.
> 
> > Maybe having a
> > single API to provide a read-only copy the list / array of trips might
> > be a better approach. I will think of a better way.
> 
> Definitely. Exporting available trip points is crucial.
> 

Yeah, I think it is the best thing to do. Share a read-only array / copy
of the needed data, and then drivers would check what ever property they
need from the array. Just make sure you document that this is a
read-only array (i.e. any possible change they do, won't affect the
original array).

> > 
> > I also request you to document it accordingly.
> 
> Ok, I will do that.

Cool!



> 
> > 
> > 
> > >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > > int trip, enum thermal_trend *trend)
> > >  {
> > > diff --git a/drivers/thermal/thermal_core.h
> > > b/drivers/thermal/thermal_core.h index ed8ff05..334a7be 100644
> > > --- a/drivers/thermal/thermal_core.h
> > > +++ b/drivers/thermal/thermal_core.h
> > > @@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
> > >  void of_thermal_destroy_zones(void);
> > >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > >  int of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *);
> > >  #else
> > >  static inline int of_parse_thermal_zones(void) { return 0; }
> > >  static inline void of_thermal_destroy_zones(void) { }
> > > @@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct
> > > thermal_zone_device *, int) {
> > >  	return 0;
> > >  }
> > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *)
> > here, it is supposed to be static inline.
> > 
> > > +{
> > > +	return 0;
> > > +}
> > >  #endif
> > >  
> > >  #endif /* __THERMAL_CORE_H__ */
> > > -- 
> > > 2.0.0.rc2
> > > 
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
@ 2014-11-07 16:06         ` Eduardo Valentin
  0 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-07 16:06 UTC (permalink / raw)
  To: linux-arm-kernel


Hello Lukasz,

On Fri, Nov 07, 2014 at 11:05:51AM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski wrote:
> > > This patch extends the of-thermal.c to provide information about
> > > number of available non critical (i.e. non HW) trip points in the
> > > system.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > >  drivers/thermal/of-thermal.c   | 12 ++++++++++++
> > >  drivers/thermal/thermal_core.h |  5 +++++
> > >  2 files changed, 17 insertions(+)
> > > 
> > > diff --git a/drivers/thermal/of-thermal.c
> > > b/drivers/thermal/of-thermal.c index 23c8d6c..cd74e64 100644
> > > --- a/drivers/thermal/of-thermal.c
> > > +++ b/drivers/thermal/of-thermal.c
> > > @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct
> > > thermal_zone_device *tz, int trip) return 1;
> > >  }
> > >  
> > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *tz)
> > > +{
> > > +	struct __thermal_zone *data = tz->devdata;
> > > +	int i;
> > > +
> > > +	for (i = 0; i < data->ntrips; i++)
> > > +		if (data->trips[i].type != THERMAL_TRIP_CRITICAL)
> > > +			continue;
> > > +
> > > +	return --i;
> > > +}
> > > +
> > 
> > 
> > 
> > I am not against this addition. But looks like we start to spread some
> > specific APIs that may not be used to other drivers.
> 
> Why do you think that this is a specific API? In the thermal OF we can
> define trip point as "active", "passive", "hot" and "critical".
> 
> With the first three we can handle them and properly react. For the last
> one SoC's PMU will power down the board.
> 
> Do you know if any board (e.g. from TI) is NOT supposed to shut down
> when "critical" temperature is passed?
> 

So, my point is not really about the usage of trip points. It is just
that the of-thermal  API will grow with in a wide way with specific
functions to check some property on the trip point array. And not all
drivers may be using these function, e.g. the above proposal.

> The real problem here is the accessibility to __thermal_trip and
> __thermal_bind arrays.
> 
> Use case:
> In the Exynos driver we do need to initialize TMU registers with
> threshold temperatures.
> The temperature is read via tz->ops->get_trip_temp() [1] (from
> of-thermal.c).
> Unfortunately, the current API is not exporting the number of
> non-critical trip points to know how many times call [1].
> Of course we could by hand instantiate [1] n times, but this looks for
> me a bit clumsy.


I understand your use case. My point was simply that this use case may
be specific to your driver (or few drivers).
> 
> Additionally, we now have implicit assumption about the order of defined
> temperatures for trip points, but I think this is not a big issue.
> 
> > Maybe having a
> > single API to provide a read-only copy the list / array of trips might
> > be a better approach. I will think of a better way.
> 
> Definitely. Exporting available trip points is crucial.
> 

Yeah, I think it is the best thing to do. Share a read-only array / copy
of the needed data, and then drivers would check what ever property they
need from the array. Just make sure you document that this is a
read-only array (i.e. any possible change they do, won't affect the
original array).

> > 
> > I also request you to document it accordingly.
> 
> Ok, I will do that.

Cool!



> 
> > 
> > 
> > >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > > int trip, enum thermal_trend *trend)
> > >  {
> > > diff --git a/drivers/thermal/thermal_core.h
> > > b/drivers/thermal/thermal_core.h index ed8ff05..334a7be 100644
> > > --- a/drivers/thermal/thermal_core.h
> > > +++ b/drivers/thermal/thermal_core.h
> > > @@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
> > >  void of_thermal_destroy_zones(void);
> > >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > >  int of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *);
> > >  #else
> > >  static inline int of_parse_thermal_zones(void) { return 0; }
> > >  static inline void of_thermal_destroy_zones(void) { }
> > > @@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct
> > > thermal_zone_device *, int) {
> > >  	return 0;
> > >  }
> > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *)
> > here, it is supposed to be static inline.
> > 
> > > +{
> > > +	return 0;
> > > +}
> > >  #endif
> > >  
> > >  #endif /* __THERMAL_CORE_H__ */
> > > -- 
> > > 2.0.0.rc2
> > > 
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141107/eeb5475a/attachment-0001.sig>

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
  2014-11-07 16:06         ` Eduardo Valentin
@ 2014-11-07 16:43           ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-07 16:43 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kukjin Kim, Linux PM list, Lukasz Majewski,
	Bartlomiej Zolnierkiewicz, Amit Daniel Kachhap, Chanwoo Choi,
	Kyungmin Park, linux-samsung-soc, Zhang Rui, linux-arm-kernel

Hi Eduardo,

> 
> Hello Lukasz,
> 
> On Fri, Nov 07, 2014 at 11:05:51AM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski wrote:
> > > > This patch extends the of-thermal.c to provide information about
> > > > number of available non critical (i.e. non HW) trip points in
> > > > the system.
> > > > 
> > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > ---
> > > >  drivers/thermal/of-thermal.c   | 12 ++++++++++++
> > > >  drivers/thermal/thermal_core.h |  5 +++++
> > > >  2 files changed, 17 insertions(+)
> > > > 
> > > > diff --git a/drivers/thermal/of-thermal.c
> > > > b/drivers/thermal/of-thermal.c index 23c8d6c..cd74e64 100644
> > > > --- a/drivers/thermal/of-thermal.c
> > > > +++ b/drivers/thermal/of-thermal.c
> > > > @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct
> > > > thermal_zone_device *tz, int trip) return 1;
> > > >  }
> > > >  
> > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > *tz) +{
> > > > +	struct __thermal_zone *data = tz->devdata;
> > > > +	int i;
> > > > +
> > > > +	for (i = 0; i < data->ntrips; i++)
> > > > +		if (data->trips[i].type !=
> > > > THERMAL_TRIP_CRITICAL)
> > > > +			continue;
> > > > +
> > > > +	return --i;
> > > > +}
> > > > +
> > > 
> > > 
> > > 
> > > I am not against this addition. But looks like we start to spread
> > > some specific APIs that may not be used to other drivers.
> > 
> > Why do you think that this is a specific API? In the thermal OF we
> > can define trip point as "active", "passive", "hot" and "critical".
> > 
> > With the first three we can handle them and properly react. For the
> > last one SoC's PMU will power down the board.
> > 
> > Do you know if any board (e.g. from TI) is NOT supposed to shut down
> > when "critical" temperature is passed?
> > 
> 
> So, my point is not really about the usage of trip points. It is just
> that the of-thermal  API will grow with in a wide way with specific
> functions to check some property on the trip point array. And not all
> drivers may be using these function, e.g. the above proposal.
> 
> > The real problem here is the accessibility to __thermal_trip and
> > __thermal_bind arrays.
> > 
> > Use case:
> > In the Exynos driver we do need to initialize TMU registers with
> > threshold temperatures.
> > The temperature is read via tz->ops->get_trip_temp() [1] (from
> > of-thermal.c).
> > Unfortunately, the current API is not exporting the number of
> > non-critical trip points to know how many times call [1].
> > Of course we could by hand instantiate [1] n times, but this looks
> > for me a bit clumsy.
> 
> 
> I understand your use case. My point was simply that this use case may
> be specific to your driver (or few drivers).
> > 
> > Additionally, we now have implicit assumption about the order of
> > defined temperatures for trip points, but I think this is not a big
> > issue.
> > 
> > > Maybe having a
> > > single API to provide a read-only copy the list / array of trips
> > > might be a better approach. I will think of a better way.
> > 
> > Definitely. Exporting available trip points is crucial.
> > 
> 
> Yeah, I think it is the best thing to do. Share a read-only array /
> copy of the needed data, and then drivers would check what ever
> property they need from the array. Just make sure you document that
> this is a read-only array (i.e. any possible change they do, won't
> affect the original array).

I agree on that.

> 
> > > 
> > > I also request you to document it accordingly.
> > 
> > Ok, I will do that.
> 
> Cool!
> 
> 
> 
> > 
> > > 
> > > 
> > > >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > > > int trip, enum thermal_trend *trend)
> > > >  {
> > > > diff --git a/drivers/thermal/thermal_core.h
> > > > b/drivers/thermal/thermal_core.h index ed8ff05..334a7be 100644
> > > > --- a/drivers/thermal/thermal_core.h
> > > > +++ b/drivers/thermal/thermal_core.h
> > > > @@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
> > > >  void of_thermal_destroy_zones(void);
> > > >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > > >  int of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > *); #else
> > > >  static inline int of_parse_thermal_zones(void) { return 0; }
> > > >  static inline void of_thermal_destroy_zones(void) { }
> > > > @@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct
> > > > thermal_zone_device *, int) {
> > > >  	return 0;
> > > >  }
> > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > *)
> > > here, it is supposed to be static inline.
> > > 
> > > > +{
> > > > +	return 0;
> > > > +}
> > > >  #endif
> > > >  
> > > >  #endif /* __THERMAL_CORE_H__ */
> > > > -- 
> > > > 2.0.0.rc2
> > > > 
> > 
> > 
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
@ 2014-11-07 16:43           ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-07 16:43 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Eduardo,

> 
> Hello Lukasz,
> 
> On Fri, Nov 07, 2014 at 11:05:51AM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski wrote:
> > > > This patch extends the of-thermal.c to provide information about
> > > > number of available non critical (i.e. non HW) trip points in
> > > > the system.
> > > > 
> > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > ---
> > > >  drivers/thermal/of-thermal.c   | 12 ++++++++++++
> > > >  drivers/thermal/thermal_core.h |  5 +++++
> > > >  2 files changed, 17 insertions(+)
> > > > 
> > > > diff --git a/drivers/thermal/of-thermal.c
> > > > b/drivers/thermal/of-thermal.c index 23c8d6c..cd74e64 100644
> > > > --- a/drivers/thermal/of-thermal.c
> > > > +++ b/drivers/thermal/of-thermal.c
> > > > @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct
> > > > thermal_zone_device *tz, int trip) return 1;
> > > >  }
> > > >  
> > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > *tz) +{
> > > > +	struct __thermal_zone *data = tz->devdata;
> > > > +	int i;
> > > > +
> > > > +	for (i = 0; i < data->ntrips; i++)
> > > > +		if (data->trips[i].type !=
> > > > THERMAL_TRIP_CRITICAL)
> > > > +			continue;
> > > > +
> > > > +	return --i;
> > > > +}
> > > > +
> > > 
> > > 
> > > 
> > > I am not against this addition. But looks like we start to spread
> > > some specific APIs that may not be used to other drivers.
> > 
> > Why do you think that this is a specific API? In the thermal OF we
> > can define trip point as "active", "passive", "hot" and "critical".
> > 
> > With the first three we can handle them and properly react. For the
> > last one SoC's PMU will power down the board.
> > 
> > Do you know if any board (e.g. from TI) is NOT supposed to shut down
> > when "critical" temperature is passed?
> > 
> 
> So, my point is not really about the usage of trip points. It is just
> that the of-thermal  API will grow with in a wide way with specific
> functions to check some property on the trip point array. And not all
> drivers may be using these function, e.g. the above proposal.
> 
> > The real problem here is the accessibility to __thermal_trip and
> > __thermal_bind arrays.
> > 
> > Use case:
> > In the Exynos driver we do need to initialize TMU registers with
> > threshold temperatures.
> > The temperature is read via tz->ops->get_trip_temp() [1] (from
> > of-thermal.c).
> > Unfortunately, the current API is not exporting the number of
> > non-critical trip points to know how many times call [1].
> > Of course we could by hand instantiate [1] n times, but this looks
> > for me a bit clumsy.
> 
> 
> I understand your use case. My point was simply that this use case may
> be specific to your driver (or few drivers).
> > 
> > Additionally, we now have implicit assumption about the order of
> > defined temperatures for trip points, but I think this is not a big
> > issue.
> > 
> > > Maybe having a
> > > single API to provide a read-only copy the list / array of trips
> > > might be a better approach. I will think of a better way.
> > 
> > Definitely. Exporting available trip points is crucial.
> > 
> 
> Yeah, I think it is the best thing to do. Share a read-only array /
> copy of the needed data, and then drivers would check what ever
> property they need from the array. Just make sure you document that
> this is a read-only array (i.e. any possible change they do, won't
> affect the original array).

I agree on that.

> 
> > > 
> > > I also request you to document it accordingly.
> > 
> > Ok, I will do that.
> 
> Cool!
> 
> 
> 
> > 
> > > 
> > > 
> > > >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > > > int trip, enum thermal_trend *trend)
> > > >  {
> > > > diff --git a/drivers/thermal/thermal_core.h
> > > > b/drivers/thermal/thermal_core.h index ed8ff05..334a7be 100644
> > > > --- a/drivers/thermal/thermal_core.h
> > > > +++ b/drivers/thermal/thermal_core.h
> > > > @@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
> > > >  void of_thermal_destroy_zones(void);
> > > >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > > >  int of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > *); #else
> > > >  static inline int of_parse_thermal_zones(void) { return 0; }
> > > >  static inline void of_thermal_destroy_zones(void) { }
> > > > @@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct
> > > > thermal_zone_device *, int) {
> > > >  	return 0;
> > > >  }
> > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > *)
> > > here, it is supposed to be static inline.
> > > 
> > > > +{
> > > > +	return 0;
> > > > +}
> > > >  #endif
> > > >  
> > > >  #endif /* __THERMAL_CORE_H__ */
> > > > -- 
> > > > 2.0.0.rc2
> > > > 
> > 
> > 
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
  2014-11-07 10:05       ` Lukasz Majewski
@ 2014-11-07 23:04         ` Dmitry Torokhov
  -1 siblings, 0 replies; 288+ messages in thread
From: Dmitry Torokhov @ 2014-11-07 23:04 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kukjin Kim, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Linux PM list, Kyungmin Park, Chanwoo Choi,
	Amit Daniel Kachhap, linux-samsung-soc, Zhang Rui,
	linux-arm-kernel

Hi Lukasz,

On Fri, Nov 7, 2014 at 2:05 AM, Lukasz Majewski <l.majewski@samsung.com> wrote:
> Hi Eduardo,
>
>> On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski wrote:
>> > This patch extends the of-thermal.c to provide information about
>> > number of available non critical (i.e. non HW) trip points in the
>> > system.
>> >
>> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>> > ---
>> >  drivers/thermal/of-thermal.c   | 12 ++++++++++++
>> >  drivers/thermal/thermal_core.h |  5 +++++
>> >  2 files changed, 17 insertions(+)
>> >
>> > diff --git a/drivers/thermal/of-thermal.c
>> > b/drivers/thermal/of-thermal.c index 23c8d6c..cd74e64 100644
>> > --- a/drivers/thermal/of-thermal.c
>> > +++ b/drivers/thermal/of-thermal.c
>> > @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct
>> > thermal_zone_device *tz, int trip) return 1;
>> >  }
>> >
>> > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *tz)
>> > +{
>> > +   struct __thermal_zone *data = tz->devdata;
>> > +   int i;
>> > +
>> > +   for (i = 0; i < data->ntrips; i++)
>> > +           if (data->trips[i].type != THERMAL_TRIP_CRITICAL)
>> > +                   continue;
>> > +
>> > +   return --i;
>> > +}
>> > +
>>
>>
>>
>> I am not against this addition. But looks like we start to spread some
>> specific APIs that may not be used to other drivers.
>
> Why do you think that this is a specific API? In the thermal OF we can
> define trip point as "active", "passive", "hot" and "critical".
>
> With the first three we can handle them and properly react. For the last
> one SoC's PMU will power down the board.
>
> Do you know if any board (e.g. from TI) is NOT supposed to shut down
> when "critical" temperature is passed?
>
> The real problem here is the accessibility to __thermal_trip and
> __thermal_bind arrays.
>
> Use case:
> In the Exynos driver we do need to initialize TMU registers with
> threshold temperatures.

Is this indeed plural or you want to program the next trip point as your
alarm temperature? If so, there was another patch floating around adding
set_trips() callback that would get passed in the low and high trip points for
the current temperature reading and you can use that data to program
alarms. Rockchip thermal driver uses it.

https://lkml.org/lkml/2014/6/27/76

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
@ 2014-11-07 23:04         ` Dmitry Torokhov
  0 siblings, 0 replies; 288+ messages in thread
From: Dmitry Torokhov @ 2014-11-07 23:04 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Lukasz,

On Fri, Nov 7, 2014 at 2:05 AM, Lukasz Majewski <l.majewski@samsung.com> wrote:
> Hi Eduardo,
>
>> On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski wrote:
>> > This patch extends the of-thermal.c to provide information about
>> > number of available non critical (i.e. non HW) trip points in the
>> > system.
>> >
>> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>> > ---
>> >  drivers/thermal/of-thermal.c   | 12 ++++++++++++
>> >  drivers/thermal/thermal_core.h |  5 +++++
>> >  2 files changed, 17 insertions(+)
>> >
>> > diff --git a/drivers/thermal/of-thermal.c
>> > b/drivers/thermal/of-thermal.c index 23c8d6c..cd74e64 100644
>> > --- a/drivers/thermal/of-thermal.c
>> > +++ b/drivers/thermal/of-thermal.c
>> > @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct
>> > thermal_zone_device *tz, int trip) return 1;
>> >  }
>> >
>> > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device *tz)
>> > +{
>> > +   struct __thermal_zone *data = tz->devdata;
>> > +   int i;
>> > +
>> > +   for (i = 0; i < data->ntrips; i++)
>> > +           if (data->trips[i].type != THERMAL_TRIP_CRITICAL)
>> > +                   continue;
>> > +
>> > +   return --i;
>> > +}
>> > +
>>
>>
>>
>> I am not against this addition. But looks like we start to spread some
>> specific APIs that may not be used to other drivers.
>
> Why do you think that this is a specific API? In the thermal OF we can
> define trip point as "active", "passive", "hot" and "critical".
>
> With the first three we can handle them and properly react. For the last
> one SoC's PMU will power down the board.
>
> Do you know if any board (e.g. from TI) is NOT supposed to shut down
> when "critical" temperature is passed?
>
> The real problem here is the accessibility to __thermal_trip and
> __thermal_bind arrays.
>
> Use case:
> In the Exynos driver we do need to initialize TMU registers with
> threshold temperatures.

Is this indeed plural or you want to program the next trip point as your
alarm temperature? If so, there was another patch floating around adding
set_trips() callback that would get passed in the low and high trip points for
the current temperature reading and you can use that data to program
alarms. Rockchip thermal driver uses it.

https://lkml.org/lkml/2014/6/27/76

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
  2014-11-07 16:06         ` Eduardo Valentin
@ 2014-11-12  9:42           ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-12  9:42 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kukjin Kim, Linux PM list, Lukasz Majewski,
	Bartlomiej Zolnierkiewicz, Amit Daniel Kachhap, Chanwoo Choi,
	Kyungmin Park, linux-samsung-soc, Zhang Rui, linux-arm-kernel

Hi Eduardo,

> 
> Hello Lukasz,
> 
> On Fri, Nov 07, 2014 at 11:05:51AM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski wrote:
> > > > This patch extends the of-thermal.c to provide information about
> > > > number of available non critical (i.e. non HW) trip points in
> > > > the system.
> > > > 
> > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > ---
> > > >  drivers/thermal/of-thermal.c   | 12 ++++++++++++
> > > >  drivers/thermal/thermal_core.h |  5 +++++
> > > >  2 files changed, 17 insertions(+)
> > > > 
> > > > diff --git a/drivers/thermal/of-thermal.c
> > > > b/drivers/thermal/of-thermal.c index 23c8d6c..cd74e64 100644
> > > > --- a/drivers/thermal/of-thermal.c
> > > > +++ b/drivers/thermal/of-thermal.c
> > > > @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct
> > > > thermal_zone_device *tz, int trip) return 1;
> > > >  }
> > > >  
> > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > *tz) +{
> > > > +	struct __thermal_zone *data = tz->devdata;
> > > > +	int i;
> > > > +
> > > > +	for (i = 0; i < data->ntrips; i++)
> > > > +		if (data->trips[i].type !=
> > > > THERMAL_TRIP_CRITICAL)
> > > > +			continue;
> > > > +
> > > > +	return --i;
> > > > +}
> > > > +
> > > 
> > > 
> > > 
> > > I am not against this addition. But looks like we start to spread
> > > some specific APIs that may not be used to other drivers.
> > 
> > Why do you think that this is a specific API? In the thermal OF we
> > can define trip point as "active", "passive", "hot" and "critical".
> > 
> > With the first three we can handle them and properly react. For the
> > last one SoC's PMU will power down the board.
> > 
> > Do you know if any board (e.g. from TI) is NOT supposed to shut down
> > when "critical" temperature is passed?
> > 
> 
> So, my point is not really about the usage of trip points. It is just
> that the of-thermal  API will grow with in a wide way with specific
> functions to check some property on the trip point array. And not all
> drivers may be using these function, e.g. the above proposal.
> 
> > The real problem here is the accessibility to __thermal_trip and
> > __thermal_bind arrays.
> > 
> > Use case:
> > In the Exynos driver we do need to initialize TMU registers with
> > threshold temperatures.
> > The temperature is read via tz->ops->get_trip_temp() [1] (from
> > of-thermal.c).
> > Unfortunately, the current API is not exporting the number of
> > non-critical trip points to know how many times call [1].
> > Of course we could by hand instantiate [1] n times, but this looks
> > for me a bit clumsy.
> 
> 
> I understand your use case. My point was simply that this use case may
> be specific to your driver (or few drivers).
> > 
> > Additionally, we now have implicit assumption about the order of
> > defined temperatures for trip points, but I think this is not a big
> > issue.
> > 
> > > Maybe having a
> > > single API to provide a read-only copy the list / array of trips
> > > might be a better approach. I will think of a better way.
> > 
> > Definitely. Exporting available trip points is crucial.
> > 
> 
> Yeah, I think it is the best thing to do. Share a read-only array /
> copy of the needed data, and then drivers would check what ever
> property they need from the array. Just make sure you document that
> this is a read-only array (i.e. any possible change they do, won't
> affect the original array).

So I assume that you don't mind that I will prepare such of-thermal.c
modification?

> 
> > > 
> > > I also request you to document it accordingly.
> > 
> > Ok, I will do that.
> 
> Cool!
> 
> 
> 
> > 
> > > 
> > > 
> > > >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > > > int trip, enum thermal_trend *trend)
> > > >  {
> > > > diff --git a/drivers/thermal/thermal_core.h
> > > > b/drivers/thermal/thermal_core.h index ed8ff05..334a7be 100644
> > > > --- a/drivers/thermal/thermal_core.h
> > > > +++ b/drivers/thermal/thermal_core.h
> > > > @@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
> > > >  void of_thermal_destroy_zones(void);
> > > >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > > >  int of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > *); #else
> > > >  static inline int of_parse_thermal_zones(void) { return 0; }
> > > >  static inline void of_thermal_destroy_zones(void) { }
> > > > @@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct
> > > > thermal_zone_device *, int) {
> > > >  	return 0;
> > > >  }
> > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > *)
> > > here, it is supposed to be static inline.
> > > 
> > > > +{
> > > > +	return 0;
> > > > +}
> > > >  #endif
> > > >  
> > > >  #endif /* __THERMAL_CORE_H__ */
> > > > -- 
> > > > 2.0.0.rc2
> > > > 
> > 
> > 
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
@ 2014-11-12  9:42           ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-12  9:42 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Eduardo,

> 
> Hello Lukasz,
> 
> On Fri, Nov 07, 2014 at 11:05:51AM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski wrote:
> > > > This patch extends the of-thermal.c to provide information about
> > > > number of available non critical (i.e. non HW) trip points in
> > > > the system.
> > > > 
> > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > ---
> > > >  drivers/thermal/of-thermal.c   | 12 ++++++++++++
> > > >  drivers/thermal/thermal_core.h |  5 +++++
> > > >  2 files changed, 17 insertions(+)
> > > > 
> > > > diff --git a/drivers/thermal/of-thermal.c
> > > > b/drivers/thermal/of-thermal.c index 23c8d6c..cd74e64 100644
> > > > --- a/drivers/thermal/of-thermal.c
> > > > +++ b/drivers/thermal/of-thermal.c
> > > > @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct
> > > > thermal_zone_device *tz, int trip) return 1;
> > > >  }
> > > >  
> > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > *tz) +{
> > > > +	struct __thermal_zone *data = tz->devdata;
> > > > +	int i;
> > > > +
> > > > +	for (i = 0; i < data->ntrips; i++)
> > > > +		if (data->trips[i].type !=
> > > > THERMAL_TRIP_CRITICAL)
> > > > +			continue;
> > > > +
> > > > +	return --i;
> > > > +}
> > > > +
> > > 
> > > 
> > > 
> > > I am not against this addition. But looks like we start to spread
> > > some specific APIs that may not be used to other drivers.
> > 
> > Why do you think that this is a specific API? In the thermal OF we
> > can define trip point as "active", "passive", "hot" and "critical".
> > 
> > With the first three we can handle them and properly react. For the
> > last one SoC's PMU will power down the board.
> > 
> > Do you know if any board (e.g. from TI) is NOT supposed to shut down
> > when "critical" temperature is passed?
> > 
> 
> So, my point is not really about the usage of trip points. It is just
> that the of-thermal  API will grow with in a wide way with specific
> functions to check some property on the trip point array. And not all
> drivers may be using these function, e.g. the above proposal.
> 
> > The real problem here is the accessibility to __thermal_trip and
> > __thermal_bind arrays.
> > 
> > Use case:
> > In the Exynos driver we do need to initialize TMU registers with
> > threshold temperatures.
> > The temperature is read via tz->ops->get_trip_temp() [1] (from
> > of-thermal.c).
> > Unfortunately, the current API is not exporting the number of
> > non-critical trip points to know how many times call [1].
> > Of course we could by hand instantiate [1] n times, but this looks
> > for me a bit clumsy.
> 
> 
> I understand your use case. My point was simply that this use case may
> be specific to your driver (or few drivers).
> > 
> > Additionally, we now have implicit assumption about the order of
> > defined temperatures for trip points, but I think this is not a big
> > issue.
> > 
> > > Maybe having a
> > > single API to provide a read-only copy the list / array of trips
> > > might be a better approach. I will think of a better way.
> > 
> > Definitely. Exporting available trip points is crucial.
> > 
> 
> Yeah, I think it is the best thing to do. Share a read-only array /
> copy of the needed data, and then drivers would check what ever
> property they need from the array. Just make sure you document that
> this is a read-only array (i.e. any possible change they do, won't
> affect the original array).

So I assume that you don't mind that I will prepare such of-thermal.c
modification?

> 
> > > 
> > > I also request you to document it accordingly.
> > 
> > Ok, I will do that.
> 
> Cool!
> 
> 
> 
> > 
> > > 
> > > 
> > > >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > > > int trip, enum thermal_trend *trend)
> > > >  {
> > > > diff --git a/drivers/thermal/thermal_core.h
> > > > b/drivers/thermal/thermal_core.h index ed8ff05..334a7be 100644
> > > > --- a/drivers/thermal/thermal_core.h
> > > > +++ b/drivers/thermal/thermal_core.h
> > > > @@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
> > > >  void of_thermal_destroy_zones(void);
> > > >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > > >  int of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > *); #else
> > > >  static inline int of_parse_thermal_zones(void) { return 0; }
> > > >  static inline void of_thermal_destroy_zones(void) { }
> > > > @@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct
> > > > thermal_zone_device *, int) {
> > > >  	return 0;
> > > >  }
> > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > *)
> > > here, it is supposed to be static inline.
> > > 
> > > > +{
> > > > +	return 0;
> > > > +}
> > > >  #endif
> > > >  
> > > >  #endif /* __THERMAL_CORE_H__ */
> > > > -- 
> > > > 2.0.0.rc2
> > > > 
> > 
> > 
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
  2014-11-12  9:42           ` Lukasz Majewski
@ 2014-11-18 15:20             ` Eduardo Valentin
  -1 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-18 15:20 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kukjin Kim, Linux PM list, Lukasz Majewski,
	Bartlomiej Zolnierkiewicz, Amit Daniel Kachhap, Chanwoo Choi,
	Kyungmin Park, linux-samsung-soc, Zhang Rui, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 5904 bytes --]

Hello Lukasz,

On Wed, Nov 12, 2014 at 10:42:41AM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > 
> > Hello Lukasz,
> > 
> > On Fri, Nov 07, 2014 at 11:05:51AM +0100, Lukasz Majewski wrote:
> > > Hi Eduardo,
> > > 
> > > > On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski wrote:
> > > > > This patch extends the of-thermal.c to provide information about
> > > > > number of available non critical (i.e. non HW) trip points in
> > > > > the system.
> > > > > 
> > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > > ---
> > > > >  drivers/thermal/of-thermal.c   | 12 ++++++++++++
> > > > >  drivers/thermal/thermal_core.h |  5 +++++
> > > > >  2 files changed, 17 insertions(+)
> > > > > 
> > > > > diff --git a/drivers/thermal/of-thermal.c
> > > > > b/drivers/thermal/of-thermal.c index 23c8d6c..cd74e64 100644
> > > > > --- a/drivers/thermal/of-thermal.c
> > > > > +++ b/drivers/thermal/of-thermal.c
> > > > > @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct
> > > > > thermal_zone_device *tz, int trip) return 1;
> > > > >  }
> > > > >  
> > > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > > *tz) +{
> > > > > +	struct __thermal_zone *data = tz->devdata;
> > > > > +	int i;
> > > > > +
> > > > > +	for (i = 0; i < data->ntrips; i++)
> > > > > +		if (data->trips[i].type !=
> > > > > THERMAL_TRIP_CRITICAL)
> > > > > +			continue;
> > > > > +
> > > > > +	return --i;
> > > > > +}
> > > > > +
> > > > 
> > > > 
> > > > 
> > > > I am not against this addition. But looks like we start to spread
> > > > some specific APIs that may not be used to other drivers.
> > > 
> > > Why do you think that this is a specific API? In the thermal OF we
> > > can define trip point as "active", "passive", "hot" and "critical".
> > > 
> > > With the first three we can handle them and properly react. For the
> > > last one SoC's PMU will power down the board.
> > > 
> > > Do you know if any board (e.g. from TI) is NOT supposed to shut down
> > > when "critical" temperature is passed?
> > > 
> > 
> > So, my point is not really about the usage of trip points. It is just
> > that the of-thermal  API will grow with in a wide way with specific
> > functions to check some property on the trip point array. And not all
> > drivers may be using these function, e.g. the above proposal.
> > 
> > > The real problem here is the accessibility to __thermal_trip and
> > > __thermal_bind arrays.
> > > 
> > > Use case:
> > > In the Exynos driver we do need to initialize TMU registers with
> > > threshold temperatures.
> > > The temperature is read via tz->ops->get_trip_temp() [1] (from
> > > of-thermal.c).
> > > Unfortunately, the current API is not exporting the number of
> > > non-critical trip points to know how many times call [1].
> > > Of course we could by hand instantiate [1] n times, but this looks
> > > for me a bit clumsy.
> > 
> > 
> > I understand your use case. My point was simply that this use case may
> > be specific to your driver (or few drivers).
> > > 
> > > Additionally, we now have implicit assumption about the order of
> > > defined temperatures for trip points, but I think this is not a big
> > > issue.
> > > 
> > > > Maybe having a
> > > > single API to provide a read-only copy the list / array of trips
> > > > might be a better approach. I will think of a better way.
> > > 
> > > Definitely. Exporting available trip points is crucial.
> > > 
> > 
> > Yeah, I think it is the best thing to do. Share a read-only array /
> > copy of the needed data, and then drivers would check what ever
> > property they need from the array. Just make sure you document that
> > this is a read-only array (i.e. any possible change they do, won't
> > affect the original array).
> 
> So I assume that you don't mind that I will prepare such of-thermal.c
> modification?

No, please, feel free to send the proposal along with your patchset. To
me, it makes sense you do it, because you will also present a real use
case of this required change.

> 
> > 
> > > > 
> > > > I also request you to document it accordingly.
> > > 
> > > Ok, I will do that.
> > 
> > Cool!
> > 
> > 
> > 
> > > 
> > > > 
> > > > 
> > > > >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > > > > int trip, enum thermal_trend *trend)
> > > > >  {
> > > > > diff --git a/drivers/thermal/thermal_core.h
> > > > > b/drivers/thermal/thermal_core.h index ed8ff05..334a7be 100644
> > > > > --- a/drivers/thermal/thermal_core.h
> > > > > +++ b/drivers/thermal/thermal_core.h
> > > > > @@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
> > > > >  void of_thermal_destroy_zones(void);
> > > > >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > > > >  int of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > > *); #else
> > > > >  static inline int of_parse_thermal_zones(void) { return 0; }
> > > > >  static inline void of_thermal_destroy_zones(void) { }
> > > > > @@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct
> > > > > thermal_zone_device *, int) {
> > > > >  	return 0;
> > > > >  }
> > > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > > *)
> > > > here, it is supposed to be static inline.
> > > > 
> > > > > +{
> > > > > +	return 0;
> > > > > +}
> > > > >  #endif
> > > > >  
> > > > >  #endif /* __THERMAL_CORE_H__ */
> > > > > -- 
> > > > > 2.0.0.rc2
> > > > > 
> > > 
> > > 
> > > 
> > > -- 
> > > Best regards,
> > > 
> > > Lukasz Majewski
> > > 
> > > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
@ 2014-11-18 15:20             ` Eduardo Valentin
  0 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-18 15:20 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Lukasz,

On Wed, Nov 12, 2014 at 10:42:41AM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > 
> > Hello Lukasz,
> > 
> > On Fri, Nov 07, 2014 at 11:05:51AM +0100, Lukasz Majewski wrote:
> > > Hi Eduardo,
> > > 
> > > > On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski wrote:
> > > > > This patch extends the of-thermal.c to provide information about
> > > > > number of available non critical (i.e. non HW) trip points in
> > > > > the system.
> > > > > 
> > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > > ---
> > > > >  drivers/thermal/of-thermal.c   | 12 ++++++++++++
> > > > >  drivers/thermal/thermal_core.h |  5 +++++
> > > > >  2 files changed, 17 insertions(+)
> > > > > 
> > > > > diff --git a/drivers/thermal/of-thermal.c
> > > > > b/drivers/thermal/of-thermal.c index 23c8d6c..cd74e64 100644
> > > > > --- a/drivers/thermal/of-thermal.c
> > > > > +++ b/drivers/thermal/of-thermal.c
> > > > > @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct
> > > > > thermal_zone_device *tz, int trip) return 1;
> > > > >  }
> > > > >  
> > > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > > *tz) +{
> > > > > +	struct __thermal_zone *data = tz->devdata;
> > > > > +	int i;
> > > > > +
> > > > > +	for (i = 0; i < data->ntrips; i++)
> > > > > +		if (data->trips[i].type !=
> > > > > THERMAL_TRIP_CRITICAL)
> > > > > +			continue;
> > > > > +
> > > > > +	return --i;
> > > > > +}
> > > > > +
> > > > 
> > > > 
> > > > 
> > > > I am not against this addition. But looks like we start to spread
> > > > some specific APIs that may not be used to other drivers.
> > > 
> > > Why do you think that this is a specific API? In the thermal OF we
> > > can define trip point as "active", "passive", "hot" and "critical".
> > > 
> > > With the first three we can handle them and properly react. For the
> > > last one SoC's PMU will power down the board.
> > > 
> > > Do you know if any board (e.g. from TI) is NOT supposed to shut down
> > > when "critical" temperature is passed?
> > > 
> > 
> > So, my point is not really about the usage of trip points. It is just
> > that the of-thermal  API will grow with in a wide way with specific
> > functions to check some property on the trip point array. And not all
> > drivers may be using these function, e.g. the above proposal.
> > 
> > > The real problem here is the accessibility to __thermal_trip and
> > > __thermal_bind arrays.
> > > 
> > > Use case:
> > > In the Exynos driver we do need to initialize TMU registers with
> > > threshold temperatures.
> > > The temperature is read via tz->ops->get_trip_temp() [1] (from
> > > of-thermal.c).
> > > Unfortunately, the current API is not exporting the number of
> > > non-critical trip points to know how many times call [1].
> > > Of course we could by hand instantiate [1] n times, but this looks
> > > for me a bit clumsy.
> > 
> > 
> > I understand your use case. My point was simply that this use case may
> > be specific to your driver (or few drivers).
> > > 
> > > Additionally, we now have implicit assumption about the order of
> > > defined temperatures for trip points, but I think this is not a big
> > > issue.
> > > 
> > > > Maybe having a
> > > > single API to provide a read-only copy the list / array of trips
> > > > might be a better approach. I will think of a better way.
> > > 
> > > Definitely. Exporting available trip points is crucial.
> > > 
> > 
> > Yeah, I think it is the best thing to do. Share a read-only array /
> > copy of the needed data, and then drivers would check what ever
> > property they need from the array. Just make sure you document that
> > this is a read-only array (i.e. any possible change they do, won't
> > affect the original array).
> 
> So I assume that you don't mind that I will prepare such of-thermal.c
> modification?

No, please, feel free to send the proposal along with your patchset. To
me, it makes sense you do it, because you will also present a real use
case of this required change.

> 
> > 
> > > > 
> > > > I also request you to document it accordingly.
> > > 
> > > Ok, I will do that.
> > 
> > Cool!
> > 
> > 
> > 
> > > 
> > > > 
> > > > 
> > > > >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > > > > int trip, enum thermal_trend *trend)
> > > > >  {
> > > > > diff --git a/drivers/thermal/thermal_core.h
> > > > > b/drivers/thermal/thermal_core.h index ed8ff05..334a7be 100644
> > > > > --- a/drivers/thermal/thermal_core.h
> > > > > +++ b/drivers/thermal/thermal_core.h
> > > > > @@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
> > > > >  void of_thermal_destroy_zones(void);
> > > > >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > > > >  int of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > > *); #else
> > > > >  static inline int of_parse_thermal_zones(void) { return 0; }
> > > > >  static inline void of_thermal_destroy_zones(void) { }
> > > > > @@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct
> > > > > thermal_zone_device *, int) {
> > > > >  	return 0;
> > > > >  }
> > > > > +int of_thermal_get_non_crit_ntrips(struct thermal_zone_device
> > > > > *)
> > > > here, it is supposed to be static inline.
> > > > 
> > > > > +{
> > > > > +	return 0;
> > > > > +}
> > > > >  #endif
> > > > >  
> > > > >  #endif /* __THERMAL_CORE_H__ */
> > > > > -- 
> > > > > 2.0.0.rc2
> > > > > 
> > > 
> > > 
> > > 
> > > -- 
> > > Best regards,
> > > 
> > > Lukasz Majewski
> > > 
> > > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141118/767cfb83/attachment-0001.sig>

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 04/21] thermal: of: Extend current of-thermal.c code to allow setting emulated temp
  2014-11-07 11:20       ` Lukasz Majewski
@ 2014-11-18 15:23         ` Eduardo Valentin
  -1 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-18 15:23 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, linux-samsung-soc, linux-arm-kernel, Linux PM list,
	Kukjin Kim, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 6145 bytes --]

Lukasz,


On Fri, Nov 07, 2014 at 12:20:35PM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > Hello,
> > 
> > On Thu, Oct 09, 2014 at 06:38:40PM +0200, Lukasz Majewski wrote:
> > > Before this change it was only possible to set get_temp() and
> > > get_trend() methods to be used in the common code handling passing
> > > parameters via device tree to "cpu-thermal" CPU thermal zone device.
> > > 
> > > Now it is possible to also set emulated value of temperature for
> > > debug purposes.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > >  drivers/thermal/of-thermal.c | 25 ++++++++++++++++++++++---
> > >  include/linux/thermal.h      |  6 ++++--
> > >  2 files changed, 26 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/drivers/thermal/of-thermal.c
> > > b/drivers/thermal/of-thermal.c index cd74e64..f206375 100644
> > > --- a/drivers/thermal/of-thermal.c
> > > +++ b/drivers/thermal/of-thermal.c
> > > @@ -98,10 +98,22 @@ struct __thermal_zone {
> > >  	void *sensor_data;
> > >  	int (*get_temp)(void *, long *);
> > >  	int (*get_trend)(void *, long *);
> > > +	int (*set_emul_temp)(void *, unsigned long);
> > >  };
> > >  
> > >  /***   DT thermal zone device callbacks   ***/
> > >  
> > > +static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
> > > +				    unsigned long temp)
> > > +{
> > > +	struct __thermal_zone *data = tz->devdata;
> > > +
> > > +	if (!data->set_emul_temp)
> > > +		return -EINVAL;
> > > +
> > > +	return data->set_emul_temp(data->sensor_data, temp);
> > > +}
> > > +
> > >  static int of_thermal_get_temp(struct thermal_zone_device *tz,
> > >  			       unsigned long *temp)
> > >  {
> > > @@ -352,7 +364,8 @@ static struct thermal_zone_device *
> > >  thermal_zone_of_add_sensor(struct device_node *zone,
> > >  			   struct device_node *sensor, void *data,
> > >  			   int (*get_temp)(void *, long *),
> > > -			   int (*get_trend)(void *, long *))
> > > +			   int (*get_trend)(void *, long *),
> > > +			   int (*set_emul_temp)(void *, unsigned
> > > long))
> > 
> > Thanks for improving the API. However, looking at what is above, it
> > starts to be pretty ugly. And for sure, this is not the last callback
> > to be added.
> 
> Presumably there would be some more callbacks.
> 
> > I believe it is time to add a .ops in the of-thermal.
> > While in here, do you mind adding the .ops in a separated patch, then
> > add the .set_emul_temp in the .ops field?
> 
> I will add an option to pass .ops with thermal_zone_of_add_sensor().
> 
> I'm only concerned a bit about testing other users of of-thermal. 
> I have only beaglebone black (BBB) for testing, which on-soc bandgap
> thermal sensor is very inaccurate and hence not supported even at BBB
> github linux kernel repository (v3.14).
> 
> Because of above I would need your support for testing.
> 

I did the .ops part that is required for your patch:
https://patchwork.kernel.org/patch/5329801/

As you already reviewed it. Do you mind refreshing your series on top of
it?

Cheers,


> > 
> > >  {
> > >  	struct thermal_zone_device *tzd;
> > >  	struct __thermal_zone *tz;
> > > @@ -366,10 +379,12 @@ thermal_zone_of_add_sensor(struct device_node
> > > *zone, mutex_lock(&tzd->lock);
> > >  	tz->get_temp = get_temp;
> > >  	tz->get_trend = get_trend;
> > > +	tz->set_emul_temp = set_emul_temp;
> > >  	tz->sensor_data = data;
> > >  
> > >  	tzd->ops->get_temp = of_thermal_get_temp;
> > >  	tzd->ops->get_trend = of_thermal_get_trend;
> > > +	tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
> > >  	mutex_unlock(&tzd->lock);
> > >  
> > >  	return tzd;
> > > @@ -411,7 +426,8 @@ thermal_zone_of_add_sensor(struct device_node
> > > *zone, struct thermal_zone_device *
> > >  thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
> > >  				void *data, int (*get_temp)(void
> > > *, long *),
> > > -				int (*get_trend)(void *, long *))
> > > +				int (*get_trend)(void *, long *),
> > > +				int (*set_emul_temp)(void *,
> > > unsigned long)) {
> > >  	struct device_node *np, *child, *sensor_np;
> > >  
> > > @@ -453,7 +469,8 @@ thermal_zone_of_sensor_register(struct device
> > > *dev, int sensor_id, return thermal_zone_of_add_sensor(child,
> > > sensor_np, data,
> > >  							  get_temp,
> > > -
> > > get_trend);
> > > +
> > > get_trend,
> > > +
> > > set_emul_temp); }
> > >  	}
> > >  	of_node_put(np);
> > > @@ -494,9 +511,11 @@ void thermal_zone_of_sensor_unregister(struct
> > > device *dev, mutex_lock(&tzd->lock);
> > >  	tzd->ops->get_temp = NULL;
> > >  	tzd->ops->get_trend = NULL;
> > > +	tzd->ops->set_emul_temp = NULL;
> > >  
> > >  	tz->get_temp = NULL;
> > >  	tz->get_trend = NULL;
> > > +	tz->set_emul_temp = NULL;
> > >  	tz->sensor_data = NULL;
> > >  	mutex_unlock(&tzd->lock);
> > >  }
> > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > index 0305cde..36010e9 100644
> > > --- a/include/linux/thermal.h
> > > +++ b/include/linux/thermal.h
> > > @@ -290,14 +290,16 @@ struct thermal_genl_event {
> > >  struct thermal_zone_device *
> > >  thermal_zone_of_sensor_register(struct device *dev, int id,
> > >  				void *data, int (*get_temp)(void
> > > *, long *),
> > > -				int (*get_trend)(void *, long *));
> > > +				int (*get_trend)(void *, long *),
> > > +				int (*set_emul_temp)(void *,
> > > unsigned long)); void thermal_zone_of_sensor_unregister(struct
> > > device *dev, struct thermal_zone_device *tz);
> > >  #else
> > >  static inline struct thermal_zone_device *
> > >  thermal_zone_of_sensor_register(struct device *dev, int id,
> > >  				void *data, int (*get_temp)(void
> > > *, long *),
> > > -				int (*get_trend)(void *, long *))
> > > +				int (*get_trend)(void *, long *),
> > > +				int (*set_emul_temp)(void *,
> > > unsigned long)) {
> > >  	return NULL;
> > >  }
> > > -- 
> > > 2.0.0.rc2
> > > 
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 04/21] thermal: of: Extend current of-thermal.c code to allow setting emulated temp
@ 2014-11-18 15:23         ` Eduardo Valentin
  0 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-18 15:23 UTC (permalink / raw)
  To: linux-arm-kernel

Lukasz,


On Fri, Nov 07, 2014 at 12:20:35PM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > Hello,
> > 
> > On Thu, Oct 09, 2014 at 06:38:40PM +0200, Lukasz Majewski wrote:
> > > Before this change it was only possible to set get_temp() and
> > > get_trend() methods to be used in the common code handling passing
> > > parameters via device tree to "cpu-thermal" CPU thermal zone device.
> > > 
> > > Now it is possible to also set emulated value of temperature for
> > > debug purposes.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > >  drivers/thermal/of-thermal.c | 25 ++++++++++++++++++++++---
> > >  include/linux/thermal.h      |  6 ++++--
> > >  2 files changed, 26 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/drivers/thermal/of-thermal.c
> > > b/drivers/thermal/of-thermal.c index cd74e64..f206375 100644
> > > --- a/drivers/thermal/of-thermal.c
> > > +++ b/drivers/thermal/of-thermal.c
> > > @@ -98,10 +98,22 @@ struct __thermal_zone {
> > >  	void *sensor_data;
> > >  	int (*get_temp)(void *, long *);
> > >  	int (*get_trend)(void *, long *);
> > > +	int (*set_emul_temp)(void *, unsigned long);
> > >  };
> > >  
> > >  /***   DT thermal zone device callbacks   ***/
> > >  
> > > +static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
> > > +				    unsigned long temp)
> > > +{
> > > +	struct __thermal_zone *data = tz->devdata;
> > > +
> > > +	if (!data->set_emul_temp)
> > > +		return -EINVAL;
> > > +
> > > +	return data->set_emul_temp(data->sensor_data, temp);
> > > +}
> > > +
> > >  static int of_thermal_get_temp(struct thermal_zone_device *tz,
> > >  			       unsigned long *temp)
> > >  {
> > > @@ -352,7 +364,8 @@ static struct thermal_zone_device *
> > >  thermal_zone_of_add_sensor(struct device_node *zone,
> > >  			   struct device_node *sensor, void *data,
> > >  			   int (*get_temp)(void *, long *),
> > > -			   int (*get_trend)(void *, long *))
> > > +			   int (*get_trend)(void *, long *),
> > > +			   int (*set_emul_temp)(void *, unsigned
> > > long))
> > 
> > Thanks for improving the API. However, looking at what is above, it
> > starts to be pretty ugly. And for sure, this is not the last callback
> > to be added.
> 
> Presumably there would be some more callbacks.
> 
> > I believe it is time to add a .ops in the of-thermal.
> > While in here, do you mind adding the .ops in a separated patch, then
> > add the .set_emul_temp in the .ops field?
> 
> I will add an option to pass .ops with thermal_zone_of_add_sensor().
> 
> I'm only concerned a bit about testing other users of of-thermal. 
> I have only beaglebone black (BBB) for testing, which on-soc bandgap
> thermal sensor is very inaccurate and hence not supported even at BBB
> github linux kernel repository (v3.14).
> 
> Because of above I would need your support for testing.
> 

I did the .ops part that is required for your patch:
https://patchwork.kernel.org/patch/5329801/

As you already reviewed it. Do you mind refreshing your series on top of
it?

Cheers,


> > 
> > >  {
> > >  	struct thermal_zone_device *tzd;
> > >  	struct __thermal_zone *tz;
> > > @@ -366,10 +379,12 @@ thermal_zone_of_add_sensor(struct device_node
> > > *zone, mutex_lock(&tzd->lock);
> > >  	tz->get_temp = get_temp;
> > >  	tz->get_trend = get_trend;
> > > +	tz->set_emul_temp = set_emul_temp;
> > >  	tz->sensor_data = data;
> > >  
> > >  	tzd->ops->get_temp = of_thermal_get_temp;
> > >  	tzd->ops->get_trend = of_thermal_get_trend;
> > > +	tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
> > >  	mutex_unlock(&tzd->lock);
> > >  
> > >  	return tzd;
> > > @@ -411,7 +426,8 @@ thermal_zone_of_add_sensor(struct device_node
> > > *zone, struct thermal_zone_device *
> > >  thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
> > >  				void *data, int (*get_temp)(void
> > > *, long *),
> > > -				int (*get_trend)(void *, long *))
> > > +				int (*get_trend)(void *, long *),
> > > +				int (*set_emul_temp)(void *,
> > > unsigned long)) {
> > >  	struct device_node *np, *child, *sensor_np;
> > >  
> > > @@ -453,7 +469,8 @@ thermal_zone_of_sensor_register(struct device
> > > *dev, int sensor_id, return thermal_zone_of_add_sensor(child,
> > > sensor_np, data,
> > >  							  get_temp,
> > > -
> > > get_trend);
> > > +
> > > get_trend,
> > > +
> > > set_emul_temp); }
> > >  	}
> > >  	of_node_put(np);
> > > @@ -494,9 +511,11 @@ void thermal_zone_of_sensor_unregister(struct
> > > device *dev, mutex_lock(&tzd->lock);
> > >  	tzd->ops->get_temp = NULL;
> > >  	tzd->ops->get_trend = NULL;
> > > +	tzd->ops->set_emul_temp = NULL;
> > >  
> > >  	tz->get_temp = NULL;
> > >  	tz->get_trend = NULL;
> > > +	tz->set_emul_temp = NULL;
> > >  	tz->sensor_data = NULL;
> > >  	mutex_unlock(&tzd->lock);
> > >  }
> > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > index 0305cde..36010e9 100644
> > > --- a/include/linux/thermal.h
> > > +++ b/include/linux/thermal.h
> > > @@ -290,14 +290,16 @@ struct thermal_genl_event {
> > >  struct thermal_zone_device *
> > >  thermal_zone_of_sensor_register(struct device *dev, int id,
> > >  				void *data, int (*get_temp)(void
> > > *, long *),
> > > -				int (*get_trend)(void *, long *));
> > > +				int (*get_trend)(void *, long *),
> > > +				int (*set_emul_temp)(void *,
> > > unsigned long)); void thermal_zone_of_sensor_unregister(struct
> > > device *dev, struct thermal_zone_device *tz);
> > >  #else
> > >  static inline struct thermal_zone_device *
> > >  thermal_zone_of_sensor_register(struct device *dev, int id,
> > >  				void *data, int (*get_temp)(void
> > > *, long *),
> > > -				int (*get_trend)(void *, long *))
> > > +				int (*get_trend)(void *, long *),
> > > +				int (*set_emul_temp)(void *,
> > > unsigned long)) {
> > >  	return NULL;
> > >  }
> > > -- 
> > > 2.0.0.rc2
> > > 
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141118/79194856/attachment.sig>

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
  2014-11-18 15:20             ` Eduardo Valentin
@ 2014-11-18 20:25               ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-18 20:25 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Lukasz Majewski, Kukjin Kim, Bartlomiej Zolnierkiewicz,
	Linux PM list, Kyungmin Park, Chanwoo Choi, Amit Daniel Kachhap,
	linux-samsung-soc, Zhang Rui, linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 6461 bytes --]

On Tue, 18 Nov 2014 11:20:26 -0400
Eduardo Valentin <edubezval@gmail.com> wrote:

> Hello Lukasz,
> 
> On Wed, Nov 12, 2014 at 10:42:41AM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > 
> > > Hello Lukasz,
> > > 
> > > On Fri, Nov 07, 2014 at 11:05:51AM +0100, Lukasz Majewski wrote:
> > > > Hi Eduardo,
> > > > 
> > > > > On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski
> > > > > wrote:
> > > > > > This patch extends the of-thermal.c to provide information
> > > > > > about number of available non critical (i.e. non HW) trip
> > > > > > points in the system.
> > > > > > 
> > > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > > > ---
> > > > > >  drivers/thermal/of-thermal.c   | 12 ++++++++++++
> > > > > >  drivers/thermal/thermal_core.h |  5 +++++
> > > > > >  2 files changed, 17 insertions(+)
> > > > > > 
> > > > > > diff --git a/drivers/thermal/of-thermal.c
> > > > > > b/drivers/thermal/of-thermal.c index 23c8d6c..cd74e64 100644
> > > > > > --- a/drivers/thermal/of-thermal.c
> > > > > > +++ b/drivers/thermal/of-thermal.c
> > > > > > @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct
> > > > > > thermal_zone_device *tz, int trip) return 1;
> > > > > >  }
> > > > > >  
> > > > > > +int of_thermal_get_non_crit_ntrips(struct
> > > > > > thermal_zone_device *tz) +{
> > > > > > +	struct __thermal_zone *data = tz->devdata;
> > > > > > +	int i;
> > > > > > +
> > > > > > +	for (i = 0; i < data->ntrips; i++)
> > > > > > +		if (data->trips[i].type !=
> > > > > > THERMAL_TRIP_CRITICAL)
> > > > > > +			continue;
> > > > > > +
> > > > > > +	return --i;
> > > > > > +}
> > > > > > +
> > > > > 
> > > > > 
> > > > > 
> > > > > I am not against this addition. But looks like we start to
> > > > > spread some specific APIs that may not be used to other
> > > > > drivers.
> > > > 
> > > > Why do you think that this is a specific API? In the thermal OF
> > > > we can define trip point as "active", "passive", "hot" and
> > > > "critical".
> > > > 
> > > > With the first three we can handle them and properly react. For
> > > > the last one SoC's PMU will power down the board.
> > > > 
> > > > Do you know if any board (e.g. from TI) is NOT supposed to shut
> > > > down when "critical" temperature is passed?
> > > > 
> > > 
> > > So, my point is not really about the usage of trip points. It is
> > > just that the of-thermal  API will grow with in a wide way with
> > > specific functions to check some property on the trip point
> > > array. And not all drivers may be using these function, e.g. the
> > > above proposal.
> > > 
> > > > The real problem here is the accessibility to __thermal_trip and
> > > > __thermal_bind arrays.
> > > > 
> > > > Use case:
> > > > In the Exynos driver we do need to initialize TMU registers with
> > > > threshold temperatures.
> > > > The temperature is read via tz->ops->get_trip_temp() [1] (from
> > > > of-thermal.c).
> > > > Unfortunately, the current API is not exporting the number of
> > > > non-critical trip points to know how many times call [1].
> > > > Of course we could by hand instantiate [1] n times, but this
> > > > looks for me a bit clumsy.
> > > 
> > > 
> > > I understand your use case. My point was simply that this use
> > > case may be specific to your driver (or few drivers).
> > > > 
> > > > Additionally, we now have implicit assumption about the order of
> > > > defined temperatures for trip points, but I think this is not a
> > > > big issue.
> > > > 
> > > > > Maybe having a
> > > > > single API to provide a read-only copy the list / array of
> > > > > trips might be a better approach. I will think of a better
> > > > > way.
> > > > 
> > > > Definitely. Exporting available trip points is crucial.
> > > > 
> > > 
> > > Yeah, I think it is the best thing to do. Share a read-only
> > > array / copy of the needed data, and then drivers would check
> > > what ever property they need from the array. Just make sure you
> > > document that this is a read-only array (i.e. any possible change
> > > they do, won't affect the original array).
> > 
> > So I assume that you don't mind that I will prepare such
> > of-thermal.c modification?
> 
> No, please, feel free to send the proposal along with your patchset.
> To me, it makes sense you do it, because you will also present a real
> use case of this required change.

Ok. I will rebase on top of your today's work.

> 
> > 
> > > 
> > > > > 
> > > > > I also request you to document it accordingly.
> > > > 
> > > > Ok, I will do that.
> > > 
> > > Cool!
> > > 
> > > 
> > > 
> > > > 
> > > > > 
> > > > > 
> > > > > >  static int of_thermal_get_trend(struct thermal_zone_device
> > > > > > *tz, int trip, enum thermal_trend *trend)
> > > > > >  {
> > > > > > diff --git a/drivers/thermal/thermal_core.h
> > > > > > b/drivers/thermal/thermal_core.h index ed8ff05..334a7be
> > > > > > 100644 --- a/drivers/thermal/thermal_core.h
> > > > > > +++ b/drivers/thermal/thermal_core.h
> > > > > > @@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
> > > > > >  void of_thermal_destroy_zones(void);
> > > > > >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > > > > >  int of_thermal_is_trip_en(struct thermal_zone_device *,
> > > > > > int); +int of_thermal_get_non_crit_ntrips(struct
> > > > > > thermal_zone_device *); #else
> > > > > >  static inline int of_parse_thermal_zones(void) { return
> > > > > > 0; } static inline void of_thermal_destroy_zones(void) { }
> > > > > > @@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct
> > > > > > thermal_zone_device *, int) {
> > > > > >  	return 0;
> > > > > >  }
> > > > > > +int of_thermal_get_non_crit_ntrips(struct
> > > > > > thermal_zone_device *)
> > > > > here, it is supposed to be static inline.
> > > > > 
> > > > > > +{
> > > > > > +	return 0;
> > > > > > +}
> > > > > >  #endif
> > > > > >  
> > > > > >  #endif /* __THERMAL_CORE_H__ */
> > > > > > -- 
> > > > > > 2.0.0.rc2
> > > > > > 
> > > > 
> > > > 
> > > > 
> > > > -- 
> > > > Best regards,
> > > > 
> > > > Lukasz Majewski
> > > > 
> > > > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
> > 
> > 
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

Best regards,
Lukasz Majewski

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points
@ 2014-11-18 20:25               ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-18 20:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 18 Nov 2014 11:20:26 -0400
Eduardo Valentin <edubezval@gmail.com> wrote:

> Hello Lukasz,
> 
> On Wed, Nov 12, 2014 at 10:42:41AM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > 
> > > Hello Lukasz,
> > > 
> > > On Fri, Nov 07, 2014 at 11:05:51AM +0100, Lukasz Majewski wrote:
> > > > Hi Eduardo,
> > > > 
> > > > > On Thu, Oct 09, 2014 at 06:38:39PM +0200, Lukasz Majewski
> > > > > wrote:
> > > > > > This patch extends the of-thermal.c to provide information
> > > > > > about number of available non critical (i.e. non HW) trip
> > > > > > points in the system.
> > > > > > 
> > > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > > > ---
> > > > > >  drivers/thermal/of-thermal.c   | 12 ++++++++++++
> > > > > >  drivers/thermal/thermal_core.h |  5 +++++
> > > > > >  2 files changed, 17 insertions(+)
> > > > > > 
> > > > > > diff --git a/drivers/thermal/of-thermal.c
> > > > > > b/drivers/thermal/of-thermal.c index 23c8d6c..cd74e64 100644
> > > > > > --- a/drivers/thermal/of-thermal.c
> > > > > > +++ b/drivers/thermal/of-thermal.c
> > > > > > @@ -128,6 +128,18 @@ int of_thermal_is_trip_en(struct
> > > > > > thermal_zone_device *tz, int trip) return 1;
> > > > > >  }
> > > > > >  
> > > > > > +int of_thermal_get_non_crit_ntrips(struct
> > > > > > thermal_zone_device *tz) +{
> > > > > > +	struct __thermal_zone *data = tz->devdata;
> > > > > > +	int i;
> > > > > > +
> > > > > > +	for (i = 0; i < data->ntrips; i++)
> > > > > > +		if (data->trips[i].type !=
> > > > > > THERMAL_TRIP_CRITICAL)
> > > > > > +			continue;
> > > > > > +
> > > > > > +	return --i;
> > > > > > +}
> > > > > > +
> > > > > 
> > > > > 
> > > > > 
> > > > > I am not against this addition. But looks like we start to
> > > > > spread some specific APIs that may not be used to other
> > > > > drivers.
> > > > 
> > > > Why do you think that this is a specific API? In the thermal OF
> > > > we can define trip point as "active", "passive", "hot" and
> > > > "critical".
> > > > 
> > > > With the first three we can handle them and properly react. For
> > > > the last one SoC's PMU will power down the board.
> > > > 
> > > > Do you know if any board (e.g. from TI) is NOT supposed to shut
> > > > down when "critical" temperature is passed?
> > > > 
> > > 
> > > So, my point is not really about the usage of trip points. It is
> > > just that the of-thermal  API will grow with in a wide way with
> > > specific functions to check some property on the trip point
> > > array. And not all drivers may be using these function, e.g. the
> > > above proposal.
> > > 
> > > > The real problem here is the accessibility to __thermal_trip and
> > > > __thermal_bind arrays.
> > > > 
> > > > Use case:
> > > > In the Exynos driver we do need to initialize TMU registers with
> > > > threshold temperatures.
> > > > The temperature is read via tz->ops->get_trip_temp() [1] (from
> > > > of-thermal.c).
> > > > Unfortunately, the current API is not exporting the number of
> > > > non-critical trip points to know how many times call [1].
> > > > Of course we could by hand instantiate [1] n times, but this
> > > > looks for me a bit clumsy.
> > > 
> > > 
> > > I understand your use case. My point was simply that this use
> > > case may be specific to your driver (or few drivers).
> > > > 
> > > > Additionally, we now have implicit assumption about the order of
> > > > defined temperatures for trip points, but I think this is not a
> > > > big issue.
> > > > 
> > > > > Maybe having a
> > > > > single API to provide a read-only copy the list / array of
> > > > > trips might be a better approach. I will think of a better
> > > > > way.
> > > > 
> > > > Definitely. Exporting available trip points is crucial.
> > > > 
> > > 
> > > Yeah, I think it is the best thing to do. Share a read-only
> > > array / copy of the needed data, and then drivers would check
> > > what ever property they need from the array. Just make sure you
> > > document that this is a read-only array (i.e. any possible change
> > > they do, won't affect the original array).
> > 
> > So I assume that you don't mind that I will prepare such
> > of-thermal.c modification?
> 
> No, please, feel free to send the proposal along with your patchset.
> To me, it makes sense you do it, because you will also present a real
> use case of this required change.

Ok. I will rebase on top of your today's work.

> 
> > 
> > > 
> > > > > 
> > > > > I also request you to document it accordingly.
> > > > 
> > > > Ok, I will do that.
> > > 
> > > Cool!
> > > 
> > > 
> > > 
> > > > 
> > > > > 
> > > > > 
> > > > > >  static int of_thermal_get_trend(struct thermal_zone_device
> > > > > > *tz, int trip, enum thermal_trend *trend)
> > > > > >  {
> > > > > > diff --git a/drivers/thermal/thermal_core.h
> > > > > > b/drivers/thermal/thermal_core.h index ed8ff05..334a7be
> > > > > > 100644 --- a/drivers/thermal/thermal_core.h
> > > > > > +++ b/drivers/thermal/thermal_core.h
> > > > > > @@ -83,6 +83,7 @@ int of_parse_thermal_zones(void);
> > > > > >  void of_thermal_destroy_zones(void);
> > > > > >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > > > > >  int of_thermal_is_trip_en(struct thermal_zone_device *,
> > > > > > int); +int of_thermal_get_non_crit_ntrips(struct
> > > > > > thermal_zone_device *); #else
> > > > > >  static inline int of_parse_thermal_zones(void) { return
> > > > > > 0; } static inline void of_thermal_destroy_zones(void) { }
> > > > > > @@ -94,6 +95,10 @@ int of_thermal_is_trip_en(struct
> > > > > > thermal_zone_device *, int) {
> > > > > >  	return 0;
> > > > > >  }
> > > > > > +int of_thermal_get_non_crit_ntrips(struct
> > > > > > thermal_zone_device *)
> > > > > here, it is supposed to be static inline.
> > > > > 
> > > > > > +{
> > > > > > +	return 0;
> > > > > > +}
> > > > > >  #endif
> > > > > >  
> > > > > >  #endif /* __THERMAL_CORE_H__ */
> > > > > > -- 
> > > > > > 2.0.0.rc2
> > > > > > 
> > > > 
> > > > 
> > > > 
> > > > -- 
> > > > Best regards,
> > > > 
> > > > Lukasz Majewski
> > > > 
> > > > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
> > 
> > 
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

Best regards,
Lukasz Majewski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141118/bfb70aa8/attachment.sig>

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH 04/21] thermal: of: Extend current of-thermal.c code to allow setting emulated temp
  2014-11-18 15:23         ` Eduardo Valentin
@ 2014-11-18 20:28           ` Lukasz Majewski
  -1 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-18 20:28 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Lukasz Majewski, Kukjin Kim, Linux PM list,
	Bartlomiej Zolnierkiewicz, Kyungmin Park, Chanwoo Choi,
	Amit Daniel Kachhap, linux-samsung-soc, Zhang Rui,
	linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 6835 bytes --]

On Tue, 18 Nov 2014 11:23:29 -0400
Eduardo Valentin <edubezval@gmail.com> wrote:

> Lukasz,
> 
> 
> On Fri, Nov 07, 2014 at 12:20:35PM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > Hello,
> > > 
> > > On Thu, Oct 09, 2014 at 06:38:40PM +0200, Lukasz Majewski wrote:
> > > > Before this change it was only possible to set get_temp() and
> > > > get_trend() methods to be used in the common code handling
> > > > passing parameters via device tree to "cpu-thermal" CPU thermal
> > > > zone device.
> > > > 
> > > > Now it is possible to also set emulated value of temperature for
> > > > debug purposes.
> > > > 
> > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > ---
> > > >  drivers/thermal/of-thermal.c | 25 ++++++++++++++++++++++---
> > > >  include/linux/thermal.h      |  6 ++++--
> > > >  2 files changed, 26 insertions(+), 5 deletions(-)
> > > > 
> > > > diff --git a/drivers/thermal/of-thermal.c
> > > > b/drivers/thermal/of-thermal.c index cd74e64..f206375 100644
> > > > --- a/drivers/thermal/of-thermal.c
> > > > +++ b/drivers/thermal/of-thermal.c
> > > > @@ -98,10 +98,22 @@ struct __thermal_zone {
> > > >  	void *sensor_data;
> > > >  	int (*get_temp)(void *, long *);
> > > >  	int (*get_trend)(void *, long *);
> > > > +	int (*set_emul_temp)(void *, unsigned long);
> > > >  };
> > > >  
> > > >  /***   DT thermal zone device callbacks   ***/
> > > >  
> > > > +static int of_thermal_set_emul_temp(struct thermal_zone_device
> > > > *tz,
> > > > +				    unsigned long temp)
> > > > +{
> > > > +	struct __thermal_zone *data = tz->devdata;
> > > > +
> > > > +	if (!data->set_emul_temp)
> > > > +		return -EINVAL;
> > > > +
> > > > +	return data->set_emul_temp(data->sensor_data, temp);
> > > > +}
> > > > +
> > > >  static int of_thermal_get_temp(struct thermal_zone_device *tz,
> > > >  			       unsigned long *temp)
> > > >  {
> > > > @@ -352,7 +364,8 @@ static struct thermal_zone_device *
> > > >  thermal_zone_of_add_sensor(struct device_node *zone,
> > > >  			   struct device_node *sensor, void
> > > > *data, int (*get_temp)(void *, long *),
> > > > -			   int (*get_trend)(void *, long *))
> > > > +			   int (*get_trend)(void *, long *),
> > > > +			   int (*set_emul_temp)(void *,
> > > > unsigned long))
> > > 
> > > Thanks for improving the API. However, looking at what is above,
> > > it starts to be pretty ugly. And for sure, this is not the last
> > > callback to be added.
> > 
> > Presumably there would be some more callbacks.
> > 
> > > I believe it is time to add a .ops in the of-thermal.
> > > While in here, do you mind adding the .ops in a separated patch,
> > > then add the .set_emul_temp in the .ops field?
> > 
> > I will add an option to pass .ops with thermal_zone_of_add_sensor().
> > 
> > I'm only concerned a bit about testing other users of of-thermal. 
> > I have only beaglebone black (BBB) for testing, which on-soc bandgap
> > thermal sensor is very inaccurate and hence not supported even at
> > BBB github linux kernel repository (v3.14).
> > 
> > Because of above I would need your support for testing.
> > 
> 
> I did the .ops part that is required for your patch:
> https://patchwork.kernel.org/patch/5329801/
> 
> As you already reviewed it. Do you mind refreshing your series on top
> of it?

Yours patches were almost identical to mine. I will wait maybe two more
days, and if nobody opposed to your concept, I send my work on top of
your patch.

Best regards,
Lukasz Majewski
> 
> Cheers,
> 
> 
> > > 
> > > >  {
> > > >  	struct thermal_zone_device *tzd;
> > > >  	struct __thermal_zone *tz;
> > > > @@ -366,10 +379,12 @@ thermal_zone_of_add_sensor(struct
> > > > device_node *zone, mutex_lock(&tzd->lock);
> > > >  	tz->get_temp = get_temp;
> > > >  	tz->get_trend = get_trend;
> > > > +	tz->set_emul_temp = set_emul_temp;
> > > >  	tz->sensor_data = data;
> > > >  
> > > >  	tzd->ops->get_temp = of_thermal_get_temp;
> > > >  	tzd->ops->get_trend = of_thermal_get_trend;
> > > > +	tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
> > > >  	mutex_unlock(&tzd->lock);
> > > >  
> > > >  	return tzd;
> > > > @@ -411,7 +426,8 @@ thermal_zone_of_add_sensor(struct
> > > > device_node *zone, struct thermal_zone_device *
> > > >  thermal_zone_of_sensor_register(struct device *dev, int
> > > > sensor_id, void *data, int (*get_temp)(void
> > > > *, long *),
> > > > -				int (*get_trend)(void *, long
> > > > *))
> > > > +				int (*get_trend)(void *, long
> > > > *),
> > > > +				int (*set_emul_temp)(void *,
> > > > unsigned long)) {
> > > >  	struct device_node *np, *child, *sensor_np;
> > > >  
> > > > @@ -453,7 +469,8 @@ thermal_zone_of_sensor_register(struct
> > > > device *dev, int sensor_id, return
> > > > thermal_zone_of_add_sensor(child, sensor_np, data,
> > > >  							  get_temp,
> > > > -
> > > > get_trend);
> > > > +
> > > > get_trend,
> > > > +
> > > > set_emul_temp); }
> > > >  	}
> > > >  	of_node_put(np);
> > > > @@ -494,9 +511,11 @@ void
> > > > thermal_zone_of_sensor_unregister(struct device *dev,
> > > > mutex_lock(&tzd->lock); tzd->ops->get_temp = NULL;
> > > >  	tzd->ops->get_trend = NULL;
> > > > +	tzd->ops->set_emul_temp = NULL;
> > > >  
> > > >  	tz->get_temp = NULL;
> > > >  	tz->get_trend = NULL;
> > > > +	tz->set_emul_temp = NULL;
> > > >  	tz->sensor_data = NULL;
> > > >  	mutex_unlock(&tzd->lock);
> > > >  }
> > > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > > index 0305cde..36010e9 100644
> > > > --- a/include/linux/thermal.h
> > > > +++ b/include/linux/thermal.h
> > > > @@ -290,14 +290,16 @@ struct thermal_genl_event {
> > > >  struct thermal_zone_device *
> > > >  thermal_zone_of_sensor_register(struct device *dev, int id,
> > > >  				void *data, int
> > > > (*get_temp)(void *, long *),
> > > > -				int (*get_trend)(void *, long
> > > > *));
> > > > +				int (*get_trend)(void *, long
> > > > *),
> > > > +				int (*set_emul_temp)(void *,
> > > > unsigned long)); void thermal_zone_of_sensor_unregister(struct
> > > > device *dev, struct thermal_zone_device *tz);
> > > >  #else
> > > >  static inline struct thermal_zone_device *
> > > >  thermal_zone_of_sensor_register(struct device *dev, int id,
> > > >  				void *data, int
> > > > (*get_temp)(void *, long *),
> > > > -				int (*get_trend)(void *, long
> > > > *))
> > > > +				int (*get_trend)(void *, long
> > > > *),
> > > > +				int (*set_emul_temp)(void *,
> > > > unsigned long)) {
> > > >  	return NULL;
> > > >  }
> > > > -- 
> > > > 2.0.0.rc2
> > > > 
> > 
> > 
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH 04/21] thermal: of: Extend current of-thermal.c code to allow setting emulated temp
@ 2014-11-18 20:28           ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-18 20:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 18 Nov 2014 11:23:29 -0400
Eduardo Valentin <edubezval@gmail.com> wrote:

> Lukasz,
> 
> 
> On Fri, Nov 07, 2014 at 12:20:35PM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > Hello,
> > > 
> > > On Thu, Oct 09, 2014 at 06:38:40PM +0200, Lukasz Majewski wrote:
> > > > Before this change it was only possible to set get_temp() and
> > > > get_trend() methods to be used in the common code handling
> > > > passing parameters via device tree to "cpu-thermal" CPU thermal
> > > > zone device.
> > > > 
> > > > Now it is possible to also set emulated value of temperature for
> > > > debug purposes.
> > > > 
> > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > ---
> > > >  drivers/thermal/of-thermal.c | 25 ++++++++++++++++++++++---
> > > >  include/linux/thermal.h      |  6 ++++--
> > > >  2 files changed, 26 insertions(+), 5 deletions(-)
> > > > 
> > > > diff --git a/drivers/thermal/of-thermal.c
> > > > b/drivers/thermal/of-thermal.c index cd74e64..f206375 100644
> > > > --- a/drivers/thermal/of-thermal.c
> > > > +++ b/drivers/thermal/of-thermal.c
> > > > @@ -98,10 +98,22 @@ struct __thermal_zone {
> > > >  	void *sensor_data;
> > > >  	int (*get_temp)(void *, long *);
> > > >  	int (*get_trend)(void *, long *);
> > > > +	int (*set_emul_temp)(void *, unsigned long);
> > > >  };
> > > >  
> > > >  /***   DT thermal zone device callbacks   ***/
> > > >  
> > > > +static int of_thermal_set_emul_temp(struct thermal_zone_device
> > > > *tz,
> > > > +				    unsigned long temp)
> > > > +{
> > > > +	struct __thermal_zone *data = tz->devdata;
> > > > +
> > > > +	if (!data->set_emul_temp)
> > > > +		return -EINVAL;
> > > > +
> > > > +	return data->set_emul_temp(data->sensor_data, temp);
> > > > +}
> > > > +
> > > >  static int of_thermal_get_temp(struct thermal_zone_device *tz,
> > > >  			       unsigned long *temp)
> > > >  {
> > > > @@ -352,7 +364,8 @@ static struct thermal_zone_device *
> > > >  thermal_zone_of_add_sensor(struct device_node *zone,
> > > >  			   struct device_node *sensor, void
> > > > *data, int (*get_temp)(void *, long *),
> > > > -			   int (*get_trend)(void *, long *))
> > > > +			   int (*get_trend)(void *, long *),
> > > > +			   int (*set_emul_temp)(void *,
> > > > unsigned long))
> > > 
> > > Thanks for improving the API. However, looking at what is above,
> > > it starts to be pretty ugly. And for sure, this is not the last
> > > callback to be added.
> > 
> > Presumably there would be some more callbacks.
> > 
> > > I believe it is time to add a .ops in the of-thermal.
> > > While in here, do you mind adding the .ops in a separated patch,
> > > then add the .set_emul_temp in the .ops field?
> > 
> > I will add an option to pass .ops with thermal_zone_of_add_sensor().
> > 
> > I'm only concerned a bit about testing other users of of-thermal. 
> > I have only beaglebone black (BBB) for testing, which on-soc bandgap
> > thermal sensor is very inaccurate and hence not supported even at
> > BBB github linux kernel repository (v3.14).
> > 
> > Because of above I would need your support for testing.
> > 
> 
> I did the .ops part that is required for your patch:
> https://patchwork.kernel.org/patch/5329801/
> 
> As you already reviewed it. Do you mind refreshing your series on top
> of it?

Yours patches were almost identical to mine. I will wait maybe two more
days, and if nobody opposed to your concept, I send my work on top of
your patch.

Best regards,
Lukasz Majewski
> 
> Cheers,
> 
> 
> > > 
> > > >  {
> > > >  	struct thermal_zone_device *tzd;
> > > >  	struct __thermal_zone *tz;
> > > > @@ -366,10 +379,12 @@ thermal_zone_of_add_sensor(struct
> > > > device_node *zone, mutex_lock(&tzd->lock);
> > > >  	tz->get_temp = get_temp;
> > > >  	tz->get_trend = get_trend;
> > > > +	tz->set_emul_temp = set_emul_temp;
> > > >  	tz->sensor_data = data;
> > > >  
> > > >  	tzd->ops->get_temp = of_thermal_get_temp;
> > > >  	tzd->ops->get_trend = of_thermal_get_trend;
> > > > +	tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
> > > >  	mutex_unlock(&tzd->lock);
> > > >  
> > > >  	return tzd;
> > > > @@ -411,7 +426,8 @@ thermal_zone_of_add_sensor(struct
> > > > device_node *zone, struct thermal_zone_device *
> > > >  thermal_zone_of_sensor_register(struct device *dev, int
> > > > sensor_id, void *data, int (*get_temp)(void
> > > > *, long *),
> > > > -				int (*get_trend)(void *, long
> > > > *))
> > > > +				int (*get_trend)(void *, long
> > > > *),
> > > > +				int (*set_emul_temp)(void *,
> > > > unsigned long)) {
> > > >  	struct device_node *np, *child, *sensor_np;
> > > >  
> > > > @@ -453,7 +469,8 @@ thermal_zone_of_sensor_register(struct
> > > > device *dev, int sensor_id, return
> > > > thermal_zone_of_add_sensor(child, sensor_np, data,
> > > >  							  get_temp,
> > > > -
> > > > get_trend);
> > > > +
> > > > get_trend,
> > > > +
> > > > set_emul_temp); }
> > > >  	}
> > > >  	of_node_put(np);
> > > > @@ -494,9 +511,11 @@ void
> > > > thermal_zone_of_sensor_unregister(struct device *dev,
> > > > mutex_lock(&tzd->lock); tzd->ops->get_temp = NULL;
> > > >  	tzd->ops->get_trend = NULL;
> > > > +	tzd->ops->set_emul_temp = NULL;
> > > >  
> > > >  	tz->get_temp = NULL;
> > > >  	tz->get_trend = NULL;
> > > > +	tz->set_emul_temp = NULL;
> > > >  	tz->sensor_data = NULL;
> > > >  	mutex_unlock(&tzd->lock);
> > > >  }
> > > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > > index 0305cde..36010e9 100644
> > > > --- a/include/linux/thermal.h
> > > > +++ b/include/linux/thermal.h
> > > > @@ -290,14 +290,16 @@ struct thermal_genl_event {
> > > >  struct thermal_zone_device *
> > > >  thermal_zone_of_sensor_register(struct device *dev, int id,
> > > >  				void *data, int
> > > > (*get_temp)(void *, long *),
> > > > -				int (*get_trend)(void *, long
> > > > *));
> > > > +				int (*get_trend)(void *, long
> > > > *),
> > > > +				int (*set_emul_temp)(void *,
> > > > unsigned long)); void thermal_zone_of_sensor_unregister(struct
> > > > device *dev, struct thermal_zone_device *tz);
> > > >  #else
> > > >  static inline struct thermal_zone_device *
> > > >  thermal_zone_of_sensor_register(struct device *dev, int id,
> > > >  				void *data, int
> > > > (*get_temp)(void *, long *),
> > > > -				int (*get_trend)(void *, long
> > > > *))
> > > > +				int (*get_trend)(void *, long
> > > > *),
> > > > +				int (*set_emul_temp)(void *,
> > > > unsigned long)) {
> > > >  	return NULL;
> > > >  }
> > > > -- 
> > > > 2.0.0.rc2
> > > > 
> > 
> > 
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141118/ffe33b35/attachment.sig>

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v2 0/4] thermal: of: of-thermal.c API extensions
  2014-10-09 16:38 ` Lukasz Majewski
                   ` (22 preceding siblings ...)
  (?)
@ 2014-11-20 16:21 ` Lukasz Majewski
  2014-11-20 16:21   ` [PATCH v2 1/4] thermal: of: Extend of-thermal.c to provide number of trip points Lukasz Majewski
                     ` (4 more replies)
  -1 siblings, 5 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-20 16:21 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, Thierry Reding, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Mikko Perttunen, Stephen Warren,
	Abhilash Kesavan, Abhilash Kesavan, Guenter Roeck, linux-kernel,
	Caesar Wang, Lukasz Majewski

Provided patch series extend of-thermal.c file API. It is necessary 
for ongoing Exynos TMU rework.
First version of this code can be found at:
http://www.spinics.net/lists/linux-samsung-soc/msg37719.html

This code provides some methods to access some of-thermal local data.
Moreover it provides a read only copy of trip points.

Lukasz Majewski (4):
  thermal: of: Extend of-thermal.c to provide number of trip points
  thermal: of: Extend of-thermal.c to provide check if trip point is
    enabled
  thermal: of: Extend of-thermal to export table of trip points
  thermal: of: Extend current of-thermal.c code to allow setting
    emulated temp

 drivers/thermal/of-thermal.c   | 97 ++++++++++++++++++++++++++++++++++++++++++
 drivers/thermal/thermal_core.h | 17 ++++++++
 include/linux/thermal.h        | 15 +++++++
 3 files changed, 129 insertions(+)

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v2 1/4] thermal: of: Extend of-thermal.c to provide number of trip points
  2014-11-20 16:21 ` [PATCH v2 0/4] thermal: of: of-thermal.c API extensions Lukasz Majewski
@ 2014-11-20 16:21   ` Lukasz Majewski
  2014-11-25  6:04     ` Eduardo Valentin
  2014-11-20 16:21   ` [PATCH v2 2/4] thermal: of: Extend of-thermal.c to provide check if trip point is enabled Lukasz Majewski
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-20 16:21 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, Thierry Reding, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Mikko Perttunen, Stephen Warren,
	Abhilash Kesavan, Abhilash Kesavan, Guenter Roeck, linux-kernel,
	Caesar Wang, Lukasz Majewski

This patch extends the of-thermal.c to provide information about number of
available trip points.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Provide detailed (doxygen like) description of the of_thermal_get_ntrips()
  method
- Check for data pointer not being NULL
---
 drivers/thermal/of-thermal.c   | 20 ++++++++++++++++++++
 drivers/thermal/thermal_core.h |  5 +++++
 2 files changed, 25 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index b7982f0..7170822 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -112,6 +112,26 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
 	return data->ops->get_temp(data->sensor_data, temp);
 }
 
+/**
+ * of_thermal_get_ntrips - function to export number of available trip
+ *			   points.
+ * @tz: pointer to a thermal zone
+ *
+ * This function is a globally visible wrapper to get number of trip points
+ * stored in the local struct __thermal_zone
+ *
+ * Return: number of available trip points, -ENODEV when data not available
+ */
+int of_thermal_get_ntrips(struct thermal_zone_device *tz)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	if (!data || IS_ERR(data))
+		return -ENODEV;
+
+	return data->ntrips;
+}
+
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 				enum thermal_trend *trend)
 {
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index d15d243..c3c7b82 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -89,9 +89,14 @@ static inline void thermal_gov_user_space_unregister(void) {}
 #ifdef CONFIG_THERMAL_OF
 int of_parse_thermal_zones(void);
 void of_thermal_destroy_zones(void);
+int of_thermal_get_ntrips(struct thermal_zone_device *);
 #else
 static inline int of_parse_thermal_zones(void) { return 0; }
 static inline void of_thermal_destroy_zones(void) { }
+static inline int of_thermal_get_ntrips(struct thermal_zone_device *)
+{
+	return 0;
+}
 #endif
 
 #endif /* __THERMAL_CORE_H__ */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 2/4] thermal: of: Extend of-thermal.c to provide check if trip point is enabled
  2014-11-20 16:21 ` [PATCH v2 0/4] thermal: of: of-thermal.c API extensions Lukasz Majewski
  2014-11-20 16:21   ` [PATCH v2 1/4] thermal: of: Extend of-thermal.c to provide number of trip points Lukasz Majewski
@ 2014-11-20 16:21   ` Lukasz Majewski
  2014-11-25  8:25     ` Eduardo Valentin
  2014-11-20 16:21   ` [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points Lukasz Majewski
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-20 16:21 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, Thierry Reding, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Mikko Perttunen, Stephen Warren,
	Abhilash Kesavan, Abhilash Kesavan, Guenter Roeck, linux-kernel,
	Caesar Wang, Lukasz Majewski

This patch extends the of-thermal.c to provide check if trip point is
enabled.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Replace int with bool
- Replace 1/0 with true/false
- Add check if data pointer is not NULL
- Add missing doxygen style comment for the function
---
 drivers/thermal/of-thermal.c   | 20 ++++++++++++++++++++
 drivers/thermal/thermal_core.h |  5 +++++
 2 files changed, 25 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 7170822..336af7f 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -132,6 +132,26 @@ int of_thermal_get_ntrips(struct thermal_zone_device *tz)
 	return data->ntrips;
 }
 
+/**
+ * of_thermal_is_trip_en - function to check if trip point is enabled
+ *
+ * @tz:	pointer to a thermal zone
+ * @trip:	trip point to evaluate
+ *
+ * This function is responsible for checking if passed trip point is enabled
+ *
+ * Return: true if trip point is enabled, false otherwise
+ */
+bool of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	if (!data || trip >= data->ntrips || trip < 0)
+		return false;
+
+	return true;
+}
+
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 				enum thermal_trend *trend)
 {
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index c3c7b82..466208c 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -90,6 +90,7 @@ static inline void thermal_gov_user_space_unregister(void) {}
 int of_parse_thermal_zones(void);
 void of_thermal_destroy_zones(void);
 int of_thermal_get_ntrips(struct thermal_zone_device *);
+bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
 #else
 static inline int of_parse_thermal_zones(void) { return 0; }
 static inline void of_thermal_destroy_zones(void) { }
@@ -97,6 +98,10 @@ static inline int of_thermal_get_ntrips(struct thermal_zone_device *)
 {
 	return 0;
 }
+static inline bool of_thermal_is_trip_en(struct thermal_zone_device *, int)
+{
+	return 0;
+}
 #endif
 
 #endif /* __THERMAL_CORE_H__ */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points
  2014-11-20 16:21 ` [PATCH v2 0/4] thermal: of: of-thermal.c API extensions Lukasz Majewski
  2014-11-20 16:21   ` [PATCH v2 1/4] thermal: of: Extend of-thermal.c to provide number of trip points Lukasz Majewski
  2014-11-20 16:21   ` [PATCH v2 2/4] thermal: of: Extend of-thermal.c to provide check if trip point is enabled Lukasz Majewski
@ 2014-11-20 16:21   ` Lukasz Majewski
  2014-11-25 20:36     ` Eduardo Valentin
  2014-11-25 20:38     ` Eduardo Valentin
  2014-11-20 16:21   ` [PATCH v2 4/4] thermal: of: Extend current of-thermal.c code to allow setting emulated temp Lukasz Majewski
  2014-12-08 17:04   ` [PATCH v3 0/5] thermal: of: of-thermal.c API extensions Lukasz Majewski
  4 siblings, 2 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-20 16:21 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, Thierry Reding, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Mikko Perttunen, Stephen Warren,
	Abhilash Kesavan, Abhilash Kesavan, Guenter Roeck, linux-kernel,
	Caesar Wang, Lukasz Majewski

This patch extends the of-thermal.c to export copy of trip points for
a given thermal zone.

Thermal drivers should use of_thermal_get_trip_points() method to get
pointer to table of thermal trip points.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- New patch - as suggested by Eduardo Valentin
---
 drivers/thermal/of-thermal.c   | 33 +++++++++++++++++++++++++++++++++
 drivers/thermal/thermal_core.h |  7 +++++++
 include/linux/thermal.h        | 14 ++++++++++++++
 3 files changed, 54 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 336af7f..33921c5 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -89,6 +89,7 @@ struct __thermal_zone {
 	/* trip data */
 	int ntrips;
 	struct __thermal_trip *trips;
+	struct thermal_trip *gtrips;
 
 	/* cooling binding data */
 	int num_tbps;
@@ -152,6 +153,27 @@ bool of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)
 	return true;
 }
 
+/**
+ * of_thermal_get_trip_points - function to get access to a globally exported
+ *				trip points
+ *
+ * @tz:	pointer to a thermal zone
+ *
+ * This function provides a pointer to the copy of trip points table
+ *
+ * Return: pointer to trip points table, NULL otherwise
+ */
+const struct thermal_trip * const
+of_thermal_get_trip_points(struct thermal_zone_device *tz)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	if (!data)
+		return NULL;
+
+	return data->gtrips;
+}
+
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 				enum thermal_trend *trend)
 {
@@ -767,6 +789,16 @@ thermal_of_build_thermal_zone(struct device_node *np)
 			goto free_tbps;
 	}
 
+	tz->gtrips = kcalloc(tz->ntrips, sizeof(*tz->gtrips), GFP_KERNEL);
+	if (!tz->gtrips) {
+		ret = -ENOMEM;
+		goto free_tbps;
+	}
+
+	for (i = 0; i < tz->ntrips; i++)
+		memcpy(&(tz->gtrips[i]), &(tz->trips[i].temperature),
+		       sizeof(*tz->gtrips));
+
 finish:
 	of_node_put(child);
 	tz->mode = THERMAL_DEVICE_DISABLED;
@@ -793,6 +825,7 @@ static inline void of_thermal_free_zone(struct __thermal_zone *tz)
 {
 	int i;
 
+	kfree(tz->gtrips);
 	for (i = 0; i < tz->num_tbps; i++)
 		of_node_put(tz->tbps[i].cooling_device);
 	kfree(tz->tbps);
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 466208c..a9580ca 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
 void of_thermal_destroy_zones(void);
 int of_thermal_get_ntrips(struct thermal_zone_device *);
 bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
+const struct thermal_trip * const
+of_thermal_get_trip_points(struct thermal_zone_device *);
 #else
 static inline int of_parse_thermal_zones(void) { return 0; }
 static inline void of_thermal_destroy_zones(void) { }
@@ -102,6 +104,11 @@ static inline bool of_thermal_is_trip_en(struct thermal_zone_device *, int)
 {
 	return 0;
 }
+static inline const struct thermal_trip * const
+of_thermal_get_trip_points(struct thermal_zone_device *)
+{
+	return NULL;
+}
 #endif
 
 #endif /* __THERMAL_CORE_H__ */
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 5bc28a7..88d7249 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -303,6 +303,20 @@ struct thermal_zone_of_device_ops {
 	int (*get_trend)(void *, long *);
 };
 
+/**
+ * struct thermal_trip - Structure representing themal trip points exported from
+ *                       of-thermal
+ *
+ * @temperature:	trip point temperature
+ * @hysteresis:		trip point hysteresis
+ * @type:		trip point type
+ */
+struct thermal_trip {
+	unsigned long int temperature;
+	unsigned long int hysteresis;
+	enum thermal_trip_type type;
+};
+
 /* Function declarations */
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 4/4] thermal: of: Extend current of-thermal.c code to allow setting emulated temp
  2014-11-20 16:21 ` [PATCH v2 0/4] thermal: of: of-thermal.c API extensions Lukasz Majewski
                     ` (2 preceding siblings ...)
  2014-11-20 16:21   ` [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points Lukasz Majewski
@ 2014-11-20 16:21   ` Lukasz Majewski
  2014-11-25 20:44     ` Eduardo Valentin
  2014-12-08 17:04   ` [PATCH v3 0/5] thermal: of: of-thermal.c API extensions Lukasz Majewski
  4 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-20 16:21 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, Thierry Reding, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Mikko Perttunen, Stephen Warren,
	Abhilash Kesavan, Abhilash Kesavan, Guenter Roeck, linux-kernel,
	Caesar Wang, Lukasz Majewski

Before this change it was only possible to set get_temp() and get_trend()
methods to be used in the common code handling passing parameters via
device tree to "cpu-thermal" CPU thermal zone device.

Now it is possible to also set emulated value of temperature for debug
purposes.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rework the emulated temperature setting code to use of_thermal_sensor_ops
structure
---
 drivers/thermal/of-thermal.c | 24 ++++++++++++++++++++++++
 include/linux/thermal.h      |  1 +
 2 files changed, 25 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 33921c5..ad7dc2b 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -174,6 +174,28 @@ of_thermal_get_trip_points(struct thermal_zone_device *tz)
 	return data->gtrips;
 }
 
+/**
+ * of_thermal_set_emul_temp - function to set emulated temperature
+ *
+ * @tz:	pointer to a thermal zone
+ * @temp:	temperature to set
+ *
+ * This function gives the ability to set emulated value of temperature,
+ * which is handy for debugging
+ *
+ * Return: zero on success, error code otherwise
+ */
+static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
+				    unsigned long temp)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	if (!data->ops || !data->ops->set_emul_temp)
+		return -EINVAL;
+
+	return data->ops->set_emul_temp(data->sensor_data, temp);
+}
+
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 				enum thermal_trend *trend)
 {
@@ -405,6 +427,7 @@ thermal_zone_of_add_sensor(struct device_node *zone,
 
 	tzd->ops->get_temp = of_thermal_get_temp;
 	tzd->ops->get_trend = of_thermal_get_trend;
+	tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
 	mutex_unlock(&tzd->lock);
 
 	return tzd;
@@ -533,6 +556,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 	mutex_lock(&tzd->lock);
 	tzd->ops->get_temp = NULL;
 	tzd->ops->get_trend = NULL;
+	tzd->ops->set_emul_temp = NULL;
 
 	tz->ops = NULL;
 	tz->sensor_data = NULL;
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 88d7249..5eb9d44 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -301,6 +301,7 @@ struct thermal_genl_event {
 struct thermal_zone_of_device_ops {
 	int (*get_temp)(void *, long *);
 	int (*get_trend)(void *, long *);
+	int (*set_emul_temp)(void *, unsigned long);
 };
 
 /**
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 1/4] thermal: of: Extend of-thermal.c to provide number of trip points
  2014-11-20 16:21   ` [PATCH v2 1/4] thermal: of: Extend of-thermal.c to provide number of trip points Lukasz Majewski
@ 2014-11-25  6:04     ` Eduardo Valentin
  2014-11-26  8:28       ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-25  6:04 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang

[-- Attachment #1: Type: text/plain, Size: 2851 bytes --]


Lukasz,

On Thu, Nov 20, 2014 at 05:21:25PM +0100, Lukasz Majewski wrote:
> This patch extends the of-thermal.c to provide information about number of
> available trip points.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Provide detailed (doxygen like) description of the of_thermal_get_ntrips()
>   method
> - Check for data pointer not being NULL
> ---
>  drivers/thermal/of-thermal.c   | 20 ++++++++++++++++++++
>  drivers/thermal/thermal_core.h |  5 +++++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index b7982f0..7170822 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -112,6 +112,26 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
>  	return data->ops->get_temp(data->sensor_data, temp);
>  }
>  
> +/**
> + * of_thermal_get_ntrips - function to export number of available trip
> + *			   points.
> + * @tz: pointer to a thermal zone
> + *
> + * This function is a globally visible wrapper to get number of trip points
> + * stored in the local struct __thermal_zone
> + *
> + * Return: number of available trip points, -ENODEV when data not available
> + */
> +int of_thermal_get_ntrips(struct thermal_zone_device *tz)
> +{
> +	struct __thermal_zone *data = tz->devdata;
> +
> +	if (!data || IS_ERR(data))
> +		return -ENODEV;
> +
> +	return data->ntrips;
> +}
> +

Missing
EXPORT_SYMBOL_GPL(of_thermal_get_ntrips);

>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
>  				enum thermal_trend *trend)
>  {
> diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> index d15d243..c3c7b82 100644
> --- a/drivers/thermal/thermal_core.h
> +++ b/drivers/thermal/thermal_core.h
> @@ -89,9 +89,14 @@ static inline void thermal_gov_user_space_unregister(void) {}
>  #ifdef CONFIG_THERMAL_OF
>  int of_parse_thermal_zones(void);
>  void of_thermal_destroy_zones(void);
> +int of_thermal_get_ntrips(struct thermal_zone_device *);
>  #else
>  static inline int of_parse_thermal_zones(void) { return 0; }
>  static inline void of_thermal_destroy_zones(void) { }
> +static inline int of_thermal_get_ntrips(struct thermal_zone_device *)

You need to declare the parameter name with a name     ---------------^ .

> +{

This produces a compilation error if CONFIG_THERMAL_OF is not set:
In file included from drivers/thermal/step_wise.c:28:0:
drivers/thermal/thermal_core.h: In function ‘of_thermal_get_ntrips’:
drivers/thermal/thermal_core.h:96:48: error: parameter name omitted
 static inline int of_thermal_get_ntrips(struct thermal_zone_device *)



> +	return 0;
> +}
>  #endif
>  
>  #endif /* __THERMAL_CORE_H__ */
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 2/4] thermal: of: Extend of-thermal.c to provide check if trip point is enabled
  2014-11-20 16:21   ` [PATCH v2 2/4] thermal: of: Extend of-thermal.c to provide check if trip point is enabled Lukasz Majewski
@ 2014-11-25  8:25     ` Eduardo Valentin
  2014-11-26  8:31       ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-25  8:25 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang

[-- Attachment #1: Type: text/plain, Size: 3129 bytes --]


Lukasz,

Same stuff here.

On Thu, Nov 20, 2014 at 05:21:26PM +0100, Lukasz Majewski wrote:
> This patch extends the of-thermal.c to provide check if trip point is
> enabled.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Replace int with bool
> - Replace 1/0 with true/false
> - Add check if data pointer is not NULL
> - Add missing doxygen style comment for the function
> ---
>  drivers/thermal/of-thermal.c   | 20 ++++++++++++++++++++
>  drivers/thermal/thermal_core.h |  5 +++++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index 7170822..336af7f 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -132,6 +132,26 @@ int of_thermal_get_ntrips(struct thermal_zone_device *tz)
>  	return data->ntrips;
>  }
>  
> +/**
> + * of_thermal_is_trip_en - function to check if trip point is enabled
> + *
> + * @tz:	pointer to a thermal zone
> + * @trip:	trip point to evaluate
> + *
> + * This function is responsible for checking if passed trip point is enabled
> + *
> + * Return: true if trip point is enabled, false otherwise
> + */
> +bool of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)

This one looks more like "is this trip point valid?" than "is this trip
point enabled?", isn't it?

By having such a function to check if a trip is enabled, one would
expect to have functions to enable / disable trips points.

What do you think of naming it:
of_thermal_is_trip_valid()
?

> +{
> +	struct __thermal_zone *data = tz->devdata;
> +
> +	if (!data || trip >= data->ntrips || trip < 0)

Even your check is about looking if the trip value is within a range,
telling the caller if the trip is valid or not, right?

> +		return false;
> +
> +	return true;
> +}
> +

Missing:
EXPORT_SYMBOL_GPL(of_thermal_is_trip_en);

or

EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid);

>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
>  				enum thermal_trend *trend)
>  {
> diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> index c3c7b82..466208c 100644
> --- a/drivers/thermal/thermal_core.h
> +++ b/drivers/thermal/thermal_core.h
> @@ -90,6 +90,7 @@ static inline void thermal_gov_user_space_unregister(void) {}
>  int of_parse_thermal_zones(void);
>  void of_thermal_destroy_zones(void);
>  int of_thermal_get_ntrips(struct thermal_zone_device *);
> +bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
>  #else
>  static inline int of_parse_thermal_zones(void) { return 0; }
>  static inline void of_thermal_destroy_zones(void) { }
> @@ -97,6 +98,10 @@ static inline int of_thermal_get_ntrips(struct thermal_zone_device *)
>  {
>  	return 0;
>  }
> +static inline bool of_thermal_is_trip_en(struct thermal_zone_device *, int)

Same as in patch 01, this produces compilation error. Please, name your
parameters.

> +{
> +	return 0;
> +}
>  #endif
>  
>  #endif /* __THERMAL_CORE_H__ */
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points
  2014-11-20 16:21   ` [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points Lukasz Majewski
@ 2014-11-25 20:36     ` Eduardo Valentin
  2014-11-26  8:35       ` Lukasz Majewski
  2014-11-25 20:38     ` Eduardo Valentin
  1 sibling, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-25 20:36 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang

[-- Attachment #1: Type: text/plain, Size: 4711 bytes --]

Hello Lukasz,

On Thu, Nov 20, 2014 at 05:21:27PM +0100, Lukasz Majewski wrote:
> This patch extends the of-thermal.c to export copy of trip points for
> a given thermal zone.
> 
> Thermal drivers should use of_thermal_get_trip_points() method to get
> pointer to table of thermal trip points.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - New patch - as suggested by Eduardo Valentin
> ---
>  drivers/thermal/of-thermal.c   | 33 +++++++++++++++++++++++++++++++++
>  drivers/thermal/thermal_core.h |  7 +++++++
>  include/linux/thermal.h        | 14 ++++++++++++++
>  3 files changed, 54 insertions(+)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index 336af7f..33921c5 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -89,6 +89,7 @@ struct __thermal_zone {
>  	/* trip data */
>  	int ntrips;
>  	struct __thermal_trip *trips;
> +	struct thermal_trip *gtrips;
>  
>  	/* cooling binding data */
>  	int num_tbps;
> @@ -152,6 +153,27 @@ bool of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)
>  	return true;
>  }
>  
> +/**
> + * of_thermal_get_trip_points - function to get access to a globally exported
> + *				trip points
> + *
> + * @tz:	pointer to a thermal zone
> + *
> + * This function provides a pointer to the copy of trip points table
> + *
> + * Return: pointer to trip points table, NULL otherwise
> + */
> +const struct thermal_trip * const
> +of_thermal_get_trip_points(struct thermal_zone_device *tz)
> +{
> +	struct __thermal_zone *data = tz->devdata;
> +
> +	if (!data)
> +		return NULL;
> +
> +	return data->gtrips;
> +}
> +

EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);

>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
>  				enum thermal_trend *trend)
>  {
> @@ -767,6 +789,16 @@ thermal_of_build_thermal_zone(struct device_node *np)
>  			goto free_tbps;
>  	}
>  
> +	tz->gtrips = kcalloc(tz->ntrips, sizeof(*tz->gtrips), GFP_KERNEL);
> +	if (!tz->gtrips) {
> +		ret = -ENOMEM;
> +		goto free_tbps;
> +	}
> +
> +	for (i = 0; i < tz->ntrips; i++)
> +		memcpy(&(tz->gtrips[i]), &(tz->trips[i].temperature),
> +		       sizeof(*tz->gtrips));
> +
>  finish:
>  	of_node_put(child);
>  	tz->mode = THERMAL_DEVICE_DISABLED;
> @@ -793,6 +825,7 @@ static inline void of_thermal_free_zone(struct __thermal_zone *tz)
>  {
>  	int i;
>  
> +	kfree(tz->gtrips);
>  	for (i = 0; i < tz->num_tbps; i++)
>  		of_node_put(tz->tbps[i].cooling_device);
>  	kfree(tz->tbps);
> diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> index 466208c..a9580ca 100644
> --- a/drivers/thermal/thermal_core.h
> +++ b/drivers/thermal/thermal_core.h
> @@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
>  void of_thermal_destroy_zones(void);
>  int of_thermal_get_ntrips(struct thermal_zone_device *);
>  bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
> +const struct thermal_trip * const
> +of_thermal_get_trip_points(struct thermal_zone_device *);
>  #else
>  static inline int of_parse_thermal_zones(void) { return 0; }
>  static inline void of_thermal_destroy_zones(void) { }
> @@ -102,6 +104,11 @@ static inline bool of_thermal_is_trip_en(struct thermal_zone_device *, int)
>  {

This produces compilation error when CONFIG_THERMAL_OF is not set. Name
the parameters to fix.

>  	return 0;
>  }
> +static inline const struct thermal_trip * const
> +of_thermal_get_trip_points(struct thermal_zone_device *)
> +{
> +	return NULL;
> +}
>  #endif
>  
>  #endif /* __THERMAL_CORE_H__ */
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 5bc28a7..88d7249 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -303,6 +303,20 @@ struct thermal_zone_of_device_ops {
>  	int (*get_trend)(void *, long *);
>  };
>  
> +/**
> + * struct thermal_trip - Structure representing themal trip points exported from
> + *                       of-thermal
> + *

The only problem I have with this name is that would look like it is in
use in all thermal framework, which is not really the case. But I do
think having a type here is a good thing. So, not sure :-)

> + * @temperature:	trip point temperature
> + * @hysteresis:		trip point hysteresis
> + * @type:		trip point type
> + */
> +struct thermal_trip {
> +	unsigned long int temperature;
> +	unsigned long int hysteresis;
> +	enum thermal_trip_type type;
> +};
> +
>  /* Function declarations */
>  #ifdef CONFIG_THERMAL_OF
>  struct thermal_zone_device *
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points
  2014-11-20 16:21   ` [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points Lukasz Majewski
  2014-11-25 20:36     ` Eduardo Valentin
@ 2014-11-25 20:38     ` Eduardo Valentin
  2014-11-26  8:39       ` Lukasz Majewski
  1 sibling, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-25 20:38 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang

[-- Attachment #1: Type: text/plain, Size: 4630 bytes --]

On Thu, Nov 20, 2014 at 05:21:27PM +0100, Lukasz Majewski wrote:
> This patch extends the of-thermal.c to export copy of trip points for
> a given thermal zone.
> 
> Thermal drivers should use of_thermal_get_trip_points() method to get
> pointer to table of thermal trip points.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - New patch - as suggested by Eduardo Valentin
> ---
>  drivers/thermal/of-thermal.c   | 33 +++++++++++++++++++++++++++++++++
>  drivers/thermal/thermal_core.h |  7 +++++++
>  include/linux/thermal.h        | 14 ++++++++++++++
>  3 files changed, 54 insertions(+)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index 336af7f..33921c5 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -89,6 +89,7 @@ struct __thermal_zone {
>  	/* trip data */
>  	int ntrips;
>  	struct __thermal_trip *trips;
> +	struct thermal_trip *gtrips;
>  
>  	/* cooling binding data */
>  	int num_tbps;
> @@ -152,6 +153,27 @@ bool of_thermal_is_trip_en(struct thermal_zone_device *tz, int trip)
>  	return true;
>  }
>  
> +/**
> + * of_thermal_get_trip_points - function to get access to a globally exported
> + *				trip points
> + *
> + * @tz:	pointer to a thermal zone
> + *
> + * This function provides a pointer to the copy of trip points table
> + *
> + * Return: pointer to trip points table, NULL otherwise
> + */
> +const struct thermal_trip * const
> +of_thermal_get_trip_points(struct thermal_zone_device *tz)

Another thing, can you please check why scripts/kernel-doc does not like
this prototype? It throws an warn:
Warning(drivers/thermal/of-thermal.c:168): cannot understand function
prototype: 'const struct thermal_trip * const
of_thermal_get_trip_points(struct thermal_zone_device *tz) '


> +{
> +	struct __thermal_zone *data = tz->devdata;
> +
> +	if (!data)
> +		return NULL;
> +
> +	return data->gtrips;
> +}
> +
>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
>  				enum thermal_trend *trend)
>  {
> @@ -767,6 +789,16 @@ thermal_of_build_thermal_zone(struct device_node *np)
>  			goto free_tbps;
>  	}
>  
> +	tz->gtrips = kcalloc(tz->ntrips, sizeof(*tz->gtrips), GFP_KERNEL);
> +	if (!tz->gtrips) {
> +		ret = -ENOMEM;
> +		goto free_tbps;
> +	}
> +
> +	for (i = 0; i < tz->ntrips; i++)
> +		memcpy(&(tz->gtrips[i]), &(tz->trips[i].temperature),
> +		       sizeof(*tz->gtrips));
> +
>  finish:
>  	of_node_put(child);
>  	tz->mode = THERMAL_DEVICE_DISABLED;
> @@ -793,6 +825,7 @@ static inline void of_thermal_free_zone(struct __thermal_zone *tz)
>  {
>  	int i;
>  
> +	kfree(tz->gtrips);
>  	for (i = 0; i < tz->num_tbps; i++)
>  		of_node_put(tz->tbps[i].cooling_device);
>  	kfree(tz->tbps);
> diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> index 466208c..a9580ca 100644
> --- a/drivers/thermal/thermal_core.h
> +++ b/drivers/thermal/thermal_core.h
> @@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
>  void of_thermal_destroy_zones(void);
>  int of_thermal_get_ntrips(struct thermal_zone_device *);
>  bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
> +const struct thermal_trip * const
> +of_thermal_get_trip_points(struct thermal_zone_device *);
>  #else
>  static inline int of_parse_thermal_zones(void) { return 0; }
>  static inline void of_thermal_destroy_zones(void) { }
> @@ -102,6 +104,11 @@ static inline bool of_thermal_is_trip_en(struct thermal_zone_device *, int)
>  {
>  	return 0;
>  }
> +static inline const struct thermal_trip * const
> +of_thermal_get_trip_points(struct thermal_zone_device *)
> +{
> +	return NULL;
> +}
>  #endif
>  
>  #endif /* __THERMAL_CORE_H__ */
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 5bc28a7..88d7249 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -303,6 +303,20 @@ struct thermal_zone_of_device_ops {
>  	int (*get_trend)(void *, long *);
>  };
>  
> +/**
> + * struct thermal_trip - Structure representing themal trip points exported from
> + *                       of-thermal
> + *
> + * @temperature:	trip point temperature
> + * @hysteresis:		trip point hysteresis
> + * @type:		trip point type
> + */
> +struct thermal_trip {
> +	unsigned long int temperature;
> +	unsigned long int hysteresis;
> +	enum thermal_trip_type type;
> +};
> +
>  /* Function declarations */
>  #ifdef CONFIG_THERMAL_OF
>  struct thermal_zone_device *
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 4/4] thermal: of: Extend current of-thermal.c code to allow setting emulated temp
  2014-11-20 16:21   ` [PATCH v2 4/4] thermal: of: Extend current of-thermal.c code to allow setting emulated temp Lukasz Majewski
@ 2014-11-25 20:44     ` Eduardo Valentin
  2014-11-26  8:47       ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-25 20:44 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang

[-- Attachment #1: Type: text/plain, Size: 2926 bytes --]

On Thu, Nov 20, 2014 at 05:21:28PM +0100, Lukasz Majewski wrote:
> Before this change it was only possible to set get_temp() and get_trend()
> methods to be used in the common code handling passing parameters via
> device tree to "cpu-thermal" CPU thermal zone device.
> 
> Now it is possible to also set emulated value of temperature for debug
> purposes.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rework the emulated temperature setting code to use of_thermal_sensor_ops
> structure
> ---
>  drivers/thermal/of-thermal.c | 24 ++++++++++++++++++++++++
>  include/linux/thermal.h      |  1 +
>  2 files changed, 25 insertions(+)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index 33921c5..ad7dc2b 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -174,6 +174,28 @@ of_thermal_get_trip_points(struct thermal_zone_device *tz)
>  	return data->gtrips;
>  }
>  
> +/**
> + * of_thermal_set_emul_temp - function to set emulated temperature
> + *
> + * @tz:	pointer to a thermal zone
> + * @temp:	temperature to set
> + *
> + * This function gives the ability to set emulated value of temperature,
> + * which is handy for debugging
> + *
> + * Return: zero on success, error code otherwise
> + */
> +static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
> +				    unsigned long temp)
> +{
> +	struct __thermal_zone *data = tz->devdata;
> +
> +	if (!data->ops || !data->ops->set_emul_temp)
> +		return -EINVAL;
> +
> +	return data->ops->set_emul_temp(data->sensor_data, temp);
> +}
> +
>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
>  				enum thermal_trend *trend)
>  {
> @@ -405,6 +427,7 @@ thermal_zone_of_add_sensor(struct device_node *zone,
>  
>  	tzd->ops->get_temp = of_thermal_get_temp;
>  	tzd->ops->get_trend = of_thermal_get_trend;
> +	tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
>  	mutex_unlock(&tzd->lock);
>  
>  	return tzd;
> @@ -533,6 +556,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
>  	mutex_lock(&tzd->lock);
>  	tzd->ops->get_temp = NULL;
>  	tzd->ops->get_trend = NULL;
> +	tzd->ops->set_emul_temp = NULL;
>  
>  	tz->ops = NULL;
>  	tz->sensor_data = NULL;
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 88d7249..5eb9d44 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -301,6 +301,7 @@ struct thermal_genl_event {
>  struct thermal_zone_of_device_ops {
>  	int (*get_temp)(void *, long *);
>  	int (*get_trend)(void *, long *);
> +	int (*set_emul_temp)(void *, unsigned long);

Please add it in the list of Optional functions in the comment above
this struct.

Apart from that:


Acked-by: Eduardo Valentin <edubezval@gmail.com>


>  };
>  
>  /**
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 1/4] thermal: of: Extend of-thermal.c to provide number of trip points
  2014-11-25  6:04     ` Eduardo Valentin
@ 2014-11-26  8:28       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-26  8:28 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang

Hi Eduardo,

> 
> Lukasz,
> 
> On Thu, Nov 20, 2014 at 05:21:25PM +0100, Lukasz Majewski wrote:
> > This patch extends the of-thermal.c to provide information about
> > number of available trip points.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Provide detailed (doxygen like) description of the
> > of_thermal_get_ntrips() method
> > - Check for data pointer not being NULL
> > ---
> >  drivers/thermal/of-thermal.c   | 20 ++++++++++++++++++++
> >  drivers/thermal/thermal_core.h |  5 +++++
> >  2 files changed, 25 insertions(+)
> > 
> > diff --git a/drivers/thermal/of-thermal.c
> > b/drivers/thermal/of-thermal.c index b7982f0..7170822 100644
> > --- a/drivers/thermal/of-thermal.c
> > +++ b/drivers/thermal/of-thermal.c
> > @@ -112,6 +112,26 @@ static int of_thermal_get_temp(struct
> > thermal_zone_device *tz, return
> > data->ops->get_temp(data->sensor_data, temp); }
> >  
> > +/**
> > + * of_thermal_get_ntrips - function to export number of available
> > trip
> > + *			   points.
> > + * @tz: pointer to a thermal zone
> > + *
> > + * This function is a globally visible wrapper to get number of
> > trip points
> > + * stored in the local struct __thermal_zone
> > + *
> > + * Return: number of available trip points, -ENODEV when data not
> > available
> > + */
> > +int of_thermal_get_ntrips(struct thermal_zone_device *tz)
> > +{
> > +	struct __thermal_zone *data = tz->devdata;
> > +
> > +	if (!data || IS_ERR(data))
> > +		return -ENODEV;
> > +
> > +	return data->ntrips;
> > +}
> > +
> 
> Missing
> EXPORT_SYMBOL_GPL(of_thermal_get_ntrips);

OK

> 
> >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > int trip, enum thermal_trend *trend)
> >  {
> > diff --git a/drivers/thermal/thermal_core.h
> > b/drivers/thermal/thermal_core.h index d15d243..c3c7b82 100644
> > --- a/drivers/thermal/thermal_core.h
> > +++ b/drivers/thermal/thermal_core.h
> > @@ -89,9 +89,14 @@ static inline void
> > thermal_gov_user_space_unregister(void) {} #ifdef CONFIG_THERMAL_OF
> >  int of_parse_thermal_zones(void);
> >  void of_thermal_destroy_zones(void);
> > +int of_thermal_get_ntrips(struct thermal_zone_device *);
> >  #else
> >  static inline int of_parse_thermal_zones(void) { return 0; }
> >  static inline void of_thermal_destroy_zones(void) { }
> > +static inline int of_thermal_get_ntrips(struct thermal_zone_device
> > *)
> 
> You need to declare the parameter name with a name
> ---------------^ .
> 
> > +{
> 
> This produces a compilation error if CONFIG_THERMAL_OF is not set:
> In file included from drivers/thermal/step_wise.c:28:0:
> drivers/thermal/thermal_core.h: In function ‘of_thermal_get_ntrips’:
> drivers/thermal/thermal_core.h:96:48: error: parameter name omitted
>  static inline int of_thermal_get_ntrips(struct thermal_zone_device *)
> 

Good point. Thanks for check.

> 
> 
> > +	return 0;
> > +}
> >  #endif
> >  
> >  #endif /* __THERMAL_CORE_H__ */
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 2/4] thermal: of: Extend of-thermal.c to provide check if trip point is enabled
  2014-11-25  8:25     ` Eduardo Valentin
@ 2014-11-26  8:31       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-26  8:31 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang

Hi Eduardo,

> 
> Lukasz,
> 
> Same stuff here.
> 
> On Thu, Nov 20, 2014 at 05:21:26PM +0100, Lukasz Majewski wrote:
> > This patch extends the of-thermal.c to provide check if trip point
> > is enabled.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Replace int with bool
> > - Replace 1/0 with true/false
> > - Add check if data pointer is not NULL
> > - Add missing doxygen style comment for the function
> > ---
> >  drivers/thermal/of-thermal.c   | 20 ++++++++++++++++++++
> >  drivers/thermal/thermal_core.h |  5 +++++
> >  2 files changed, 25 insertions(+)
> > 
> > diff --git a/drivers/thermal/of-thermal.c
> > b/drivers/thermal/of-thermal.c index 7170822..336af7f 100644
> > --- a/drivers/thermal/of-thermal.c
> > +++ b/drivers/thermal/of-thermal.c
> > @@ -132,6 +132,26 @@ int of_thermal_get_ntrips(struct
> > thermal_zone_device *tz) return data->ntrips;
> >  }
> >  
> > +/**
> > + * of_thermal_is_trip_en - function to check if trip point is
> > enabled
> > + *
> > + * @tz:	pointer to a thermal zone
> > + * @trip:	trip point to evaluate
> > + *
> > + * This function is responsible for checking if passed trip point
> > is enabled
> > + *
> > + * Return: true if trip point is enabled, false otherwise
> > + */
> > +bool of_thermal_is_trip_en(struct thermal_zone_device *tz, int
> > trip)
> 
> This one looks more like "is this trip point valid?" than "is this
> trip point enabled?", isn't it?
> 
> By having such a function to check if a trip is enabled, one would
> expect to have functions to enable / disable trips points.
> 
> What do you think of naming it:
> of_thermal_is_trip_valid()
> ?
> 

Good point. I think that of_thermal_is_trip_valid() is a better name.

> > +{
> > +	struct __thermal_zone *data = tz->devdata;
> > +
> > +	if (!data || trip >= data->ntrips || trip < 0)
> 
> Even your check is about looking if the trip value is within a range,
> telling the caller if the trip is valid or not, right?

Yes. Correct. it justifies function rename to of_thermal_is_trip_valid()

> 
> > +		return false;
> > +
> > +	return true;
> > +}
> > +
> 
> Missing:
> EXPORT_SYMBOL_GPL(of_thermal_is_trip_en);
> 
> or
> 
> EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid);

I will add that, no problem.

> 
> >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > int trip, enum thermal_trend *trend)
> >  {
> > diff --git a/drivers/thermal/thermal_core.h
> > b/drivers/thermal/thermal_core.h index c3c7b82..466208c 100644
> > --- a/drivers/thermal/thermal_core.h
> > +++ b/drivers/thermal/thermal_core.h
> > @@ -90,6 +90,7 @@ static inline void
> > thermal_gov_user_space_unregister(void) {} int
> > of_parse_thermal_zones(void); void of_thermal_destroy_zones(void);
> >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > +bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
> >  #else
> >  static inline int of_parse_thermal_zones(void) { return 0; }
> >  static inline void of_thermal_destroy_zones(void) { }
> > @@ -97,6 +98,10 @@ static inline int of_thermal_get_ntrips(struct
> > thermal_zone_device *) {
> >  	return 0;
> >  }
> > +static inline bool of_thermal_is_trip_en(struct
> > thermal_zone_device *, int)
> 
> Same as in patch 01, this produces compilation error. Please, name
> your parameters.

Ok.

> 
> > +{
> > +	return 0;
> > +}
> >  #endif
> >  
> >  #endif /* __THERMAL_CORE_H__ */
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points
  2014-11-25 20:36     ` Eduardo Valentin
@ 2014-11-26  8:35       ` Lukasz Majewski
  2014-11-26 15:18         ` Eduardo Valentin
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-26  8:35 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang

Hi Eduardo,

> Hello Lukasz,
> 
> On Thu, Nov 20, 2014 at 05:21:27PM +0100, Lukasz Majewski wrote:
> > This patch extends the of-thermal.c to export copy of trip points
> > for a given thermal zone.
> > 
> > Thermal drivers should use of_thermal_get_trip_points() method to
> > get pointer to table of thermal trip points.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - New patch - as suggested by Eduardo Valentin
> > ---
> >  drivers/thermal/of-thermal.c   | 33
> > +++++++++++++++++++++++++++++++++ drivers/thermal/thermal_core.h |
> > 7 +++++++ include/linux/thermal.h        | 14 ++++++++++++++
> >  3 files changed, 54 insertions(+)
> > 
> > diff --git a/drivers/thermal/of-thermal.c
> > b/drivers/thermal/of-thermal.c index 336af7f..33921c5 100644
> > --- a/drivers/thermal/of-thermal.c
> > +++ b/drivers/thermal/of-thermal.c
> > @@ -89,6 +89,7 @@ struct __thermal_zone {
> >  	/* trip data */
> >  	int ntrips;
> >  	struct __thermal_trip *trips;
> > +	struct thermal_trip *gtrips;
> >  
> >  	/* cooling binding data */
> >  	int num_tbps;
> > @@ -152,6 +153,27 @@ bool of_thermal_is_trip_en(struct
> > thermal_zone_device *tz, int trip) return true;
> >  }
> >  
> > +/**
> > + * of_thermal_get_trip_points - function to get access to a
> > globally exported
> > + *				trip points
> > + *
> > + * @tz:	pointer to a thermal zone
> > + *
> > + * This function provides a pointer to the copy of trip points
> > table
> > + *
> > + * Return: pointer to trip points table, NULL otherwise
> > + */
> > +const struct thermal_trip * const
> > +of_thermal_get_trip_points(struct thermal_zone_device *tz)
> > +{
> > +	struct __thermal_zone *data = tz->devdata;
> > +
> > +	if (!data)
> > +		return NULL;
> > +
> > +	return data->gtrips;
> > +}
> > +
> 
> EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);

Ok.

> 
> >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > int trip, enum thermal_trend *trend)
> >  {
> > @@ -767,6 +789,16 @@ thermal_of_build_thermal_zone(struct
> > device_node *np) goto free_tbps;
> >  	}
> >  
> > +	tz->gtrips = kcalloc(tz->ntrips, sizeof(*tz->gtrips),
> > GFP_KERNEL);
> > +	if (!tz->gtrips) {
> > +		ret = -ENOMEM;
> > +		goto free_tbps;
> > +	}
> > +
> > +	for (i = 0; i < tz->ntrips; i++)
> > +		memcpy(&(tz->gtrips[i]),
> > &(tz->trips[i].temperature),
> > +		       sizeof(*tz->gtrips));
> > +
> >  finish:
> >  	of_node_put(child);
> >  	tz->mode = THERMAL_DEVICE_DISABLED;
> > @@ -793,6 +825,7 @@ static inline void of_thermal_free_zone(struct
> > __thermal_zone *tz) {
> >  	int i;
> >  
> > +	kfree(tz->gtrips);
> >  	for (i = 0; i < tz->num_tbps; i++)
> >  		of_node_put(tz->tbps[i].cooling_device);
> >  	kfree(tz->tbps);
> > diff --git a/drivers/thermal/thermal_core.h
> > b/drivers/thermal/thermal_core.h index 466208c..a9580ca 100644
> > --- a/drivers/thermal/thermal_core.h
> > +++ b/drivers/thermal/thermal_core.h
> > @@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
> >  void of_thermal_destroy_zones(void);
> >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> >  bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > +const struct thermal_trip * const
> > +of_thermal_get_trip_points(struct thermal_zone_device *);
> >  #else
> >  static inline int of_parse_thermal_zones(void) { return 0; }
> >  static inline void of_thermal_destroy_zones(void) { }
> > @@ -102,6 +104,11 @@ static inline bool
> > of_thermal_is_trip_en(struct thermal_zone_device *, int) {
> 
> This produces compilation error when CONFIG_THERMAL_OF is not set.
> Name the parameters to fix.

As all the other cases, I will fix that.

> 
> >  	return 0;
> >  }
> > +static inline const struct thermal_trip * const
> > +of_thermal_get_trip_points(struct thermal_zone_device *)
> > +{
> > +	return NULL;
> > +}
> >  #endif
> >  
> >  #endif /* __THERMAL_CORE_H__ */
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index 5bc28a7..88d7249 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -303,6 +303,20 @@ struct thermal_zone_of_device_ops {
> >  	int (*get_trend)(void *, long *);
> >  };
> >  
> > +/**
> > + * struct thermal_trip - Structure representing themal trip points
> > exported from
> > + *                       of-thermal
> > + *
> 
> The only problem I have with this name is that would look like it is
> in use in all thermal framework, which is not really the case. But I
> do think having a type here is a good thing. So, not sure :-)

It can stay to be struct thermal_trip or we can rename it to
struct of_thermal_trip.

I'm fine with both names.

> 
> > + * @temperature:	trip point temperature
> > + * @hysteresis:		trip point hysteresis
> > + * @type:		trip point type
> > + */
> > +struct thermal_trip {
> > +	unsigned long int temperature;
> > +	unsigned long int hysteresis;
> > +	enum thermal_trip_type type;
> > +};
> > +
> >  /* Function declarations */
> >  #ifdef CONFIG_THERMAL_OF
> >  struct thermal_zone_device *
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points
  2014-11-25 20:38     ` Eduardo Valentin
@ 2014-11-26  8:39       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-26  8:39 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang

Hi Eduardo,

> On Thu, Nov 20, 2014 at 05:21:27PM +0100, Lukasz Majewski wrote:
> > This patch extends the of-thermal.c to export copy of trip points
> > for a given thermal zone.
> > 
> > Thermal drivers should use of_thermal_get_trip_points() method to
> > get pointer to table of thermal trip points.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - New patch - as suggested by Eduardo Valentin
> > ---
> >  drivers/thermal/of-thermal.c   | 33
> > +++++++++++++++++++++++++++++++++ drivers/thermal/thermal_core.h |
> > 7 +++++++ include/linux/thermal.h        | 14 ++++++++++++++
> >  3 files changed, 54 insertions(+)
> > 
> > diff --git a/drivers/thermal/of-thermal.c
> > b/drivers/thermal/of-thermal.c index 336af7f..33921c5 100644
> > --- a/drivers/thermal/of-thermal.c
> > +++ b/drivers/thermal/of-thermal.c
> > @@ -89,6 +89,7 @@ struct __thermal_zone {
> >  	/* trip data */
> >  	int ntrips;
> >  	struct __thermal_trip *trips;
> > +	struct thermal_trip *gtrips;
> >  
> >  	/* cooling binding data */
> >  	int num_tbps;
> > @@ -152,6 +153,27 @@ bool of_thermal_is_trip_en(struct
> > thermal_zone_device *tz, int trip) return true;
> >  }
> >  
> > +/**
> > + * of_thermal_get_trip_points - function to get access to a
> > globally exported
> > + *				trip points
> > + *
> > + * @tz:	pointer to a thermal zone
> > + *
> > + * This function provides a pointer to the copy of trip points
> > table
> > + *
> > + * Return: pointer to trip points table, NULL otherwise
> > + */
> > +const struct thermal_trip * const
> > +of_thermal_get_trip_points(struct thermal_zone_device *tz)
> 
> Another thing, can you please check why scripts/kernel-doc does not
> like this prototype? It throws an warn:
> Warning(drivers/thermal/of-thermal.c:168): cannot understand function
> prototype: 'const struct thermal_trip * const
> of_thermal_get_trip_points(struct thermal_zone_device *tz) '
> 

I will check that. However the warning looks a bit strange.

> 
> > +{
> > +	struct __thermal_zone *data = tz->devdata;
> > +
> > +	if (!data)
> > +		return NULL;
> > +
> > +	return data->gtrips;
> > +}
> > +
> >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > int trip, enum thermal_trend *trend)
> >  {
> > @@ -767,6 +789,16 @@ thermal_of_build_thermal_zone(struct
> > device_node *np) goto free_tbps;
> >  	}
> >  
> > +	tz->gtrips = kcalloc(tz->ntrips, sizeof(*tz->gtrips),
> > GFP_KERNEL);
> > +	if (!tz->gtrips) {
> > +		ret = -ENOMEM;
> > +		goto free_tbps;
> > +	}
> > +
> > +	for (i = 0; i < tz->ntrips; i++)
> > +		memcpy(&(tz->gtrips[i]),
> > &(tz->trips[i].temperature),
> > +		       sizeof(*tz->gtrips));
> > +
> >  finish:
> >  	of_node_put(child);
> >  	tz->mode = THERMAL_DEVICE_DISABLED;
> > @@ -793,6 +825,7 @@ static inline void of_thermal_free_zone(struct
> > __thermal_zone *tz) {
> >  	int i;
> >  
> > +	kfree(tz->gtrips);
> >  	for (i = 0; i < tz->num_tbps; i++)
> >  		of_node_put(tz->tbps[i].cooling_device);
> >  	kfree(tz->tbps);
> > diff --git a/drivers/thermal/thermal_core.h
> > b/drivers/thermal/thermal_core.h index 466208c..a9580ca 100644
> > --- a/drivers/thermal/thermal_core.h
> > +++ b/drivers/thermal/thermal_core.h
> > @@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
> >  void of_thermal_destroy_zones(void);
> >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> >  bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > +const struct thermal_trip * const
> > +of_thermal_get_trip_points(struct thermal_zone_device *);
> >  #else
> >  static inline int of_parse_thermal_zones(void) { return 0; }
> >  static inline void of_thermal_destroy_zones(void) { }
> > @@ -102,6 +104,11 @@ static inline bool
> > of_thermal_is_trip_en(struct thermal_zone_device *, int) {
> >  	return 0;
> >  }
> > +static inline const struct thermal_trip * const
> > +of_thermal_get_trip_points(struct thermal_zone_device *)
> > +{
> > +	return NULL;
> > +}
> >  #endif
> >  
> >  #endif /* __THERMAL_CORE_H__ */
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index 5bc28a7..88d7249 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -303,6 +303,20 @@ struct thermal_zone_of_device_ops {
> >  	int (*get_trend)(void *, long *);
> >  };
> >  
> > +/**
> > + * struct thermal_trip - Structure representing themal trip points
> > exported from
> > + *                       of-thermal
> > + *
> > + * @temperature:	trip point temperature
> > + * @hysteresis:		trip point hysteresis
> > + * @type:		trip point type
> > + */
> > +struct thermal_trip {
> > +	unsigned long int temperature;
> > +	unsigned long int hysteresis;
> > +	enum thermal_trip_type type;
> > +};
> > +
> >  /* Function declarations */
> >  #ifdef CONFIG_THERMAL_OF
> >  struct thermal_zone_device *
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 4/4] thermal: of: Extend current of-thermal.c code to allow setting emulated temp
  2014-11-25 20:44     ` Eduardo Valentin
@ 2014-11-26  8:47       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-26  8:47 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang

Hi Eduardo,

> On Thu, Nov 20, 2014 at 05:21:28PM +0100, Lukasz Majewski wrote:
> > Before this change it was only possible to set get_temp() and
> > get_trend() methods to be used in the common code handling passing
> > parameters via device tree to "cpu-thermal" CPU thermal zone device.
> > 
> > Now it is possible to also set emulated value of temperature for
> > debug purposes.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Rework the emulated temperature setting code to use
> > of_thermal_sensor_ops structure
> > ---
> >  drivers/thermal/of-thermal.c | 24 ++++++++++++++++++++++++
> >  include/linux/thermal.h      |  1 +
> >  2 files changed, 25 insertions(+)
> > 
> > diff --git a/drivers/thermal/of-thermal.c
> > b/drivers/thermal/of-thermal.c index 33921c5..ad7dc2b 100644
> > --- a/drivers/thermal/of-thermal.c
> > +++ b/drivers/thermal/of-thermal.c
> > @@ -174,6 +174,28 @@ of_thermal_get_trip_points(struct
> > thermal_zone_device *tz) return data->gtrips;
> >  }
> >  
> > +/**
> > + * of_thermal_set_emul_temp - function to set emulated temperature
> > + *
> > + * @tz:	pointer to a thermal zone
> > + * @temp:	temperature to set
> > + *
> > + * This function gives the ability to set emulated value of
> > temperature,
> > + * which is handy for debugging
> > + *
> > + * Return: zero on success, error code otherwise
> > + */
> > +static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
> > +				    unsigned long temp)
> > +{
> > +	struct __thermal_zone *data = tz->devdata;
> > +
> > +	if (!data->ops || !data->ops->set_emul_temp)
> > +		return -EINVAL;
> > +
> > +	return data->ops->set_emul_temp(data->sensor_data, temp);
> > +}
> > +
> >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > int trip, enum thermal_trend *trend)
> >  {
> > @@ -405,6 +427,7 @@ thermal_zone_of_add_sensor(struct device_node
> > *zone, 
> >  	tzd->ops->get_temp = of_thermal_get_temp;
> >  	tzd->ops->get_trend = of_thermal_get_trend;
> > +	tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
> >  	mutex_unlock(&tzd->lock);
> >  
> >  	return tzd;
> > @@ -533,6 +556,7 @@ void thermal_zone_of_sensor_unregister(struct
> > device *dev, mutex_lock(&tzd->lock);
> >  	tzd->ops->get_temp = NULL;
> >  	tzd->ops->get_trend = NULL;
> > +	tzd->ops->set_emul_temp = NULL;
> >  
> >  	tz->ops = NULL;
> >  	tz->sensor_data = NULL;
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index 88d7249..5eb9d44 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -301,6 +301,7 @@ struct thermal_genl_event {
> >  struct thermal_zone_of_device_ops {
> >  	int (*get_temp)(void *, long *);
> >  	int (*get_trend)(void *, long *);
> > +	int (*set_emul_temp)(void *, unsigned long);
> 
> Please add it in the list of Optional functions in the comment above
> this struct.

I will add proper comment to struct thermal_zone_of_device_ops comment.

> 
> Apart from that:
> 
> 
> Acked-by: Eduardo Valentin <edubezval@gmail.com>
> 
> 
> >  };
> >  
> >  /**
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points
  2014-11-26  8:35       ` Lukasz Majewski
@ 2014-11-26 15:18         ` Eduardo Valentin
  2014-11-26 20:43             ` navneet kumar
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-26 15:18 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang

[-- Attachment #1: Type: text/plain, Size: 5779 bytes --]

Hello,

On Wed, Nov 26, 2014 at 09:35:10AM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > Hello Lukasz,
> > 
> > On Thu, Nov 20, 2014 at 05:21:27PM +0100, Lukasz Majewski wrote:
> > > This patch extends the of-thermal.c to export copy of trip points
> > > for a given thermal zone.
> > > 
> > > Thermal drivers should use of_thermal_get_trip_points() method to
> > > get pointer to table of thermal trip points.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > > Changes for v2:
> > > - New patch - as suggested by Eduardo Valentin
> > > ---
> > >  drivers/thermal/of-thermal.c   | 33
> > > +++++++++++++++++++++++++++++++++ drivers/thermal/thermal_core.h |
> > > 7 +++++++ include/linux/thermal.h        | 14 ++++++++++++++
> > >  3 files changed, 54 insertions(+)
> > > 
> > > diff --git a/drivers/thermal/of-thermal.c
> > > b/drivers/thermal/of-thermal.c index 336af7f..33921c5 100644
> > > --- a/drivers/thermal/of-thermal.c
> > > +++ b/drivers/thermal/of-thermal.c
> > > @@ -89,6 +89,7 @@ struct __thermal_zone {
> > >  	/* trip data */
> > >  	int ntrips;
> > >  	struct __thermal_trip *trips;
> > > +	struct thermal_trip *gtrips;
> > >  
> > >  	/* cooling binding data */
> > >  	int num_tbps;
> > > @@ -152,6 +153,27 @@ bool of_thermal_is_trip_en(struct
> > > thermal_zone_device *tz, int trip) return true;
> > >  }
> > >  
> > > +/**
> > > + * of_thermal_get_trip_points - function to get access to a
> > > globally exported
> > > + *				trip points
> > > + *
> > > + * @tz:	pointer to a thermal zone
> > > + *
> > > + * This function provides a pointer to the copy of trip points
> > > table
> > > + *
> > > + * Return: pointer to trip points table, NULL otherwise
> > > + */
> > > +const struct thermal_trip * const
> > > +of_thermal_get_trip_points(struct thermal_zone_device *tz)
> > > +{
> > > +	struct __thermal_zone *data = tz->devdata;
> > > +
> > > +	if (!data)
> > > +		return NULL;
> > > +
> > > +	return data->gtrips;
> > > +}
> > > +
> > 
> > EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);
> 
> Ok.
> 
> > 
> > >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > > int trip, enum thermal_trend *trend)
> > >  {
> > > @@ -767,6 +789,16 @@ thermal_of_build_thermal_zone(struct
> > > device_node *np) goto free_tbps;
> > >  	}
> > >  
> > > +	tz->gtrips = kcalloc(tz->ntrips, sizeof(*tz->gtrips),
> > > GFP_KERNEL);
> > > +	if (!tz->gtrips) {
> > > +		ret = -ENOMEM;
> > > +		goto free_tbps;
> > > +	}
> > > +
> > > +	for (i = 0; i < tz->ntrips; i++)
> > > +		memcpy(&(tz->gtrips[i]),
> > > &(tz->trips[i].temperature),
> > > +		       sizeof(*tz->gtrips));
> > > +
> > >  finish:
> > >  	of_node_put(child);
> > >  	tz->mode = THERMAL_DEVICE_DISABLED;
> > > @@ -793,6 +825,7 @@ static inline void of_thermal_free_zone(struct
> > > __thermal_zone *tz) {
> > >  	int i;
> > >  
> > > +	kfree(tz->gtrips);
> > >  	for (i = 0; i < tz->num_tbps; i++)
> > >  		of_node_put(tz->tbps[i].cooling_device);
> > >  	kfree(tz->tbps);
> > > diff --git a/drivers/thermal/thermal_core.h
> > > b/drivers/thermal/thermal_core.h index 466208c..a9580ca 100644
> > > --- a/drivers/thermal/thermal_core.h
> > > +++ b/drivers/thermal/thermal_core.h
> > > @@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
> > >  void of_thermal_destroy_zones(void);
> > >  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > >  bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > > +const struct thermal_trip * const
> > > +of_thermal_get_trip_points(struct thermal_zone_device *);
> > >  #else
> > >  static inline int of_parse_thermal_zones(void) { return 0; }
> > >  static inline void of_thermal_destroy_zones(void) { }
> > > @@ -102,6 +104,11 @@ static inline bool
> > > of_thermal_is_trip_en(struct thermal_zone_device *, int) {
> > 
> > This produces compilation error when CONFIG_THERMAL_OF is not set.
> > Name the parameters to fix.
> 
> As all the other cases, I will fix that.
> 
> > 
> > >  	return 0;
> > >  }
> > > +static inline const struct thermal_trip * const
> > > +of_thermal_get_trip_points(struct thermal_zone_device *)
> > > +{
> > > +	return NULL;
> > > +}
> > >  #endif
> > >  
> > >  #endif /* __THERMAL_CORE_H__ */
> > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > index 5bc28a7..88d7249 100644
> > > --- a/include/linux/thermal.h
> > > +++ b/include/linux/thermal.h
> > > @@ -303,6 +303,20 @@ struct thermal_zone_of_device_ops {
> > >  	int (*get_trend)(void *, long *);
> > >  };
> > >  
> > > +/**
> > > + * struct thermal_trip - Structure representing themal trip points
> > > exported from
> > > + *                       of-thermal
> > > + *
> > 
> > The only problem I have with this name is that would look like it is
> > in use in all thermal framework, which is not really the case. But I
> > do think having a type here is a good thing. So, not sure :-)
> 
> It can stay to be struct thermal_trip or we can rename it to
> struct of_thermal_trip.
> 
> I'm fine with both names.

Leave it as 'thermal_trip'.

> 
> > 
> > > + * @temperature:	trip point temperature
> > > + * @hysteresis:		trip point hysteresis
> > > + * @type:		trip point type
> > > + */
> > > +struct thermal_trip {
> > > +	unsigned long int temperature;
> > > +	unsigned long int hysteresis;
> > > +	enum thermal_trip_type type;
> > > +};
> > > +
> > >  /* Function declarations */
> > >  #ifdef CONFIG_THERMAL_OF
> > >  struct thermal_zone_device *
> > > -- 
> > > 2.0.0.rc2
> > > 
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points
  2014-11-26 15:18         ` Eduardo Valentin
@ 2014-11-26 20:43             ` navneet kumar
  0 siblings, 0 replies; 288+ messages in thread
From: navneet kumar @ 2014-11-26 20:43 UTC (permalink / raw)
  To: Eduardo Valentin, Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang


Hi Eduardo, Lukasz,

[Combining my concerns as a single text blob here]

I. Firstly, with the current patch
	1. is it really needed to duplicate the struct thermal_trip? Why don’t
	we get rid of the __thermal_trip and stay with the 'thermal_trip' ? it
	is not a big change.

	2. gtrips is not updated on "set_trip_temp" etc. actions via sysfs. (am
	I missing something?).

II. The other concern is more of a design question
	1. Do we intend to keep the of-thermal as a middle layer between the
	thermal_core and the sensor device? OR, is the role of of-thermal just
	to parse the DT and opt out ? currently of-thermal is somewhat a hybrid
	of these as, in addition to parsing the dt, it holds on to the data
	related to trip points etc. etc.

	2. assuming latter is true (OF is just a dt parser helper): we should
	not be adding more intelligence and dependencies linked to the OF.

	3. assuming former is true (OF is a well-defined middle layer): All is
	good till the point OF maintains the trip points (which is a good thing
	since, OF caches on to the data); BUT, if we expose this information to
	the sensor device too (as this patch is doing),

		3a. we violate the layering principle :-)

		3b. more importantly, this is all just excessive logic that we
		put in which *could be useful* only if we intend to extend the
		role of OF as a trip point management layer that does more than
		just holding on to the data. This may include -

			-> The sensor devices to know nothing about the
			trip_points, instead the sensor devices would work on
			"temperature thresholds" and OF would map sensor
			thresholds to the actual trip points as needed
			(configured from DT); while the sensor devices stick to
			using "thresholds".

			-> Queuing from above, sensors, most of the time, only
			need to know a high and a low temp threshold; which
			essentially is a subset of the active/passive etc. trip
			points. Calculation of that based on the current temp,
			as of today is replicated across all the sensor drivers
			and can be hoisted up to the of-thermal.

Seems like this is the opportune time to make a call about the role of of-thermal?

On 11/26/2014 07:18 AM, Eduardo Valentin wrote:
> * PGP Signed by an unknown key
> 
> Hello,
> 
> On Wed, Nov 26, 2014 at 09:35:10AM +0100, Lukasz Majewski wrote:
>> Hi Eduardo,
>>
>>> Hello Lukasz,
>>>
>>> On Thu, Nov 20, 2014 at 05:21:27PM +0100, Lukasz Majewski wrote:
>>>> This patch extends the of-thermal.c to export copy of trip points
>>>> for a given thermal zone.
>>>>
>>>> Thermal drivers should use of_thermal_get_trip_points() method to
>>>> get pointer to table of thermal trip points.
>>>>
>>>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>>>> ---
>>>> Changes for v2:
>>>> - New patch - as suggested by Eduardo Valentin
>>>> ---
>>>>  drivers/thermal/of-thermal.c   | 33
>>>> +++++++++++++++++++++++++++++++++ drivers/thermal/thermal_core.h |
>>>> 7 +++++++ include/linux/thermal.h        | 14 ++++++++++++++
>>>>  3 files changed, 54 insertions(+)
>>>>
>>>> diff --git a/drivers/thermal/of-thermal.c
>>>> b/drivers/thermal/of-thermal.c index 336af7f..33921c5 100644
>>>> --- a/drivers/thermal/of-thermal.c
>>>> +++ b/drivers/thermal/of-thermal.c
>>>> @@ -89,6 +89,7 @@ struct __thermal_zone {
>>>>  	/* trip data */
>>>>  	int ntrips;
>>>>  	struct __thermal_trip *trips;
>>>> +	struct thermal_trip *gtrips;
Do we really need this duplication ?
>>>>  
>>>>  	/* cooling binding data */
>>>>  	int num_tbps;
>>>> @@ -152,6 +153,27 @@ bool of_thermal_is_trip_en(struct
>>>> thermal_zone_device *tz, int trip) return true;
>>>>  }
>>>>  
>>>> +/**
>>>> + * of_thermal_get_trip_points - function to get access to a
>>>> globally exported
>>>> + *				trip points
>>>> + *
>>>> + * @tz:	pointer to a thermal zone
>>>> + *
>>>> + * This function provides a pointer to the copy of trip points
>>>> table
>>>> + *
>>>> + * Return: pointer to trip points table, NULL otherwise
>>>> + */
>>>> +const struct thermal_trip * const
>>>> +of_thermal_get_trip_points(struct thermal_zone_device *tz)
>>>> +{
>>>> +	struct __thermal_zone *data = tz->devdata;
>>>> +
>>>> +	if (!data)
>>>> +		return NULL;
>>>> +
>>>> +	return data->gtrips;
>>>> +}
>>>> +
>>>
>>> EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);
>>
>> Ok.
>>
>>>
>>>>  static int of_thermal_get_trend(struct thermal_zone_device *tz,
>>>> int trip, enum thermal_trend *trend)
>>>>  {
>>>> @@ -767,6 +789,16 @@ thermal_of_build_thermal_zone(struct
>>>> device_node *np) goto free_tbps;
>>>>  	}
>>>>  
>>>> +	tz->gtrips = kcalloc(tz->ntrips, sizeof(*tz->gtrips),
>>>> GFP_KERNEL);
>>>> +	if (!tz->gtrips) {
>>>> +		ret = -ENOMEM;
>>>> +		goto free_tbps;
>>>> +	}
>>>> +
>>>> +	for (i = 0; i < tz->ntrips; i++)
>>>> +		memcpy(&(tz->gtrips[i]),
>>>> &(tz->trips[i].temperature),
>>>> +		       sizeof(*tz->gtrips));
>>>> +
>>>>  finish:
>>>>  	of_node_put(child);
>>>>  	tz->mode = THERMAL_DEVICE_DISABLED;
>>>> @@ -793,6 +825,7 @@ static inline void of_thermal_free_zone(struct
>>>> __thermal_zone *tz) {
>>>>  	int i;
>>>>  
>>>> +	kfree(tz->gtrips);
>>>>  	for (i = 0; i < tz->num_tbps; i++)
>>>>  		of_node_put(tz->tbps[i].cooling_device);
>>>>  	kfree(tz->tbps);
Couldn't find the code that updates *gtrips as a result of set_trip_temp via
sysfs.

>>>> diff --git a/drivers/thermal/thermal_core.h
>>>> b/drivers/thermal/thermal_core.h index 466208c..a9580ca 100644
>>>> --- a/drivers/thermal/thermal_core.h
>>>> +++ b/drivers/thermal/thermal_core.h
>>>> @@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
>>>>  void of_thermal_destroy_zones(void);
>>>>  int of_thermal_get_ntrips(struct thermal_zone_device *);
>>>>  bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
>>>> +const struct thermal_trip * const
>>>> +of_thermal_get_trip_points(struct thermal_zone_device *);
>>>>  #else
>>>>  static inline int of_parse_thermal_zones(void) { return 0; }
>>>>  static inline void of_thermal_destroy_zones(void) { }
>>>> @@ -102,6 +104,11 @@ static inline bool
>>>> of_thermal_is_trip_en(struct thermal_zone_device *, int) {
>>>
>>> This produces compilation error when CONFIG_THERMAL_OF is not set.
>>> Name the parameters to fix.
>>
>> As all the other cases, I will fix that.
>>
>>>
>>>>  	return 0;
>>>>  }
>>>> +static inline const struct thermal_trip * const
>>>> +of_thermal_get_trip_points(struct thermal_zone_device *)
>>>> +{
>>>> +	return NULL;
>>>> +}
>>>>  #endif
>>>>  
>>>>  #endif /* __THERMAL_CORE_H__ */
>>>> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
>>>> index 5bc28a7..88d7249 100644
>>>> --- a/include/linux/thermal.h
>>>> +++ b/include/linux/thermal.h
>>>> @@ -303,6 +303,20 @@ struct thermal_zone_of_device_ops {
>>>>  	int (*get_trend)(void *, long *);
>>>>  };
>>>>  
>>>> +/**
>>>> + * struct thermal_trip - Structure representing themal trip points
>>>> exported from
>>>> + *                       of-thermal
>>>> + *
>>>
>>> The only problem I have with this name is that would look like it is
>>> in use in all thermal framework, which is not really the case. But I
>>> do think having a type here is a good thing. So, not sure :-)
>>
>> It can stay to be struct thermal_trip or we can rename it to
>> struct of_thermal_trip.
>>
>> I'm fine with both names.
> 
> Leave it as 'thermal_trip'.
> 
>>
>>>
>>>> + * @temperature:	trip point temperature
>>>> + * @hysteresis:		trip point hysteresis
>>>> + * @type:		trip point type
>>>> + */
>>>> +struct thermal_trip {
>>>> +	unsigned long int temperature;
>>>> +	unsigned long int hysteresis;
>>>> +	enum thermal_trip_type type;
>>>> +};
>>>> +
>>>>  /* Function declarations */
>>>>  #ifdef CONFIG_THERMAL_OF
>>>>  struct thermal_zone_device *
>>>> -- 
>>>> 2.0.0.rc2
>>>>
>>
>>
>>
>> -- 
>> Best regards,
>>
>> Lukasz Majewski
>>
>> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
> 
> * Unknown Key
> * 0x7DA4E256
> 

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points
@ 2014-11-26 20:43             ` navneet kumar
  0 siblings, 0 replies; 288+ messages in thread
From: navneet kumar @ 2014-11-26 20:43 UTC (permalink / raw)
  To: Eduardo Valentin, Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang


Hi Eduardo, Lukasz,

[Combining my concerns as a single text blob here]

I. Firstly, with the current patch
	1. is it really needed to duplicate the struct thermal_trip? Why don’t
	we get rid of the __thermal_trip and stay with the 'thermal_trip' ? it
	is not a big change.

	2. gtrips is not updated on "set_trip_temp" etc. actions via sysfs. (am
	I missing something?).

II. The other concern is more of a design question
	1. Do we intend to keep the of-thermal as a middle layer between the
	thermal_core and the sensor device? OR, is the role of of-thermal just
	to parse the DT and opt out ? currently of-thermal is somewhat a hybrid
	of these as, in addition to parsing the dt, it holds on to the data
	related to trip points etc. etc.

	2. assuming latter is true (OF is just a dt parser helper): we should
	not be adding more intelligence and dependencies linked to the OF.

	3. assuming former is true (OF is a well-defined middle layer): All is
	good till the point OF maintains the trip points (which is a good thing
	since, OF caches on to the data); BUT, if we expose this information to
	the sensor device too (as this patch is doing),

		3a. we violate the layering principle :-)

		3b. more importantly, this is all just excessive logic that we
		put in which *could be useful* only if we intend to extend the
		role of OF as a trip point management layer that does more than
		just holding on to the data. This may include -

			-> The sensor devices to know nothing about the
			trip_points, instead the sensor devices would work on
			"temperature thresholds" and OF would map sensor
			thresholds to the actual trip points as needed
			(configured from DT); while the sensor devices stick to
			using "thresholds".

			-> Queuing from above, sensors, most of the time, only
			need to know a high and a low temp threshold; which
			essentially is a subset of the active/passive etc. trip
			points. Calculation of that based on the current temp,
			as of today is replicated across all the sensor drivers
			and can be hoisted up to the of-thermal.

Seems like this is the opportune time to make a call about the role of of-thermal?

On 11/26/2014 07:18 AM, Eduardo Valentin wrote:
> * PGP Signed by an unknown key
> 
> Hello,
> 
> On Wed, Nov 26, 2014 at 09:35:10AM +0100, Lukasz Majewski wrote:
>> Hi Eduardo,
>>
>>> Hello Lukasz,
>>>
>>> On Thu, Nov 20, 2014 at 05:21:27PM +0100, Lukasz Majewski wrote:
>>>> This patch extends the of-thermal.c to export copy of trip points
>>>> for a given thermal zone.
>>>>
>>>> Thermal drivers should use of_thermal_get_trip_points() method to
>>>> get pointer to table of thermal trip points.
>>>>
>>>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>>>> ---
>>>> Changes for v2:
>>>> - New patch - as suggested by Eduardo Valentin
>>>> ---
>>>>  drivers/thermal/of-thermal.c   | 33
>>>> +++++++++++++++++++++++++++++++++ drivers/thermal/thermal_core.h |
>>>> 7 +++++++ include/linux/thermal.h        | 14 ++++++++++++++
>>>>  3 files changed, 54 insertions(+)
>>>>
>>>> diff --git a/drivers/thermal/of-thermal.c
>>>> b/drivers/thermal/of-thermal.c index 336af7f..33921c5 100644
>>>> --- a/drivers/thermal/of-thermal.c
>>>> +++ b/drivers/thermal/of-thermal.c
>>>> @@ -89,6 +89,7 @@ struct __thermal_zone {
>>>>  	/* trip data */
>>>>  	int ntrips;
>>>>  	struct __thermal_trip *trips;
>>>> +	struct thermal_trip *gtrips;
Do we really need this duplication ?
>>>>  
>>>>  	/* cooling binding data */
>>>>  	int num_tbps;
>>>> @@ -152,6 +153,27 @@ bool of_thermal_is_trip_en(struct
>>>> thermal_zone_device *tz, int trip) return true;
>>>>  }
>>>>  
>>>> +/**
>>>> + * of_thermal_get_trip_points - function to get access to a
>>>> globally exported
>>>> + *				trip points
>>>> + *
>>>> + * @tz:	pointer to a thermal zone
>>>> + *
>>>> + * This function provides a pointer to the copy of trip points
>>>> table
>>>> + *
>>>> + * Return: pointer to trip points table, NULL otherwise
>>>> + */
>>>> +const struct thermal_trip * const
>>>> +of_thermal_get_trip_points(struct thermal_zone_device *tz)
>>>> +{
>>>> +	struct __thermal_zone *data = tz->devdata;
>>>> +
>>>> +	if (!data)
>>>> +		return NULL;
>>>> +
>>>> +	return data->gtrips;
>>>> +}
>>>> +
>>>
>>> EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);
>>
>> Ok.
>>
>>>
>>>>  static int of_thermal_get_trend(struct thermal_zone_device *tz,
>>>> int trip, enum thermal_trend *trend)
>>>>  {
>>>> @@ -767,6 +789,16 @@ thermal_of_build_thermal_zone(struct
>>>> device_node *np) goto free_tbps;
>>>>  	}
>>>>  
>>>> +	tz->gtrips = kcalloc(tz->ntrips, sizeof(*tz->gtrips),
>>>> GFP_KERNEL);
>>>> +	if (!tz->gtrips) {
>>>> +		ret = -ENOMEM;
>>>> +		goto free_tbps;
>>>> +	}
>>>> +
>>>> +	for (i = 0; i < tz->ntrips; i++)
>>>> +		memcpy(&(tz->gtrips[i]),
>>>> &(tz->trips[i].temperature),
>>>> +		       sizeof(*tz->gtrips));
>>>> +
>>>>  finish:
>>>>  	of_node_put(child);
>>>>  	tz->mode = THERMAL_DEVICE_DISABLED;
>>>> @@ -793,6 +825,7 @@ static inline void of_thermal_free_zone(struct
>>>> __thermal_zone *tz) {
>>>>  	int i;
>>>>  
>>>> +	kfree(tz->gtrips);
>>>>  	for (i = 0; i < tz->num_tbps; i++)
>>>>  		of_node_put(tz->tbps[i].cooling_device);
>>>>  	kfree(tz->tbps);
Couldn't find the code that updates *gtrips as a result of set_trip_temp via
sysfs.

>>>> diff --git a/drivers/thermal/thermal_core.h
>>>> b/drivers/thermal/thermal_core.h index 466208c..a9580ca 100644
>>>> --- a/drivers/thermal/thermal_core.h
>>>> +++ b/drivers/thermal/thermal_core.h
>>>> @@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
>>>>  void of_thermal_destroy_zones(void);
>>>>  int of_thermal_get_ntrips(struct thermal_zone_device *);
>>>>  bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
>>>> +const struct thermal_trip * const
>>>> +of_thermal_get_trip_points(struct thermal_zone_device *);
>>>>  #else
>>>>  static inline int of_parse_thermal_zones(void) { return 0; }
>>>>  static inline void of_thermal_destroy_zones(void) { }
>>>> @@ -102,6 +104,11 @@ static inline bool
>>>> of_thermal_is_trip_en(struct thermal_zone_device *, int) {
>>>
>>> This produces compilation error when CONFIG_THERMAL_OF is not set.
>>> Name the parameters to fix.
>>
>> As all the other cases, I will fix that.
>>
>>>
>>>>  	return 0;
>>>>  }
>>>> +static inline const struct thermal_trip * const
>>>> +of_thermal_get_trip_points(struct thermal_zone_device *)
>>>> +{
>>>> +	return NULL;
>>>> +}
>>>>  #endif
>>>>  
>>>>  #endif /* __THERMAL_CORE_H__ */
>>>> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
>>>> index 5bc28a7..88d7249 100644
>>>> --- a/include/linux/thermal.h
>>>> +++ b/include/linux/thermal.h
>>>> @@ -303,6 +303,20 @@ struct thermal_zone_of_device_ops {
>>>>  	int (*get_trend)(void *, long *);
>>>>  };
>>>>  
>>>> +/**
>>>> + * struct thermal_trip - Structure representing themal trip points
>>>> exported from
>>>> + *                       of-thermal
>>>> + *
>>>
>>> The only problem I have with this name is that would look like it is
>>> in use in all thermal framework, which is not really the case. But I
>>> do think having a type here is a good thing. So, not sure :-)
>>
>> It can stay to be struct thermal_trip or we can rename it to
>> struct of_thermal_trip.
>>
>> I'm fine with both names.
> 
> Leave it as 'thermal_trip'.
> 
>>
>>>
>>>> + * @temperature:	trip point temperature
>>>> + * @hysteresis:		trip point hysteresis
>>>> + * @type:		trip point type
>>>> + */
>>>> +struct thermal_trip {
>>>> +	unsigned long int temperature;
>>>> +	unsigned long int hysteresis;
>>>> +	enum thermal_trip_type type;
>>>> +};
>>>> +
>>>>  /* Function declarations */
>>>>  #ifdef CONFIG_THERMAL_OF
>>>>  struct thermal_zone_device *
>>>> -- 
>>>> 2.0.0.rc2
>>>>
>>
>>
>>
>> -- 
>> Best regards,
>>
>> Lukasz Majewski
>>
>> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
> 
> * Unknown Key
> * 0x7DA4E256
> 

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points
  2014-11-26 20:43             ` navneet kumar
  (?)
@ 2014-11-26 21:12             ` Guenter Roeck
  2014-11-26 23:12                 ` navneet kumar
  -1 siblings, 1 reply; 288+ messages in thread
From: Guenter Roeck @ 2014-11-26 21:12 UTC (permalink / raw)
  To: navneet kumar, Eduardo Valentin, Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan, linux-kernel,
	Caesar Wang

On 11/26/2014 12:43 PM, navneet kumar wrote:
>
> Hi Eduardo, Lukasz,
>
> [Combining my concerns as a single text blob here]
>
> I. Firstly, with the current patch
> 	1. is it really needed to duplicate the struct thermal_trip? Why don’t
> 	we get rid of the __thermal_trip and stay with the 'thermal_trip' ? it
> 	is not a big change.
>
> 	2. gtrips is not updated on "set_trip_temp" etc. actions via sysfs. (am
> 	I missing something?).
>
> II. The other concern is more of a design question
> 	1. Do we intend to keep the of-thermal as a middle layer between the
> 	thermal_core and the sensor device? OR, is the role of of-thermal just
> 	to parse the DT and opt out ? currently of-thermal is somewhat a hybrid
> 	of these as, in addition to parsing the dt, it holds on to the data
> 	related to trip points etc. etc.
>
> 	2. assuming latter is true (OF is just a dt parser helper): we should
> 	not be adding more intelligence and dependencies linked to the OF.
>
> 	3. assuming former is true (OF is a well-defined middle layer): All is
> 	good till the point OF maintains the trip points (which is a good thing
> 	since, OF caches on to the data); BUT, if we expose this information to
> 	the sensor device too (as this patch is doing),
>
> 		3a. we violate the layering principle :-)
>
> 		3b. more importantly, this is all just excessive logic that we
> 		put in which *could be useful* only if we intend to extend the
> 		role of OF as a trip point management layer that does more than
> 		just holding on to the data. This may include -
>
> 			-> The sensor devices to know nothing about the
> 			trip_points, instead the sensor devices would work on
> 			"temperature thresholds" and OF would map sensor
> 			thresholds to the actual trip points as needed
> 			(configured from DT); while the sensor devices stick to
> 			using "thresholds".
>
> 			-> Queuing from above, sensors, most of the time, only
> 			need to know a high and a low temp threshold; which
> 			essentially is a subset of the active/passive etc. trip
> 			points. Calculation of that based on the current temp,
> 			as of today is replicated across all the sensor drivers
> 			and can be hoisted up to the of-thermal.
>

Sorry, lost you here. What replicated calculation do you refer to ?

Thanks,
Guenter

> Seems like this is the opportune time to make a call about the role of of-thermal?
>
> On 11/26/2014 07:18 AM, Eduardo Valentin wrote:
>> * PGP Signed by an unknown key
>>
>> Hello,
>>
>> On Wed, Nov 26, 2014 at 09:35:10AM +0100, Lukasz Majewski wrote:
>>> Hi Eduardo,
>>>
>>>> Hello Lukasz,
>>>>
>>>> On Thu, Nov 20, 2014 at 05:21:27PM +0100, Lukasz Majewski wrote:
>>>>> This patch extends the of-thermal.c to export copy of trip points
>>>>> for a given thermal zone.
>>>>>
>>>>> Thermal drivers should use of_thermal_get_trip_points() method to
>>>>> get pointer to table of thermal trip points.
>>>>>
>>>>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>>>>> ---
>>>>> Changes for v2:
>>>>> - New patch - as suggested by Eduardo Valentin
>>>>> ---
>>>>>   drivers/thermal/of-thermal.c   | 33
>>>>> +++++++++++++++++++++++++++++++++ drivers/thermal/thermal_core.h |
>>>>> 7 +++++++ include/linux/thermal.h        | 14 ++++++++++++++
>>>>>   3 files changed, 54 insertions(+)
>>>>>
>>>>> diff --git a/drivers/thermal/of-thermal.c
>>>>> b/drivers/thermal/of-thermal.c index 336af7f..33921c5 100644
>>>>> --- a/drivers/thermal/of-thermal.c
>>>>> +++ b/drivers/thermal/of-thermal.c
>>>>> @@ -89,6 +89,7 @@ struct __thermal_zone {
>>>>>   	/* trip data */
>>>>>   	int ntrips;
>>>>>   	struct __thermal_trip *trips;
>>>>> +	struct thermal_trip *gtrips;
> Do we really need this duplication ?
>>>>>
>>>>>   	/* cooling binding data */
>>>>>   	int num_tbps;
>>>>> @@ -152,6 +153,27 @@ bool of_thermal_is_trip_en(struct
>>>>> thermal_zone_device *tz, int trip) return true;
>>>>>   }
>>>>>
>>>>> +/**
>>>>> + * of_thermal_get_trip_points - function to get access to a
>>>>> globally exported
>>>>> + *				trip points
>>>>> + *
>>>>> + * @tz:	pointer to a thermal zone
>>>>> + *
>>>>> + * This function provides a pointer to the copy of trip points
>>>>> table
>>>>> + *
>>>>> + * Return: pointer to trip points table, NULL otherwise
>>>>> + */
>>>>> +const struct thermal_trip * const
>>>>> +of_thermal_get_trip_points(struct thermal_zone_device *tz)
>>>>> +{
>>>>> +	struct __thermal_zone *data = tz->devdata;
>>>>> +
>>>>> +	if (!data)
>>>>> +		return NULL;
>>>>> +
>>>>> +	return data->gtrips;
>>>>> +}
>>>>> +
>>>>
>>>> EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);
>>>
>>> Ok.
>>>
>>>>
>>>>>   static int of_thermal_get_trend(struct thermal_zone_device *tz,
>>>>> int trip, enum thermal_trend *trend)
>>>>>   {
>>>>> @@ -767,6 +789,16 @@ thermal_of_build_thermal_zone(struct
>>>>> device_node *np) goto free_tbps;
>>>>>   	}
>>>>>
>>>>> +	tz->gtrips = kcalloc(tz->ntrips, sizeof(*tz->gtrips),
>>>>> GFP_KERNEL);
>>>>> +	if (!tz->gtrips) {
>>>>> +		ret = -ENOMEM;
>>>>> +		goto free_tbps;
>>>>> +	}
>>>>> +
>>>>> +	for (i = 0; i < tz->ntrips; i++)
>>>>> +		memcpy(&(tz->gtrips[i]),
>>>>> &(tz->trips[i].temperature),
>>>>> +		       sizeof(*tz->gtrips));
>>>>> +
>>>>>   finish:
>>>>>   	of_node_put(child);
>>>>>   	tz->mode = THERMAL_DEVICE_DISABLED;
>>>>> @@ -793,6 +825,7 @@ static inline void of_thermal_free_zone(struct
>>>>> __thermal_zone *tz) {
>>>>>   	int i;
>>>>>
>>>>> +	kfree(tz->gtrips);
>>>>>   	for (i = 0; i < tz->num_tbps; i++)
>>>>>   		of_node_put(tz->tbps[i].cooling_device);
>>>>>   	kfree(tz->tbps);
> Couldn't find the code that updates *gtrips as a result of set_trip_temp via
> sysfs.
>
>>>>> diff --git a/drivers/thermal/thermal_core.h
>>>>> b/drivers/thermal/thermal_core.h index 466208c..a9580ca 100644
>>>>> --- a/drivers/thermal/thermal_core.h
>>>>> +++ b/drivers/thermal/thermal_core.h
>>>>> @@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
>>>>>   void of_thermal_destroy_zones(void);
>>>>>   int of_thermal_get_ntrips(struct thermal_zone_device *);
>>>>>   bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
>>>>> +const struct thermal_trip * const
>>>>> +of_thermal_get_trip_points(struct thermal_zone_device *);
>>>>>   #else
>>>>>   static inline int of_parse_thermal_zones(void) { return 0; }
>>>>>   static inline void of_thermal_destroy_zones(void) { }
>>>>> @@ -102,6 +104,11 @@ static inline bool
>>>>> of_thermal_is_trip_en(struct thermal_zone_device *, int) {
>>>>
>>>> This produces compilation error when CONFIG_THERMAL_OF is not set.
>>>> Name the parameters to fix.
>>>
>>> As all the other cases, I will fix that.
>>>
>>>>
>>>>>   	return 0;
>>>>>   }
>>>>> +static inline const struct thermal_trip * const
>>>>> +of_thermal_get_trip_points(struct thermal_zone_device *)
>>>>> +{
>>>>> +	return NULL;
>>>>> +}
>>>>>   #endif
>>>>>
>>>>>   #endif /* __THERMAL_CORE_H__ */
>>>>> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
>>>>> index 5bc28a7..88d7249 100644
>>>>> --- a/include/linux/thermal.h
>>>>> +++ b/include/linux/thermal.h
>>>>> @@ -303,6 +303,20 @@ struct thermal_zone_of_device_ops {
>>>>>   	int (*get_trend)(void *, long *);
>>>>>   };
>>>>>
>>>>> +/**
>>>>> + * struct thermal_trip - Structure representing themal trip points
>>>>> exported from
>>>>> + *                       of-thermal
>>>>> + *
>>>>
>>>> The only problem I have with this name is that would look like it is
>>>> in use in all thermal framework, which is not really the case. But I
>>>> do think having a type here is a good thing. So, not sure :-)
>>>
>>> It can stay to be struct thermal_trip or we can rename it to
>>> struct of_thermal_trip.
>>>
>>> I'm fine with both names.
>>
>> Leave it as 'thermal_trip'.
>>
>>>
>>>>
>>>>> + * @temperature:	trip point temperature
>>>>> + * @hysteresis:		trip point hysteresis
>>>>> + * @type:		trip point type
>>>>> + */
>>>>> +struct thermal_trip {
>>>>> +	unsigned long int temperature;
>>>>> +	unsigned long int hysteresis;
>>>>> +	enum thermal_trip_type type;
>>>>> +};
>>>>> +
>>>>>   /* Function declarations */
>>>>>   #ifdef CONFIG_THERMAL_OF
>>>>>   struct thermal_zone_device *
>>>>> --
>>>>> 2.0.0.rc2
>>>>>
>>>
>>>
>>>
>>> --
>>> Best regards,
>>>
>>> Lukasz Majewski
>>>
>>> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
>>
>> * Unknown Key
>> * 0x7DA4E256
>>
>


^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points
  2014-11-26 20:43             ` navneet kumar
  (?)
  (?)
@ 2014-11-26 23:09             ` Eduardo Valentin
  2014-11-27  9:42                 ` Lukasz Majewski
  -1 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2014-11-26 23:09 UTC (permalink / raw)
  To: navneet kumar
  Cc: Lukasz Majewski, Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang

[-- Attachment #1: Type: text/plain, Size: 11604 bytes --]


Hello Navneet,

On Wed, Nov 26, 2014 at 12:43:18PM -0800, navneet kumar wrote:
> 
> Hi Eduardo, Lukasz,
> 
> [Combining my concerns as a single text blob here]
> 
> I. Firstly, with the current patch
> 	1. is it really needed to duplicate the struct thermal_trip? Why don’t
> 	we get rid of the __thermal_trip and stay with the 'thermal_trip' ? it
> 	is not a big change.
> 
> 	2. gtrips is not updated on "set_trip_temp" etc. actions via sysfs. (am
> 	I missing something?).
> 

Good! Comments are always welcome, that's how we make patches :-).

Both above make sense to me.

> II. The other concern is more of a design question
> 	1. Do we intend to keep the of-thermal as a middle layer between the
> 	thermal_core and the sensor device? OR, is the role of of-thermal just
> 	to parse the DT and opt out ? currently of-thermal is somewhat a hybrid
> 	of these as, in addition to parsing the dt, it holds on to the data
> 	related to trip points etc. etc.
> 

of-thermal has always been as your latter statement, and I intend to keep it as it should
be, just a of parser for thermal data.

> 	2. assuming latter is true (OF is just a dt parser helper): we should
> 	not be adding more intelligence and dependencies linked to the OF.
> 

Yes this is right. We should never be adding intelligence to it, except
for parsing the thermal data out of device tree and adding the proper
structures inside the kernel.

> 	3. assuming former is true (OF is a well-defined middle layer): All is
> 	good till the point OF maintains the trip points (which is a good thing
> 	since, OF caches on to the data); BUT, if we expose this information to
> 	the sensor device too (as this patch is doing),
> 

the former is not true.

> 		3a. we violate the layering principle :-)
> 

well, even if it was, I disagree here. :-) The split between data
coming from DT and the driver is still in place. Besides, there is other
layers that expose some of their data, and that doesn't violate their
layering principles. CPUfreq, for one closer example, exposes its freq table.

It would be different if by exposing this data, the users would be
affecting the behavior of the layer. And that is not the intention of
cpufreq table. In the same way, that is not the intention of this patch.

> 		3b. more importantly, this is all just excessive logic that we
> 		put in which *could be useful* only if we intend to extend the
> 		role of OF as a trip point management layer that does more than
> 		just holding on to the data. This may include -
> 
> 			-> The sensor devices to know nothing about the
> 			trip_points, instead the sensor devices would work on
> 			"temperature thresholds" and OF would map sensor
> 			thresholds to the actual trip points as needed
> 			(configured from DT); while the sensor devices stick to
> 			using "thresholds".
> 
> 			-> Queuing from above, sensors, most of the time, only
> 			need to know a high and a low temp threshold; which
> 			essentially is a subset of the active/passive etc. trip
> 			points. Calculation of that based on the current temp,
> 			as of today is replicated across all the sensor drivers
> 			and can be hoisted up to the of-thermal.
> 

There is no intention to add such logic to of thermal. The main reason
is of-thermal should never be competing with thermal core. Any extension
in of-thermal needs to be supported by thermal core.

I believe all the above is left currently to thermal zone device
drivers. The problem with of-thermal is that it had to be born as a
thermal zone device driver. And that is because..

> Seems like this is the opportune time to make a call about the role of of-thermal?
> 

.. the point one may be missing here is the fact that with current
thermal subsystem implementation, handling thermal devices is somewhat
different from other devices within the kernel.

The real design issue (or not an issue) we have is the fact that thermal
drivers adds both the driver and the device. Changing that is somewhat
disruptive. Not impossible, but requires considering the existing driver's code.

If we had a better split from who adds the device and who provides the
driver, then of-thermal would never be a "glue layer" or born as thermal
zone device driver. It would simply, parse DT, add the devices, done.

Then, drivers would register themselves as handlers for specific thermal
devices. That is the correct design, based on common design found in other
parts of the kernel. Another little missing end would be the "compatible"
string for thermal zone devices in DT. But as I said, it should not be a
blocker.

So, given the current situation, we have essentially two options: (a)
stick to the same design we have for now, having of-thermal as dummy as
possible, and grow in small steps towards the correct design; or (b)
redesign thermal core to have a better split between devices and
drivers, then adjust of-thermal.


For now, the path we are taking is (a). In fact, to fit the needs of
coming drivers, specially considering they are based on DT booting
platforms, it is always tempting to add intelligence to of-thermal. But,
as I mentioned, I want to avoid growing intelligence in it, for obvious
reasons.

> On 11/26/2014 07:18 AM, Eduardo Valentin wrote:
> > * PGP Signed by an unknown key
> > 
> > Hello,
> > 
> > On Wed, Nov 26, 2014 at 09:35:10AM +0100, Lukasz Majewski wrote:
> >> Hi Eduardo,
> >>
> >>> Hello Lukasz,
> >>>
> >>> On Thu, Nov 20, 2014 at 05:21:27PM +0100, Lukasz Majewski wrote:
> >>>> This patch extends the of-thermal.c to export copy of trip points
> >>>> for a given thermal zone.
> >>>>
> >>>> Thermal drivers should use of_thermal_get_trip_points() method to
> >>>> get pointer to table of thermal trip points.
> >>>>
> >>>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> >>>> ---
> >>>> Changes for v2:
> >>>> - New patch - as suggested by Eduardo Valentin
> >>>> ---
> >>>>  drivers/thermal/of-thermal.c   | 33
> >>>> +++++++++++++++++++++++++++++++++ drivers/thermal/thermal_core.h |
> >>>> 7 +++++++ include/linux/thermal.h        | 14 ++++++++++++++
> >>>>  3 files changed, 54 insertions(+)
> >>>>
> >>>> diff --git a/drivers/thermal/of-thermal.c
> >>>> b/drivers/thermal/of-thermal.c index 336af7f..33921c5 100644
> >>>> --- a/drivers/thermal/of-thermal.c
> >>>> +++ b/drivers/thermal/of-thermal.c
> >>>> @@ -89,6 +89,7 @@ struct __thermal_zone {
> >>>>  	/* trip data */
> >>>>  	int ntrips;
> >>>>  	struct __thermal_trip *trips;
> >>>> +	struct thermal_trip *gtrips;
> Do we really need this duplication ?
> >>>>  
> >>>>  	/* cooling binding data */
> >>>>  	int num_tbps;
> >>>> @@ -152,6 +153,27 @@ bool of_thermal_is_trip_en(struct
> >>>> thermal_zone_device *tz, int trip) return true;
> >>>>  }
> >>>>  
> >>>> +/**
> >>>> + * of_thermal_get_trip_points - function to get access to a
> >>>> globally exported
> >>>> + *				trip points
> >>>> + *
> >>>> + * @tz:	pointer to a thermal zone
> >>>> + *
> >>>> + * This function provides a pointer to the copy of trip points
> >>>> table
> >>>> + *
> >>>> + * Return: pointer to trip points table, NULL otherwise
> >>>> + */
> >>>> +const struct thermal_trip * const
> >>>> +of_thermal_get_trip_points(struct thermal_zone_device *tz)
> >>>> +{
> >>>> +	struct __thermal_zone *data = tz->devdata;
> >>>> +
> >>>> +	if (!data)
> >>>> +		return NULL;
> >>>> +
> >>>> +	return data->gtrips;
> >>>> +}
> >>>> +
> >>>
> >>> EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);
> >>
> >> Ok.
> >>
> >>>
> >>>>  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> >>>> int trip, enum thermal_trend *trend)
> >>>>  {
> >>>> @@ -767,6 +789,16 @@ thermal_of_build_thermal_zone(struct
> >>>> device_node *np) goto free_tbps;
> >>>>  	}
> >>>>  
> >>>> +	tz->gtrips = kcalloc(tz->ntrips, sizeof(*tz->gtrips),
> >>>> GFP_KERNEL);
> >>>> +	if (!tz->gtrips) {
> >>>> +		ret = -ENOMEM;
> >>>> +		goto free_tbps;
> >>>> +	}
> >>>> +
> >>>> +	for (i = 0; i < tz->ntrips; i++)
> >>>> +		memcpy(&(tz->gtrips[i]),
> >>>> &(tz->trips[i].temperature),
> >>>> +		       sizeof(*tz->gtrips));
> >>>> +
> >>>>  finish:
> >>>>  	of_node_put(child);
> >>>>  	tz->mode = THERMAL_DEVICE_DISABLED;
> >>>> @@ -793,6 +825,7 @@ static inline void of_thermal_free_zone(struct
> >>>> __thermal_zone *tz) {
> >>>>  	int i;
> >>>>  
> >>>> +	kfree(tz->gtrips);
> >>>>  	for (i = 0; i < tz->num_tbps; i++)
> >>>>  		of_node_put(tz->tbps[i].cooling_device);
> >>>>  	kfree(tz->tbps);
> Couldn't find the code that updates *gtrips as a result of set_trip_temp via
> sysfs.
> 
> >>>> diff --git a/drivers/thermal/thermal_core.h
> >>>> b/drivers/thermal/thermal_core.h index 466208c..a9580ca 100644
> >>>> --- a/drivers/thermal/thermal_core.h
> >>>> +++ b/drivers/thermal/thermal_core.h
> >>>> @@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
> >>>>  void of_thermal_destroy_zones(void);
> >>>>  int of_thermal_get_ntrips(struct thermal_zone_device *);
> >>>>  bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
> >>>> +const struct thermal_trip * const
> >>>> +of_thermal_get_trip_points(struct thermal_zone_device *);
> >>>>  #else
> >>>>  static inline int of_parse_thermal_zones(void) { return 0; }
> >>>>  static inline void of_thermal_destroy_zones(void) { }
> >>>> @@ -102,6 +104,11 @@ static inline bool
> >>>> of_thermal_is_trip_en(struct thermal_zone_device *, int) {
> >>>
> >>> This produces compilation error when CONFIG_THERMAL_OF is not set.
> >>> Name the parameters to fix.
> >>
> >> As all the other cases, I will fix that.
> >>
> >>>
> >>>>  	return 0;
> >>>>  }
> >>>> +static inline const struct thermal_trip * const
> >>>> +of_thermal_get_trip_points(struct thermal_zone_device *)
> >>>> +{
> >>>> +	return NULL;
> >>>> +}
> >>>>  #endif
> >>>>  
> >>>>  #endif /* __THERMAL_CORE_H__ */
> >>>> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> >>>> index 5bc28a7..88d7249 100644
> >>>> --- a/include/linux/thermal.h
> >>>> +++ b/include/linux/thermal.h
> >>>> @@ -303,6 +303,20 @@ struct thermal_zone_of_device_ops {
> >>>>  	int (*get_trend)(void *, long *);
> >>>>  };
> >>>>  
> >>>> +/**
> >>>> + * struct thermal_trip - Structure representing themal trip points
> >>>> exported from
> >>>> + *                       of-thermal
> >>>> + *
> >>>
> >>> The only problem I have with this name is that would look like it is
> >>> in use in all thermal framework, which is not really the case. But I
> >>> do think having a type here is a good thing. So, not sure :-)
> >>
> >> It can stay to be struct thermal_trip or we can rename it to
> >> struct of_thermal_trip.
> >>
> >> I'm fine with both names.
> > 
> > Leave it as 'thermal_trip'.
> > 
> >>
> >>>
> >>>> + * @temperature:	trip point temperature
> >>>> + * @hysteresis:		trip point hysteresis
> >>>> + * @type:		trip point type
> >>>> + */
> >>>> +struct thermal_trip {
> >>>> +	unsigned long int temperature;
> >>>> +	unsigned long int hysteresis;
> >>>> +	enum thermal_trip_type type;
> >>>> +};
> >>>> +
> >>>>  /* Function declarations */
> >>>>  #ifdef CONFIG_THERMAL_OF
> >>>>  struct thermal_zone_device *
> >>>> -- 
> >>>> 2.0.0.rc2
> >>>>
> >>
> >>
> >>
> >> -- 
> >> Best regards,
> >>
> >> Lukasz Majewski
> >>
> >> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
> > 
> > * Unknown Key
> > * 0x7DA4E256
> > 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points
  2014-11-26 21:12             ` Guenter Roeck
@ 2014-11-26 23:12                 ` navneet kumar
  0 siblings, 0 replies; 288+ messages in thread
From: navneet kumar @ 2014-11-26 23:12 UTC (permalink / raw)
  To: Guenter Roeck, Eduardo Valentin, Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan, linux-kernel,
	Caesar Wang



On 11/26/2014 01:12 PM, Guenter Roeck wrote:
> On 11/26/2014 12:43 PM, navneet kumar wrote:
>>
>> Hi Eduardo, Lukasz,
>>
>> [Combining my concerns as a single text blob here]
>>
>> I. Firstly, with the current patch
>>     1. is it really needed to duplicate the struct thermal_trip? Why
>> don’t
>>     we get rid of the __thermal_trip and stay with the 'thermal_trip'
>> ? it
>>     is not a big change.
>>
>>     2. gtrips is not updated on "set_trip_temp" etc. actions via
>> sysfs. (am
>>     I missing something?).
>>
>> II. The other concern is more of a design question
>>     1. Do we intend to keep the of-thermal as a middle layer between the
>>     thermal_core and the sensor device? OR, is the role of of-thermal
>> just
>>     to parse the DT and opt out ? currently of-thermal is somewhat a
>> hybrid
>>     of these as, in addition to parsing the dt, it holds on to the data
>>     related to trip points etc. etc.
>>
>>     2. assuming latter is true (OF is just a dt parser helper): we should
>>     not be adding more intelligence and dependencies linked to the OF.
>>
>>     3. assuming former is true (OF is a well-defined middle layer):
>> All is
>>     good till the point OF maintains the trip points (which is a good
>> thing
>>     since, OF caches on to the data); BUT, if we expose this
>> information to
>>     the sensor device too (as this patch is doing),
>>
>>         3a. we violate the layering principle :-)
>>
>>         3b. more importantly, this is all just excessive logic that we
>>         put in which *could be useful* only if we intend to extend the
>>         role of OF as a trip point management layer that does more than
>>         just holding on to the data. This may include -
>>
>>             -> The sensor devices to know nothing about the
>>             trip_points, instead the sensor devices would work on
>>             "temperature thresholds" and OF would map sensor
>>             thresholds to the actual trip points as needed
>>             (configured from DT); while the sensor devices stick to
>>             using "thresholds".
>>
>>             -> Queuing from above, sensors, most of the time, only
>>             need to know a high and a low temp threshold; which
>>             essentially is a subset of the active/passive etc. trip
>>             points. Calculation of that based on the current temp,
>>             as of today is replicated across all the sensor drivers
>>             and can be hoisted up to the of-thermal.
>>
> 
> Sorry, lost you here. What replicated calculation do you refer to ?
> 
> Thanks,
> Guenter
> 
Some sensors have an ability to generate interrupts based upon a configured high
and low temp thresholds/values. Once any of these limits is crossed, the sensor
hardware has to be reconfigured with a new set of such values.

I'll try to explain with an example -
consider trip points TP1, TP2, TP3, TP4 sorted as low to high; and the current 
temp T1 such that -
TP2<T1<TP3

With the conditions as is, and assuming the interrupts have been configured, an
interrupt will trigger if T1 goes below TP2 or exceeds TP3.

Now, say, T1 crosses TP3, the sensor hardware generates an interrupt (avoids polling 
on the zone temp). Furthermore, we require that the new limits for the interrupts
be TP3 and TP4 for 'low' and 'high' thresholds interrupts
respectively, such that an interrupt will be fired when temp goes below TP3 or
exceeds TP4.

Above case is when the temp crosses a set of High-low. The same situation may
occur when a trip point temp is changed from sysfs, in which case, the thresholds
for configuring the interrupts may have to be reconfigured.

Today, the sensors find the high-low thresholds by -
1. querying the temp from the thermal_zone
2. traversing the trip points (which may have been cached locally by the sensor),
   and figuring out the high/low temperature thresholds. 

These above steps aka 'replicated calculation'.

Whatever the case may be, the real question is the role and scope of of-thermal.


>> Seems like this is the opportune time to make a call about the role of
>> of-thermal?
>>
>> On 11/26/2014 07:18 AM, Eduardo Valentin wrote:
>>> * PGP Signed by an unknown key
>>>
>>> Hello,
>>>
>>> On Wed, Nov 26, 2014 at 09:35:10AM +0100, Lukasz Majewski wrote:
>>>> Hi Eduardo,
>>>>
>>>>> Hello Lukasz,
>>>>>
>>>>> On Thu, Nov 20, 2014 at 05:21:27PM +0100, Lukasz Majewski wrote:
>>>>>> This patch extends the of-thermal.c to export copy of trip points
>>>>>> for a given thermal zone.
>>>>>>
>>>>>> Thermal drivers should use of_thermal_get_trip_points() method to
>>>>>> get pointer to table of thermal trip points.
>>>>>>
>>>>>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>>>>>> ---
>>>>>> Changes for v2:
>>>>>> - New patch - as suggested by Eduardo Valentin
>>>>>> ---
>>>>>>   drivers/thermal/of-thermal.c   | 33
>>>>>> +++++++++++++++++++++++++++++++++ drivers/thermal/thermal_core.h |
>>>>>> 7 +++++++ include/linux/thermal.h        | 14 ++++++++++++++
>>>>>>   3 files changed, 54 insertions(+)
>>>>>>
>>>>>> diff --git a/drivers/thermal/of-thermal.c
>>>>>> b/drivers/thermal/of-thermal.c index 336af7f..33921c5 100644
>>>>>> --- a/drivers/thermal/of-thermal.c
>>>>>> +++ b/drivers/thermal/of-thermal.c
>>>>>> @@ -89,6 +89,7 @@ struct __thermal_zone {
>>>>>>       /* trip data */
>>>>>>       int ntrips;
>>>>>>       struct __thermal_trip *trips;
>>>>>> +    struct thermal_trip *gtrips;
>> Do we really need this duplication ?
>>>>>>
>>>>>>       /* cooling binding data */
>>>>>>       int num_tbps;
>>>>>> @@ -152,6 +153,27 @@ bool of_thermal_is_trip_en(struct
>>>>>> thermal_zone_device *tz, int trip) return true;
>>>>>>   }
>>>>>>
>>>>>> +/**
>>>>>> + * of_thermal_get_trip_points - function to get access to a
>>>>>> globally exported
>>>>>> + *                trip points
>>>>>> + *
>>>>>> + * @tz:    pointer to a thermal zone
>>>>>> + *
>>>>>> + * This function provides a pointer to the copy of trip points
>>>>>> table
>>>>>> + *
>>>>>> + * Return: pointer to trip points table, NULL otherwise
>>>>>> + */
>>>>>> +const struct thermal_trip * const
>>>>>> +of_thermal_get_trip_points(struct thermal_zone_device *tz)
>>>>>> +{
>>>>>> +    struct __thermal_zone *data = tz->devdata;
>>>>>> +
>>>>>> +    if (!data)
>>>>>> +        return NULL;
>>>>>> +
>>>>>> +    return data->gtrips;
>>>>>> +}
>>>>>> +
>>>>>
>>>>> EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);
>>>>
>>>> Ok.
>>>>
>>>>>
>>>>>>   static int of_thermal_get_trend(struct thermal_zone_device *tz,
>>>>>> int trip, enum thermal_trend *trend)
>>>>>>   {
>>>>>> @@ -767,6 +789,16 @@ thermal_of_build_thermal_zone(struct
>>>>>> device_node *np) goto free_tbps;
>>>>>>       }
>>>>>>
>>>>>> +    tz->gtrips = kcalloc(tz->ntrips, sizeof(*tz->gtrips),
>>>>>> GFP_KERNEL);
>>>>>> +    if (!tz->gtrips) {
>>>>>> +        ret = -ENOMEM;
>>>>>> +        goto free_tbps;
>>>>>> +    }
>>>>>> +
>>>>>> +    for (i = 0; i < tz->ntrips; i++)
>>>>>> +        memcpy(&(tz->gtrips[i]),
>>>>>> &(tz->trips[i].temperature),
>>>>>> +               sizeof(*tz->gtrips));
>>>>>> +
>>>>>>   finish:
>>>>>>       of_node_put(child);
>>>>>>       tz->mode = THERMAL_DEVICE_DISABLED;
>>>>>> @@ -793,6 +825,7 @@ static inline void of_thermal_free_zone(struct
>>>>>> __thermal_zone *tz) {
>>>>>>       int i;
>>>>>>
>>>>>> +    kfree(tz->gtrips);
>>>>>>       for (i = 0; i < tz->num_tbps; i++)
>>>>>>           of_node_put(tz->tbps[i].cooling_device);
>>>>>>       kfree(tz->tbps);
>> Couldn't find the code that updates *gtrips as a result of
>> set_trip_temp via
>> sysfs.
>>
>>>>>> diff --git a/drivers/thermal/thermal_core.h
>>>>>> b/drivers/thermal/thermal_core.h index 466208c..a9580ca 100644
>>>>>> --- a/drivers/thermal/thermal_core.h
>>>>>> +++ b/drivers/thermal/thermal_core.h
>>>>>> @@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
>>>>>>   void of_thermal_destroy_zones(void);
>>>>>>   int of_thermal_get_ntrips(struct thermal_zone_device *);
>>>>>>   bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
>>>>>> +const struct thermal_trip * const
>>>>>> +of_thermal_get_trip_points(struct thermal_zone_device *);
>>>>>>   #else
>>>>>>   static inline int of_parse_thermal_zones(void) { return 0; }
>>>>>>   static inline void of_thermal_destroy_zones(void) { }
>>>>>> @@ -102,6 +104,11 @@ static inline bool
>>>>>> of_thermal_is_trip_en(struct thermal_zone_device *, int) {
>>>>>
>>>>> This produces compilation error when CONFIG_THERMAL_OF is not set.
>>>>> Name the parameters to fix.
>>>>
>>>> As all the other cases, I will fix that.
>>>>
>>>>>
>>>>>>       return 0;
>>>>>>   }
>>>>>> +static inline const struct thermal_trip * const
>>>>>> +of_thermal_get_trip_points(struct thermal_zone_device *)
>>>>>> +{
>>>>>> +    return NULL;
>>>>>> +}
>>>>>>   #endif
>>>>>>
>>>>>>   #endif /* __THERMAL_CORE_H__ */
>>>>>> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
>>>>>> index 5bc28a7..88d7249 100644
>>>>>> --- a/include/linux/thermal.h
>>>>>> +++ b/include/linux/thermal.h
>>>>>> @@ -303,6 +303,20 @@ struct thermal_zone_of_device_ops {
>>>>>>       int (*get_trend)(void *, long *);
>>>>>>   };
>>>>>>
>>>>>> +/**
>>>>>> + * struct thermal_trip - Structure representing themal trip points
>>>>>> exported from
>>>>>> + *                       of-thermal
>>>>>> + *
>>>>>
>>>>> The only problem I have with this name is that would look like it is
>>>>> in use in all thermal framework, which is not really the case. But I
>>>>> do think having a type here is a good thing. So, not sure :-)
>>>>
>>>> It can stay to be struct thermal_trip or we can rename it to
>>>> struct of_thermal_trip.
>>>>
>>>> I'm fine with both names.
>>>
>>> Leave it as 'thermal_trip'.
>>>
>>>>
>>>>>
>>>>>> + * @temperature:    trip point temperature
>>>>>> + * @hysteresis:        trip point hysteresis
>>>>>> + * @type:        trip point type
>>>>>> + */
>>>>>> +struct thermal_trip {
>>>>>> +    unsigned long int temperature;
>>>>>> +    unsigned long int hysteresis;
>>>>>> +    enum thermal_trip_type type;
>>>>>> +};
>>>>>> +
>>>>>>   /* Function declarations */
>>>>>>   #ifdef CONFIG_THERMAL_OF
>>>>>>   struct thermal_zone_device *
>>>>>> -- 
>>>>>> 2.0.0.rc2
>>>>>>
>>>>
>>>>
>>>>
>>>> -- 
>>>> Best regards,
>>>>
>>>> Lukasz Majewski
>>>>
>>>> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
>>>
>>> * Unknown Key
>>> * 0x7DA4E256
>>>
>>
> 
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points
@ 2014-11-26 23:12                 ` navneet kumar
  0 siblings, 0 replies; 288+ messages in thread
From: navneet kumar @ 2014-11-26 23:12 UTC (permalink / raw)
  To: Guenter Roeck, Eduardo Valentin, Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan, linux-kernel,
	Caesar Wang



On 11/26/2014 01:12 PM, Guenter Roeck wrote:
> On 11/26/2014 12:43 PM, navneet kumar wrote:
>>
>> Hi Eduardo, Lukasz,
>>
>> [Combining my concerns as a single text blob here]
>>
>> I. Firstly, with the current patch
>>     1. is it really needed to duplicate the struct thermal_trip? Why
>> don’t
>>     we get rid of the __thermal_trip and stay with the 'thermal_trip'
>> ? it
>>     is not a big change.
>>
>>     2. gtrips is not updated on "set_trip_temp" etc. actions via
>> sysfs. (am
>>     I missing something?).
>>
>> II. The other concern is more of a design question
>>     1. Do we intend to keep the of-thermal as a middle layer between the
>>     thermal_core and the sensor device? OR, is the role of of-thermal
>> just
>>     to parse the DT and opt out ? currently of-thermal is somewhat a
>> hybrid
>>     of these as, in addition to parsing the dt, it holds on to the data
>>     related to trip points etc. etc.
>>
>>     2. assuming latter is true (OF is just a dt parser helper): we should
>>     not be adding more intelligence and dependencies linked to the OF.
>>
>>     3. assuming former is true (OF is a well-defined middle layer):
>> All is
>>     good till the point OF maintains the trip points (which is a good
>> thing
>>     since, OF caches on to the data); BUT, if we expose this
>> information to
>>     the sensor device too (as this patch is doing),
>>
>>         3a. we violate the layering principle :-)
>>
>>         3b. more importantly, this is all just excessive logic that we
>>         put in which *could be useful* only if we intend to extend the
>>         role of OF as a trip point management layer that does more than
>>         just holding on to the data. This may include -
>>
>>             -> The sensor devices to know nothing about the
>>             trip_points, instead the sensor devices would work on
>>             "temperature thresholds" and OF would map sensor
>>             thresholds to the actual trip points as needed
>>             (configured from DT); while the sensor devices stick to
>>             using "thresholds".
>>
>>             -> Queuing from above, sensors, most of the time, only
>>             need to know a high and a low temp threshold; which
>>             essentially is a subset of the active/passive etc. trip
>>             points. Calculation of that based on the current temp,
>>             as of today is replicated across all the sensor drivers
>>             and can be hoisted up to the of-thermal.
>>
> 
> Sorry, lost you here. What replicated calculation do you refer to ?
> 
> Thanks,
> Guenter
> 
Some sensors have an ability to generate interrupts based upon a configured high
and low temp thresholds/values. Once any of these limits is crossed, the sensor
hardware has to be reconfigured with a new set of such values.

I'll try to explain with an example -
consider trip points TP1, TP2, TP3, TP4 sorted as low to high; and the current 
temp T1 such that -
TP2<T1<TP3

With the conditions as is, and assuming the interrupts have been configured, an
interrupt will trigger if T1 goes below TP2 or exceeds TP3.

Now, say, T1 crosses TP3, the sensor hardware generates an interrupt (avoids polling 
on the zone temp). Furthermore, we require that the new limits for the interrupts
be TP3 and TP4 for 'low' and 'high' thresholds interrupts
respectively, such that an interrupt will be fired when temp goes below TP3 or
exceeds TP4.

Above case is when the temp crosses a set of High-low. The same situation may
occur when a trip point temp is changed from sysfs, in which case, the thresholds
for configuring the interrupts may have to be reconfigured.

Today, the sensors find the high-low thresholds by -
1. querying the temp from the thermal_zone
2. traversing the trip points (which may have been cached locally by the sensor),
   and figuring out the high/low temperature thresholds. 

These above steps aka 'replicated calculation'.

Whatever the case may be, the real question is the role and scope of of-thermal.


>> Seems like this is the opportune time to make a call about the role of
>> of-thermal?
>>
>> On 11/26/2014 07:18 AM, Eduardo Valentin wrote:
>>> * PGP Signed by an unknown key
>>>
>>> Hello,
>>>
>>> On Wed, Nov 26, 2014 at 09:35:10AM +0100, Lukasz Majewski wrote:
>>>> Hi Eduardo,
>>>>
>>>>> Hello Lukasz,
>>>>>
>>>>> On Thu, Nov 20, 2014 at 05:21:27PM +0100, Lukasz Majewski wrote:
>>>>>> This patch extends the of-thermal.c to export copy of trip points
>>>>>> for a given thermal zone.
>>>>>>
>>>>>> Thermal drivers should use of_thermal_get_trip_points() method to
>>>>>> get pointer to table of thermal trip points.
>>>>>>
>>>>>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>>>>>> ---
>>>>>> Changes for v2:
>>>>>> - New patch - as suggested by Eduardo Valentin
>>>>>> ---
>>>>>>   drivers/thermal/of-thermal.c   | 33
>>>>>> +++++++++++++++++++++++++++++++++ drivers/thermal/thermal_core.h |
>>>>>> 7 +++++++ include/linux/thermal.h        | 14 ++++++++++++++
>>>>>>   3 files changed, 54 insertions(+)
>>>>>>
>>>>>> diff --git a/drivers/thermal/of-thermal.c
>>>>>> b/drivers/thermal/of-thermal.c index 336af7f..33921c5 100644
>>>>>> --- a/drivers/thermal/of-thermal.c
>>>>>> +++ b/drivers/thermal/of-thermal.c
>>>>>> @@ -89,6 +89,7 @@ struct __thermal_zone {
>>>>>>       /* trip data */
>>>>>>       int ntrips;
>>>>>>       struct __thermal_trip *trips;
>>>>>> +    struct thermal_trip *gtrips;
>> Do we really need this duplication ?
>>>>>>
>>>>>>       /* cooling binding data */
>>>>>>       int num_tbps;
>>>>>> @@ -152,6 +153,27 @@ bool of_thermal_is_trip_en(struct
>>>>>> thermal_zone_device *tz, int trip) return true;
>>>>>>   }
>>>>>>
>>>>>> +/**
>>>>>> + * of_thermal_get_trip_points - function to get access to a
>>>>>> globally exported
>>>>>> + *                trip points
>>>>>> + *
>>>>>> + * @tz:    pointer to a thermal zone
>>>>>> + *
>>>>>> + * This function provides a pointer to the copy of trip points
>>>>>> table
>>>>>> + *
>>>>>> + * Return: pointer to trip points table, NULL otherwise
>>>>>> + */
>>>>>> +const struct thermal_trip * const
>>>>>> +of_thermal_get_trip_points(struct thermal_zone_device *tz)
>>>>>> +{
>>>>>> +    struct __thermal_zone *data = tz->devdata;
>>>>>> +
>>>>>> +    if (!data)
>>>>>> +        return NULL;
>>>>>> +
>>>>>> +    return data->gtrips;
>>>>>> +}
>>>>>> +
>>>>>
>>>>> EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);
>>>>
>>>> Ok.
>>>>
>>>>>
>>>>>>   static int of_thermal_get_trend(struct thermal_zone_device *tz,
>>>>>> int trip, enum thermal_trend *trend)
>>>>>>   {
>>>>>> @@ -767,6 +789,16 @@ thermal_of_build_thermal_zone(struct
>>>>>> device_node *np) goto free_tbps;
>>>>>>       }
>>>>>>
>>>>>> +    tz->gtrips = kcalloc(tz->ntrips, sizeof(*tz->gtrips),
>>>>>> GFP_KERNEL);
>>>>>> +    if (!tz->gtrips) {
>>>>>> +        ret = -ENOMEM;
>>>>>> +        goto free_tbps;
>>>>>> +    }
>>>>>> +
>>>>>> +    for (i = 0; i < tz->ntrips; i++)
>>>>>> +        memcpy(&(tz->gtrips[i]),
>>>>>> &(tz->trips[i].temperature),
>>>>>> +               sizeof(*tz->gtrips));
>>>>>> +
>>>>>>   finish:
>>>>>>       of_node_put(child);
>>>>>>       tz->mode = THERMAL_DEVICE_DISABLED;
>>>>>> @@ -793,6 +825,7 @@ static inline void of_thermal_free_zone(struct
>>>>>> __thermal_zone *tz) {
>>>>>>       int i;
>>>>>>
>>>>>> +    kfree(tz->gtrips);
>>>>>>       for (i = 0; i < tz->num_tbps; i++)
>>>>>>           of_node_put(tz->tbps[i].cooling_device);
>>>>>>       kfree(tz->tbps);
>> Couldn't find the code that updates *gtrips as a result of
>> set_trip_temp via
>> sysfs.
>>
>>>>>> diff --git a/drivers/thermal/thermal_core.h
>>>>>> b/drivers/thermal/thermal_core.h index 466208c..a9580ca 100644
>>>>>> --- a/drivers/thermal/thermal_core.h
>>>>>> +++ b/drivers/thermal/thermal_core.h
>>>>>> @@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
>>>>>>   void of_thermal_destroy_zones(void);
>>>>>>   int of_thermal_get_ntrips(struct thermal_zone_device *);
>>>>>>   bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
>>>>>> +const struct thermal_trip * const
>>>>>> +of_thermal_get_trip_points(struct thermal_zone_device *);
>>>>>>   #else
>>>>>>   static inline int of_parse_thermal_zones(void) { return 0; }
>>>>>>   static inline void of_thermal_destroy_zones(void) { }
>>>>>> @@ -102,6 +104,11 @@ static inline bool
>>>>>> of_thermal_is_trip_en(struct thermal_zone_device *, int) {
>>>>>
>>>>> This produces compilation error when CONFIG_THERMAL_OF is not set.
>>>>> Name the parameters to fix.
>>>>
>>>> As all the other cases, I will fix that.
>>>>
>>>>>
>>>>>>       return 0;
>>>>>>   }
>>>>>> +static inline const struct thermal_trip * const
>>>>>> +of_thermal_get_trip_points(struct thermal_zone_device *)
>>>>>> +{
>>>>>> +    return NULL;
>>>>>> +}
>>>>>>   #endif
>>>>>>
>>>>>>   #endif /* __THERMAL_CORE_H__ */
>>>>>> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
>>>>>> index 5bc28a7..88d7249 100644
>>>>>> --- a/include/linux/thermal.h
>>>>>> +++ b/include/linux/thermal.h
>>>>>> @@ -303,6 +303,20 @@ struct thermal_zone_of_device_ops {
>>>>>>       int (*get_trend)(void *, long *);
>>>>>>   };
>>>>>>
>>>>>> +/**
>>>>>> + * struct thermal_trip - Structure representing themal trip points
>>>>>> exported from
>>>>>> + *                       of-thermal
>>>>>> + *
>>>>>
>>>>> The only problem I have with this name is that would look like it is
>>>>> in use in all thermal framework, which is not really the case. But I
>>>>> do think having a type here is a good thing. So, not sure :-)
>>>>
>>>> It can stay to be struct thermal_trip or we can rename it to
>>>> struct of_thermal_trip.
>>>>
>>>> I'm fine with both names.
>>>
>>> Leave it as 'thermal_trip'.
>>>
>>>>
>>>>>
>>>>>> + * @temperature:    trip point temperature
>>>>>> + * @hysteresis:        trip point hysteresis
>>>>>> + * @type:        trip point type
>>>>>> + */
>>>>>> +struct thermal_trip {
>>>>>> +    unsigned long int temperature;
>>>>>> +    unsigned long int hysteresis;
>>>>>> +    enum thermal_trip_type type;
>>>>>> +};
>>>>>> +
>>>>>>   /* Function declarations */
>>>>>>   #ifdef CONFIG_THERMAL_OF
>>>>>>   struct thermal_zone_device *
>>>>>> -- 
>>>>>> 2.0.0.rc2
>>>>>>
>>>>
>>>>
>>>>
>>>> -- 
>>>> Best regards,
>>>>
>>>> Lukasz Majewski
>>>>
>>>> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
>>>
>>> * Unknown Key
>>> * 0x7DA4E256
>>>
>>
> 
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points
  2014-11-26 23:09             ` Eduardo Valentin
@ 2014-11-27  9:42                 ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-27  9:42 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: navneet kumar, Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang, Lukasz Majewski

Hi Eduardo,

> 
> Hello Navneet,
> 
> On Wed, Nov 26, 2014 at 12:43:18PM -0800, navneet kumar wrote:
> > 
> > Hi Eduardo, Lukasz,
> > 
> > [Combining my concerns as a single text blob here]
> > 
> > I. Firstly, with the current patch
> > 	1. is it really needed to duplicate the struct
> > thermal_trip? Why don’t we get rid of the __thermal_trip and stay
> > with the 'thermal_trip' ? it is not a big change.

The __thermal_trip seems to be somehow "private" structure (to
of-thermal) which holds not only data which could be exposed to sensors.

> > 
> > 	2. gtrips is not updated on "set_trip_temp" etc. actions
> > via sysfs. (am I missing something?).

True. This is a bug. Thanks for spotting.

> > 
> 
> Good! Comments are always welcome, that's how we make patches :-).
> 
> Both above make sense to me.
> 
> > II. The other concern is more of a design question
> > 	1. Do we intend to keep the of-thermal as a middle layer
> > between the thermal_core and the sensor device? OR, is the role of
> > of-thermal just to parse the DT and opt out ? currently of-thermal
> > is somewhat a hybrid of these as, in addition to parsing the dt, it
> > holds on to the data related to trip points etc. etc.
> > 
> 
> of-thermal has always been as your latter statement, and I intend to
> keep it as it should be, just a of parser for thermal data.

It seems to me that now of-thermal is doing more than parsing
thermal data. 

For example it is an abstraction layer for
calling .get_temp(), .get_trend().

It has its own set of "private" trip points which aren't exposed to
sensors.

Also, it registers thermal_zone_device.

A lot of stuff is done by the of-thermal. Frankly, I don't
mind, since this is a common code for many sensors.

For example with of-thermal.c usage, we are able to cut down LOC number
by half for Exynos TMU when moving to OF.

> 
> > 	2. assuming latter is true (OF is just a dt parser helper):
> > we should not be adding more intelligence and dependencies linked
> > to the OF.
> > 
> 
> Yes this is right. We should never be adding intelligence to it,

But a lot of stuff is already added and to be worse it is well adopted
API by sensors.

> except for parsing the thermal data out of device tree and adding the
> proper structures inside the kernel.

In my understanding the of-thermal code to expose the above features
need to:
- parse device tree
- export trip points in a table to sensors
- export cpu frequencies (OPPs?) with information about corresponding
  temperature

And that is all. The sensor is then responsible for initializing HW and
register the thermal zone with thermal_core.


> 
> > 	3. assuming former is true (OF is a well-defined middle
> > layer): All is good till the point OF maintains the trip points
> > (which is a good thing since, OF caches on to the data); BUT, if we
> > expose this information to the sensor device too (as this patch is
> > doing),
> > 
> 
> the former is not true.
> 
> > 		3a. we violate the layering principle :-)
> > 

Are we? of-thermal.c is parsing DT and it exposes read only information
about trip points. Also it gives you information about e.g. number of
available trip points.

> 
> well, even if it was, I disagree here. :-) The split between data
> coming from DT and the driver is still in place. Besides, there is
> other layers that expose some of their data, and that doesn't violate
> their layering principles. CPUfreq, for one closer example, exposes
> its freq table.
> 
> It would be different if by exposing this data, the users would be
> affecting the behavior of the layer. And that is not the intention of
> cpufreq table. In the same way, that is not the intention of this
> patch.
> 
> > 		3b. more importantly, this is all just excessive
> > logic that we put in which *could be useful* only if we intend to
> > extend the role of OF as a trip point management layer that does
> > more than just holding on to the data. This may include -
> > 
> > 			-> The sensor devices to know nothing about
> > the trip_points, instead the sensor devices would work on
> > 			"temperature thresholds" and OF would map
> > sensor thresholds to the actual trip points as needed
> > 			(configured from DT); while the sensor
> > devices stick to using "thresholds".
> > 
> > 			-> Queuing from above, sensors, most of the
> > time, only need to know a high and a low temp threshold; which
> > 			essentially is a subset of the
> > active/passive etc. trip points. Calculation of that based on the
> > current temp, as of today is replicated across all the sensor
> > drivers and can be hoisted up to the of-thermal.
> > 
> 
> There is no intention to add such logic to of thermal. The main reason
> is of-thermal should never be competing with thermal core. Any
> extension in of-thermal needs to be supported by thermal core.
> 
> I believe all the above is left currently to thermal zone device
> drivers. The problem with of-thermal is that it had to be born as a
> thermal zone device driver. And that is because..
> 
> > Seems like this is the opportune time to make a call about the role
> > of of-thermal?
> > 
> 
> .. the point one may be missing here is the fact that with current
> thermal subsystem implementation, handling thermal devices is somewhat
> different from other devices within the kernel.
> 
> The real design issue (or not an issue) we have is the fact that
> thermal drivers adds both the driver and the device. Changing that is
> somewhat disruptive. Not impossible, but requires considering the
> existing driver's code.
> 
> If we had a better split from who adds the device and who provides the
> driver, then of-thermal would never be a "glue layer" or born as
> thermal zone device driver. It would simply, parse DT, add the
> devices, done.
> 
> Then, drivers would register themselves as handlers for specific
> thermal devices. That is the correct design, based on common design
> found in other parts of the kernel. Another little missing end would
> be the "compatible" string for thermal zone devices in DT. But as I
> said, it should not be a blocker.
> 
> So, given the current situation, we have essentially two options: (a)
> stick to the same design we have for now, having of-thermal as dummy
> as possible, and grow in small steps towards the correct design; or
> (b) redesign thermal core to have a better split between devices and
> drivers, then adjust of-thermal.
> 
> 
> For now, the path we are taking is (a). In fact, to fit the needs of
> coming drivers, specially considering they are based on DT booting
> platforms, it is always tempting to add intelligence to of-thermal.
> But, as I mentioned, I want to avoid growing intelligence in it, for
> obvious reasons.

Eventually, it is your call if we make __thermal_trip [1] exported to
sensors (with or without struct device_node *np)
 or if we have new structure (e.g. struct thermal_trip) which is a read
only reference to relevant fields of [1]?

> 
> > On 11/26/2014 07:18 AM, Eduardo Valentin wrote:
> > > * PGP Signed by an unknown key
> > > 
> > > Hello,
> > > 
> > > On Wed, Nov 26, 2014 at 09:35:10AM +0100, Lukasz Majewski wrote:
> > >> Hi Eduardo,
> > >>
> > >>> Hello Lukasz,
> > >>>
> > >>> On Thu, Nov 20, 2014 at 05:21:27PM +0100, Lukasz Majewski wrote:
> > >>>> This patch extends the of-thermal.c to export copy of trip
> > >>>> points for a given thermal zone.
> > >>>>
> > >>>> Thermal drivers should use of_thermal_get_trip_points() method
> > >>>> to get pointer to table of thermal trip points.
> > >>>>
> > >>>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > >>>> ---
> > >>>> Changes for v2:
> > >>>> - New patch - as suggested by Eduardo Valentin
> > >>>> ---
> > >>>>  drivers/thermal/of-thermal.c   | 33
> > >>>> +++++++++++++++++++++++++++++++++
> > >>>> drivers/thermal/thermal_core.h | 7 +++++++
> > >>>> include/linux/thermal.h        | 14 ++++++++++++++ 3 files
> > >>>> changed, 54 insertions(+)
> > >>>>
> > >>>> diff --git a/drivers/thermal/of-thermal.c
> > >>>> b/drivers/thermal/of-thermal.c index 336af7f..33921c5 100644
> > >>>> --- a/drivers/thermal/of-thermal.c
> > >>>> +++ b/drivers/thermal/of-thermal.c
> > >>>> @@ -89,6 +89,7 @@ struct __thermal_zone {
> > >>>>  	/* trip data */
> > >>>>  	int ntrips;
> > >>>>  	struct __thermal_trip *trips;
> > >>>> +	struct thermal_trip *gtrips;
> > Do we really need this duplication ?
> > >>>>  
> > >>>>  	/* cooling binding data */
> > >>>>  	int num_tbps;
> > >>>> @@ -152,6 +153,27 @@ bool of_thermal_is_trip_en(struct
> > >>>> thermal_zone_device *tz, int trip) return true;
> > >>>>  }
> > >>>>  
> > >>>> +/**
> > >>>> + * of_thermal_get_trip_points - function to get access to a
> > >>>> globally exported
> > >>>> + *				trip points
> > >>>> + *
> > >>>> + * @tz:	pointer to a thermal zone
> > >>>> + *
> > >>>> + * This function provides a pointer to the copy of trip points
> > >>>> table
> > >>>> + *
> > >>>> + * Return: pointer to trip points table, NULL otherwise
> > >>>> + */
> > >>>> +const struct thermal_trip * const
> > >>>> +of_thermal_get_trip_points(struct thermal_zone_device *tz)
> > >>>> +{
> > >>>> +	struct __thermal_zone *data = tz->devdata;
> > >>>> +
> > >>>> +	if (!data)
> > >>>> +		return NULL;
> > >>>> +
> > >>>> +	return data->gtrips;
> > >>>> +}
> > >>>> +
> > >>>
> > >>> EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);
> > >>
> > >> Ok.
> > >>
> > >>>
> > >>>>  static int of_thermal_get_trend(struct thermal_zone_device
> > >>>> *tz, int trip, enum thermal_trend *trend)
> > >>>>  {
> > >>>> @@ -767,6 +789,16 @@ thermal_of_build_thermal_zone(struct
> > >>>> device_node *np) goto free_tbps;
> > >>>>  	}
> > >>>>  
> > >>>> +	tz->gtrips = kcalloc(tz->ntrips, sizeof(*tz->gtrips),
> > >>>> GFP_KERNEL);
> > >>>> +	if (!tz->gtrips) {
> > >>>> +		ret = -ENOMEM;
> > >>>> +		goto free_tbps;
> > >>>> +	}
> > >>>> +
> > >>>> +	for (i = 0; i < tz->ntrips; i++)
> > >>>> +		memcpy(&(tz->gtrips[i]),
> > >>>> &(tz->trips[i].temperature),
> > >>>> +		       sizeof(*tz->gtrips));
> > >>>> +
> > >>>>  finish:
> > >>>>  	of_node_put(child);
> > >>>>  	tz->mode = THERMAL_DEVICE_DISABLED;
> > >>>> @@ -793,6 +825,7 @@ static inline void
> > >>>> of_thermal_free_zone(struct __thermal_zone *tz) {
> > >>>>  	int i;
> > >>>>  
> > >>>> +	kfree(tz->gtrips);
> > >>>>  	for (i = 0; i < tz->num_tbps; i++)
> > >>>>  		of_node_put(tz->tbps[i].cooling_device);
> > >>>>  	kfree(tz->tbps);
> > Couldn't find the code that updates *gtrips as a result of
> > set_trip_temp via sysfs.
> > 
> > >>>> diff --git a/drivers/thermal/thermal_core.h
> > >>>> b/drivers/thermal/thermal_core.h index 466208c..a9580ca 100644
> > >>>> --- a/drivers/thermal/thermal_core.h
> > >>>> +++ b/drivers/thermal/thermal_core.h
> > >>>> @@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
> > >>>>  void of_thermal_destroy_zones(void);
> > >>>>  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > >>>>  bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > >>>> +const struct thermal_trip * const
> > >>>> +of_thermal_get_trip_points(struct thermal_zone_device *);
> > >>>>  #else
> > >>>>  static inline int of_parse_thermal_zones(void) { return 0; }
> > >>>>  static inline void of_thermal_destroy_zones(void) { }
> > >>>> @@ -102,6 +104,11 @@ static inline bool
> > >>>> of_thermal_is_trip_en(struct thermal_zone_device *, int) {
> > >>>
> > >>> This produces compilation error when CONFIG_THERMAL_OF is not
> > >>> set. Name the parameters to fix.
> > >>
> > >> As all the other cases, I will fix that.
> > >>
> > >>>
> > >>>>  	return 0;
> > >>>>  }
> > >>>> +static inline const struct thermal_trip * const
> > >>>> +of_thermal_get_trip_points(struct thermal_zone_device *)
> > >>>> +{
> > >>>> +	return NULL;
> > >>>> +}
> > >>>>  #endif
> > >>>>  
> > >>>>  #endif /* __THERMAL_CORE_H__ */
> > >>>> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > >>>> index 5bc28a7..88d7249 100644
> > >>>> --- a/include/linux/thermal.h
> > >>>> +++ b/include/linux/thermal.h
> > >>>> @@ -303,6 +303,20 @@ struct thermal_zone_of_device_ops {
> > >>>>  	int (*get_trend)(void *, long *);
> > >>>>  };
> > >>>>  
> > >>>> +/**
> > >>>> + * struct thermal_trip - Structure representing themal trip
> > >>>> points exported from
> > >>>> + *                       of-thermal
> > >>>> + *
> > >>>
> > >>> The only problem I have with this name is that would look like
> > >>> it is in use in all thermal framework, which is not really the
> > >>> case. But I do think having a type here is a good thing. So,
> > >>> not sure :-)
> > >>
> > >> It can stay to be struct thermal_trip or we can rename it to
> > >> struct of_thermal_trip.
> > >>
> > >> I'm fine with both names.
> > > 
> > > Leave it as 'thermal_trip'.
> > > 
> > >>
> > >>>
> > >>>> + * @temperature:	trip point temperature
> > >>>> + * @hysteresis:		trip point hysteresis
> > >>>> + * @type:		trip point type
> > >>>> + */
> > >>>> +struct thermal_trip {
> > >>>> +	unsigned long int temperature;
> > >>>> +	unsigned long int hysteresis;
> > >>>> +	enum thermal_trip_type type;
> > >>>> +};
> > >>>> +
> > >>>>  /* Function declarations */
> > >>>>  #ifdef CONFIG_THERMAL_OF
> > >>>>  struct thermal_zone_device *
> > >>>> -- 
> > >>>> 2.0.0.rc2
> > >>>>
> > >>
> > >>
> > >>
> > >> -- 
> > >> Best regards,
> > >>
> > >> Lukasz Majewski
> > >>
> > >> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
> > > 
> > > * Unknown Key
> > > * 0x7DA4E256
> > > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points
@ 2014-11-27  9:42                 ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-11-27  9:42 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: navneet kumar, Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang

Hi Eduardo,

> 
> Hello Navneet,
> 
> On Wed, Nov 26, 2014 at 12:43:18PM -0800, navneet kumar wrote:
> > 
> > Hi Eduardo, Lukasz,
> > 
> > [Combining my concerns as a single text blob here]
> > 
> > I. Firstly, with the current patch
> > 	1. is it really needed to duplicate the struct
> > thermal_trip? Why don’t we get rid of the __thermal_trip and stay
> > with the 'thermal_trip' ? it is not a big change.

The __thermal_trip seems to be somehow "private" structure (to
of-thermal) which holds not only data which could be exposed to sensors.

> > 
> > 	2. gtrips is not updated on "set_trip_temp" etc. actions
> > via sysfs. (am I missing something?).

True. This is a bug. Thanks for spotting.

> > 
> 
> Good! Comments are always welcome, that's how we make patches :-).
> 
> Both above make sense to me.
> 
> > II. The other concern is more of a design question
> > 	1. Do we intend to keep the of-thermal as a middle layer
> > between the thermal_core and the sensor device? OR, is the role of
> > of-thermal just to parse the DT and opt out ? currently of-thermal
> > is somewhat a hybrid of these as, in addition to parsing the dt, it
> > holds on to the data related to trip points etc. etc.
> > 
> 
> of-thermal has always been as your latter statement, and I intend to
> keep it as it should be, just a of parser for thermal data.

It seems to me that now of-thermal is doing more than parsing
thermal data. 

For example it is an abstraction layer for
calling .get_temp(), .get_trend().

It has its own set of "private" trip points which aren't exposed to
sensors.

Also, it registers thermal_zone_device.

A lot of stuff is done by the of-thermal. Frankly, I don't
mind, since this is a common code for many sensors.

For example with of-thermal.c usage, we are able to cut down LOC number
by half for Exynos TMU when moving to OF.

> 
> > 	2. assuming latter is true (OF is just a dt parser helper):
> > we should not be adding more intelligence and dependencies linked
> > to the OF.
> > 
> 
> Yes this is right. We should never be adding intelligence to it,

But a lot of stuff is already added and to be worse it is well adopted
API by sensors.

> except for parsing the thermal data out of device tree and adding the
> proper structures inside the kernel.

In my understanding the of-thermal code to expose the above features
need to:
- parse device tree
- export trip points in a table to sensors
- export cpu frequencies (OPPs?) with information about corresponding
  temperature

And that is all. The sensor is then responsible for initializing HW and
register the thermal zone with thermal_core.


> 
> > 	3. assuming former is true (OF is a well-defined middle
> > layer): All is good till the point OF maintains the trip points
> > (which is a good thing since, OF caches on to the data); BUT, if we
> > expose this information to the sensor device too (as this patch is
> > doing),
> > 
> 
> the former is not true.
> 
> > 		3a. we violate the layering principle :-)
> > 

Are we? of-thermal.c is parsing DT and it exposes read only information
about trip points. Also it gives you information about e.g. number of
available trip points.

> 
> well, even if it was, I disagree here. :-) The split between data
> coming from DT and the driver is still in place. Besides, there is
> other layers that expose some of their data, and that doesn't violate
> their layering principles. CPUfreq, for one closer example, exposes
> its freq table.
> 
> It would be different if by exposing this data, the users would be
> affecting the behavior of the layer. And that is not the intention of
> cpufreq table. In the same way, that is not the intention of this
> patch.
> 
> > 		3b. more importantly, this is all just excessive
> > logic that we put in which *could be useful* only if we intend to
> > extend the role of OF as a trip point management layer that does
> > more than just holding on to the data. This may include -
> > 
> > 			-> The sensor devices to know nothing about
> > the trip_points, instead the sensor devices would work on
> > 			"temperature thresholds" and OF would map
> > sensor thresholds to the actual trip points as needed
> > 			(configured from DT); while the sensor
> > devices stick to using "thresholds".
> > 
> > 			-> Queuing from above, sensors, most of the
> > time, only need to know a high and a low temp threshold; which
> > 			essentially is a subset of the
> > active/passive etc. trip points. Calculation of that based on the
> > current temp, as of today is replicated across all the sensor
> > drivers and can be hoisted up to the of-thermal.
> > 
> 
> There is no intention to add such logic to of thermal. The main reason
> is of-thermal should never be competing with thermal core. Any
> extension in of-thermal needs to be supported by thermal core.
> 
> I believe all the above is left currently to thermal zone device
> drivers. The problem with of-thermal is that it had to be born as a
> thermal zone device driver. And that is because..
> 
> > Seems like this is the opportune time to make a call about the role
> > of of-thermal?
> > 
> 
> .. the point one may be missing here is the fact that with current
> thermal subsystem implementation, handling thermal devices is somewhat
> different from other devices within the kernel.
> 
> The real design issue (or not an issue) we have is the fact that
> thermal drivers adds both the driver and the device. Changing that is
> somewhat disruptive. Not impossible, but requires considering the
> existing driver's code.
> 
> If we had a better split from who adds the device and who provides the
> driver, then of-thermal would never be a "glue layer" or born as
> thermal zone device driver. It would simply, parse DT, add the
> devices, done.
> 
> Then, drivers would register themselves as handlers for specific
> thermal devices. That is the correct design, based on common design
> found in other parts of the kernel. Another little missing end would
> be the "compatible" string for thermal zone devices in DT. But as I
> said, it should not be a blocker.
> 
> So, given the current situation, we have essentially two options: (a)
> stick to the same design we have for now, having of-thermal as dummy
> as possible, and grow in small steps towards the correct design; or
> (b) redesign thermal core to have a better split between devices and
> drivers, then adjust of-thermal.
> 
> 
> For now, the path we are taking is (a). In fact, to fit the needs of
> coming drivers, specially considering they are based on DT booting
> platforms, it is always tempting to add intelligence to of-thermal.
> But, as I mentioned, I want to avoid growing intelligence in it, for
> obvious reasons.

Eventually, it is your call if we make __thermal_trip [1] exported to
sensors (with or without struct device_node *np)
 or if we have new structure (e.g. struct thermal_trip) which is a read
only reference to relevant fields of [1]?

> 
> > On 11/26/2014 07:18 AM, Eduardo Valentin wrote:
> > > * PGP Signed by an unknown key
> > > 
> > > Hello,
> > > 
> > > On Wed, Nov 26, 2014 at 09:35:10AM +0100, Lukasz Majewski wrote:
> > >> Hi Eduardo,
> > >>
> > >>> Hello Lukasz,
> > >>>
> > >>> On Thu, Nov 20, 2014 at 05:21:27PM +0100, Lukasz Majewski wrote:
> > >>>> This patch extends the of-thermal.c to export copy of trip
> > >>>> points for a given thermal zone.
> > >>>>
> > >>>> Thermal drivers should use of_thermal_get_trip_points() method
> > >>>> to get pointer to table of thermal trip points.
> > >>>>
> > >>>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > >>>> ---
> > >>>> Changes for v2:
> > >>>> - New patch - as suggested by Eduardo Valentin
> > >>>> ---
> > >>>>  drivers/thermal/of-thermal.c   | 33
> > >>>> +++++++++++++++++++++++++++++++++
> > >>>> drivers/thermal/thermal_core.h | 7 +++++++
> > >>>> include/linux/thermal.h        | 14 ++++++++++++++ 3 files
> > >>>> changed, 54 insertions(+)
> > >>>>
> > >>>> diff --git a/drivers/thermal/of-thermal.c
> > >>>> b/drivers/thermal/of-thermal.c index 336af7f..33921c5 100644
> > >>>> --- a/drivers/thermal/of-thermal.c
> > >>>> +++ b/drivers/thermal/of-thermal.c
> > >>>> @@ -89,6 +89,7 @@ struct __thermal_zone {
> > >>>>  	/* trip data */
> > >>>>  	int ntrips;
> > >>>>  	struct __thermal_trip *trips;
> > >>>> +	struct thermal_trip *gtrips;
> > Do we really need this duplication ?
> > >>>>  
> > >>>>  	/* cooling binding data */
> > >>>>  	int num_tbps;
> > >>>> @@ -152,6 +153,27 @@ bool of_thermal_is_trip_en(struct
> > >>>> thermal_zone_device *tz, int trip) return true;
> > >>>>  }
> > >>>>  
> > >>>> +/**
> > >>>> + * of_thermal_get_trip_points - function to get access to a
> > >>>> globally exported
> > >>>> + *				trip points
> > >>>> + *
> > >>>> + * @tz:	pointer to a thermal zone
> > >>>> + *
> > >>>> + * This function provides a pointer to the copy of trip points
> > >>>> table
> > >>>> + *
> > >>>> + * Return: pointer to trip points table, NULL otherwise
> > >>>> + */
> > >>>> +const struct thermal_trip * const
> > >>>> +of_thermal_get_trip_points(struct thermal_zone_device *tz)
> > >>>> +{
> > >>>> +	struct __thermal_zone *data = tz->devdata;
> > >>>> +
> > >>>> +	if (!data)
> > >>>> +		return NULL;
> > >>>> +
> > >>>> +	return data->gtrips;
> > >>>> +}
> > >>>> +
> > >>>
> > >>> EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);
> > >>
> > >> Ok.
> > >>
> > >>>
> > >>>>  static int of_thermal_get_trend(struct thermal_zone_device
> > >>>> *tz, int trip, enum thermal_trend *trend)
> > >>>>  {
> > >>>> @@ -767,6 +789,16 @@ thermal_of_build_thermal_zone(struct
> > >>>> device_node *np) goto free_tbps;
> > >>>>  	}
> > >>>>  
> > >>>> +	tz->gtrips = kcalloc(tz->ntrips, sizeof(*tz->gtrips),
> > >>>> GFP_KERNEL);
> > >>>> +	if (!tz->gtrips) {
> > >>>> +		ret = -ENOMEM;
> > >>>> +		goto free_tbps;
> > >>>> +	}
> > >>>> +
> > >>>> +	for (i = 0; i < tz->ntrips; i++)
> > >>>> +		memcpy(&(tz->gtrips[i]),
> > >>>> &(tz->trips[i].temperature),
> > >>>> +		       sizeof(*tz->gtrips));
> > >>>> +
> > >>>>  finish:
> > >>>>  	of_node_put(child);
> > >>>>  	tz->mode = THERMAL_DEVICE_DISABLED;
> > >>>> @@ -793,6 +825,7 @@ static inline void
> > >>>> of_thermal_free_zone(struct __thermal_zone *tz) {
> > >>>>  	int i;
> > >>>>  
> > >>>> +	kfree(tz->gtrips);
> > >>>>  	for (i = 0; i < tz->num_tbps; i++)
> > >>>>  		of_node_put(tz->tbps[i].cooling_device);
> > >>>>  	kfree(tz->tbps);
> > Couldn't find the code that updates *gtrips as a result of
> > set_trip_temp via sysfs.
> > 
> > >>>> diff --git a/drivers/thermal/thermal_core.h
> > >>>> b/drivers/thermal/thermal_core.h index 466208c..a9580ca 100644
> > >>>> --- a/drivers/thermal/thermal_core.h
> > >>>> +++ b/drivers/thermal/thermal_core.h
> > >>>> @@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
> > >>>>  void of_thermal_destroy_zones(void);
> > >>>>  int of_thermal_get_ntrips(struct thermal_zone_device *);
> > >>>>  bool of_thermal_is_trip_en(struct thermal_zone_device *, int);
> > >>>> +const struct thermal_trip * const
> > >>>> +of_thermal_get_trip_points(struct thermal_zone_device *);
> > >>>>  #else
> > >>>>  static inline int of_parse_thermal_zones(void) { return 0; }
> > >>>>  static inline void of_thermal_destroy_zones(void) { }
> > >>>> @@ -102,6 +104,11 @@ static inline bool
> > >>>> of_thermal_is_trip_en(struct thermal_zone_device *, int) {
> > >>>
> > >>> This produces compilation error when CONFIG_THERMAL_OF is not
> > >>> set. Name the parameters to fix.
> > >>
> > >> As all the other cases, I will fix that.
> > >>
> > >>>
> > >>>>  	return 0;
> > >>>>  }
> > >>>> +static inline const struct thermal_trip * const
> > >>>> +of_thermal_get_trip_points(struct thermal_zone_device *)
> > >>>> +{
> > >>>> +	return NULL;
> > >>>> +}
> > >>>>  #endif
> > >>>>  
> > >>>>  #endif /* __THERMAL_CORE_H__ */
> > >>>> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > >>>> index 5bc28a7..88d7249 100644
> > >>>> --- a/include/linux/thermal.h
> > >>>> +++ b/include/linux/thermal.h
> > >>>> @@ -303,6 +303,20 @@ struct thermal_zone_of_device_ops {
> > >>>>  	int (*get_trend)(void *, long *);
> > >>>>  };
> > >>>>  
> > >>>> +/**
> > >>>> + * struct thermal_trip - Structure representing themal trip
> > >>>> points exported from
> > >>>> + *                       of-thermal
> > >>>> + *
> > >>>
> > >>> The only problem I have with this name is that would look like
> > >>> it is in use in all thermal framework, which is not really the
> > >>> case. But I do think having a type here is a good thing. So,
> > >>> not sure :-)
> > >>
> > >> It can stay to be struct thermal_trip or we can rename it to
> > >> struct of_thermal_trip.
> > >>
> > >> I'm fine with both names.
> > > 
> > > Leave it as 'thermal_trip'.
> > > 
> > >>
> > >>>
> > >>>> + * @temperature:	trip point temperature
> > >>>> + * @hysteresis:		trip point hysteresis
> > >>>> + * @type:		trip point type
> > >>>> + */
> > >>>> +struct thermal_trip {
> > >>>> +	unsigned long int temperature;
> > >>>> +	unsigned long int hysteresis;
> > >>>> +	enum thermal_trip_type type;
> > >>>> +};
> > >>>> +
> > >>>>  /* Function declarations */
> > >>>>  #ifdef CONFIG_THERMAL_OF
> > >>>>  struct thermal_zone_device *
> > >>>> -- 
> > >>>> 2.0.0.rc2
> > >>>>
> > >>
> > >>
> > >>
> > >> -- 
> > >> Best regards,
> > >>
> > >> Lukasz Majewski
> > >>
> > >> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
> > > 
> > > * Unknown Key
> > > * 0x7DA4E256
> > > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v3 0/5] thermal: of: of-thermal.c API extensions
  2014-11-20 16:21 ` [PATCH v2 0/4] thermal: of: of-thermal.c API extensions Lukasz Majewski
                     ` (3 preceding siblings ...)
  2014-11-20 16:21   ` [PATCH v2 4/4] thermal: of: Extend current of-thermal.c code to allow setting emulated temp Lukasz Majewski
@ 2014-12-08 17:04   ` Lukasz Majewski
  2014-12-08 17:04     ` [PATCH v3 1/5] thermal: of: Extend of-thermal.c to provide number of trip points Lukasz Majewski
                       ` (5 more replies)
  4 siblings, 6 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-08 17:04 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, Thierry Reding, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Mikko Perttunen, Stephen Warren,
	Abhilash Kesavan, Abhilash Kesavan, Guenter Roeck, linux-kernel,
	Caesar Wang, navneet kumar, Lukasz Majewski

Provided patch series extend of-thermal.c file API. It is necessary 
for ongoing Exynos TMU rework.

First version of this code can be found at:
http://www.spinics.net/lists/linux-samsung-soc/msg37719.html

Second version:
http://www.spinics.net/lists/kernel/msg1872274.html

This code provides methods to access some of-thermal local data.
Moreover it provides a read only access to of-thermal trip points.

Lukasz Majewski (5):
  thermal: of: Extend of-thermal.c to provide number of trip points
  thermal: of: Extend of-thermal.c to provide check if trip point is
    valid
  thermal: of: Rename struct __thermal_trip to struct thermal_trip
  thermal: of: Extend of-thermal to export table of trip points
  thermal: of: Extend current of-thermal.c code to allow setting
    emulated temp

 drivers/thermal/of-thermal.c   | 109 ++++++++++++++++++++++++++++++++++-------
 drivers/thermal/thermal_core.h |  18 +++++++
 include/linux/thermal.h        |  18 +++++++
 3 files changed, 127 insertions(+), 18 deletions(-)

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v3 1/5] thermal: of: Extend of-thermal.c to provide number of trip points
  2014-12-08 17:04   ` [PATCH v3 0/5] thermal: of: of-thermal.c API extensions Lukasz Majewski
@ 2014-12-08 17:04     ` Lukasz Majewski
  2014-12-08 19:52       ` Eduardo Valentin
  2014-12-08 17:04     ` [PATCH v3 2/5] thermal: of: Extend of-thermal.c to provide check if trip point is valid Lukasz Majewski
                       ` (4 subsequent siblings)
  5 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-08 17:04 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, Thierry Reding, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Mikko Perttunen, Stephen Warren,
	Abhilash Kesavan, Abhilash Kesavan, Guenter Roeck, linux-kernel,
	Caesar Wang, navneet kumar, Lukasz Majewski

This patch extends the of-thermal.c to provide information about number of
available trip points.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v3:
- Exporting of_thermal_get_ntrips symbol as a GPL
- Fix build error when CONFIG_THERMAL_OF is disabled

Changes for v2:
- Provide detailed (doxygen like) description of the of_thermal_get_ntrips()
  method
- Check for data pointer not being NULL
---
 drivers/thermal/of-thermal.c   | 21 +++++++++++++++++++++
 drivers/thermal/thermal_core.h |  5 +++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index b7982f0..7facd23 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -112,6 +112,27 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
 	return data->ops->get_temp(data->sensor_data, temp);
 }
 
+/**
+ * of_thermal_get_ntrips - function to export number of available trip
+ *			   points.
+ * @tz: pointer to a thermal zone
+ *
+ * This function is a globally visible wrapper to get number of trip points
+ * stored in the local struct __thermal_zone
+ *
+ * Return: number of available trip points, -ENODEV when data not available
+ */
+int of_thermal_get_ntrips(struct thermal_zone_device *tz)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	if (!data || IS_ERR(data))
+		return -ENODEV;
+
+	return data->ntrips;
+}
+EXPORT_SYMBOL_GPL(of_thermal_get_ntrips);
+
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 				enum thermal_trend *trend)
 {
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index d15d243..1cc5041 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -89,9 +89,14 @@ static inline void thermal_gov_user_space_unregister(void) {}
 #ifdef CONFIG_THERMAL_OF
 int of_parse_thermal_zones(void);
 void of_thermal_destroy_zones(void);
+int of_thermal_get_ntrips(struct thermal_zone_device *);
 #else
 static inline int of_parse_thermal_zones(void) { return 0; }
 static inline void of_thermal_destroy_zones(void) { }
+static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz)
+{
+	return 0;
+}
 #endif
 
 #endif /* __THERMAL_CORE_H__ */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 2/5] thermal: of: Extend of-thermal.c to provide check if trip point is valid
  2014-12-08 17:04   ` [PATCH v3 0/5] thermal: of: of-thermal.c API extensions Lukasz Majewski
  2014-12-08 17:04     ` [PATCH v3 1/5] thermal: of: Extend of-thermal.c to provide number of trip points Lukasz Majewski
@ 2014-12-08 17:04     ` Lukasz Majewski
  2014-12-08 17:04     ` [PATCH v3 3/5] thermal: of: Rename struct __thermal_trip to struct thermal_trip Lukasz Majewski
                       ` (3 subsequent siblings)
  5 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-08 17:04 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, Thierry Reding, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Mikko Perttunen, Stephen Warren,
	Abhilash Kesavan, Abhilash Kesavan, Guenter Roeck, linux-kernel,
	Caesar Wang, navneet kumar, Lukasz Majewski

This patch extends the of-thermal.c to provide check if trip point is
valid.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v3:
- Rename of_thermal_is_trip_en() to of_thermal_is_trip_valid()
- Export of_thermal_is_trip_valid symbol as GPL
- Fix the build error when CONFIG_THERMAL_OF is not defined

Changes for v2:
- Replace int with bool
- Replace 1/0 with true/false
- Add check if data pointer is not NULL
- Add missing doxygen style comment for the function
---
 drivers/thermal/of-thermal.c   | 21 +++++++++++++++++++++
 drivers/thermal/thermal_core.h |  6 ++++++
 2 files changed, 27 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 7facd23..87b9cfe 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -133,6 +133,27 @@ int of_thermal_get_ntrips(struct thermal_zone_device *tz)
 }
 EXPORT_SYMBOL_GPL(of_thermal_get_ntrips);
 
+/**
+ * of_thermal_is_trip_valid - function to check if trip point is valid
+ *
+ * @tz:	pointer to a thermal zone
+ * @trip:	trip point to evaluate
+ *
+ * This function is responsible for checking if passed trip point is valid
+ *
+ * Return: true if trip point is valid, false otherwise
+ */
+bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	if (!data || trip >= data->ntrips || trip < 0)
+		return false;
+
+	return true;
+}
+EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid);
+
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 				enum thermal_trend *trend)
 {
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 1cc5041..58a0dfa 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -90,6 +90,7 @@ static inline void thermal_gov_user_space_unregister(void) {}
 int of_parse_thermal_zones(void);
 void of_thermal_destroy_zones(void);
 int of_thermal_get_ntrips(struct thermal_zone_device *);
+bool of_thermal_is_trip_valid(struct thermal_zone_device *, int);
 #else
 static inline int of_parse_thermal_zones(void) { return 0; }
 static inline void of_thermal_destroy_zones(void) { }
@@ -97,6 +98,11 @@ static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz)
 {
 	return 0;
 }
+static inline bool of_thermal_is_trip_valid(struct thermal_zone_device *tz,
+					    int trip)
+{
+	return 0;
+}
 #endif
 
 #endif /* __THERMAL_CORE_H__ */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 3/5] thermal: of: Rename struct __thermal_trip to struct thermal_trip
  2014-12-08 17:04   ` [PATCH v3 0/5] thermal: of: of-thermal.c API extensions Lukasz Majewski
  2014-12-08 17:04     ` [PATCH v3 1/5] thermal: of: Extend of-thermal.c to provide number of trip points Lukasz Majewski
  2014-12-08 17:04     ` [PATCH v3 2/5] thermal: of: Extend of-thermal.c to provide check if trip point is valid Lukasz Majewski
@ 2014-12-08 17:04     ` Lukasz Majewski
  2014-12-08 17:04     ` [PATCH v3 4/5] thermal: of: Extend of-thermal to export table of trip points Lukasz Majewski
                       ` (2 subsequent siblings)
  5 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-08 17:04 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, Thierry Reding, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Mikko Perttunen, Stephen Warren,
	Abhilash Kesavan, Abhilash Kesavan, Guenter Roeck, linux-kernel,
	Caesar Wang, navneet kumar, Lukasz Majewski

This patch changes name of struct __thermal_trip to thermal_trip and moves
declaration of the latter to ./include/linux/thermal.h for better visibility.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v3:
- New patch - as suggested by Navneet Kumar
---
 drivers/thermal/of-thermal.c | 21 +++------------------
 include/linux/thermal.h      | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 87b9cfe..d3ac117 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -37,21 +37,6 @@
 /***   Private data structures to represent thermal device tree data ***/
 
 /**
- * struct __thermal_trip - representation of a point in temperature domain
- * @np: pointer to struct device_node that this trip point was created from
- * @temperature: temperature value in miliCelsius
- * @hysteresis: relative hysteresis in miliCelsius
- * @type: trip point type
- */
-
-struct __thermal_trip {
-	struct device_node *np;
-	unsigned long int temperature;
-	unsigned long int hysteresis;
-	enum thermal_trip_type type;
-};
-
-/**
  * struct __thermal_bind_param - a match between trip and cooling device
  * @cooling_device: a pointer to identify the referred cooling device
  * @trip_id: the trip point index
@@ -88,7 +73,7 @@ struct __thermal_zone {
 
 	/* trip data */
 	int ntrips;
-	struct __thermal_trip *trips;
+	struct thermal_trip *trips;
 
 	/* cooling binding data */
 	int num_tbps;
@@ -538,7 +523,7 @@ EXPORT_SYMBOL_GPL(thermal_zone_of_sensor_unregister);
  */
 static int thermal_of_populate_bind_params(struct device_node *np,
 					   struct __thermal_bind_params *__tbp,
-					   struct __thermal_trip *trips,
+					   struct thermal_trip *trips,
 					   int ntrips)
 {
 	struct of_phandle_args cooling_spec;
@@ -641,7 +626,7 @@ static int thermal_of_get_trip_type(struct device_node *np,
  * Return: 0 on success, proper error code otherwise
  */
 static int thermal_of_populate_trip(struct device_node *np,
-				    struct __thermal_trip *trip)
+				    struct thermal_trip *trip)
 {
 	int prop;
 	int ret;
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 5bc28a7..b8d91ef 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -303,6 +303,21 @@ struct thermal_zone_of_device_ops {
 	int (*get_trend)(void *, long *);
 };
 
+/**
+ * struct thermal_trip - representation of a point in temperature domain
+ * @np: pointer to struct device_node that this trip point was created from
+ * @temperature: temperature value in miliCelsius
+ * @hysteresis: relative hysteresis in miliCelsius
+ * @type: trip point type
+ */
+
+struct thermal_trip {
+	struct device_node *np;
+	unsigned long int temperature;
+	unsigned long int hysteresis;
+	enum thermal_trip_type type;
+};
+
 /* Function declarations */
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 4/5] thermal: of: Extend of-thermal to export table of trip points
  2014-12-08 17:04   ` [PATCH v3 0/5] thermal: of: of-thermal.c API extensions Lukasz Majewski
                       ` (2 preceding siblings ...)
  2014-12-08 17:04     ` [PATCH v3 3/5] thermal: of: Rename struct __thermal_trip to struct thermal_trip Lukasz Majewski
@ 2014-12-08 17:04     ` Lukasz Majewski
  2014-12-08 17:04     ` [PATCH v3 5/5] thermal: of: Extend current of-thermal.c code to allow setting emulated temp Lukasz Majewski
  2014-12-09  1:21     ` [PATCH v3 0/5] thermal: of: of-thermal.c API extensions Eduardo Valentin
  5 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-08 17:04 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, Thierry Reding, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Mikko Perttunen, Stephen Warren,
	Abhilash Kesavan, Abhilash Kesavan, Guenter Roeck, linux-kernel,
	Caesar Wang, navneet kumar, Lukasz Majewski

This patch extends the of-thermal.c to export trip points for a given
thermal zone.

Thermal drivers should use of_thermal_get_trip_points() method to get
pointer to table of thermal trip points.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v3:
- Export of_thermal_get_trip_points symbol as GPL
- Fix the build error when CONFIG_THERMAL_OF is not defined

Changes for v2:
- New patch - as suggested by Eduardo Valentin
---
 drivers/thermal/of-thermal.c   | 22 ++++++++++++++++++++++
 drivers/thermal/thermal_core.h |  7 +++++++
 2 files changed, 29 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index d3ac117..e062bf5 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -139,6 +139,28 @@ bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip)
 }
 EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid);
 
+/**
+ * of_thermal_get_trip_points - function to get access to a globally exported
+ *				trip points
+ *
+ * @tz:	pointer to a thermal zone
+ *
+ * This function provides a pointer to trip points table
+ *
+ * Return: pointer to trip points table, NULL otherwise
+ */
+const struct thermal_trip * const
+of_thermal_get_trip_points(struct thermal_zone_device *tz)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	if (!data)
+		return NULL;
+
+	return data->trips;
+}
+EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);
+
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 				enum thermal_trend *trend)
 {
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 58a0dfa..9083e75 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -91,6 +91,8 @@ int of_parse_thermal_zones(void);
 void of_thermal_destroy_zones(void);
 int of_thermal_get_ntrips(struct thermal_zone_device *);
 bool of_thermal_is_trip_valid(struct thermal_zone_device *, int);
+const struct thermal_trip * const
+of_thermal_get_trip_points(struct thermal_zone_device *);
 #else
 static inline int of_parse_thermal_zones(void) { return 0; }
 static inline void of_thermal_destroy_zones(void) { }
@@ -103,6 +105,11 @@ static inline bool of_thermal_is_trip_valid(struct thermal_zone_device *tz,
 {
 	return 0;
 }
+static inline const struct thermal_trip * const
+of_thermal_get_trip_points(struct thermal_zone_device *tz)
+{
+	return NULL;
+}
 #endif
 
 #endif /* __THERMAL_CORE_H__ */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 5/5] thermal: of: Extend current of-thermal.c code to allow setting emulated temp
  2014-12-08 17:04   ` [PATCH v3 0/5] thermal: of: of-thermal.c API extensions Lukasz Majewski
                       ` (3 preceding siblings ...)
  2014-12-08 17:04     ` [PATCH v3 4/5] thermal: of: Extend of-thermal to export table of trip points Lukasz Majewski
@ 2014-12-08 17:04     ` Lukasz Majewski
  2014-12-09  1:21     ` [PATCH v3 0/5] thermal: of: of-thermal.c API extensions Eduardo Valentin
  5 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-08 17:04 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, Thierry Reding, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Mikko Perttunen, Stephen Warren,
	Abhilash Kesavan, Abhilash Kesavan, Guenter Roeck, linux-kernel,
	Caesar Wang, navneet kumar, Lukasz Majewski

Before this change it was only possible to set get_temp() and get_trend()
methods to be used in the common code handling passing parameters via
device tree to "cpu-thermal" CPU thermal zone device.

Now it is possible to also set emulated value of temperature for debug
purposes.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v3:
- Update comment for .set_emul_temp method to indicate that it is optional

Changes for v2:
- Rework the emulated temperature setting code to use of_thermal_sensor_ops
structure
---
 drivers/thermal/of-thermal.c | 24 ++++++++++++++++++++++++
 include/linux/thermal.h      |  3 +++
 2 files changed, 27 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index e062bf5..e145b66 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -161,6 +161,28 @@ of_thermal_get_trip_points(struct thermal_zone_device *tz)
 }
 EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);
 
+/**
+ * of_thermal_set_emul_temp - function to set emulated temperature
+ *
+ * @tz:	pointer to a thermal zone
+ * @temp:	temperature to set
+ *
+ * This function gives the ability to set emulated value of temperature,
+ * which is handy for debugging
+ *
+ * Return: zero on success, error code otherwise
+ */
+static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
+				    unsigned long temp)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	if (!data->ops || !data->ops->set_emul_temp)
+		return -EINVAL;
+
+	return data->ops->set_emul_temp(data->sensor_data, temp);
+}
+
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 				enum thermal_trend *trend)
 {
@@ -392,6 +414,7 @@ thermal_zone_of_add_sensor(struct device_node *zone,
 
 	tzd->ops->get_temp = of_thermal_get_temp;
 	tzd->ops->get_trend = of_thermal_get_trend;
+	tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
 	mutex_unlock(&tzd->lock);
 
 	return tzd;
@@ -520,6 +543,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 	mutex_lock(&tzd->lock);
 	tzd->ops->get_temp = NULL;
 	tzd->ops->get_trend = NULL;
+	tzd->ops->set_emul_temp = NULL;
 
 	tz->ops = NULL;
 	tz->sensor_data = NULL;
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index b8d91ef..99be7fc 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -297,10 +297,13 @@ struct thermal_genl_event {
  *
  * Optional:
  * @get_trend: a pointer to a function that reads the sensor temperature trend.
+ * @set_emul_temp: a pointer to a function that sets sensor emulated
+ *		   temperature.
  */
 struct thermal_zone_of_device_ops {
 	int (*get_temp)(void *, long *);
 	int (*get_trend)(void *, long *);
+	int (*set_emul_temp)(void *, unsigned long);
 };
 
 /**
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 1/5] thermal: of: Extend of-thermal.c to provide number of trip points
  2014-12-08 17:04     ` [PATCH v3 1/5] thermal: of: Extend of-thermal.c to provide number of trip points Lukasz Majewski
@ 2014-12-08 19:52       ` Eduardo Valentin
  2014-12-08 23:02         ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2014-12-08 19:52 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang, navneet kumar

[-- Attachment #1: Type: text/plain, Size: 2938 bytes --]

On Mon, Dec 08, 2014 at 06:04:17PM +0100, Lukasz Majewski wrote:
> This patch extends the of-thermal.c to provide information about number of
> available trip points.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v3:
> - Exporting of_thermal_get_ntrips symbol as a GPL
> - Fix build error when CONFIG_THERMAL_OF is disabled
> 
> Changes for v2:
> - Provide detailed (doxygen like) description of the of_thermal_get_ntrips()
>   method
> - Check for data pointer not being NULL
> ---
>  drivers/thermal/of-thermal.c   | 21 +++++++++++++++++++++
>  drivers/thermal/thermal_core.h |  5 +++++
>  2 files changed, 26 insertions(+)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index b7982f0..7facd23 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -112,6 +112,27 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
>  	return data->ops->get_temp(data->sensor_data, temp);
>  }
>  
> +/**
> + * of_thermal_get_ntrips - function to export number of available trip
> + *			   points.
> + * @tz: pointer to a thermal zone
> + *
> + * This function is a globally visible wrapper to get number of trip points
> + * stored in the local struct __thermal_zone
> + *
> + * Return: number of available trip points, -ENODEV when data not available
> + */
> +int of_thermal_get_ntrips(struct thermal_zone_device *tz)
> +{
> +	struct __thermal_zone *data = tz->devdata;
> +
> +	if (!data || IS_ERR(data))
> +		return -ENODEV;
> +
> +	return data->ntrips;
> +}
> +EXPORT_SYMBOL_GPL(of_thermal_get_ntrips);
> +
>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
>  				enum thermal_trend *trend)
>  {
> diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> index d15d243..1cc5041 100644
> --- a/drivers/thermal/thermal_core.h
> +++ b/drivers/thermal/thermal_core.h
> @@ -89,9 +89,14 @@ static inline void thermal_gov_user_space_unregister(void) {}
>  #ifdef CONFIG_THERMAL_OF
>  int of_parse_thermal_zones(void);
>  void of_thermal_destroy_zones(void);
> +int of_thermal_get_ntrips(struct thermal_zone_device *);

Lukasz,

Here is a question that applies to all patches in this series adding
functions in this header.

i suppose you intend to use these new functions in driver code, right?
Add them here, will limit their usage to code inside drivers/thermal.

Shouldn't these new APIs be declared under include/linux/thermal.h?

This way, they can be be available to other parts of the kernel too.


>  #else
>  static inline int of_parse_thermal_zones(void) { return 0; }
>  static inline void of_thermal_destroy_zones(void) { }
> +static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz)
> +{
> +	return 0;
> +}
>  #endif
>  
>  #endif /* __THERMAL_CORE_H__ */
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 1/5] thermal: of: Extend of-thermal.c to provide number of trip points
  2014-12-08 19:52       ` Eduardo Valentin
@ 2014-12-08 23:02         ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-08 23:02 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Lukasz Majewski, Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Mikko Perttunen, Stephen Warren,
	Abhilash Kesavan, Abhilash Kesavan, Guenter Roeck, linux-kernel,
	Caesar Wang, navneet kumar

[-- Attachment #1: Type: text/plain, Size: 3586 bytes --]

On Mon, 8 Dec 2014 15:52:49 -0400
Eduardo Valentin <edubezval@gmail.com> wrote:

Hi Eduardo,

> On Mon, Dec 08, 2014 at 06:04:17PM +0100, Lukasz Majewski wrote:
> > This patch extends the of-thermal.c to provide information about
> > number of available trip points.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v3:
> > - Exporting of_thermal_get_ntrips symbol as a GPL
> > - Fix build error when CONFIG_THERMAL_OF is disabled
> > 
> > Changes for v2:
> > - Provide detailed (doxygen like) description of the
> > of_thermal_get_ntrips() method
> > - Check for data pointer not being NULL
> > ---
> >  drivers/thermal/of-thermal.c   | 21 +++++++++++++++++++++
> >  drivers/thermal/thermal_core.h |  5 +++++
> >  2 files changed, 26 insertions(+)
> > 
> > diff --git a/drivers/thermal/of-thermal.c
> > b/drivers/thermal/of-thermal.c index b7982f0..7facd23 100644
> > --- a/drivers/thermal/of-thermal.c
> > +++ b/drivers/thermal/of-thermal.c
> > @@ -112,6 +112,27 @@ static int of_thermal_get_temp(struct
> > thermal_zone_device *tz, return
> > data->ops->get_temp(data->sensor_data, temp); }
> >  
> > +/**
> > + * of_thermal_get_ntrips - function to export number of available
> > trip
> > + *			   points.
> > + * @tz: pointer to a thermal zone
> > + *
> > + * This function is a globally visible wrapper to get number of
> > trip points
> > + * stored in the local struct __thermal_zone
> > + *
> > + * Return: number of available trip points, -ENODEV when data not
> > available
> > + */
> > +int of_thermal_get_ntrips(struct thermal_zone_device *tz)
> > +{
> > +	struct __thermal_zone *data = tz->devdata;
> > +
> > +	if (!data || IS_ERR(data))
> > +		return -ENODEV;
> > +
> > +	return data->ntrips;
> > +}
> > +EXPORT_SYMBOL_GPL(of_thermal_get_ntrips);
> > +
> >  static int of_thermal_get_trend(struct thermal_zone_device *tz,
> > int trip, enum thermal_trend *trend)
> >  {
> > diff --git a/drivers/thermal/thermal_core.h
> > b/drivers/thermal/thermal_core.h index d15d243..1cc5041 100644
> > --- a/drivers/thermal/thermal_core.h
> > +++ b/drivers/thermal/thermal_core.h
> > @@ -89,9 +89,14 @@ static inline void
> > thermal_gov_user_space_unregister(void) {} #ifdef CONFIG_THERMAL_OF
> >  int of_parse_thermal_zones(void);
> >  void of_thermal_destroy_zones(void);
> > +int of_thermal_get_ntrips(struct thermal_zone_device *);
> 
> Lukasz,
> 
> Here is a question that applies to all patches in this series adding
> functions in this header.
> 
> i suppose you intend to use these new functions in driver code, right?

Yes, right.

> Add them here, will limit their usage to code inside drivers/thermal.

This is my intention - at least for now the use case is to configure the
thermal driver (i.e. Exynos TMU). Other drivers (e.g. TI) can benefit
from this code too.

> 
> Shouldn't these new APIs be declared under include/linux/thermal.h?

I'd prefer to leave this API in ./drivers/thermal and move them to
./include/linux/thermal.h only when other parts of the kernel require
it.

> 
> This way, they can be be available to other parts of the kernel too.
> 
> 
> >  #else
> >  static inline int of_parse_thermal_zones(void) { return 0; }
> >  static inline void of_thermal_destroy_zones(void) { }
> > +static inline int of_thermal_get_ntrips(struct thermal_zone_device
> > *tz) +{
> > +	return 0;
> > +}
> >  #endif
> >  
> >  #endif /* __THERMAL_CORE_H__ */
> > -- 
> > 2.0.0.rc2
> > 

Best Regards,

Lukasz Majewski

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 0/5] thermal: of: of-thermal.c API extensions
  2014-12-08 17:04   ` [PATCH v3 0/5] thermal: of: of-thermal.c API extensions Lukasz Majewski
                       ` (4 preceding siblings ...)
  2014-12-08 17:04     ` [PATCH v3 5/5] thermal: of: Extend current of-thermal.c code to allow setting emulated temp Lukasz Majewski
@ 2014-12-09  1:21     ` Eduardo Valentin
  5 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2014-12-09  1:21 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Mikko Perttunen,
	Stephen Warren, Abhilash Kesavan, Abhilash Kesavan,
	Guenter Roeck, linux-kernel, Caesar Wang, navneet kumar

[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]

On Mon, Dec 08, 2014 at 06:04:16PM +0100, Lukasz Majewski wrote:
> Provided patch series extend of-thermal.c file API. It is necessary 
> for ongoing Exynos TMU rework.
> 
> First version of this code can be found at:
> http://www.spinics.net/lists/linux-samsung-soc/msg37719.html
> 
> Second version:
> http://www.spinics.net/lists/kernel/msg1872274.html
> 
> This code provides methods to access some of-thermal local data.
> Moreover it provides a read only access to of-thermal trip points.
> 
> Lukasz Majewski (5):
>   thermal: of: Extend of-thermal.c to provide number of trip points
>   thermal: of: Extend of-thermal.c to provide check if trip point is
>     valid
>   thermal: of: Rename struct __thermal_trip to struct thermal_trip
>   thermal: of: Extend of-thermal to export table of trip points
>   thermal: of: Extend current of-thermal.c code to allow setting
>     emulated temp

Applied the series in my -linus branch.

Cheers

> 
>  drivers/thermal/of-thermal.c   | 109 ++++++++++++++++++++++++++++++++++-------
>  drivers/thermal/thermal_core.h |  18 +++++++
>  include/linux/thermal.h        |  18 +++++++
>  3 files changed, 127 insertions(+), 18 deletions(-)
> 
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
@ 2014-12-10 10:27   ` Eduardo Valentin
  2014-12-10 14:19     ` Lukasz Majewski
  2014-12-10 12:09   ` [PATCH v2 01/17] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
                     ` (17 subsequent siblings)
  18 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2014-12-10 10:27 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 6941 bytes --]

On Wed, Dec 10, 2014 at 01:09:39PM +0100, Lukasz Majewski wrote:
> 1. Introduction
> 
> Following patches aim to clean up the current implementation of the thermal
> framework on Exynos devices.
> 
> The main goal was to use a generic code for reading thermal configuration
> (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
> were removed.
> 

Very good! Thanks for cleaning the code.

Given the decision to be DT only, my only question now is if you need to
support non-DT booting systems. Do you (Exynos platforms in general) care
about booting without DT?

If not, then removing makes completely sense to me.


> Around 400 lines of code (LOC) were removed directly by this patch, which
> is around 20% of the Exynos thermal code base.
> 

Great!

> This work should NOT bring any functional changes to Exynos thermal 
> subsystem.
> 

OK.

> 2. Patch-set structure
> 
> Then the cpu_cooling functionality has been preserved to allow cooling
> devices by reducing operating frequency. Definition of trip points and
> cpufreq's cooling properties were moved to device tree.
> 

uhh.. OK. but, by supporting of-thermal that means drivers should never
care about loading cpu cooling. That is done via cpufreq-dt. That is why
we had the cycle with cpufreq folks, remember?

(I will have a look in your patches)

> Then the rework of the way in which configuration data is provided to
> the Exynos thermal subsystem was performed. Now device tree is used for
> configuration.

This is very good. Do you care sending feedback if you need extra
configuration or does of-thermal cover your scenarios (a part from the
amendments you already did)?

I know people (tegra and rockchip) are interested in hw trip points,
which I believe should be of your interest too. Of course, that is maybe
an off-topic for this series.


> 
> Patch series end with removing exynos5250/exynos3250 TMU compatibles.
> Both SoCs have thermal management unit (TMU) compatible with the one first 
> introduced at Exynos4412.

OK. I will have a look in DT changes you did. But in general, removing
support needs to be done carefully for backward compatibility :-(.

> 
> 3. Dead code removal
> 
> Thermal support for some SoCs, previously available in the exynos_tmu_data.c 
> file, was removed since, as of (almost) 3.19-rc1, they didn't have TMU bindings.
> 
> Moreover, support for cpu_cooling devices was preserved only on those
> SoCs which had available and working cpufreq driver.


Have you tried your series with cpufreq-dt?

> 
> 4. Testing
> 
> Test devices:
> - Exynos4210 - Trats (TMU zone + cpu_cooling)
> - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> - Exynos5420 - Arndale-octa (only TMU zones)
> 
> Unfortunately, I don't posses Exynos5440 for testing. Its functionality
> has been preserved in the code, but not tested on the hardware. I would
> be grateful for help in testing.
> 
> 5. This work apply on the following tree:
> 
> kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> SHA1: c42c7a44c7a543dcb388c1ee1a798e6ed76ad8cf
> 
> 
> Lukasz Majewski (17):
>   thermal: exynos: cosmetic: Correct comment format
>   thermal: exynos: Provide thermal_exynos.h file to be included in
>     device tree files
>   thermal: dts: trats: Enable TMU on the Exynos4210 trats device
>   thermal: dts: exynos: Add LD010 regulator node necessary for TMU on
>     Odroid
>   thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device
>   thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu
>     cooling functionality
>   thermal: cpu_cooling: Modify exynos thermal code to use device tree
>     for cpu cooling configuration
>   thermal: exynos: dts: Add default definition of the TMU sensor
>     parameter
>   thermal: dts: Default trip points definition for Exynos5420 SoCs
>   thermal: exynos: dts: Define default thermal-zones for Exynos4
>   thermal: dts: exynos: Trip points and sensor configuration data for
>     Exynos5440
>   thermal: exynos: dts: Provide device tree bindings identical to one in
>     exynos_tmu_data.c
>   thermal: samsung: core: Exynos TMU rework to use device tree for
>     configuration
>   thermal: exynos: Remove exynos_thermal_common.[c|h] files
>   thermal: exynos: Remove exynos_tmu_data.c file
>   thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412
>   thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412
> 
>  arch/arm/boot/dts/exynos3250.dtsi                 |   6 +-
>  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi        |  52 +++
>  arch/arm/boot/dts/exynos4.dtsi                    |   5 +
>  arch/arm/boot/dts/exynos4210-trats.dts            |  19 +
>  arch/arm/boot/dts/exynos4210.dtsi                 |  43 ++-
>  arch/arm/boot/dts/exynos4212.dtsi                 |  20 +
>  arch/arm/boot/dts/exynos4412-odroid-common.dtsi   |  27 ++
>  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi |  24 ++
>  arch/arm/boot/dts/exynos4412-trats2.dts           |  15 +
>  arch/arm/boot/dts/exynos4412.dtsi                 |  32 ++
>  arch/arm/boot/dts/exynos4x12.dtsi                 |   3 +
>  arch/arm/boot/dts/exynos5250.dtsi                 |  29 +-
>  arch/arm/boot/dts/exynos5420-trip-points.dtsi     |  35 ++
>  arch/arm/boot/dts/exynos5420.dtsi                 |  33 ++
>  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi |  25 ++
>  arch/arm/boot/dts/exynos5440-trip-points.dtsi     |  25 ++
>  arch/arm/boot/dts/exynos5440.dtsi                 |  18 +
>  drivers/cpufreq/exynos-cpufreq.c                  |  23 +-
>  drivers/thermal/samsung/Makefile                  |   2 -
>  drivers/thermal/samsung/exynos_thermal_common.c   | 427 ----------------------
>  drivers/thermal/samsung/exynos_thermal_common.h   | 106 ------
>  drivers/thermal/samsung/exynos_tmu.c              | 337 ++++++++++-------
>  drivers/thermal/samsung/exynos_tmu.h              |  80 +---
>  drivers/thermal/samsung/exynos_tmu_data.c         | 264 -------------
>  include/dt-bindings/thermal/thermal_exynos.h      |  37 ++
>  25 files changed, 669 insertions(+), 1018 deletions(-)

Good!

>  create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
>  delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
>  create mode 100644 include/dt-bindings/thermal/thermal_exynos.h
> 
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree
  2014-10-09 16:38 ` Lukasz Majewski
                   ` (23 preceding siblings ...)
  (?)
@ 2014-12-10 12:09 ` Lukasz Majewski
  2014-12-10 10:27   ` Eduardo Valentin
                     ` (18 more replies)
  -1 siblings, 19 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

1. Introduction

Following patches aim to clean up the current implementation of the thermal
framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration
(of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which
is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal 
subsystem.

2. Patch-set structure

Then the cpu_cooling functionality has been preserved to allow cooling
devices by reducing operating frequency. Definition of trip points and
cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to
the Exynos thermal subsystem was performed. Now device tree is used for
configuration.

Patch series end with removing exynos5250/exynos3250 TMU compatibles.
Both SoCs have thermal management unit (TMU) compatible with the one first 
introduced at Exynos4412.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c 
file, was removed since, as of (almost) 3.19-rc1, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those
SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality
has been preserved in the code, but not tested on the hardware. I would
be grateful for help in testing.

5. This work apply on the following tree:

kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
SHA1: c42c7a44c7a543dcb388c1ee1a798e6ed76ad8cf


Lukasz Majewski (17):
  thermal: exynos: cosmetic: Correct comment format
  thermal: exynos: Provide thermal_exynos.h file to be included in
    device tree files
  thermal: dts: trats: Enable TMU on the Exynos4210 trats device
  thermal: dts: exynos: Add LD010 regulator node necessary for TMU on
    Odroid
  thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device
  thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu
    cooling functionality
  thermal: cpu_cooling: Modify exynos thermal code to use device tree
    for cpu cooling configuration
  thermal: exynos: dts: Add default definition of the TMU sensor
    parameter
  thermal: dts: Default trip points definition for Exynos5420 SoCs
  thermal: exynos: dts: Define default thermal-zones for Exynos4
  thermal: dts: exynos: Trip points and sensor configuration data for
    Exynos5440
  thermal: exynos: dts: Provide device tree bindings identical to one in
    exynos_tmu_data.c
  thermal: samsung: core: Exynos TMU rework to use device tree for
    configuration
  thermal: exynos: Remove exynos_thermal_common.[c|h] files
  thermal: exynos: Remove exynos_tmu_data.c file
  thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412
  thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412

 arch/arm/boot/dts/exynos3250.dtsi                 |   6 +-
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi        |  52 +++
 arch/arm/boot/dts/exynos4.dtsi                    |   5 +
 arch/arm/boot/dts/exynos4210-trats.dts            |  19 +
 arch/arm/boot/dts/exynos4210.dtsi                 |  43 ++-
 arch/arm/boot/dts/exynos4212.dtsi                 |  20 +
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi   |  27 ++
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi |  24 ++
 arch/arm/boot/dts/exynos4412-trats2.dts           |  15 +
 arch/arm/boot/dts/exynos4412.dtsi                 |  32 ++
 arch/arm/boot/dts/exynos4x12.dtsi                 |   3 +
 arch/arm/boot/dts/exynos5250.dtsi                 |  29 +-
 arch/arm/boot/dts/exynos5420-trip-points.dtsi     |  35 ++
 arch/arm/boot/dts/exynos5420.dtsi                 |  33 ++
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi |  25 ++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi     |  25 ++
 arch/arm/boot/dts/exynos5440.dtsi                 |  18 +
 drivers/cpufreq/exynos-cpufreq.c                  |  23 +-
 drivers/thermal/samsung/Makefile                  |   2 -
 drivers/thermal/samsung/exynos_thermal_common.c   | 427 ----------------------
 drivers/thermal/samsung/exynos_thermal_common.h   | 106 ------
 drivers/thermal/samsung/exynos_tmu.c              | 337 ++++++++++-------
 drivers/thermal/samsung/exynos_tmu.h              |  80 +---
 drivers/thermal/samsung/exynos_tmu_data.c         | 264 -------------
 include/dt-bindings/thermal/thermal_exynos.h      |  37 ++
 25 files changed, 669 insertions(+), 1018 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

-- 
2.0.0.rc2

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v2 01/17] thermal: exynos: cosmetic: Correct comment format
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
  2014-12-10 10:27   ` Eduardo Valentin
@ 2014-12-10 12:09   ` Lukasz Majewski
  2014-12-10 12:09   ` [PATCH v2 02/17] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
                     ` (16 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 drivers/thermal/samsung/exynos_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 8d7395c..32ac366 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -576,7 +576,7 @@ out:
 #define exynos5440_tmu_set_emulation NULL
 static int exynos_tmu_set_emulation(void *drv_data,	unsigned long temp)
 	{ return -EINVAL; }
-#endif/*CONFIG_THERMAL_EMULATION*/
+#endif /* CONFIG_THERMAL_EMULATION */
 
 static int exynos4210_tmu_read(struct exynos_tmu_data *data)
 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 02/17] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
  2014-12-10 10:27   ` Eduardo Valentin
  2014-12-10 12:09   ` [PATCH v2 01/17] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2014-12-10 12:09   ` [PATCH v2 03/17] thermal: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
                     ` (15 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

This patch is a preparatory patch to be able to read Exynos thermal
configuration from the device tree.

It turned out that DTC is not able to interpret enums properly and hence
it is necessary to #define those values explicitly.

For this reason the ./include/dt-bindings/thermal/thermal_exynos.h file
has been introduced.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 drivers/thermal/samsung/exynos_tmu.c         |  2 +-
 drivers/thermal/samsung/exynos_tmu.h         | 24 +++---------------
 include/dt-bindings/thermal/thermal_exynos.h | 37 ++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 21 deletions(-)
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 32ac366..936d16f 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -144,7 +144,7 @@ struct exynos_tmu_data {
 	void __iomem *base;
 	void __iomem *base_second;
 	int irq;
-	enum soc_type soc;
+	int soc;
 	struct work_struct irq_work;
 	struct mutex lock;
 	struct clk *clk, *clk_sec;
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index da3009b..03ebdd0 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -26,24 +26,7 @@
 
 #include "exynos_thermal_common.h"
 
-enum calibration_type {
-	TYPE_ONE_POINT_TRIMMING,
-	TYPE_ONE_POINT_TRIMMING_25,
-	TYPE_ONE_POINT_TRIMMING_85,
-	TYPE_TWO_POINT_TRIMMING,
-	TYPE_NONE,
-};
-
-enum soc_type {
-	SOC_ARCH_EXYNOS3250 = 1,
-	SOC_ARCH_EXYNOS4210,
-	SOC_ARCH_EXYNOS4412,
-	SOC_ARCH_EXYNOS5250,
-	SOC_ARCH_EXYNOS5260,
-	SOC_ARCH_EXYNOS5420,
-	SOC_ARCH_EXYNOS5420_TRIMINFO,
-	SOC_ARCH_EXYNOS5440,
-};
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
@@ -115,8 +98,9 @@ struct exynos_tmu_platform_data {
 	u8 second_point_trim;
 	u8 default_temp_offset;
 
-	enum calibration_type cal_type;
-	enum soc_type type;
+	u32 cal_type;
+	u32 cal_mode;
+	u32 type;
 	struct freq_clip_table freq_tab[4];
 	unsigned int freq_tab_count;
 };
diff --git a/include/dt-bindings/thermal/thermal_exynos.h b/include/dt-bindings/thermal/thermal_exynos.h
new file mode 100644
index 0000000..85789be
--- /dev/null
+++ b/include/dt-bindings/thermal/thermal_exynos.h
@@ -0,0 +1,37 @@
+/*
+ * thermal_exynos.h - Samsung EXYNOS TMU device tree definitions
+ *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef _EXYNOS_THERMAL_TMU_DT_H
+#define _EXYNOS_THERMAL_TMU_DT_H
+
+#define TYPE_ONE_POINT_TRIMMING 0
+#define TYPE_ONE_POINT_TRIMMING_25 1
+#define TYPE_ONE_POINT_TRIMMING_85 2
+#define TYPE_TWO_POINT_TRIMMING 3
+#define TYPE_NONE 4
+
+#define SOC_ARCH_EXYNOS3250 1
+#define SOC_ARCH_EXYNOS4210 2
+#define SOC_ARCH_EXYNOS4412 3
+#define SOC_ARCH_EXYNOS5250 4
+#define SOC_ARCH_EXYNOS5260 5
+#define SOC_ARCH_EXYNOS5420_TRIMINFO 6
+#define SOC_ARCH_EXYNOS5420 7
+#define SOC_ARCH_EXYNOS5440 8
+
+#endif /* _EXYNOS_THERMAL_TMU_DT_H */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 03/17] thermal: dts: trats: Enable TMU on the Exynos4210 trats device
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (2 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 02/17] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2014-12-10 12:09   ` [PATCH v2 04/17] thermal: dts: exynos: Add LD010 regulator node necessary for TMU on Odroid Lukasz Majewski
                     ` (14 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

The thermal IP block (Thermal Management Unit) called TMU has been enabled
in this device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 arch/arm/boot/dts/exynos4210-trats.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index f516da9..b59019c 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -424,6 +424,10 @@
 		status = "okay";
 	};
 
+	tmu@100C0000 {
+		status = "okay";
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 04/17] thermal: dts: exynos: Add LD010 regulator node necessary for TMU on Odroid
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (3 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 03/17] thermal: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2014-12-10 12:09   ` [PATCH v2 05/17] thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
                     ` (13 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index c697ff0..9366f5a 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -205,6 +205,13 @@
 					regulator-always-on;
 				};
 
+				ldo10_reg: LDO10 {
+					regulator-name = "VDD18_MIPIHSI_1.8V";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <1800000>;
+					regulator-always-on;
+				};
+
 				ldo11_reg: LDO11 {
 					regulator-name = "VDD18_ABB1_1.8V";
 					regulator-min-microvolt = <1800000>;
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 05/17] thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (4 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 04/17] thermal: dts: exynos: Add LD010 regulator node necessary for TMU on Odroid Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2014-12-10 12:09   ` [PATCH v2 06/17] thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu cooling functionality Lukasz Majewski
                     ` (12 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

This commit enables TMU IP block on the Exynos4412 Odroid U3
device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 9366f5a..eb1c08c 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -370,6 +370,11 @@
 	ehci: ehci@12580000 {
 		status = "okay";
 	};
+
+	tmu@100C0000 {
+		vtmu-supply = <&ldo10_reg>;
+		status = "okay";
+	};
 };
 
 &pinctrl_1 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 06/17] thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu cooling functionality
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (5 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 05/17] thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2015-01-02 18:15     ` Eduardo Valentin
  2014-12-10 12:09   ` [PATCH v2 07/17] thermal: cpu_cooling: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
                     ` (11 subsequent siblings)
  18 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

Presented patch aims to move data necessary for correct CPU cooling device
configuration from exynos_tmu_data.c to device tree.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 arch/arm/boot/dts/exynos4210-trats.dts          | 15 ++++++++++++
 arch/arm/boot/dts/exynos4210.dtsi               | 20 ++++++++++++++++
 arch/arm/boot/dts/exynos4212.dtsi               | 20 ++++++++++++++++
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 15 ++++++++++++
 arch/arm/boot/dts/exynos4412-trats2.dts         | 15 ++++++++++++
 arch/arm/boot/dts/exynos4412.dtsi               | 32 +++++++++++++++++++++++++
 arch/arm/boot/dts/exynos5250.dtsi               | 20 +++++++++++++++-
 7 files changed, 136 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index b59019c..d9dd9a7 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -428,6 +428,21 @@
 		status = "okay";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				    /* Corresponds to 800MHz at freq_table */
+				    cooling-device = <&cpu0 2 2>;
+				};
+				map1 {
+				   /* Corresponds to 200MHz at freq_table */
+				   cooling-device = <&cpu0 4 4>;
+			       };
+		       };
+		};
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index 807bb5b..10e8915 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -41,6 +41,26 @@
 		#clock-cells = <1>;
 	};
 
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu0: cpu@0 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a9";
+			reg = <0x900>;
+			cooling-min-level = <4>;
+			cooling-max-level = <2>;
+			#cooling-cells = <2>; /* min followed by max */
+		};
+
+		cpu@1 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a9";
+			reg = <0x901>;
+		};
+	};
+
 	sysram@02020000 {
 		compatible = "mmio-sram";
 		reg = <0x02020000 0x20000>;
diff --git a/arch/arm/boot/dts/exynos4212.dtsi b/arch/arm/boot/dts/exynos4212.dtsi
index 3c00e6e..6405954 100644
--- a/arch/arm/boot/dts/exynos4212.dtsi
+++ b/arch/arm/boot/dts/exynos4212.dtsi
@@ -22,6 +22,26 @@
 / {
 	compatible = "samsung,exynos4212", "samsung,exynos4";
 
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu0: cpu@0 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a9";
+			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
+		};
+
+		cpu@1 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a9";
+			reg = <0xA01>;
+		};
+	};
+
 	combiner: interrupt-controller@10440000 {
 		samsung,combiner-nr = <18>;
 	};
diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index eb1c08c..15d45f0 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -375,6 +375,21 @@
 		vtmu-supply = <&ldo10_reg>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				    /* Corresponds to 800MHz at freq_table */
+				    cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				   /* Corresponds to 200MHz at freq_table */
+				   cooling-device = <&cpu0 13 13>;
+			       };
+		       };
+		};
+	};
 };
 
 &pinctrl_1 {
diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts b/arch/arm/boot/dts/exynos4412-trats2.dts
index 121430d..396c525 100644
--- a/arch/arm/boot/dts/exynos4412-trats2.dts
+++ b/arch/arm/boot/dts/exynos4412-trats2.dts
@@ -786,4 +786,19 @@
 		pulldown-ohm = <100000>; /* 100K */
 		io-channels = <&adc 2>;  /* Battery temperature */
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				    /* Corresponds to 800MHz at freq_table */
+				    cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				   /* Corresponds to 200MHz at freq_table */
+				   cooling-device = <&cpu0 13 13>;
+			       };
+		       };
+		};
+	};
 };
diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
index d8bc059e..9ed8925 100644
--- a/arch/arm/boot/dts/exynos4412.dtsi
+++ b/arch/arm/boot/dts/exynos4412.dtsi
@@ -22,6 +22,38 @@
 / {
 	compatible = "samsung,exynos4412", "samsung,exynos4";
 
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu0: cpu@0 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a9";
+			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
+		};
+
+		cpu@1 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a9";
+			reg = <0xA01>;
+		};
+
+		cpu@2 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a9";
+			reg = <0xA02>;
+		};
+
+		cpu@3 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a9";
+			reg = <0xA03>;
+		};
+	};
+
 	combiner: interrupt-controller@10440000 {
 		samsung,combiner-nr = <20>;
 	};
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index d55c1a2..a5bbc1a 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -58,11 +58,14 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@0 {
+		cpu0: cpu@0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a15";
 			reg = <0>;
 			clock-frequency = <1700000000>;
+			cooling-min-level = <15>;
+			cooling-max-level = <9>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 		cpu@1 {
 			device_type = "cpu";
@@ -241,6 +244,21 @@
 		clock-names = "tmu_apbif";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				    /* Corresponds to 800MHz at freq_table */
+				    cooling-device = <&cpu0 9 9>;
+				};
+				map1 {
+				   /* Corresponds to 200MHz at freq_table */
+				   cooling-device = <&cpu0 15 15>;
+			       };
+		       };
+		};
+	};
+
 	serial@12C00000 {
 		clocks = <&clock CLK_UART0>, <&clock CLK_SCLK_UART0>;
 		clock-names = "uart", "clk_uart_baud0";
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 07/17] thermal: cpu_cooling: Modify exynos thermal code to use device tree for cpu cooling configuration
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (6 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 06/17] thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu cooling functionality Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2015-01-02 18:18     ` Eduardo Valentin
  2014-12-10 12:09   ` [PATCH v2 08/17] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
                     ` (10 subsequent siblings)
  18 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

Up till now exynos_tmu_data.c was used for storing CPU cooling configuration
data. Now the Exynos thermal core code uses device tree to get this data.
For this purpose generic thermal code for configuring CPU cooling was
used.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 drivers/cpufreq/exynos-cpufreq.c                |  23 ++++-
 drivers/thermal/samsung/exynos_thermal_common.c | 122 ++++++++++++++----------
 drivers/thermal/samsung/exynos_tmu.c            |   7 --
 drivers/thermal/samsung/exynos_tmu.h            |   5 -
 drivers/thermal/samsung/exynos_tmu_data.c       |  42 +-------
 5 files changed, 94 insertions(+), 105 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 1e0ec57..fdedb8d 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -18,10 +18,13 @@
 #include <linux/cpufreq.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/cpu_cooling.h>
+#include <linux/cpu.h>
 
 #include "exynos-cpufreq.h"
 
 static struct exynos_dvfs_info *exynos_info;
+static struct thermal_cooling_device *cdev;
 static struct regulator *arm_regulator;
 static unsigned int locking_frequency;
 
@@ -156,6 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
+	struct device_node *np;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -198,9 +202,24 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	/* Done here as we want to capture boot frequency */
 	locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;
 
-	if (!cpufreq_register_driver(&exynos_driver))
-		return 0;
+	if (cpufreq_register_driver(&exynos_driver))
+		goto err;
 
+	np = of_find_node_by_path("/cpus/cpu@0");
+	if (!np) {
+		pr_err("failed to find cpu0 node\n");
+		return -ENOENT;
+	}
+	if (of_find_property(np, "#cooling-cells", NULL)) {
+		cdev = of_cpufreq_cooling_register(np, cpu_present_mask);
+		if (IS_ERR(cdev))
+			pr_err("running cpufreq without cooling device: %ld\n",
+			       PTR_ERR(cdev));
+	}
+	of_node_put(np);
+
+	return 0;
+ err:
 	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
 	regulator_put(arm_regulator);
 err_vdd_arm:
diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 6dc3815..00aa688 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -133,47 +133,62 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
 static int exynos_bind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size, level;
-	struct freq_clip_table *tab_ptr, *clip_data;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
+	struct of_phandle_args cooling_spec;
+	unsigned long max, state = 0;
+	int ret = 0, i = 0;
 
-	tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data;
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_ptr == NULL || tab_size == 0)
+	/*
+	 * Below code is necessary to skip binding when cpufreq's
+	 * frequency table is not yet initialized.
+	 */
+	cdev->ops->get_max_state(cdev, &state);
+	if (!state && !th_zone->cool_dev_size) {
+		th_zone->cool_dev_size = 1;
+		th_zone->cool_dev[0] = cdev;
+		th_zone->bind = false;
 		return 0;
+	}
 
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
 
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
+	child = of_get_child_by_name(np, "cooling-maps");
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		clip_data = (struct freq_clip_table *)&(tab_ptr[i]);
-		level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max);
-		if (level == THERMAL_CSTATE_INVALID)
-			return 0;
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-								level, 0)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = true;
-			break;
-		default:
+	for_each_child_of_node(child, gchild) {
+		ret = of_parse_phandle_with_args(gchild, "cooling-device",
+						 "#cooling-cells",
+						 0, &cooling_spec);
+		if (ret < 0) {
+			pr_err("missing cooling_device property\n");
+			goto end;
+		}
+
+		if (cooling_spec.args_count < 2) {
 			ret = -EINVAL;
+			goto end;
 		}
+
+		max = cooling_spec.args[0];
+		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
+						     max, 0)) {
+			dev_err(data->dev,
+				"thermal error unbinding cdev inst=%d\n", i);
+
+			ret = -EINVAL;
+			goto end;
+		}
+		i++;
 	}
+	th_zone->bind = true;
+end:
+	of_node_put(child);
+	of_node_put(np);
 
 	return ret;
 }
@@ -182,16 +197,12 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 static int exynos_unbind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size;
+	int ret = 0, i;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
 
-	if (th_zone->bind == false)
-		return 0;
-
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_size == 0)
+	if (th_zone->bind == false || !th_zone->cool_dev_size)
 		return 0;
 
 	/* find the cooling device registered*/
@@ -203,23 +214,30 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
 	if (i == th_zone->cool_dev_size)
 		return 0;
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_unbind_cooling_device(thermal, i,
-								cdev)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = false;
-			break;
-		default:
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
+
+	child = of_get_child_by_name(np, "cooling-maps");
+
+	i = 0;
+	for_each_child_of_node(child, gchild) {
+		if (thermal_zone_unbind_cooling_device(thermal, i,
+						       cdev)) {
+			dev_err(data->dev,
+				"error unbinding cdev inst=%d\n", i);
 			ret = -EINVAL;
+			goto end;
 		}
+		i++;
 	}
+	th_zone->bind = false;
+end:
+	of_node_put(child);
+	of_node_put(np);
+
 	return ret;
 }
 
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 936d16f..d2d6b53 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -916,13 +916,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 
 	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
 
-	sensor_conf->cooling_data.freq_clip_count = pdata->freq_tab_count;
-	for (i = 0; i < pdata->freq_tab_count; i++) {
-		sensor_conf->cooling_data.freq_data[i].freq_clip_max =
-					pdata->freq_tab[i].freq_clip_max;
-		sensor_conf->cooling_data.freq_data[i].temp_level =
-					pdata->freq_tab[i].temp_level;
-	}
 	sensor_conf->dev = &pdev->dev;
 	/* Register the sensor with thermal management interface */
 	ret = exynos_register_thermal(sensor_conf);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 03ebdd0..fcdb2fc 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -73,9 +73,6 @@
  * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
- * @freq_clip_table: Table representing frequency reduction percentage.
- * @freq_tab_count: Count of the above table as frequency reduction may
- *	applicable to only some of the trigger levels.
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
@@ -101,8 +98,6 @@ struct exynos_tmu_platform_data {
 	u32 cal_type;
 	u32 cal_mode;
 	u32 type;
-	struct freq_clip_table freq_tab[4];
-	unsigned int freq_tab_count;
 };
 
 /**
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
index b239100..a993f3d 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -47,15 +47,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 		.first_point_trim = 25,
 		.second_point_trim = 85,
 		.default_temp_offset = 50,
-		.freq_tab[0] = {
-			.freq_clip_max = 800 * 1000,
-			.temp_level = 85,
-			},
-		.freq_tab[1] = {
-			.freq_clip_max = 200 * 1000,
-			.temp_level = 100,
-		},
-		.freq_tab_count = 2,
 		.type = SOC_ARCH_EXYNOS4210,
 		},
 	},
@@ -87,16 +78,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 800 * 1000, \
-		.temp_level = 70, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 400 * 1000, \
-		.temp_level = 95, \
-	}, \
-	.freq_tab_count = 2
+	.default_temp_offset = 50
 
 struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 	.tmu_data = {
@@ -133,16 +115,7 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 1400 * 1000, \
-		.temp_level = 70, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 400 * 1000, \
-		.temp_level = 95, \
-	}, \
-	.freq_tab_count = 2
+	.default_temp_offset = 50
 
 struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
 	.tmu_data = {
@@ -189,16 +162,7 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 800 * 1000, \
-		.temp_level = 85, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 200 * 1000, \
-		.temp_level = 103, \
-	}, \
-	.freq_tab_count = 2, \
+	.default_temp_offset = 50,
 
 #define EXYNOS5260_TMU_DATA \
 	__EXYNOS5260_TMU_DATA \
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 08/17] thermal: exynos: dts: Add default definition of the TMU sensor parameter
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (7 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 07/17] thermal: cpu_cooling: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2015-01-02 18:11     ` Eduardo Valentin
  2014-12-10 12:09   ` [PATCH v2 09/17] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
                     ` (9 subsequent siblings)
  18 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

Exynos 4 and 5 family of SoCs uses almost identical TMU sensor to measure the
on chip temperature. For this reason it is possible to group TMU configuration
parameters in one dts file.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi | 24 +++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi

diff --git a/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
new file mode 100644
index 0000000..ee6d8bb
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
@@ -0,0 +1,24 @@
+/*
+ * Device tree sources for Exynos4412 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+gain = <8>;
+reference_voltage = <16>;
+noise_cancel_mode = <4>;
+efuse_value = <55>;
+min_efuse_value = <40>;
+max_efuse_value = <100>;
+first_point_trim = <25>;
+second_point_trim = <85>;
+default_temp_offset = <50>;
+cal_type = <TYPE_ONE_POINT_TRIMMING>;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 09/17] thermal: dts: Default trip points definition for Exynos5420 SoCs
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (8 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 08/17] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2014-12-10 12:09   ` [PATCH v2 10/17] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
                     ` (8 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

This code groups in one place default settings of trip points. It is used
in SoCs with multiple instances of TMU sensor.

Separate device tree file prevents from multiple copying of the same data.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 arch/arm/boot/dts/exynos5420-trip-points.dtsi | 35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi

diff --git a/arch/arm/boot/dts/exynos5420-trip-points.dtsi b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
new file mode 100644
index 0000000..09d6c56
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
@@ -0,0 +1,35 @@
+/*
+ * Device tree sources for default Exynos 5420 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <85000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-1 {
+		temperature = <103000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-2 {
+		temperature = <110000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1200000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 10/17] thermal: exynos: dts: Define default thermal-zones for Exynos4
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (9 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 09/17] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2014-12-10 12:09   ` [PATCH v2 11/17] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
                     ` (7 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

Trip points corresponding to the one defined in the exynos_tmu_data.c
for Exynos4 have been included.
This thermal-zones attribute is afterwards reused for Exynos4210, Exynos4412
and Exynos5250.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi | 52 ++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi

diff --git a/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
new file mode 100644
index 0000000..506600a
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
@@ -0,0 +1,52 @@
+/*
+ * Device tree sources for Exynos4 thermal zone
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal.h>
+
+/ {
+  thermal-zones {
+	cpu_thermal: cpu-thermal {
+		thermal-sensors = <&tmu 0>;
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		trips {
+			cpu_alert0: cpu-alert-0 {
+				temperature = <70000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert1: cpu-alert-1 {
+				temperature = <95000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert2: cpu-alert-2 {
+				temperature = <110000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_crit0: cpu-crit-0 {
+				temperature = <120000>; /* millicelsius */
+				hysteresis = <0>; /* millicelsius */
+				type = "critical";
+			};
+		};
+		cooling-maps {
+			map0 {
+			    trip = <&cpu_alert0>;
+			};
+			map1 {
+			    trip = <&cpu_alert1>;
+			};
+		};
+	};
+  };
+};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 11/17] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (10 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 10/17] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2014-12-10 12:09   ` [PATCH v2 12/17] thermal: exynos: dts: Provide device tree bindings identical to one in exynos_tmu_data.c Lukasz Majewski
                     ` (6 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

This commit provides information about Exynos5440 device configuration.
Previously this information was available in exynos_tmu_data.c file.
Now it is available in the device tree.
Such approach allows reusing some common code for thermal.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi | 25 +++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi     | 25 +++++++++++++++++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi

diff --git a/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
new file mode 100644
index 0000000..336cb12
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
@@ -0,0 +1,25 @@
+/*
+ * Device tree sources for Exynos5440 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+gain = <5>;
+reference_voltage = <16>;
+noise_cancel_mode = <4>;
+efuse_value = <0x5d2d>;
+min_efuse_value = <16>;
+max_efuse_value = <76>;
+first_point_trim = <25>;
+second_point_trim = <70>;
+default_temp_offset = <25>;
+cal_type = <TYPE_ONE_POINT_TRIMMING>;
+type = <SOC_ARCH_EXYNOS5440>;
diff --git a/arch/arm/boot/dts/exynos5440-trip-points.dtsi b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
new file mode 100644
index 0000000..48adfa8
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
@@ -0,0 +1,25 @@
+/*
+ * Device tree sources for default Exynos5440 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <100000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1050000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 12/17] thermal: exynos: dts: Provide device tree bindings identical to one in exynos_tmu_data.c
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (11 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 11/17] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2015-01-02 18:13     ` Eduardo Valentin
  2014-12-10 12:09   ` [PATCH v2 13/17] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
                     ` (5 subsequent siblings)
  18 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

Presented device tree bindings provide data already hardcoded in the
exynos_tmu_data.c file.
After this commit, it should be possible to reuse common thermal core
framework in Exynos SoCs.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Add proper TMU entries for exynos3250.dtsi
---
 arch/arm/boot/dts/exynos3250.dtsi |  4 ++++
 arch/arm/boot/dts/exynos4.dtsi    |  5 +++++
 arch/arm/boot/dts/exynos4210.dtsi | 23 ++++++++++++++++++++++-
 arch/arm/boot/dts/exynos4x12.dtsi |  3 +++
 arch/arm/boot/dts/exynos5250.dtsi |  7 +++++--
 arch/arm/boot/dts/exynos5420.dtsi | 33 +++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440.dtsi | 18 ++++++++++++++++++
 7 files changed, 90 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/exynos3250.dtsi b/arch/arm/boot/dts/exynos3250.dtsi
index 693a327..6edfa76 100644
--- a/arch/arm/boot/dts/exynos3250.dtsi
+++ b/arch/arm/boot/dts/exynos3250.dtsi
@@ -18,7 +18,9 @@
  */
 
 #include "skeleton.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 #include <dt-bindings/clock/exynos3250.h>
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 / {
 	compatible = "samsung,exynos3250";
@@ -188,6 +190,8 @@
 			interrupts = <0 216 0>;
 			clocks = <&cmu CLK_TMU_APBIF>;
 			clock-names = "tmu_apbif";
+			type = <SOC_ARCH_EXYNOS3250>;
+			#include "exynos4412-tmu-sensor-conf.dtsi"
 			status = "disabled";
 		};
 
diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index e0278ec..1735bb3 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -21,6 +21,7 @@
 
 #include <dt-bindings/clock/exynos4.h>
 #include <dt-bindings/clock/exynos-audss-clk.h>
+#include <dt-bindings/thermal/thermal_exynos.h>
 #include "skeleton.dtsi"
 
 / {
@@ -645,4 +646,8 @@
 		samsung,sysreg = <&sys_reg>;
 		status = "disabled";
 	};
+
+	tmu: tmu@100C0000 {
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+	};
 };
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index 10e8915..1c52681 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -21,6 +21,8 @@
 
 #include "exynos4.dtsi"
 #include "exynos4210-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 / {
 	compatible = "samsung,exynos4210", "samsung,exynos4";
@@ -146,16 +148,35 @@
 		reg = <0x03860000 0x1000>;
 	};
 
-	tmu@100C0000 {
+	tmu: tmu@100C0000 {
 		compatible = "samsung,exynos4210-tmu";
 		interrupt-parent = <&combiner>;
 		reg = <0x100C0000 0x100>;
 		interrupts = <2 4>;
 		clocks = <&clock CLK_TMU_APBIF>;
 		clock-names = "tmu_apbif";
+		gain = <15>;
+		reference_voltage = <7>;
+		type = <SOC_ARCH_EXYNOS4210>;
 		status = "disabled";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			trips {
+			      cpu_alert0: cpu-alert-0 {
+				      temperature = <85000>; /* millicelsius */
+			      };
+			      cpu_alert1: cpu-alert-1 {
+				      temperature = <100000>; /* millicelsius */
+			      };
+			      cpu_alert2: cpu-alert-2 {
+				      temperature = <110000>; /* millicelsius */
+			      };
+			};
+		};
+	};
+
 	g2d@12800000 {
 		compatible = "samsung,s5pv210-g2d";
 		reg = <0x12800000 0x1000>;
diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi
index 2e9f1f7..ee24d83 100644
--- a/arch/arm/boot/dts/exynos4x12.dtsi
+++ b/arch/arm/boot/dts/exynos4x12.dtsi
@@ -19,6 +19,8 @@
 
 #include "exynos4.dtsi"
 #include "exynos4x12-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 / {
 	aliases {
@@ -279,6 +281,7 @@
 		reg = <0x100C0000 0x100>;
 		clocks = <&clock 383>;
 		clock-names = "tmu_apbif";
+		type = <SOC_ARCH_EXYNOS4412>;
 		status = "disabled";
 	};
 };
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index a5bbc1a..2167394 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -20,8 +20,9 @@
 #include <dt-bindings/clock/exynos5250.h>
 #include "exynos5.dtsi"
 #include "exynos5250-pinctrl.dtsi"
-
+#include "exynos4-cpu-thermal.dtsi"
 #include <dt-bindings/clock/exynos-audss-clk.h>
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 / {
 	compatible = "samsung,exynos5250", "samsung,exynos5";
@@ -236,12 +237,14 @@
 		status = "disabled";
 	};
 
-	tmu@10060000 {
+	tmu: tmu@10060000 {
 		compatible = "samsung,exynos5250-tmu";
 		reg = <0x10060000 0x100>;
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		type = <SOC_ARCH_EXYNOS5250>;
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	thermal-zones {
diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
index 8617a03..23d488b 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -756,6 +756,8 @@
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420>;
 	};
 
 	tmu_cpu1: tmu@10064000 {
@@ -764,6 +766,8 @@
 		interrupts = <0 183 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420>;
 	};
 
 	tmu_cpu2: tmu@10068000 {
@@ -772,6 +776,8 @@
 		interrupts = <0 184 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
 	};
 
 	tmu_cpu3: tmu@1006c000 {
@@ -780,6 +786,8 @@
 		interrupts = <0 185 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU_GPU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
 	};
 
 	tmu_gpu: tmu@100a0000 {
@@ -788,6 +796,31 @@
 		interrupts = <0 215 0>;
 		clocks = <&clock CLK_TMU_GPU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmu_cpu0>;
+			#include "exynos5420-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmu_cpu1>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmu_cpu2>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu3_thermal: cpu3-thermal {
+		       thermal-sensors = <&tmu_cpu3>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		gpu_thermal: gpu-thermal {
+		       thermal-sensors = <&tmu_gpu>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
 	};
 
         watchdog: watchdog@101D0000 {
diff --git a/arch/arm/boot/dts/exynos5440.dtsi b/arch/arm/boot/dts/exynos5440.dtsi
index 8f3373c..59d9416 100644
--- a/arch/arm/boot/dts/exynos5440.dtsi
+++ b/arch/arm/boot/dts/exynos5440.dtsi
@@ -219,6 +219,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_1: tmuctrl@16011C {
@@ -227,6 +228,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_2: tmuctrl@160120 {
@@ -235,6 +237,22 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmuctrl_0>;
+			#include "exynos5440-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmuctrl_1>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmuctrl_2>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
 	};
 
 	sata@210000 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 13/17] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (12 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 12/17] thermal: exynos: dts: Provide device tree bindings identical to one in exynos_tmu_data.c Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2014-12-10 12:09   ` [PATCH v2 14/17] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
                     ` (4 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

This patch brings support for providing configuration via device tree.
Previously this data has been hardcoded in the exynos_tmu_data.c file.
Such approach was not scalable and very often required copying the whole
data.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
- Usage of of-thermal.c exported trip points table
---
 drivers/thermal/samsung/Makefile     |   2 -
 drivers/thermal/samsung/exynos_tmu.c | 320 ++++++++++++++++++++++-------------
 drivers/thermal/samsung/exynos_tmu.h |  51 ------
 3 files changed, 200 insertions(+), 173 deletions(-)

diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile
index c09d830..1e47d0d 100644
--- a/drivers/thermal/samsung/Makefile
+++ b/drivers/thermal/samsung/Makefile
@@ -3,5 +3,3 @@
 #
 obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_thermal.o
 exynos_thermal-y				:= exynos_tmu.o
-exynos_thermal-y				+= exynos_tmu_data.o
-exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+= exynos_thermal_common.o
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index d2d6b53..dfbf9bd 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -1,6 +1,10 @@
 /*
  * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
  *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
  *  Copyright (C) 2011 Samsung Electronics
  *  Donggeun Kim <dg77.kim@samsung.com>
  *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
@@ -31,8 +35,8 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 
-#include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
+#include "../thermal_core.h"
 
 /* Exynos generic registers */
 #define EXYNOS_TMU_REG_TRIMINFO		0x0
@@ -115,6 +119,7 @@
 #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
 #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
 
+#define MCELSIUS	1000
 /**
  * struct exynos_tmu_data : A structure to hold the private data of the TMU
 	driver
@@ -150,7 +155,8 @@ struct exynos_tmu_data {
 	struct clk *clk, *clk_sec;
 	u8 temp_error1, temp_error2;
 	struct regulator *regulator;
-	struct thermal_sensor_conf *reg_conf;
+	struct thermal_zone_device *tzd;
+
 	int (*tmu_initialize)(struct platform_device *pdev);
 	void (*tmu_control)(struct platform_device *pdev, bool on);
 	int (*tmu_read)(struct exynos_tmu_data *data);
@@ -159,6 +165,33 @@ struct exynos_tmu_data {
 	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
 };
 
+static void exynos_report_trigger(struct exynos_tmu_data *p)
+{
+	char data[10], *envp[] = { data, NULL };
+	struct thermal_zone_device *tz = p->tzd;
+	unsigned long temp;
+	unsigned int i;
+
+	if (!p) {
+		pr_err("Wrong temperature configuration data\n");
+		return;
+	}
+
+	thermal_zone_device_update(tz);
+
+	mutex_lock(&tz->lock);
+	/* Find the level for which trip happened */
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		tz->ops->get_trip_temp(tz, i, &temp);
+		if (tz->last_temperature < temp)
+			break;
+	}
+
+	snprintf(data, sizeof(data), "%u", i);
+	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
+	mutex_unlock(&tz->lock);
+}
+
 /*
  * TMU treats temperature as a mapped temperature code.
  * The temperature is converted differently depending on the calibration type.
@@ -234,14 +267,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
 
 static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling)
 {
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
+	unsigned long temp;
 	int i;
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
-		u8 temp = pdata->trigger_levels[i];
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
+		       __func__);
+		return 0;
+	}
+
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL)
+			continue;
 
+		temp = trips[i].temperature / MCELSIUS;
 		if (falling)
-			temp -= pdata->threshold_falling;
+			temp -= (trips[i].hysteresis / MCELSIUS);
 		else
 			threshold &= ~(0xff << 8 * i);
 
@@ -305,9 +349,19 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 static int exynos4210_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
-	unsigned int status;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
 	int ret = 0, threshold_code, i;
+	unsigned long reference, temp;
+	unsigned int status;
+
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
+		       __func__);
+		ret = -ENODEV;
+		goto out;
+	}
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct platform_device *pdev)
 	sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));
 
 	/* Write temperature code for threshold */
-	threshold_code = temp_to_code(data, pdata->threshold);
+	reference = trips[0].temperature / MCELSIUS;
+	threshold_code = temp_to_code(data, reference);
+	if (threshold_code < 0) {
+		ret = threshold_code;
+		goto out;
+	}
 	writeb(threshold_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
-		writeb(pdata->trigger_levels[i], data->base +
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		temp = trips[i].temperature / MCELSIUS;
+		writeb(temp - reference, data->base +
 		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
+	}
 
 	data->tmu_clear_irqs(data);
 out:
@@ -333,9 +394,11 @@ out:
 static int exynos4412_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(data->tzd);
 	unsigned int status, trim_info, con, ctrl, rising_threshold;
 	int ret = 0, threshold_code, i;
+	unsigned long crit_temp = 0;
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
 	data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
-		/* 1-4 level to be assigned in th0 reg */
-		rising_threshold &= ~(0xff << 8 * i);
-		rising_threshold |= threshold_code << 8 * i;
-		writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
-		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
-		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
-		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
+			crit_temp = trips[i].temperature;
+			break;
+		}
 	}
+
+	if (i == of_thermal_get_ntrips(data->tzd)) {
+		pr_err("%s: No CRITICAL trip point defined at of-thermal.c!\n",
+		       __func__);
+		ret = -EINVAL;
+		goto out;
+	}
+
+	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
+	/* 1-4 level to be assigned in th0 reg */
+	rising_threshold &= ~(0xff << 8 * i);
+	rising_threshold |= threshold_code << 8 * i;
+	writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
+	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
+	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
+	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+
 out:
 	return ret;
 }
@@ -391,9 +466,9 @@ out:
 static int exynos5440_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
 	unsigned int trim_info = 0, con, rising_threshold;
-	int ret = 0, threshold_code, i;
+	int ret = 0, threshold_code;
+	unsigned long crit_temp = 0;
 
 	/*
 	 * For exynos5440 soc triminfo value is swapped between TMU0 and
@@ -422,9 +497,8 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 	data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
+	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp)) {
+		threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
 		/* 5th level to be assigned in th2 reg */
 		rising_threshold =
 			threshold_code << EXYNOS5440_TMU_TH_RISE4_SHIFT;
@@ -442,7 +516,7 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
@@ -450,10 +524,15 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS_TMU_INTEN_RISE0_SHIFT;
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
+
 		if (data->soc != SOC_ARCH_EXYNOS4210)
 			interrupt_en |=
 				interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
@@ -468,7 +547,7 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS5440_TMU_S0_7_CTRL));
@@ -476,11 +555,16 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
-		interrupt_en |= interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
+		interrupt_en |=
+			interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
 	} else {
 		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en = 0; /* Disable all interrupts */
@@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL);
 }
 
-static int exynos_tmu_read(struct exynos_tmu_data *data)
+int exynos_get_temp(void *p, long *temp)
 {
-	int ret;
+	struct exynos_tmu_data *data = p;
+
+	if (!data)
+		return -EINVAL;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
-	ret = data->tmu_read(data);
-	if (ret >= 0)
-		ret = code_to_temp(data, ret);
+
+	*temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS;
+
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
 
-	return ret;
+	return 0;
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
@@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct *work)
 	if (!IS_ERR(data->clk_sec))
 		clk_disable(data->clk_sec);
 
-	exynos_report_trigger(data->reg_conf);
+	exynos_report_trigger(data);
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
@@ -673,55 +760,64 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 static const struct of_device_id exynos_tmu_match[] = {
 	{
 		.compatible = "samsung,exynos3250-tmu",
-		.data = &exynos3250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4210-tmu",
-		.data = &exynos4210_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4412-tmu",
-		.data = &exynos4412_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5250-tmu",
-		.data = &exynos5250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5260-tmu",
-		.data = &exynos5260_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu-ext-triminfo",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5440-tmu",
-		.data = &exynos5440_default_tmu_data,
 	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 
-static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
-			struct platform_device *pdev, int id)
+static int exynos_of_sensor_conf(struct device_node *np,
+				 struct exynos_tmu_platform_data *pdata)
 {
-	struct  exynos_tmu_init_data *data_table;
-	struct exynos_tmu_platform_data *tmu_data;
-	const struct of_device_id *match;
-
-	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
-	if (!match)
-		return NULL;
-	data_table = (struct exynos_tmu_init_data *) match->data;
-	if (!data_table || id >= data_table->tmu_count)
-		return NULL;
-	tmu_data = data_table->tmu_data;
-	return (struct exynos_tmu_platform_data *) (tmu_data + id);
+	u32 value;
+	int ret;
+
+	of_node_get(np);
+
+	ret = of_property_read_u32(np, "gain", &value);
+	pdata->gain = (u8) value;
+	of_property_read_u32(np, "reference_voltage", &value);
+	pdata->reference_voltage = (u8) value;
+	of_property_read_u32(np, "noise_cancel_mode", &value);
+	pdata->noise_cancel_mode = (u8) value;
+
+	of_property_read_u32(np, "efuse_value", &pdata->efuse_value);
+	of_property_read_u32(np, "min_efuse_value", &pdata->min_efuse_value);
+	of_property_read_u32(np, "max_efuse_value", &pdata->max_efuse_value);
+
+	of_property_read_u32(np, "first_point_trim", &value);
+	pdata->first_point_trim = (u8) value;
+	of_property_read_u32(np, "second_point_trim", &value);
+	pdata->second_point_trim = (u8) value;
+	of_property_read_u32(np, "default_temp_offset", &value);
+	pdata->default_temp_offset = (u8) value;
+
+	of_property_read_u32(np, "cal_type", &pdata->cal_type);
+	of_property_read_u32(np, "cal_mode", &pdata->cal_mode);
+	of_property_read_u32(np, "type", &pdata->type);
+
+	of_node_put(np);
+	return 0;
 }
 
 static int exynos_map_dt_data(struct platform_device *pdev)
@@ -771,12 +867,13 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 		return -EADDRNOTAVAIL;
 	}
 
-	pdata = exynos_get_driver_data(pdev, data->id);
-	if (!pdata) {
-		dev_err(&pdev->dev, "No platform init data supplied.\n");
-		return -ENODEV;
-	}
+	pdata = devm_kzalloc(&pdev->dev,
+			     sizeof(struct exynos_tmu_platform_data),
+			     GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
 
+	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
 	data->pdata = pdata;
 	data->soc = pdata->type;
 
@@ -834,12 +931,16 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 	return 0;
 }
 
+static struct thermal_zone_of_device_ops exynos_sensor_ops = {
+	.get_temp = exynos_get_temp,
+	.set_emul_temp = exynos_tmu_set_emulation,
+};
+
 static int exynos_tmu_probe(struct platform_device *pdev)
 {
-	struct exynos_tmu_data *data;
 	struct exynos_tmu_platform_data *pdata;
-	struct thermal_sensor_conf *sensor_conf;
-	int ret, i;
+	struct exynos_tmu_data *data;
+	int ret;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
 					GFP_KERNEL);
@@ -849,9 +950,15 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, data);
 	mutex_init(&data->lock);
 
+	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
+						    &exynos_sensor_ops);
+	if (IS_ERR(data->tzd)) {
+		pr_err("thermal: tz: %p ERROR\n", data->tzd);
+		return PTR_ERR(data->tzd);
+	}
 	ret = exynos_map_dt_data(pdev);
 	if (ret)
-		return ret;
+		goto err_sensor;
 
 	pdata = data->pdata;
 
@@ -860,20 +967,22 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
 	if (IS_ERR(data->clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
-		return  PTR_ERR(data->clk);
+		ret = PTR_ERR(data->clk);
+		goto err_sensor;
 	}
 
 	data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
 	if (IS_ERR(data->clk_sec)) {
 		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
 			dev_err(&pdev->dev, "Failed to get triminfo clock\n");
-			return PTR_ERR(data->clk_sec);
+			ret = PTR_ERR(data->clk_sec);
+			goto err_sensor;
 		}
 	} else {
 		ret = clk_prepare(data->clk_sec);
 		if (ret) {
 			dev_err(&pdev->dev, "Failed to get clock\n");
-			return ret;
+			goto err_sensor;
 		}
 	}
 
@@ -889,45 +998,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	exynos_tmu_control(pdev, true);
-
-	/* Allocate a structure to register with the exynos core thermal */
-	sensor_conf = devm_kzalloc(&pdev->dev,
-				sizeof(struct thermal_sensor_conf), GFP_KERNEL);
-	if (!sensor_conf) {
-		ret = -ENOMEM;
-		goto err_clk;
-	}
-	sprintf(sensor_conf->name, "therm_zone%d", data->id);
-	sensor_conf->read_temperature = (int (*)(void *))exynos_tmu_read;
-	sensor_conf->write_emul_temp =
-		(int (*)(void *, unsigned long))exynos_tmu_set_emulation;
-	sensor_conf->driver_data = data;
-	sensor_conf->trip_data.trip_count = pdata->trigger_enable[0] +
-			pdata->trigger_enable[1] + pdata->trigger_enable[2]+
-			pdata->trigger_enable[3];
-
-	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
-		sensor_conf->trip_data.trip_val[i] =
-			pdata->threshold + pdata->trigger_levels[i];
-		sensor_conf->trip_data.trip_type[i] =
-					pdata->trigger_type[i];
-	}
-
-	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
-
-	sensor_conf->dev = &pdev->dev;
-	/* Register the sensor with thermal management interface */
-	ret = exynos_register_thermal(sensor_conf);
-	if (ret) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"Failed to register thermal interface: %d\n",
-				ret);
-		goto err_clk;
-	}
-	data->reg_conf = sensor_conf;
-
 	ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
 		IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
 	if (ret) {
@@ -935,21 +1005,31 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
+	ret = exynos_tmu_initialize(pdev);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to initialize TMU\n");
+		goto err_clk;
+	}
+	exynos_tmu_control(pdev, true);
 	return 0;
+
 err_clk:
 	clk_unprepare(data->clk);
 err_clk_sec:
 	if (!IS_ERR(data->clk_sec))
 		clk_unprepare(data->clk_sec);
+err_sensor:
+	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
+
 	return ret;
 }
 
 static int exynos_tmu_remove(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	struct thermal_zone_device *tzd = data->tzd;
 
-	exynos_unregister_thermal(data->reg_conf);
-
+	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
 	exynos_tmu_control(pdev, false);
 
 	clk_unprepare(data->clk);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index fcdb2fc..b5400b7 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -24,40 +24,10 @@
 #define _EXYNOS_TMU_H
 #include <linux/cpu_cooling.h>
 
-#include "exynos_thermal_common.h"
-
 #include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
- * @threshold: basic temperature for generating interrupt
- *	       25 <= threshold <= 125 [unit: degree Celsius]
- * @threshold_falling: differntial value for setting threshold
- *		       of temperature falling interrupt.
- * @trigger_levels: array for each interrupt levels
- *	[unit: degree Celsius]
- *	0: temperature for trigger_level0 interrupt
- *	   condition for trigger_level0 interrupt:
- *		current temperature > threshold + trigger_levels[0]
- *	1: temperature for trigger_level1 interrupt
- *	   condition for trigger_level1 interrupt:
- *		current temperature > threshold + trigger_levels[1]
- *	2: temperature for trigger_level2 interrupt
- *	   condition for trigger_level2 interrupt:
- *		current temperature > threshold + trigger_levels[2]
- *	3: temperature for trigger_level3 interrupt
- *	   condition for trigger_level3 interrupt:
- *		current temperature > threshold + trigger_levels[3]
- * @trigger_type: defines the type of trigger. Possible values are,
- *	THROTTLE_ACTIVE trigger type
- *	THROTTLE_PASSIVE trigger type
- *	SW_TRIP trigger type
- *	HW_TRIP
- * @trigger_enable[]: array to denote which trigger levels are enabled.
- *	1 = enable trigger_level[] interrupt,
- *	0 = disable trigger_level[] interrupt
- * @max_trigger_level: max trigger level supported by the TMU
- * @non_hw_trigger_levels: number of defined non-hardware trigger levels
  * @gain: gain of amplifier in the positive-TC generator block
  *	0 < gain <= 15
  * @reference_voltage: reference voltage of amplifier
@@ -69,21 +39,12 @@
  * @efuse_value: platform defined fuse value
  * @min_efuse_value: minimum valid trimming data
  * @max_efuse_value: maximum valid trimming data
- * @first_point_trim: temp value of the first point trimming
- * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
 struct exynos_tmu_platform_data {
-	u8 threshold;
-	u8 threshold_falling;
-	u8 trigger_levels[MAX_TRIP_COUNT];
-	enum trigger_type trigger_type[MAX_TRIP_COUNT];
-	bool trigger_enable[MAX_TRIP_COUNT];
-	u8 max_trigger_level;
-	u8 non_hw_trigger_levels;
 	u8 gain;
 	u8 reference_voltage;
 	u8 noise_cancel_mode;
@@ -100,18 +61,6 @@ struct exynos_tmu_platform_data {
 	u32 type;
 };
 
-/**
- * struct exynos_tmu_init_data
- * @tmu_count: number of TMU instances.
- * @tmu_data: platform data of all TMU instances.
- * This structure is required to store data for multi-instance exynos tmu
- * driver.
- */
-struct exynos_tmu_init_data {
-	int tmu_count;
-	struct exynos_tmu_platform_data tmu_data[];
-};
-
 extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
 extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
 extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 14/17] thermal: exynos: Remove exynos_thermal_common.[c|h] files
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (13 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 13/17] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2014-12-10 12:09   ` [PATCH v2 15/17] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
                     ` (3 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

After defining all necessary Exynos data in the device tree and heavy
reusage of the of-thermal.c those files can be removed.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 drivers/thermal/samsung/exynos_thermal_common.c | 445 ------------------------
 drivers/thermal/samsung/exynos_thermal_common.h | 106 ------
 2 files changed, 551 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
deleted file mode 100644
index 00aa688..0000000
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ /dev/null
@@ -1,445 +0,0 @@
-/*
- * exynos_thermal_common.c - Samsung EXYNOS common thermal file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include <linux/cpu_cooling.h>
-#include <linux/err.h>
-#include <linux/slab.h>
-#include <linux/thermal.h>
-
-#include "exynos_thermal_common.h"
-
-struct exynos_thermal_zone {
-	enum thermal_device_mode mode;
-	struct thermal_zone_device *therm_dev;
-	struct thermal_cooling_device *cool_dev[MAX_COOLING_DEVICE];
-	unsigned int cool_dev_size;
-	struct platform_device *exynos4_dev;
-	struct thermal_sensor_conf *sensor_conf;
-	bool bind;
-};
-
-/* Get mode callback functions for thermal zone */
-static int exynos_get_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode *mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (th_zone)
-		*mode = th_zone->mode;
-	return 0;
-}
-
-/* Set mode callback functions for thermal zone */
-static int exynos_set_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (!th_zone) {
-		dev_err(&thermal->device,
-			"thermal zone not registered\n");
-		return 0;
-	}
-
-	mutex_lock(&thermal->lock);
-
-	if (mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling)
-		thermal->polling_delay = IDLE_INTERVAL;
-	else
-		thermal->polling_delay = 0;
-
-	mutex_unlock(&thermal->lock);
-
-	th_zone->mode = mode;
-	thermal_zone_device_update(thermal);
-	dev_dbg(th_zone->sensor_conf->dev,
-		"thermal polling set for duration=%d msec\n",
-		thermal->polling_delay);
-	return 0;
-}
-
-
-/* Get trip type callback functions for thermal zone */
-static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
-				 enum thermal_trip_type *type)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	int trip_type;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	trip_type = th_zone->sensor_conf->trip_data.trip_type[trip];
-
-	if (trip_type == SW_TRIP)
-		*type = THERMAL_TRIP_CRITICAL;
-	else if (trip_type == THROTTLE_ACTIVE)
-		*type = THERMAL_TRIP_ACTIVE;
-	else if (trip_type == THROTTLE_PASSIVE)
-		*type = THERMAL_TRIP_PASSIVE;
-	else
-		return -EINVAL;
-
-	return 0;
-}
-
-/* Get trip temperature callback functions for thermal zone */
-static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	*temp = th_zone->sensor_conf->trip_data.trip_val[trip];
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-
-	return 0;
-}
-
-/* Get critical temperature callback functions for thermal zone */
-static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	/* Get the temp of highest trip*/
-	return exynos_get_trip_temp(thermal, max_trip - 1, temp);
-}
-
-/* Bind callback functions for thermal zone */
-static int exynos_bind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-	struct of_phandle_args cooling_spec;
-	unsigned long max, state = 0;
-	int ret = 0, i = 0;
-
-	/*
-	 * Below code is necessary to skip binding when cpufreq's
-	 * frequency table is not yet initialized.
-	 */
-	cdev->ops->get_max_state(cdev, &state);
-	if (!state && !th_zone->cool_dev_size) {
-		th_zone->cool_dev_size = 1;
-		th_zone->cool_dev[0] = cdev;
-		th_zone->bind = false;
-		return 0;
-	}
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	for_each_child_of_node(child, gchild) {
-		ret = of_parse_phandle_with_args(gchild, "cooling-device",
-						 "#cooling-cells",
-						 0, &cooling_spec);
-		if (ret < 0) {
-			pr_err("missing cooling_device property\n");
-			goto end;
-		}
-
-		if (cooling_spec.args_count < 2) {
-			ret = -EINVAL;
-			goto end;
-		}
-
-		max = cooling_spec.args[0];
-		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-						     max, 0)) {
-			dev_err(data->dev,
-				"thermal error unbinding cdev inst=%d\n", i);
-
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = true;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Unbind callback functions for thermal zone */
-static int exynos_unbind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	int ret = 0, i;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-
-	if (th_zone->bind == false || !th_zone->cool_dev_size)
-		return 0;
-
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
-
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	i = 0;
-	for_each_child_of_node(child, gchild) {
-		if (thermal_zone_unbind_cooling_device(thermal, i,
-						       cdev)) {
-			dev_err(data->dev,
-				"error unbinding cdev inst=%d\n", i);
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = false;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_get_temp(struct thermal_zone_device *thermal,
-			unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	void *data;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	*temp = th_zone->sensor_conf->read_temperature(data);
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-	return 0;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
-						unsigned long temp)
-{
-	void *data;
-	int ret = -EINVAL;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	if (th_zone->sensor_conf->write_emul_temp)
-		ret = th_zone->sensor_conf->write_emul_temp(data, temp);
-	return ret;
-}
-
-/* Get the temperature trend */
-static int exynos_get_trend(struct thermal_zone_device *thermal,
-			int trip, enum thermal_trend *trend)
-{
-	int ret;
-	unsigned long trip_temp;
-
-	ret = exynos_get_trip_temp(thermal, trip, &trip_temp);
-	if (ret < 0)
-		return ret;
-
-	if (thermal->temperature >= trip_temp)
-		*trend = THERMAL_TREND_RAISE_FULL;
-	else
-		*trend = THERMAL_TREND_DROP_FULL;
-
-	return 0;
-}
-/* Operation callback functions for thermal zone */
-static struct thermal_zone_device_ops exynos_dev_ops = {
-	.bind = exynos_bind,
-	.unbind = exynos_unbind,
-	.get_temp = exynos_get_temp,
-	.set_emul_temp = exynos_set_emul_temp,
-	.get_trend = exynos_get_trend,
-	.get_mode = exynos_get_mode,
-	.set_mode = exynos_set_mode,
-	.get_trip_type = exynos_get_trip_type,
-	.get_trip_temp = exynos_get_trip_temp,
-	.get_crit_temp = exynos_get_crit_temp,
-};
-
-/*
- * This function may be called from interrupt based temperature sensor
- * when threshold is changed.
- */
-void exynos_report_trigger(struct thermal_sensor_conf *conf)
-{
-	unsigned int i;
-	char data[10];
-	char *envp[] = { data, NULL };
-	struct exynos_thermal_zone *th_zone;
-
-	if (!conf || !conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = conf->pzone_data;
-
-	if (th_zone->bind == false) {
-		for (i = 0; i < th_zone->cool_dev_size; i++) {
-			if (!th_zone->cool_dev[i])
-				continue;
-			exynos_bind(th_zone->therm_dev,
-					th_zone->cool_dev[i]);
-		}
-	}
-
-	thermal_zone_device_update(th_zone->therm_dev);
-
-	mutex_lock(&th_zone->therm_dev->lock);
-	/* Find the level for which trip happened */
-	for (i = 0; i < th_zone->sensor_conf->trip_data.trip_count; i++) {
-		if (th_zone->therm_dev->last_temperature <
-			th_zone->sensor_conf->trip_data.trip_val[i] * MCELSIUS)
-			break;
-	}
-
-	if (th_zone->mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling) {
-		if (i > 0)
-			th_zone->therm_dev->polling_delay = ACTIVE_INTERVAL;
-		else
-			th_zone->therm_dev->polling_delay = IDLE_INTERVAL;
-	}
-
-	snprintf(data, sizeof(data), "%u", i);
-	kobject_uevent_env(&th_zone->therm_dev->device.kobj, KOBJ_CHANGE, envp);
-	mutex_unlock(&th_zone->therm_dev->lock);
-}
-
-/* Register with the in-kernel thermal management */
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int ret;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->read_temperature) {
-		pr_err("Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-
-	th_zone = devm_kzalloc(sensor_conf->dev,
-				sizeof(struct exynos_thermal_zone), GFP_KERNEL);
-	if (!th_zone)
-		return -ENOMEM;
-
-	th_zone->sensor_conf = sensor_conf;
-	/*
-	 * TODO: 1) Handle multiple cooling devices in a thermal zone
-	 *	 2) Add a flag/name in cooling info to map to specific
-	 *	 sensor
-	 */
-	if (sensor_conf->cooling_data.freq_clip_count > 0) {
-		th_zone->cool_dev[th_zone->cool_dev_size] =
-				cpufreq_cooling_register(cpu_present_mask);
-		if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
-			ret = PTR_ERR(th_zone->cool_dev[th_zone->cool_dev_size]);
-			if (ret != -EPROBE_DEFER)
-				dev_err(sensor_conf->dev,
-					"Failed to register cpufreq cooling device: %d\n",
-					ret);
-			goto err_unregister;
-		}
-		th_zone->cool_dev_size++;
-	}
-
-	th_zone->therm_dev = thermal_zone_device_register(
-			sensor_conf->name, sensor_conf->trip_data.trip_count,
-			0, th_zone, &exynos_dev_ops, NULL, 0,
-			sensor_conf->trip_data.trigger_falling ? 0 :
-			IDLE_INTERVAL);
-
-	if (IS_ERR(th_zone->therm_dev)) {
-		dev_err(sensor_conf->dev,
-			"Failed to register thermal zone device\n");
-		ret = PTR_ERR(th_zone->therm_dev);
-		goto err_unregister;
-	}
-	th_zone->mode = THERMAL_DEVICE_ENABLED;
-	sensor_conf->pzone_data = th_zone;
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Thermal zone(%s) registered\n", sensor_conf->name);
-
-	return 0;
-
-err_unregister:
-	exynos_unregister_thermal(sensor_conf);
-	return ret;
-}
-
-/* Un-Register with the in-kernel thermal management */
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int i;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = sensor_conf->pzone_data;
-
-	thermal_zone_device_unregister(th_zone->therm_dev);
-
-	for (i = 0; i < th_zone->cool_dev_size; ++i)
-		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Kernel Thermal management unregistered\n");
-}
diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h
deleted file mode 100644
index cd44719..0000000
--- a/drivers/thermal/samsung/exynos_thermal_common.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * exynos_thermal_common.h - Samsung EXYNOS common header file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#ifndef _EXYNOS_THERMAL_COMMON_H
-#define _EXYNOS_THERMAL_COMMON_H
-
-/* In-kernel thermal framework related macros & definations */
-#define SENSOR_NAME_LEN	16
-#define MAX_TRIP_COUNT	8
-#define MAX_COOLING_DEVICE 4
-
-#define ACTIVE_INTERVAL 500
-#define IDLE_INTERVAL 10000
-#define MCELSIUS	1000
-
-/* CPU Zone information */
-#define PANIC_ZONE      4
-#define WARN_ZONE       3
-#define MONITOR_ZONE    2
-#define SAFE_ZONE       1
-
-#define GET_ZONE(trip) (trip + 2)
-#define GET_TRIP(zone) (zone - 2)
-
-enum trigger_type {
-	THROTTLE_ACTIVE = 1,
-	THROTTLE_PASSIVE,
-	SW_TRIP,
-	HW_TRIP,
-};
-
-/**
- * struct freq_clip_table
- * @freq_clip_max: maximum frequency allowed for this cooling state.
- * @temp_level: Temperature level at which the temperature clipping will
- *	happen.
- * @mask_val: cpumask of the allowed cpu's where the clipping will take place.
- *
- * This structure is required to be filled and passed to the
- * cpufreq_cooling_unregister function.
- */
-struct freq_clip_table {
-	unsigned int freq_clip_max;
-	unsigned int temp_level;
-	const struct cpumask *mask_val;
-};
-
-struct	thermal_trip_point_conf {
-	int trip_val[MAX_TRIP_COUNT];
-	int trip_type[MAX_TRIP_COUNT];
-	int trip_count;
-	unsigned char trigger_falling;
-};
-
-struct	thermal_cooling_conf {
-	struct freq_clip_table freq_data[MAX_TRIP_COUNT];
-	int freq_clip_count;
-};
-
-struct thermal_sensor_conf {
-	char name[SENSOR_NAME_LEN];
-	int (*read_temperature)(void *data);
-	int (*write_emul_temp)(void *drv_data, unsigned long temp);
-	struct thermal_trip_point_conf trip_data;
-	struct thermal_cooling_conf cooling_data;
-	void *driver_data;
-	void *pzone_data;
-	struct device *dev;
-};
-
-/*Functions used exynos based thermal sensor driver*/
-#ifdef CONFIG_EXYNOS_THERMAL_CORE
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf);
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf);
-void exynos_report_trigger(struct thermal_sensor_conf *sensor_conf);
-#else
-static inline void
-exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf) { return; }
-
-static inline int
-exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) { return 0; }
-
-static inline void
-exynos_report_trigger(struct thermal_sensor_conf *sensor_conf) { return; }
-
-#endif /* CONFIG_EXYNOS_THERMAL_CORE */
-#endif /* _EXYNOS_THERMAL_COMMON_H */
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 15/17] thermal: exynos: Remove exynos_tmu_data.c file
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (14 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 14/17] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2014-12-10 12:09   ` [PATCH v2 16/17] thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412 Lukasz Majewski
                     ` (2 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

Data already present in the exynos_tmu_data.c file has been moved to the
appropriate device tree files.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 drivers/thermal/samsung/exynos_tmu_data.c | 228 ------------------------------
 1 file changed, 228 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c

diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
deleted file mode 100644
index a993f3d..0000000
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * exynos_tmu_data.c - Samsung EXYNOS tmu data file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include "exynos_thermal_common.h"
-#include "exynos_tmu.h"
-
-struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
-	.tmu_data = {
-		{
-		.threshold = 80,
-		.trigger_levels[0] = 5,
-		.trigger_levels[1] = 20,
-		.trigger_levels[2] = 30,
-		.trigger_enable[0] = true,
-		.trigger_enable[1] = true,
-		.trigger_enable[2] = true,
-		.trigger_enable[3] = false,
-		.trigger_type[0] = THROTTLE_ACTIVE,
-		.trigger_type[1] = THROTTLE_ACTIVE,
-		.trigger_type[2] = SW_TRIP,
-		.max_trigger_level = 4,
-		.non_hw_trigger_levels = 3,
-		.gain = 15,
-		.reference_voltage = 7,
-		.cal_type = TYPE_ONE_POINT_TRIMMING,
-		.min_efuse_value = 40,
-		.max_efuse_value = 100,
-		.first_point_trim = 25,
-		.second_point_trim = 85,
-		.default_temp_offset = 50,
-		.type = SOC_ARCH_EXYNOS4210,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS3250_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_TWO_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS3250_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS3250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS4412_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS4412,
-		},
-	},
-	.tmu_count = 1,
-};
-
-struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS5250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define __EXYNOS5260_TMU_DATA	\
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 85, \
-	.trigger_levels[1] = 103, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50,
-
-#define EXYNOS5260_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5260
-
-struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5420_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420
-
-#define EXYNOS5420_TMU_DATA_SHARED \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420_TRIMINFO
-
-struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5440_TMU_DATA \
-	.trigger_levels[0] = 100, \
-	.trigger_levels[4] = 105, \
-	.trigger_enable[0] = 1, \
-	.trigger_type[0] = SW_TRIP, \
-	.trigger_type[4] = HW_TRIP, \
-	.max_trigger_level = 5, \
-	.non_hw_trigger_levels = 1, \
-	.gain = 5, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 0x5b2d, \
-	.min_efuse_value = 16, \
-	.max_efuse_value = 76, \
-	.first_point_trim = 25, \
-	.second_point_trim = 70, \
-	.default_temp_offset = 25, \
-	.type = SOC_ARCH_EXYNOS5440
-
-struct exynos_tmu_init_data const exynos5440_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-	},
-	.tmu_count = 3,
-};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 16/17] thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (15 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 15/17] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2014-12-10 12:09   ` [PATCH v2 17/17] thermal: exynos: Make Exynos3250 " Lukasz Majewski
  2015-01-02 18:25   ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Eduardo Valentin
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

Both SoCs have the same TMU IP block embedded on them. Necessary differences
are specified via device tree.

Therefore there is no need to maintain a separate compatible entry.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 arch/arm/boot/dts/exynos5250.dtsi    | 2 +-
 drivers/thermal/samsung/exynos_tmu.c | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index 2167394..7cb1a5b 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -238,7 +238,7 @@
 	};
 
 	tmu: tmu@10060000 {
-		compatible = "samsung,exynos5250-tmu";
+		compatible = "samsung,exynos4412-tmu";
 		reg = <0x10060000 0x100>;
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index dfbf9bd..05441fc 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -768,9 +768,6 @@ static const struct of_device_id exynos_tmu_match[] = {
 		.compatible = "samsung,exynos4412-tmu",
 	},
 	{
-		.compatible = "samsung,exynos5250-tmu",
-	},
-	{
 		.compatible = "samsung,exynos5260-tmu",
 	},
 	{
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v2 17/17] thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (16 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 16/17] thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412 Lukasz Majewski
@ 2014-12-10 12:09   ` Lukasz Majewski
  2015-01-02 18:25   ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Eduardo Valentin
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi,
	Lukasz Majewski

Both SoCs have the same TMU IP block embedded on them. Necessary differences
are specified via device tree.

Therefore there is no need to maintain a separate compatible entry.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Update DTS TMU entry for Exynos3250 to be compatible with Exynos4412
---
 arch/arm/boot/dts/exynos3250.dtsi    | 2 +-
 drivers/thermal/samsung/exynos_tmu.c | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/exynos3250.dtsi b/arch/arm/boot/dts/exynos3250.dtsi
index 6edfa76..306d988 100644
--- a/arch/arm/boot/dts/exynos3250.dtsi
+++ b/arch/arm/boot/dts/exynos3250.dtsi
@@ -185,7 +185,7 @@
 		};
 
 		tmu: tmu@100C0000 {
-			compatible = "samsung,exynos3250-tmu";
+			compatible = "samsung,exynos4412-tmu";
 			reg = <0x100C0000 0x100>;
 			interrupts = <0 216 0>;
 			clocks = <&cmu CLK_TMU_APBIF>;
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 05441fc..86728c5 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -759,9 +759,6 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 
 static const struct of_device_id exynos_tmu_match[] = {
 	{
-		.compatible = "samsung,exynos3250-tmu",
-	},
-	{
 		.compatible = "samsung,exynos4210-tmu",
 	},
 	{
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree
  2014-12-10 10:27   ` Eduardo Valentin
@ 2014-12-10 14:19     ` Lukasz Majewski
  2014-12-22 15:50       ` Abhilash Kesavan
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-10 14:19 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

Hi Eduardo,

> On Wed, Dec 10, 2014 at 01:09:39PM +0100, Lukasz Majewski wrote:
> > 1. Introduction
> > 
> > Following patches aim to clean up the current implementation of the
> > thermal framework on Exynos devices.
> > 
> > The main goal was to use a generic code for reading thermal
> > configuration (of-thermal.c). Due to that redundant
> > exynos_thermal_common.[h|c] files were removed.
> > 
> 
> Very good! Thanks for cleaning the code.
> 
> Given the decision to be DT only, my only question now is if you need
> to support non-DT booting systems. Do you (Exynos platforms in
> general) care about booting without DT?

As fair as I know all Exynos systems have been ported to DT. Support
for new Exynos based devices is only accepted if configuration is DT
based.

> 
> If not, then removing makes completely sense to me.
> 
> 
> > Around 400 lines of code (LOC) were removed directly by this patch,
> > which is around 20% of the Exynos thermal code base.
> > 
> 
> Great!
> 
> > This work should NOT bring any functional changes to Exynos thermal 
> > subsystem.
> > 
> 
> OK.
> 
> > 2. Patch-set structure
> > 
> > Then the cpu_cooling functionality has been preserved to allow
> > cooling devices by reducing operating frequency. Definition of trip
> > points and cpufreq's cooling properties were moved to device tree.
> > 
> 
> uhh.. OK. but, by supporting of-thermal that means drivers should
> never care about loading cpu cooling. That is done via cpufreq-dt.

Up till now exynos has a Kbuild option to enable cpu_cooling for its
thermal subsystem.

cpufreq for Exynos also undergo major rework (done by Tomas Abraham):
"cpufreq: use generic cpufreq drivers for exynos platforms" [1]

It converts some Exynos 4 and 5 platform to use cpufreq-dt/cpufreq-bL
and is pretty close to be added in this merge window.

Unfortunately not all devices were converted (e.g. Exynos 4412) and old
legacy cpufreq code is used (I simply wait with porting Exynos4412 for
"base" patches landing in the kernel).

Although, this shouldn't be a problem.

> That is why we had the cycle with cpufreq folks, remember?
> 
> (I will have a look in your patches)

It would be great if those patches could find their way to therma -next.
Then also Abhilash could benefit from them.

> 
> > Then the rework of the way in which configuration data is provided
> > to the Exynos thermal subsystem was performed. Now device tree is
> > used for configuration.
> 
> This is very good. Do you care sending feedback if you need extra
> configuration or does of-thermal cover your scenarios (a part from the
> amendments you already did)?

Changes, which I did recently to of-thermal.c are enough.

> 
> I know people (tegra and rockchip) are interested in hw trip points,
> which I believe should be of your interest too. Of course, that is
> maybe an off-topic for this series.

With this patch series I've tried to preserve previous functionality.
I've got some ideas for improvements, but those are for other
discussion.

> 
> 
> > 
> > Patch series end with removing exynos5250/exynos3250 TMU
> > compatibles. Both SoCs have thermal management unit (TMU)
> > compatible with the one first introduced at Exynos4412.
> 
> OK. I will have a look in DT changes you did. But in general, removing
> support needs to be done carefully for backward compatibility :-(.

Essentially this is a clean up, not removing support. The trick here is
that Exynos4412 (which was added first to mainline), Exynos5250 and
Exynos3250 use the same TMU IP block.

> 
> > 
> > 3. Dead code removal
> > 
> > Thermal support for some SoCs, previously available in the
> > exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc1,
> > they didn't have TMU bindings.
> > 
> > Moreover, support for cpu_cooling devices was preserved only on
> > those SoCs which had available and working cpufreq driver.
> 
> 
> Have you tried your series with cpufreq-dt?

Since I don't know if [1] will be finally accepted - I've used already
available cpufreq code (with exynos_defconfig + cpu_cooling enabled).

I don't think that there should be any problem with using cpufreq-dt.
Moreover, we would have enough time for potential fixes before next
kernel (3.19) is released.

> 
> > 
> > 4. Testing
> > 
> > Test devices:
> > - Exynos4210 - Trats (TMU zone + cpu_cooling)
> > - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> > - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> > - Exynos5420 - Arndale-octa (only TMU zones)
> > 
> > Unfortunately, I don't posses Exynos5440 for testing. Its
> > functionality has been preserved in the code, but not tested on the
> > hardware. I would be grateful for help in testing.
> > 
> > 5. This work apply on the following tree:
> > 
> > kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> > SHA1: c42c7a44c7a543dcb388c1ee1a798e6ed76ad8cf
> > 
> > 
> > Lukasz Majewski (17):
> >   thermal: exynos: cosmetic: Correct comment format
> >   thermal: exynos: Provide thermal_exynos.h file to be included in
> >     device tree files
> >   thermal: dts: trats: Enable TMU on the Exynos4210 trats device
> >   thermal: dts: exynos: Add LD010 regulator node necessary for TMU
> > on Odroid
> >   thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device
> >   thermal: cpu_cooling: dts: Define device tree bindings for Exynos
> > cpu cooling functionality
> >   thermal: cpu_cooling: Modify exynos thermal code to use device
> > tree for cpu cooling configuration
> >   thermal: exynos: dts: Add default definition of the TMU sensor
> >     parameter
> >   thermal: dts: Default trip points definition for Exynos5420 SoCs
> >   thermal: exynos: dts: Define default thermal-zones for Exynos4
> >   thermal: dts: exynos: Trip points and sensor configuration data
> > for Exynos5440
> >   thermal: exynos: dts: Provide device tree bindings identical to
> > one in exynos_tmu_data.c
> >   thermal: samsung: core: Exynos TMU rework to use device tree for
> >     configuration
> >   thermal: exynos: Remove exynos_thermal_common.[c|h] files
> >   thermal: exynos: Remove exynos_tmu_data.c file
> >   thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412
> >   thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412
> > 
> >  arch/arm/boot/dts/exynos3250.dtsi                 |   6 +-
> >  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi        |  52 +++
> >  arch/arm/boot/dts/exynos4.dtsi                    |   5 +
> >  arch/arm/boot/dts/exynos4210-trats.dts            |  19 +
> >  arch/arm/boot/dts/exynos4210.dtsi                 |  43 ++-
> >  arch/arm/boot/dts/exynos4212.dtsi                 |  20 +
> >  arch/arm/boot/dts/exynos4412-odroid-common.dtsi   |  27 ++
> >  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi |  24 ++
> >  arch/arm/boot/dts/exynos4412-trats2.dts           |  15 +
> >  arch/arm/boot/dts/exynos4412.dtsi                 |  32 ++
> >  arch/arm/boot/dts/exynos4x12.dtsi                 |   3 +
> >  arch/arm/boot/dts/exynos5250.dtsi                 |  29 +-
> >  arch/arm/boot/dts/exynos5420-trip-points.dtsi     |  35 ++
> >  arch/arm/boot/dts/exynos5420.dtsi                 |  33 ++
> >  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi |  25 ++
> >  arch/arm/boot/dts/exynos5440-trip-points.dtsi     |  25 ++
> >  arch/arm/boot/dts/exynos5440.dtsi                 |  18 +
> >  drivers/cpufreq/exynos-cpufreq.c                  |  23 +-
> >  drivers/thermal/samsung/Makefile                  |   2 -
> >  drivers/thermal/samsung/exynos_thermal_common.c   | 427
> > ----------------------
> > drivers/thermal/samsung/exynos_thermal_common.h   | 106 ------
> > drivers/thermal/samsung/exynos_tmu.c              | 337
> > ++++++++++------- drivers/thermal/samsung/exynos_tmu.h
> > |  80 +--- drivers/thermal/samsung/exynos_tmu_data.c         | 264
> > ------------- include/dt-bindings/thermal/thermal_exynos.h      |
> > 37 ++ 25 files changed, 669 insertions(+), 1018 deletions(-)
> 
> Good!
> 
> >  create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
> >  create mode 100644
> > arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi create mode
> > 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi create mode
> > 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi create
> > mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi delete
> > mode 100644 drivers/thermal/samsung/exynos_thermal_common.c delete
> > mode 100644 drivers/thermal/samsung/exynos_thermal_common.h delete
> > mode 100644 drivers/thermal/samsung/exynos_tmu_data.c create mode
> > 100644 include/dt-bindings/thermal/thermal_exynos.h
> > 
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree
  2014-12-10 14:19     ` Lukasz Majewski
@ 2014-12-22 15:50       ` Abhilash Kesavan
  2014-12-22 16:21         ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Abhilash Kesavan @ 2014-12-22 15:50 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Kyungmin Park, Chanwoo Choi

Hi Lukasz and Eduardo,

[...]
>
> Although, this shouldn't be a problem.
>
>> That is why we had the cycle with cpufreq folks, remember?
>>
>> (I will have a look in your patches)
>
> It would be great if those patches could find their way to therma -next.
> Then also Abhilash could benefit from them.

I have a couple of 5420/5800 based chromebooks that I will test this
series on. Is it OK for me to start basing my Exynos7 TMU support on
this series ? Please let me know if I can help in any other way with
this.

Regards,
Abhilash

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree
  2014-12-22 15:50       ` Abhilash Kesavan
@ 2014-12-22 16:21         ` Lukasz Majewski
  2014-12-23 15:27           ` Abhilash Kesavan
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:21 UTC (permalink / raw)
  To: Abhilash Kesavan, Eduardo Valentin
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Kyungmin Park, Chanwoo Choi

Hi Abhilash,

> Hi Lukasz and Eduardo,
> 
> [...]
> >
> > Although, this shouldn't be a problem.
> >
> >> That is why we had the cycle with cpufreq folks, remember?
> >>
> >> (I will have a look in your patches)
> >
> > It would be great if those patches could find their way to therma
> > -next. Then also Abhilash could benefit from them.
> 
> I have a couple of 5420/5800 based chromebooks that I will test this
> series on. Is it OK for me to start basing my Exynos7 TMU support on
> this series ? Please let me know if I can help in any other way with
> this.

I'm fine if you rebase on top of my patches. 

However, it is up to Eduardo when he decides to pull them to -next
branch.

I hope that it will happen soon.

> 
> Regards,
> Abhilash



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree
  2014-12-22 16:21         ` Lukasz Majewski
@ 2014-12-23 15:27           ` Abhilash Kesavan
  0 siblings, 0 replies; 288+ messages in thread
From: Abhilash Kesavan @ 2014-12-23 15:27 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Kyungmin Park, Chanwoo Choi

Hi Lukasz,

On Mon, Dec 22, 2014 at 9:51 PM, Lukasz Majewski <l.majewski@samsung.com> wrote:
> Hi Abhilash,
>
>> Hi Lukasz and Eduardo,
>>
>> [...]
>> >
>> > Although, this shouldn't be a problem.
>> >
>> >> That is why we had the cycle with cpufreq folks, remember?
>> >>
>> >> (I will have a look in your patches)
>> >
>> > It would be great if those patches could find their way to therma
>> > -next. Then also Abhilash could benefit from them.
>>
>> I have a couple of 5420/5800 based chromebooks that I will test this
>> series on. Is it OK for me to start basing my Exynos7 TMU support on
>> this series ? Please let me know if I can help in any other way with
>> this.
>
> I'm fine if you rebase on top of my patches.
>
> However, it is up to Eduardo when he decides to pull them to -next
> branch.
>
> I hope that it will happen soon.

I tested a Peach Pit (5420 based chromebook) with your patches and
they work well (temperatures and software tripping). However, my
earlier comments with regards to duplicate exynos_tmu_initialize() and
the thermal zone showing as disabled in sysfs .

Also, I think the documentation for the dt properties are missing ?

I will post my exynos7 work based on your patches soon. Please take a look.

Regards,
Abhilash
>
>>
>> Regards,
>> Abhilash
>
>
>
> --
> Best regards,
>
> Lukasz Majewski
>
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 08/17] thermal: exynos: dts: Add default definition of the TMU sensor parameter
  2014-12-10 12:09   ` [PATCH v2 08/17] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
@ 2015-01-02 18:11     ` Eduardo Valentin
  2015-01-02 18:26       ` Eduardo Valentin
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:11 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 1858 bytes --]

Lukasz,

On Wed, Dec 10, 2014 at 01:09:47PM +0100, Lukasz Majewski wrote:
> Exynos 4 and 5 family of SoCs uses almost identical TMU sensor to measure the
> on chip temperature. For this reason it is possible to group TMU configuration
> parameters in one dts file.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - None
> ---
>  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi | 24 +++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>  create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
> 
> diff --git a/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
> new file mode 100644
> index 0000000..ee6d8bb
> --- /dev/null
> +++ b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
> @@ -0,0 +1,24 @@
> +/*
> + * Device tree sources for Exynos4412 TMU sensor configuration
> + *
> + * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + */
> +
> +#include <dt-bindings/thermal/thermal_exynos.h>
> +
> +#thermal-sensor-cells = <0>;
> +gain = <8>;
> +reference_voltage = <16>;
> +noise_cancel_mode = <4>;
> +efuse_value = <55>;
> +min_efuse_value = <40>;
> +max_efuse_value = <100>;
> +first_point_trim = <25>;
> +second_point_trim = <85>;
> +default_temp_offset = <50>;
> +cal_type = <TYPE_ONE_POINT_TRIMMING>;

Are the above properties specific to exynos? For specific DT entries,
they need to be marked with a prefix. Please read the 'Device Specific
Data' section of Device tree Documentation [1].

[1] - http://devicetree.org/Device_Tree_Usage
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 12/17] thermal: exynos: dts: Provide device tree bindings identical to one in exynos_tmu_data.c
  2014-12-10 12:09   ` [PATCH v2 12/17] thermal: exynos: dts: Provide device tree bindings identical to one in exynos_tmu_data.c Lukasz Majewski
@ 2015-01-02 18:13     ` Eduardo Valentin
  2015-01-12 15:36       ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:13 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 8913 bytes --]

Lukasz

On Wed, Dec 10, 2014 at 01:09:51PM +0100, Lukasz Majewski wrote:
> Presented device tree bindings provide data already hardcoded in the
> exynos_tmu_data.c file.
> After this commit, it should be possible to reuse common thermal core
> framework in Exynos SoCs.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Add proper TMU entries for exynos3250.dtsi
> ---
>  arch/arm/boot/dts/exynos3250.dtsi |  4 ++++
>  arch/arm/boot/dts/exynos4.dtsi    |  5 +++++
>  arch/arm/boot/dts/exynos4210.dtsi | 23 ++++++++++++++++++++++-
>  arch/arm/boot/dts/exynos4x12.dtsi |  3 +++
>  arch/arm/boot/dts/exynos5250.dtsi |  7 +++++--
>  arch/arm/boot/dts/exynos5420.dtsi | 33 +++++++++++++++++++++++++++++++++
>  arch/arm/boot/dts/exynos5440.dtsi | 18 ++++++++++++++++++
>  7 files changed, 90 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/exynos3250.dtsi b/arch/arm/boot/dts/exynos3250.dtsi
> index 693a327..6edfa76 100644
> --- a/arch/arm/boot/dts/exynos3250.dtsi
> +++ b/arch/arm/boot/dts/exynos3250.dtsi
> @@ -18,7 +18,9 @@
>   */
>  
>  #include "skeleton.dtsi"
> +#include "exynos4-cpu-thermal.dtsi"
>  #include <dt-bindings/clock/exynos3250.h>
> +#include <dt-bindings/thermal/thermal_exynos.h>
>  
>  / {
>  	compatible = "samsung,exynos3250";
> @@ -188,6 +190,8 @@
>  			interrupts = <0 216 0>;
>  			clocks = <&cmu CLK_TMU_APBIF>;
>  			clock-names = "tmu_apbif";
> +			type = <SOC_ARCH_EXYNOS3250>;

Why do we need a 'type' property here? Can't we reuse compatible?

> +			#include "exynos4412-tmu-sensor-conf.dtsi"
>  			status = "disabled";
>  		};
>  
> diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
> index e0278ec..1735bb3 100644
> --- a/arch/arm/boot/dts/exynos4.dtsi
> +++ b/arch/arm/boot/dts/exynos4.dtsi
> @@ -21,6 +21,7 @@
>  
>  #include <dt-bindings/clock/exynos4.h>
>  #include <dt-bindings/clock/exynos-audss-clk.h>
> +#include <dt-bindings/thermal/thermal_exynos.h>
>  #include "skeleton.dtsi"
>  
>  / {
> @@ -645,4 +646,8 @@
>  		samsung,sysreg = <&sys_reg>;
>  		status = "disabled";
>  	};
> +
> +	tmu: tmu@100C0000 {
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
> +	};
>  };
> diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
> index 10e8915..1c52681 100644
> --- a/arch/arm/boot/dts/exynos4210.dtsi
> +++ b/arch/arm/boot/dts/exynos4210.dtsi
> @@ -21,6 +21,8 @@
>  
>  #include "exynos4.dtsi"
>  #include "exynos4210-pinctrl.dtsi"
> +#include "exynos4-cpu-thermal.dtsi"
> +#include <dt-bindings/thermal/thermal_exynos.h>
>  
>  / {
>  	compatible = "samsung,exynos4210", "samsung,exynos4";
> @@ -146,16 +148,35 @@
>  		reg = <0x03860000 0x1000>;
>  	};
>  
> -	tmu@100C0000 {
> +	tmu: tmu@100C0000 {
>  		compatible = "samsung,exynos4210-tmu";
>  		interrupt-parent = <&combiner>;
>  		reg = <0x100C0000 0x100>;
>  		interrupts = <2 4>;
>  		clocks = <&clock CLK_TMU_APBIF>;
>  		clock-names = "tmu_apbif";
> +		gain = <15>;
> +		reference_voltage = <7>;
> +		type = <SOC_ARCH_EXYNOS4210>;
>  		status = "disabled";
>  	};
>  
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			trips {
> +			      cpu_alert0: cpu-alert-0 {
> +				      temperature = <85000>; /* millicelsius */
> +			      };
> +			      cpu_alert1: cpu-alert-1 {
> +				      temperature = <100000>; /* millicelsius */
> +			      };
> +			      cpu_alert2: cpu-alert-2 {
> +				      temperature = <110000>; /* millicelsius */
> +			      };
> +			};
> +		};
> +	};
> +
>  	g2d@12800000 {
>  		compatible = "samsung,s5pv210-g2d";
>  		reg = <0x12800000 0x1000>;
> diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi
> index 2e9f1f7..ee24d83 100644
> --- a/arch/arm/boot/dts/exynos4x12.dtsi
> +++ b/arch/arm/boot/dts/exynos4x12.dtsi
> @@ -19,6 +19,8 @@
>  
>  #include "exynos4.dtsi"
>  #include "exynos4x12-pinctrl.dtsi"
> +#include "exynos4-cpu-thermal.dtsi"
> +#include <dt-bindings/thermal/thermal_exynos.h>
>  
>  / {
>  	aliases {
> @@ -279,6 +281,7 @@
>  		reg = <0x100C0000 0x100>;
>  		clocks = <&clock 383>;
>  		clock-names = "tmu_apbif";
> +		type = <SOC_ARCH_EXYNOS4412>;
>  		status = "disabled";
>  	};
>  };
> diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
> index a5bbc1a..2167394 100644
> --- a/arch/arm/boot/dts/exynos5250.dtsi
> +++ b/arch/arm/boot/dts/exynos5250.dtsi
> @@ -20,8 +20,9 @@
>  #include <dt-bindings/clock/exynos5250.h>
>  #include "exynos5.dtsi"
>  #include "exynos5250-pinctrl.dtsi"
> -
> +#include "exynos4-cpu-thermal.dtsi"
>  #include <dt-bindings/clock/exynos-audss-clk.h>
> +#include <dt-bindings/thermal/thermal_exynos.h>
>  
>  / {
>  	compatible = "samsung,exynos5250", "samsung,exynos5";
> @@ -236,12 +237,14 @@
>  		status = "disabled";
>  	};
>  
> -	tmu@10060000 {
> +	tmu: tmu@10060000 {
>  		compatible = "samsung,exynos5250-tmu";
>  		reg = <0x10060000 0x100>;
>  		interrupts = <0 65 0>;
>  		clocks = <&clock CLK_TMU>;
>  		clock-names = "tmu_apbif";
> +		type = <SOC_ARCH_EXYNOS5250>;
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
>  	};
>  
>  	thermal-zones {
> diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
> index 8617a03..23d488b 100644
> --- a/arch/arm/boot/dts/exynos5420.dtsi
> +++ b/arch/arm/boot/dts/exynos5420.dtsi
> @@ -756,6 +756,8 @@
>  		interrupts = <0 65 0>;
>  		clocks = <&clock CLK_TMU>;
>  		clock-names = "tmu_apbif";
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
> +		type = <SOC_ARCH_EXYNOS5420>;
>  	};
>  
>  	tmu_cpu1: tmu@10064000 {
> @@ -764,6 +766,8 @@
>  		interrupts = <0 183 0>;
>  		clocks = <&clock CLK_TMU>;
>  		clock-names = "tmu_apbif";
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
> +		type = <SOC_ARCH_EXYNOS5420>;
>  	};
>  
>  	tmu_cpu2: tmu@10068000 {
> @@ -772,6 +776,8 @@
>  		interrupts = <0 184 0>;
>  		clocks = <&clock CLK_TMU>, <&clock CLK_TMU>;
>  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
> +		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
>  	};
>  
>  	tmu_cpu3: tmu@1006c000 {
> @@ -780,6 +786,8 @@
>  		interrupts = <0 185 0>;
>  		clocks = <&clock CLK_TMU>, <&clock CLK_TMU_GPU>;
>  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
> +		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
>  	};
>  
>  	tmu_gpu: tmu@100a0000 {
> @@ -788,6 +796,31 @@
>  		interrupts = <0 215 0>;
>  		clocks = <&clock CLK_TMU_GPU>, <&clock CLK_TMU>;
>  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
> +		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
> +	};
> +
> +	thermal-zones {
> +		cpu0_thermal: cpu0-thermal {
> +			thermal-sensors = <&tmu_cpu0>;
> +			#include "exynos5420-trip-points.dtsi"
> +		};
> +		cpu1_thermal: cpu1-thermal {
> +		       thermal-sensors = <&tmu_cpu1>;
> +		       #include "exynos5420-trip-points.dtsi"
> +		};
> +		cpu2_thermal: cpu2-thermal {
> +		       thermal-sensors = <&tmu_cpu2>;
> +		       #include "exynos5420-trip-points.dtsi"
> +		};
> +		cpu3_thermal: cpu3-thermal {
> +		       thermal-sensors = <&tmu_cpu3>;
> +		       #include "exynos5420-trip-points.dtsi"
> +		};
> +		gpu_thermal: gpu-thermal {
> +		       thermal-sensors = <&tmu_gpu>;
> +		       #include "exynos5420-trip-points.dtsi"
> +		};
>  	};
>  
>          watchdog: watchdog@101D0000 {
> diff --git a/arch/arm/boot/dts/exynos5440.dtsi b/arch/arm/boot/dts/exynos5440.dtsi
> index 8f3373c..59d9416 100644
> --- a/arch/arm/boot/dts/exynos5440.dtsi
> +++ b/arch/arm/boot/dts/exynos5440.dtsi
> @@ -219,6 +219,7 @@
>  		interrupts = <0 58 0>;
>  		clocks = <&clock CLK_B_125>;
>  		clock-names = "tmu_apbif";
> +		#include "exynos5440-tmu-sensor-conf.dtsi"
>  	};
>  
>  	tmuctrl_1: tmuctrl@16011C {
> @@ -227,6 +228,7 @@
>  		interrupts = <0 58 0>;
>  		clocks = <&clock CLK_B_125>;
>  		clock-names = "tmu_apbif";
> +		#include "exynos5440-tmu-sensor-conf.dtsi"
>  	};
>  
>  	tmuctrl_2: tmuctrl@160120 {
> @@ -235,6 +237,22 @@
>  		interrupts = <0 58 0>;
>  		clocks = <&clock CLK_B_125>;
>  		clock-names = "tmu_apbif";
> +		#include "exynos5440-tmu-sensor-conf.dtsi"
> +	};
> +
> +	thermal-zones {
> +		cpu0_thermal: cpu0-thermal {
> +			thermal-sensors = <&tmuctrl_0>;
> +			#include "exynos5440-trip-points.dtsi"
> +		};
> +		cpu1_thermal: cpu1-thermal {
> +		       thermal-sensors = <&tmuctrl_1>;
> +		       #include "exynos5440-trip-points.dtsi"
> +		};
> +		cpu2_thermal: cpu2-thermal {
> +		       thermal-sensors = <&tmuctrl_2>;
> +		       #include "exynos5440-trip-points.dtsi"
> +		};
>  	};
>  
>  	sata@210000 {
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 06/17] thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu cooling functionality
  2014-12-10 12:09   ` [PATCH v2 06/17] thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu cooling functionality Lukasz Majewski
@ 2015-01-02 18:15     ` Eduardo Valentin
  2015-01-12 14:09       ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:15 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 7134 bytes --]

On Wed, Dec 10, 2014 at 01:09:45PM +0100, Lukasz Majewski wrote:
> Presented patch aims to move data necessary for correct CPU cooling device
> configuration from exynos_tmu_data.c to device tree.

I believe the patch title is misleading. Looks like you are changing
something at cpu cooling, but in fact, you are changing DTS files. I
would suggest you to use a prefix like 'arm: dts: ....'

> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - None
> ---
>  arch/arm/boot/dts/exynos4210-trats.dts          | 15 ++++++++++++
>  arch/arm/boot/dts/exynos4210.dtsi               | 20 ++++++++++++++++
>  arch/arm/boot/dts/exynos4212.dtsi               | 20 ++++++++++++++++
>  arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 15 ++++++++++++
>  arch/arm/boot/dts/exynos4412-trats2.dts         | 15 ++++++++++++
>  arch/arm/boot/dts/exynos4412.dtsi               | 32 +++++++++++++++++++++++++
>  arch/arm/boot/dts/exynos5250.dtsi               | 20 +++++++++++++++-
>  7 files changed, 136 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
> index b59019c..d9dd9a7 100644
> --- a/arch/arm/boot/dts/exynos4210-trats.dts
> +++ b/arch/arm/boot/dts/exynos4210-trats.dts
> @@ -428,6 +428,21 @@
>  		status = "okay";
>  	};
>  
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				    /* Corresponds to 800MHz at freq_table */
> +				    cooling-device = <&cpu0 2 2>;
> +				};
> +				map1 {
> +				   /* Corresponds to 200MHz at freq_table */
> +				   cooling-device = <&cpu0 4 4>;
> +			       };
> +		       };
> +		};
> +	};
> +
>  	camera {
>  		pinctrl-names = "default";
>  		pinctrl-0 = <>;
> diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
> index 807bb5b..10e8915 100644
> --- a/arch/arm/boot/dts/exynos4210.dtsi
> +++ b/arch/arm/boot/dts/exynos4210.dtsi
> @@ -41,6 +41,26 @@
>  		#clock-cells = <1>;
>  	};
>  
> +	cpus {
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		cpu0: cpu@0 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a9";
> +			reg = <0x900>;
> +			cooling-min-level = <4>;
> +			cooling-max-level = <2>;
> +			#cooling-cells = <2>; /* min followed by max */
> +		};
> +
> +		cpu@1 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a9";
> +			reg = <0x901>;
> +		};
> +	};
> +
>  	sysram@02020000 {
>  		compatible = "mmio-sram";
>  		reg = <0x02020000 0x20000>;
> diff --git a/arch/arm/boot/dts/exynos4212.dtsi b/arch/arm/boot/dts/exynos4212.dtsi
> index 3c00e6e..6405954 100644
> --- a/arch/arm/boot/dts/exynos4212.dtsi
> +++ b/arch/arm/boot/dts/exynos4212.dtsi
> @@ -22,6 +22,26 @@
>  / {
>  	compatible = "samsung,exynos4212", "samsung,exynos4";
>  
> +	cpus {
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		cpu0: cpu@0 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a9";
> +			reg = <0xA00>;
> +			cooling-min-level = <13>;
> +			cooling-max-level = <7>;
> +			#cooling-cells = <2>; /* min followed by max */
> +		};
> +
> +		cpu@1 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a9";
> +			reg = <0xA01>;
> +		};
> +	};
> +
>  	combiner: interrupt-controller@10440000 {
>  		samsung,combiner-nr = <18>;
>  	};
> diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
> index eb1c08c..15d45f0 100644
> --- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
> +++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
> @@ -375,6 +375,21 @@
>  		vtmu-supply = <&ldo10_reg>;
>  		status = "okay";
>  	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				    /* Corresponds to 800MHz at freq_table */
> +				    cooling-device = <&cpu0 7 7>;
> +				};
> +				map1 {
> +				   /* Corresponds to 200MHz at freq_table */
> +				   cooling-device = <&cpu0 13 13>;
> +			       };
> +		       };
> +		};
> +	};
>  };
>  
>  &pinctrl_1 {
> diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts b/arch/arm/boot/dts/exynos4412-trats2.dts
> index 121430d..396c525 100644
> --- a/arch/arm/boot/dts/exynos4412-trats2.dts
> +++ b/arch/arm/boot/dts/exynos4412-trats2.dts
> @@ -786,4 +786,19 @@
>  		pulldown-ohm = <100000>; /* 100K */
>  		io-channels = <&adc 2>;  /* Battery temperature */
>  	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				    /* Corresponds to 800MHz at freq_table */
> +				    cooling-device = <&cpu0 7 7>;
> +				};
> +				map1 {
> +				   /* Corresponds to 200MHz at freq_table */
> +				   cooling-device = <&cpu0 13 13>;
> +			       };
> +		       };
> +		};
> +	};
>  };
> diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
> index d8bc059e..9ed8925 100644
> --- a/arch/arm/boot/dts/exynos4412.dtsi
> +++ b/arch/arm/boot/dts/exynos4412.dtsi
> @@ -22,6 +22,38 @@
>  / {
>  	compatible = "samsung,exynos4412", "samsung,exynos4";
>  
> +	cpus {
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		cpu0: cpu@0 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a9";
> +			reg = <0xA00>;
> +			cooling-min-level = <13>;
> +			cooling-max-level = <7>;
> +			#cooling-cells = <2>; /* min followed by max */
> +		};
> +
> +		cpu@1 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a9";
> +			reg = <0xA01>;
> +		};
> +
> +		cpu@2 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a9";
> +			reg = <0xA02>;
> +		};
> +
> +		cpu@3 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a9";
> +			reg = <0xA03>;
> +		};
> +	};
> +
>  	combiner: interrupt-controller@10440000 {
>  		samsung,combiner-nr = <20>;
>  	};
> diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
> index d55c1a2..a5bbc1a 100644
> --- a/arch/arm/boot/dts/exynos5250.dtsi
> +++ b/arch/arm/boot/dts/exynos5250.dtsi
> @@ -58,11 +58,14 @@
>  		#address-cells = <1>;
>  		#size-cells = <0>;
>  
> -		cpu@0 {
> +		cpu0: cpu@0 {
>  			device_type = "cpu";
>  			compatible = "arm,cortex-a15";
>  			reg = <0>;
>  			clock-frequency = <1700000000>;
> +			cooling-min-level = <15>;
> +			cooling-max-level = <9>;
> +			#cooling-cells = <2>; /* min followed by max */
>  		};
>  		cpu@1 {
>  			device_type = "cpu";
> @@ -241,6 +244,21 @@
>  		clock-names = "tmu_apbif";
>  	};
>  
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				    /* Corresponds to 800MHz at freq_table */
> +				    cooling-device = <&cpu0 9 9>;
> +				};
> +				map1 {
> +				   /* Corresponds to 200MHz at freq_table */
> +				   cooling-device = <&cpu0 15 15>;
> +			       };
> +		       };
> +		};
> +	};
> +
>  	serial@12C00000 {
>  		clocks = <&clock CLK_UART0>, <&clock CLK_SCLK_UART0>;
>  		clock-names = "uart", "clk_uart_baud0";
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 07/17] thermal: cpu_cooling: Modify exynos thermal code to use device tree for cpu cooling configuration
  2014-12-10 12:09   ` [PATCH v2 07/17] thermal: cpu_cooling: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
@ 2015-01-02 18:18     ` Eduardo Valentin
  2015-01-12 17:08       ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:18 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 12047 bytes --]

On Wed, Dec 10, 2014 at 01:09:46PM +0100, Lukasz Majewski wrote:
> Up till now exynos_tmu_data.c was used for storing CPU cooling configuration
> data. Now the Exynos thermal core code uses device tree to get this data.
> For this purpose generic thermal code for configuring CPU cooling was
> used.

Title prefix also does not help here, I would use 'thermal: exynos: ....'

> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - None
> ---
>  drivers/cpufreq/exynos-cpufreq.c                |  23 ++++-
>  drivers/thermal/samsung/exynos_thermal_common.c | 122 ++++++++++++++----------
>  drivers/thermal/samsung/exynos_tmu.c            |   7 --
>  drivers/thermal/samsung/exynos_tmu.h            |   5 -
>  drivers/thermal/samsung/exynos_tmu_data.c       |  42 +-------
>  5 files changed, 94 insertions(+), 105 deletions(-)
> 
> diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
> index 1e0ec57..fdedb8d 100644
> --- a/drivers/cpufreq/exynos-cpufreq.c
> +++ b/drivers/cpufreq/exynos-cpufreq.c
> @@ -18,10 +18,13 @@
>  #include <linux/cpufreq.h>
>  #include <linux/platform_device.h>
>  #include <linux/of.h>
> +#include <linux/cpu_cooling.h>
> +#include <linux/cpu.h>
>  
>  #include "exynos-cpufreq.h"
>  
>  static struct exynos_dvfs_info *exynos_info;
> +static struct thermal_cooling_device *cdev;
>  static struct regulator *arm_regulator;
>  static unsigned int locking_frequency;
>  
> @@ -156,6 +159,7 @@ static struct cpufreq_driver exynos_driver = {
>  
>  static int exynos_cpufreq_probe(struct platform_device *pdev)
>  {
> +	struct device_node *np;
>  	int ret = -EINVAL;
>  
>  	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
> @@ -198,9 +202,24 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
>  	/* Done here as we want to capture boot frequency */
>  	locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;
>  
> -	if (!cpufreq_register_driver(&exynos_driver))
> -		return 0;
> +	if (cpufreq_register_driver(&exynos_driver))
> +		goto err;
>  
> +	np = of_find_node_by_path("/cpus/cpu@0");
> +	if (!np) {
> +		pr_err("failed to find cpu0 node\n");
> +		return -ENOENT;
> +	}
> +	if (of_find_property(np, "#cooling-cells", NULL)) {
> +		cdev = of_cpufreq_cooling_register(np, cpu_present_mask);
> +		if (IS_ERR(cdev))
> +			pr_err("running cpufreq without cooling device: %ld\n",
> +			       PTR_ERR(cdev));
> +	}
> +	of_node_put(np);
> +
> +	return 0;
> + err:
>  	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
>  	regulator_put(arm_regulator);
>  err_vdd_arm:
> diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
> index 6dc3815..00aa688 100644
> --- a/drivers/thermal/samsung/exynos_thermal_common.c
> +++ b/drivers/thermal/samsung/exynos_thermal_common.c
> @@ -133,47 +133,62 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
>  static int exynos_bind(struct thermal_zone_device *thermal,
>  			struct thermal_cooling_device *cdev)
>  {
> -	int ret = 0, i, tab_size, level;
> -	struct freq_clip_table *tab_ptr, *clip_data;
>  	struct exynos_thermal_zone *th_zone = thermal->devdata;
>  	struct thermal_sensor_conf *data = th_zone->sensor_conf;
> +	struct device_node *child, *gchild, *np;
> +	struct of_phandle_args cooling_spec;
> +	unsigned long max, state = 0;
> +	int ret = 0, i = 0;
>  
> -	tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data;
> -	tab_size = data->cooling_data.freq_clip_count;
> -
> -	if (tab_ptr == NULL || tab_size == 0)
> +	/*
> +	 * Below code is necessary to skip binding when cpufreq's
> +	 * frequency table is not yet initialized.
> +	 */
> +	cdev->ops->get_max_state(cdev, &state);
> +	if (!state && !th_zone->cool_dev_size) {
> +		th_zone->cool_dev_size = 1;
> +		th_zone->cool_dev[0] = cdev;
> +		th_zone->bind = false;
>  		return 0;
> +	}
>  
> -	/* find the cooling device registered*/
> -	for (i = 0; i < th_zone->cool_dev_size; i++)
> -		if (cdev == th_zone->cool_dev[i])
> -			break;
> +	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
> +	if (!np) {
> +		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
> +		return -ENOENT;
> +	}
>  
> -	/* No matching cooling device */
> -	if (i == th_zone->cool_dev_size)
> -		return 0;
> +	child = of_get_child_by_name(np, "cooling-maps");
>  
> -	/* Bind the thermal zone to the cpufreq cooling device */
> -	for (i = 0; i < tab_size; i++) {
> -		clip_data = (struct freq_clip_table *)&(tab_ptr[i]);
> -		level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max);
> -		if (level == THERMAL_CSTATE_INVALID)
> -			return 0;
> -		switch (GET_ZONE(i)) {
> -		case MONITOR_ZONE:
> -		case WARN_ZONE:
> -			if (thermal_zone_bind_cooling_device(thermal, i, cdev,
> -								level, 0)) {
> -				dev_err(data->dev,
> -					"error unbinding cdev inst=%d\n", i);
> -				ret = -EINVAL;
> -			}
> -			th_zone->bind = true;
> -			break;
> -		default:
> +	for_each_child_of_node(child, gchild) {
> +		ret = of_parse_phandle_with_args(gchild, "cooling-device",
> +						 "#cooling-cells",
> +						 0, &cooling_spec);


hmm.. Why do we need to duplicate the same parsing found at of-thermal?
Can you please help me understand the reasoning?

> +		if (ret < 0) {
> +			pr_err("missing cooling_device property\n");
> +			goto end;
> +		}
> +
> +		if (cooling_spec.args_count < 2) {
>  			ret = -EINVAL;
> +			goto end;
>  		}
> +
> +		max = cooling_spec.args[0];
> +		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
> +						     max, 0)) {
> +			dev_err(data->dev,
> +				"thermal error unbinding cdev inst=%d\n", i);
> +
> +			ret = -EINVAL;
> +			goto end;
> +		}
> +		i++;
>  	}
> +	th_zone->bind = true;
> +end:
> +	of_node_put(child);
> +	of_node_put(np);
>  
>  	return ret;
>  }
> @@ -182,16 +197,12 @@ static int exynos_bind(struct thermal_zone_device *thermal,
>  static int exynos_unbind(struct thermal_zone_device *thermal,
>  			struct thermal_cooling_device *cdev)
>  {
> -	int ret = 0, i, tab_size;
> +	int ret = 0, i;
>  	struct exynos_thermal_zone *th_zone = thermal->devdata;
>  	struct thermal_sensor_conf *data = th_zone->sensor_conf;
> +	struct device_node *child, *gchild, *np;
>  
> -	if (th_zone->bind == false)
> -		return 0;
> -
> -	tab_size = data->cooling_data.freq_clip_count;
> -
> -	if (tab_size == 0)
> +	if (th_zone->bind == false || !th_zone->cool_dev_size)
>  		return 0;
>  
>  	/* find the cooling device registered*/
> @@ -203,23 +214,30 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
>  	if (i == th_zone->cool_dev_size)
>  		return 0;
>  
> -	/* Bind the thermal zone to the cpufreq cooling device */
> -	for (i = 0; i < tab_size; i++) {
> -		switch (GET_ZONE(i)) {
> -		case MONITOR_ZONE:
> -		case WARN_ZONE:
> -			if (thermal_zone_unbind_cooling_device(thermal, i,
> -								cdev)) {
> -				dev_err(data->dev,
> -					"error unbinding cdev inst=%d\n", i);
> -				ret = -EINVAL;
> -			}
> -			th_zone->bind = false;
> -			break;
> -		default:
> +	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
> +	if (!np) {
> +		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
> +		return -ENOENT;
> +	}
> +
> +	child = of_get_child_by_name(np, "cooling-maps");
> +
> +	i = 0;
> +	for_each_child_of_node(child, gchild) {
> +		if (thermal_zone_unbind_cooling_device(thermal, i,
> +						       cdev)) {
> +			dev_err(data->dev,
> +				"error unbinding cdev inst=%d\n", i);
>  			ret = -EINVAL;
> +			goto end;
>  		}
> +		i++;
>  	}
> +	th_zone->bind = false;
> +end:
> +	of_node_put(child);
> +	of_node_put(np);
> +
>  	return ret;
>  }
>  
> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index 936d16f..d2d6b53 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -916,13 +916,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  
>  	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
>  
> -	sensor_conf->cooling_data.freq_clip_count = pdata->freq_tab_count;
> -	for (i = 0; i < pdata->freq_tab_count; i++) {
> -		sensor_conf->cooling_data.freq_data[i].freq_clip_max =
> -					pdata->freq_tab[i].freq_clip_max;
> -		sensor_conf->cooling_data.freq_data[i].temp_level =
> -					pdata->freq_tab[i].temp_level;
> -	}
>  	sensor_conf->dev = &pdev->dev;
>  	/* Register the sensor with thermal management interface */
>  	ret = exynos_register_thermal(sensor_conf);
> diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
> index 03ebdd0..fcdb2fc 100644
> --- a/drivers/thermal/samsung/exynos_tmu.h
> +++ b/drivers/thermal/samsung/exynos_tmu.h
> @@ -73,9 +73,6 @@
>   * @second_point_trim: temp value of the second point trimming
>   * @default_temp_offset: default temperature offset in case of no trimming
>   * @cal_type: calibration type for temperature
> - * @freq_clip_table: Table representing frequency reduction percentage.
> - * @freq_tab_count: Count of the above table as frequency reduction may
> - *	applicable to only some of the trigger levels.
>   *
>   * This structure is required for configuration of exynos_tmu driver.
>   */
> @@ -101,8 +98,6 @@ struct exynos_tmu_platform_data {
>  	u32 cal_type;
>  	u32 cal_mode;
>  	u32 type;
> -	struct freq_clip_table freq_tab[4];
> -	unsigned int freq_tab_count;
>  };
>  
>  /**
> diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
> index b239100..a993f3d 100644
> --- a/drivers/thermal/samsung/exynos_tmu_data.c
> +++ b/drivers/thermal/samsung/exynos_tmu_data.c
> @@ -47,15 +47,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
>  		.first_point_trim = 25,
>  		.second_point_trim = 85,
>  		.default_temp_offset = 50,
> -		.freq_tab[0] = {
> -			.freq_clip_max = 800 * 1000,
> -			.temp_level = 85,
> -			},
> -		.freq_tab[1] = {
> -			.freq_clip_max = 200 * 1000,
> -			.temp_level = 100,
> -		},
> -		.freq_tab_count = 2,
>  		.type = SOC_ARCH_EXYNOS4210,
>  		},
>  	},
> @@ -87,16 +78,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
>  	.max_efuse_value = 100, \
>  	.first_point_trim = 25, \
>  	.second_point_trim = 85, \
> -	.default_temp_offset = 50, \
> -	.freq_tab[0] = { \
> -		.freq_clip_max = 800 * 1000, \
> -		.temp_level = 70, \
> -	}, \
> -	.freq_tab[1] = { \
> -		.freq_clip_max = 400 * 1000, \
> -		.temp_level = 95, \
> -	}, \
> -	.freq_tab_count = 2
> +	.default_temp_offset = 50
>  
>  struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
>  	.tmu_data = {
> @@ -133,16 +115,7 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
>  	.max_efuse_value = 100, \
>  	.first_point_trim = 25, \
>  	.second_point_trim = 85, \
> -	.default_temp_offset = 50, \
> -	.freq_tab[0] = { \
> -		.freq_clip_max = 1400 * 1000, \
> -		.temp_level = 70, \
> -	}, \
> -	.freq_tab[1] = { \
> -		.freq_clip_max = 400 * 1000, \
> -		.temp_level = 95, \
> -	}, \
> -	.freq_tab_count = 2
> +	.default_temp_offset = 50
>  
>  struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
>  	.tmu_data = {
> @@ -189,16 +162,7 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
>  	.max_efuse_value = 100, \
>  	.first_point_trim = 25, \
>  	.second_point_trim = 85, \
> -	.default_temp_offset = 50, \
> -	.freq_tab[0] = { \
> -		.freq_clip_max = 800 * 1000, \
> -		.temp_level = 85, \
> -	}, \
> -	.freq_tab[1] = { \
> -		.freq_clip_max = 200 * 1000, \
> -		.temp_level = 103, \
> -	}, \
> -	.freq_tab_count = 2, \
> +	.default_temp_offset = 50,
>  
>  #define EXYNOS5260_TMU_DATA \
>  	__EXYNOS5260_TMU_DATA \
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree
  2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
                     ` (17 preceding siblings ...)
  2014-12-10 12:09   ` [PATCH v2 17/17] thermal: exynos: Make Exynos3250 " Lukasz Majewski
@ 2015-01-02 18:25   ` Eduardo Valentin
  2015-01-03 19:53     ` Lukasz Majewski
  18 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:25 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 6212 bytes --]


Lukasz,

On Wed, Dec 10, 2014 at 01:09:39PM +0100, Lukasz Majewski wrote:
> 1. Introduction
> 
> Following patches aim to clean up the current implementation of the thermal
> framework on Exynos devices.
> 
> The main goal was to use a generic code for reading thermal configuration
> (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
> were removed.
> 
> Around 400 lines of code (LOC) were removed directly by this patch, which
> is around 20% of the Exynos thermal code base.
> 
> This work should NOT bring any functional changes to Exynos thermal 
> subsystem.
> 
> 2. Patch-set structure
> 
> Then the cpu_cooling functionality has been preserved to allow cooling
> devices by reducing operating frequency. Definition of trip points and
> cpufreq's cooling properties were moved to device tree.
> 
> Then the rework of the way in which configuration data is provided to
> the Exynos thermal subsystem was performed. Now device tree is used for
> configuration.
> 
> Patch series end with removing exynos5250/exynos3250 TMU compatibles.
> Both SoCs have thermal management unit (TMU) compatible with the one first 
> introduced at Exynos4412.
> 
> 3. Dead code removal
> 
> Thermal support for some SoCs, previously available in the exynos_tmu_data.c 
> file, was removed since, as of (almost) 3.19-rc1, they didn't have TMU bindings.
> 
> Moreover, support for cpu_cooling devices was preserved only on those
> SoCs which had available and working cpufreq driver.
> 
> 4. Testing
> 
> Test devices:
> - Exynos4210 - Trats (TMU zone + cpu_cooling)
> - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> - Exynos5420 - Arndale-octa (only TMU zones)
> 
> Unfortunately, I don't posses Exynos5440 for testing. Its functionality
> has been preserved in the code, but not tested on the hardware. I would
> be grateful for help in testing.
> 
> 5. This work apply on the following tree:
> 
> kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> SHA1: c42c7a44c7a543dcb388c1ee1a798e6ed76ad8cf
> 
> 
> Lukasz Majewski (17):
>   thermal: exynos: cosmetic: Correct comment format
>   thermal: exynos: Provide thermal_exynos.h file to be included in
>     device tree files
>   thermal: dts: trats: Enable TMU on the Exynos4210 trats device
>   thermal: dts: exynos: Add LD010 regulator node necessary for TMU on
>     Odroid
>   thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device
>   thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu
>     cooling functionality
>   thermal: cpu_cooling: Modify exynos thermal code to use device tree
>     for cpu cooling configuration
>   thermal: exynos: dts: Add default definition of the TMU sensor
>     parameter
>   thermal: dts: Default trip points definition for Exynos5420 SoCs
>   thermal: exynos: dts: Define default thermal-zones for Exynos4
>   thermal: dts: exynos: Trip points and sensor configuration data for
>     Exynos5440
>   thermal: exynos: dts: Provide device tree bindings identical to one in
>     exynos_tmu_data.c
>   thermal: samsung: core: Exynos TMU rework to use device tree for
>     configuration
>   thermal: exynos: Remove exynos_thermal_common.[c|h] files
>   thermal: exynos: Remove exynos_tmu_data.c file
>   thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412
>   thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412
> 
>  arch/arm/boot/dts/exynos3250.dtsi                 |   6 +-
>  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi        |  52 +++
>  arch/arm/boot/dts/exynos4.dtsi                    |   5 +
>  arch/arm/boot/dts/exynos4210-trats.dts            |  19 +
>  arch/arm/boot/dts/exynos4210.dtsi                 |  43 ++-
>  arch/arm/boot/dts/exynos4212.dtsi                 |  20 +
>  arch/arm/boot/dts/exynos4412-odroid-common.dtsi   |  27 ++
>  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi |  24 ++
>  arch/arm/boot/dts/exynos4412-trats2.dts           |  15 +
>  arch/arm/boot/dts/exynos4412.dtsi                 |  32 ++
>  arch/arm/boot/dts/exynos4x12.dtsi                 |   3 +
>  arch/arm/boot/dts/exynos5250.dtsi                 |  29 +-
>  arch/arm/boot/dts/exynos5420-trip-points.dtsi     |  35 ++
>  arch/arm/boot/dts/exynos5420.dtsi                 |  33 ++
>  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi |  25 ++
>  arch/arm/boot/dts/exynos5440-trip-points.dtsi     |  25 ++
>  arch/arm/boot/dts/exynos5440.dtsi                 |  18 +
>  drivers/cpufreq/exynos-cpufreq.c                  |  23 +-
>  drivers/thermal/samsung/Makefile                  |   2 -
>  drivers/thermal/samsung/exynos_thermal_common.c   | 427 ----------------------
>  drivers/thermal/samsung/exynos_thermal_common.h   | 106 ------
>  drivers/thermal/samsung/exynos_tmu.c              | 337 ++++++++++-------
>  drivers/thermal/samsung/exynos_tmu.h              |  80 +---
>  drivers/thermal/samsung/exynos_tmu_data.c         | 264 -------------
>  include/dt-bindings/thermal/thermal_exynos.h      |  37 ++
>  25 files changed, 669 insertions(+), 1018 deletions(-)

Pretty good work moving data out of your driver. Impressed.

I sent out a couple of comments, most are minor. Major part is on
duplication of of-thermal parser.

>  create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi

good stuff here too. Only concern is regarding 'type' property (possible
to reuse compatible) and exynos specific data.

>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
>  delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
>  create mode 100644 include/dt-bindings/thermal/thermal_exynos.h
> 
> -- 
> 2.0.0.rc2
> 

Apologize for late answer.

Cheers,

Eduardo Valentin.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 08/17] thermal: exynos: dts: Add default definition of the TMU sensor parameter
  2015-01-02 18:11     ` Eduardo Valentin
@ 2015-01-02 18:26       ` Eduardo Valentin
  2015-01-12 14:42         ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:26 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 2135 bytes --]

On Fri, Jan 02, 2015 at 02:11:41PM -0400, Eduardo Valentin wrote:
> Lukasz,
> 
> On Wed, Dec 10, 2014 at 01:09:47PM +0100, Lukasz Majewski wrote:
> > Exynos 4 and 5 family of SoCs uses almost identical TMU sensor to measure the
> > on chip temperature. For this reason it is possible to group TMU configuration
> > parameters in one dts file.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - None
> > ---
> >  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi | 24 +++++++++++++++++++++++
> >  1 file changed, 24 insertions(+)
> >  create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
> > 
> > diff --git a/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
> > new file mode 100644
> > index 0000000..ee6d8bb
> > --- /dev/null
> > +++ b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
> > @@ -0,0 +1,24 @@
> > +/*
> > + * Device tree sources for Exynos4412 TMU sensor configuration
> > + *
> > + * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + *
> > + */
> > +
> > +#include <dt-bindings/thermal/thermal_exynos.h>
> > +
> > +#thermal-sensor-cells = <0>;
> > +gain = <8>;
> > +reference_voltage = <16>;
> > +noise_cancel_mode = <4>;
> > +efuse_value = <55>;
> > +min_efuse_value = <40>;
> > +max_efuse_value = <100>;
> > +first_point_trim = <25>;
> > +second_point_trim = <85>;
> > +default_temp_offset = <50>;
> > +cal_type = <TYPE_ONE_POINT_TRIMMING>;
> 
> Are the above properties specific to exynos? For specific DT entries,
> they need to be marked with a prefix. Please read the 'Device Specific
> Data' section of Device tree Documentation [1].
> 
> [1] - http://devicetree.org/Device_Tree_Usage


BTW, you have to update:
Documentation/devicetree/bindings/thermal/exynos-thermal.txt


> > -- 
> > 2.0.0.rc2
> > 



[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree
  2015-01-02 18:25   ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Eduardo Valentin
@ 2015-01-03 19:53     ` Lukasz Majewski
  2015-01-05 21:11       ` Eduardo Valentin
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-03 19:53 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Lukasz Majewski, Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 6775 bytes --]

On Fri, 2 Jan 2015 14:25:26 -0400
Eduardo Valentin <edubezval@gmail.com> wrote:

> 
> Lukasz,
> 
> On Wed, Dec 10, 2014 at 01:09:39PM +0100, Lukasz Majewski wrote:
> > 1. Introduction
> > 
> > Following patches aim to clean up the current implementation of the
> > thermal framework on Exynos devices.
> > 
> > The main goal was to use a generic code for reading thermal
> > configuration (of-thermal.c). Due to that redundant
> > exynos_thermal_common.[h|c] files were removed.
> > 
> > Around 400 lines of code (LOC) were removed directly by this patch,
> > which is around 20% of the Exynos thermal code base.
> > 
> > This work should NOT bring any functional changes to Exynos thermal 
> > subsystem.
> > 
> > 2. Patch-set structure
> > 
> > Then the cpu_cooling functionality has been preserved to allow
> > cooling devices by reducing operating frequency. Definition of trip
> > points and cpufreq's cooling properties were moved to device tree.
> > 
> > Then the rework of the way in which configuration data is provided
> > to the Exynos thermal subsystem was performed. Now device tree is
> > used for configuration.
> > 
> > Patch series end with removing exynos5250/exynos3250 TMU
> > compatibles. Both SoCs have thermal management unit (TMU)
> > compatible with the one first introduced at Exynos4412.
> > 
> > 3. Dead code removal
> > 
> > Thermal support for some SoCs, previously available in the
> > exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc1,
> > they didn't have TMU bindings.
> > 
> > Moreover, support for cpu_cooling devices was preserved only on
> > those SoCs which had available and working cpufreq driver.
> > 
> > 4. Testing
> > 
> > Test devices:
> > - Exynos4210 - Trats (TMU zone + cpu_cooling)
> > - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> > - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> > - Exynos5420 - Arndale-octa (only TMU zones)
> > 
> > Unfortunately, I don't posses Exynos5440 for testing. Its
> > functionality has been preserved in the code, but not tested on the
> > hardware. I would be grateful for help in testing.
> > 
> > 5. This work apply on the following tree:
> > 
> > kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> > SHA1: c42c7a44c7a543dcb388c1ee1a798e6ed76ad8cf
> > 
> > 
> > Lukasz Majewski (17):
> >   thermal: exynos: cosmetic: Correct comment format
> >   thermal: exynos: Provide thermal_exynos.h file to be included in
> >     device tree files
> >   thermal: dts: trats: Enable TMU on the Exynos4210 trats device
> >   thermal: dts: exynos: Add LD010 regulator node necessary for TMU
> > on Odroid
> >   thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device
> >   thermal: cpu_cooling: dts: Define device tree bindings for Exynos
> > cpu cooling functionality
> >   thermal: cpu_cooling: Modify exynos thermal code to use device
> > tree for cpu cooling configuration
> >   thermal: exynos: dts: Add default definition of the TMU sensor
> >     parameter
> >   thermal: dts: Default trip points definition for Exynos5420 SoCs
> >   thermal: exynos: dts: Define default thermal-zones for Exynos4
> >   thermal: dts: exynos: Trip points and sensor configuration data
> > for Exynos5440
> >   thermal: exynos: dts: Provide device tree bindings identical to
> > one in exynos_tmu_data.c
> >   thermal: samsung: core: Exynos TMU rework to use device tree for
> >     configuration
> >   thermal: exynos: Remove exynos_thermal_common.[c|h] files
> >   thermal: exynos: Remove exynos_tmu_data.c file
> >   thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412
> >   thermal: exynos: Make Exynos3250 TMU compatible with Exynos4412
> > 
> >  arch/arm/boot/dts/exynos3250.dtsi                 |   6 +-
> >  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi        |  52 +++
> >  arch/arm/boot/dts/exynos4.dtsi                    |   5 +
> >  arch/arm/boot/dts/exynos4210-trats.dts            |  19 +
> >  arch/arm/boot/dts/exynos4210.dtsi                 |  43 ++-
> >  arch/arm/boot/dts/exynos4212.dtsi                 |  20 +
> >  arch/arm/boot/dts/exynos4412-odroid-common.dtsi   |  27 ++
> >  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi |  24 ++
> >  arch/arm/boot/dts/exynos4412-trats2.dts           |  15 +
> >  arch/arm/boot/dts/exynos4412.dtsi                 |  32 ++
> >  arch/arm/boot/dts/exynos4x12.dtsi                 |   3 +
> >  arch/arm/boot/dts/exynos5250.dtsi                 |  29 +-
> >  arch/arm/boot/dts/exynos5420-trip-points.dtsi     |  35 ++
> >  arch/arm/boot/dts/exynos5420.dtsi                 |  33 ++
> >  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi |  25 ++
> >  arch/arm/boot/dts/exynos5440-trip-points.dtsi     |  25 ++
> >  arch/arm/boot/dts/exynos5440.dtsi                 |  18 +
> >  drivers/cpufreq/exynos-cpufreq.c                  |  23 +-
> >  drivers/thermal/samsung/Makefile                  |   2 -
> >  drivers/thermal/samsung/exynos_thermal_common.c   | 427
> > ----------------------
> > drivers/thermal/samsung/exynos_thermal_common.h   | 106 ------
> > drivers/thermal/samsung/exynos_tmu.c              | 337
> > ++++++++++------- drivers/thermal/samsung/exynos_tmu.h
> > |  80 +--- drivers/thermal/samsung/exynos_tmu_data.c         | 264
> > ------------- include/dt-bindings/thermal/thermal_exynos.h      |
> > 37 ++ 25 files changed, 669 insertions(+), 1018 deletions(-)
> 
> Pretty good work moving data out of your driver. Impressed.
> 
> I sent out a couple of comments, most are minor. Major part is on
> duplication of of-thermal parser.
> 

Thanks for your feedback.

> >  create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
> >  create mode 100644
> > arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi create mode
> > 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi create mode
> > 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi create
> > mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
> 
> good stuff here too. Only concern is regarding 'type' property
> (possible to reuse compatible) and exynos specific data.
> 
> >  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
> >  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
> >  delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
> >  create mode 100644 include/dt-bindings/thermal/thermal_exynos.h
> > 
> > -- 
> > 2.0.0.rc2
> > 
> 
> Apologize for late answer.

I will be able to address your comments no sooner than next Monday.
Moreover I still believe that we will manage to add this code to your
-next branch :-)

> 
> Cheers,
> 
> Eduardo Valentin.

Best regards,
Lukasz Majewski

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree
  2015-01-03 19:53     ` Lukasz Majewski
@ 2015-01-05 21:11       ` Eduardo Valentin
  0 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-05 21:11 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Lukasz Majewski, Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Kukjin Kim, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

Hi,

On Sat, Jan 03, 2015 at 08:53:45PM +0100, Lukasz Majewski wrote:

<cut> 
> > 

> > Apologize for late answer.
> 
> I will be able to address your comments no sooner than next Monday.
> Moreover I still believe that we will manage to add this code to your
> -next branch :-)

Good! Take your time.

Cheers,

Eduardo Valentin

> 
> > 
> > Cheers,
> > 
> > Eduardo Valentin.
> 
> Best regards,
> Lukasz Majewski



[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 06/17] thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu cooling functionality
  2015-01-02 18:15     ` Eduardo Valentin
@ 2015-01-12 14:09       ` Lukasz Majewski
  2015-01-12 14:24         ` Eduardo Valentin
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-12 14:09 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

Hi Eduardo,

> > Presented patch aims to move data necessary for correct CPU cooling
> > device configuration from exynos_tmu_data.c to device tree.  
> 
> I believe the patch title is misleading. Looks like you are changing
> something at cpu cooling, but in fact, you are changing DTS files. I
> would suggest you to use a prefix like 'arm: dts: ....'

Now this patch name is:
thermal: cpu_cooling: dts: ......

All the code in this patch adds bindings for 'thermal-zone' to map
cooling device to proper trip points.
In fact this is solely related to cpu_cooling...

>From the above, I think that the already provided convention is more
suitable and "arm: dts: cpu_cooling: thermal" seems a bit awkward for
me.

If you don't regard my justification as valid, then I will fix this.

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 06/17] thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu cooling functionality
  2015-01-12 14:09       ` Lukasz Majewski
@ 2015-01-12 14:24         ` Eduardo Valentin
  2015-01-13  8:22           ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-12 14:24 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]


On Mon, Jan 12, 2015 at 03:09:16PM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > > Presented patch aims to move data necessary for correct CPU cooling
> > > device configuration from exynos_tmu_data.c to device tree.  
> > 
> > I believe the patch title is misleading. Looks like you are changing
> > something at cpu cooling, but in fact, you are changing DTS files. I
> > would suggest you to use a prefix like 'arm: dts: ....'
> 
> Now this patch name is:
> thermal: cpu_cooling: dts: ......
> 
> All the code in this patch adds bindings for 'thermal-zone' to map
> cooling device to proper trip points.
> In fact this is solely related to cpu_cooling...
> 
> From the above, I think that the already provided convention is more
> suitable and "arm: dts: cpu_cooling: thermal" seems a bit awkward for
> me.
> 
> If you don't regard my justification as valid, then I will fix this.

Still, the naming is confusing. With that prefix you are saying this
patch is something generic about cpu cooling and thermal dts. And that
is not what this patch is about.

Saying "arm: dts: add cpu cooling bindings for Exynos" is a short and
direct subject. Besides, you have the plus to call the attention of the
ARM and device tree maintainers. It will be also in my radar.


The original subject also makes me think you are dealing with C code,
while the former says already upfront that you are talking about arm dts
bindings. 

Cheers,
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 08/17] thermal: exynos: dts: Add default definition of the TMU sensor parameter
  2015-01-02 18:26       ` Eduardo Valentin
@ 2015-01-12 14:42         ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-12 14:42 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

Hi Eduardo,

> On Fri, Jan 02, 2015 at 02:11:41PM -0400, Eduardo Valentin wrote:
> > Lukasz,
> > 
> > On Wed, Dec 10, 2014 at 01:09:47PM +0100, Lukasz Majewski wrote:
> > > Exynos 4 and 5 family of SoCs uses almost identical TMU sensor to
> > > measure the on chip temperature. For this reason it is possible
> > > to group TMU configuration parameters in one dts file.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > > Changes for v2:
> > > - None
> > > ---
> > >  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi | 24
> > > +++++++++++++++++++++++ 1 file changed, 24 insertions(+)
> > >  create mode 100644
> > > arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
> > > 
> > > diff --git a/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
> > > b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi new file mode
> > > 100644 index 0000000..ee6d8bb
> > > --- /dev/null
> > > +++ b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
> > > @@ -0,0 +1,24 @@
> > > +/*
> > > + * Device tree sources for Exynos4412 TMU sensor configuration
> > > + *
> > > + * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
> > > + *
> > > + * This program is free software; you can redistribute it and/or
> > > modify
> > > + * it under the terms of the GNU General Public License version
> > > 2 as
> > > + * published by the Free Software Foundation.
> > > + *
> > > + */
> > > +
> > > +#include <dt-bindings/thermal/thermal_exynos.h>
> > > +
> > > +#thermal-sensor-cells = <0>;
> > > +gain = <8>;
> > > +reference_voltage = <16>;
> > > +noise_cancel_mode = <4>;
> > > +efuse_value = <55>;
> > > +min_efuse_value = <40>;
> > > +max_efuse_value = <100>;
> > > +first_point_trim = <25>;
> > > +second_point_trim = <85>;
> > > +default_temp_offset = <50>;
> > > +cal_type = <TYPE_ONE_POINT_TRIMMING>;
> > 
> > Are the above properties specific to exynos? 

Yes, they are specific for Exynos.

> > For specific DT
> > entries, they need to be marked with a prefix. Please read the
> > 'Device Specific Data' section of Device tree Documentation [1].

Ok, I will. Thanks for tip.

> > 
> > [1] - http://devicetree.org/Device_Tree_Usage
> 
> 
> BTW, you have to update:
> Documentation/devicetree/bindings/thermal/exynos-thermal.txt

I've forgotten to update this entry. Will be fixed at v3.

> 
> 
> > > -- 
> > > 2.0.0.rc2
> > > 
> 
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 12/17] thermal: exynos: dts: Provide device tree bindings identical to one in exynos_tmu_data.c
  2015-01-02 18:13     ` Eduardo Valentin
@ 2015-01-12 15:36       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-12 15:36 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

Hi Eduardo,

> Lukasz
> 
> On Wed, Dec 10, 2014 at 01:09:51PM +0100, Lukasz Majewski wrote:
> > Presented device tree bindings provide data already hardcoded in the
> > exynos_tmu_data.c file.
> > After this commit, it should be possible to reuse common thermal
> > core framework in Exynos SoCs.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Add proper TMU entries for exynos3250.dtsi
> > ---
> >  arch/arm/boot/dts/exynos3250.dtsi |  4 ++++
> >  arch/arm/boot/dts/exynos4.dtsi    |  5 +++++
> >  arch/arm/boot/dts/exynos4210.dtsi | 23 ++++++++++++++++++++++-
> >  arch/arm/boot/dts/exynos4x12.dtsi |  3 +++
> >  arch/arm/boot/dts/exynos5250.dtsi |  7 +++++--
> >  arch/arm/boot/dts/exynos5420.dtsi | 33
> > +++++++++++++++++++++++++++++++++ arch/arm/boot/dts/exynos5440.dtsi
> > | 18 ++++++++++++++++++ 7 files changed, 90 insertions(+), 3
> > deletions(-)
> > 
> > diff --git a/arch/arm/boot/dts/exynos3250.dtsi
> > b/arch/arm/boot/dts/exynos3250.dtsi index 693a327..6edfa76 100644
> > --- a/arch/arm/boot/dts/exynos3250.dtsi
> > +++ b/arch/arm/boot/dts/exynos3250.dtsi
> > @@ -18,7 +18,9 @@
> >   */
> >  
> >  #include "skeleton.dtsi"
> > +#include "exynos4-cpu-thermal.dtsi"
> >  #include <dt-bindings/clock/exynos3250.h>
> > +#include <dt-bindings/thermal/thermal_exynos.h>
> >  
> >  / {
> >  	compatible = "samsung,exynos3250";
> > @@ -188,6 +190,8 @@
> >  			interrupts = <0 216 0>;
> >  			clocks = <&cmu CLK_TMU_APBIF>;
> >  			clock-names = "tmu_apbif";
> > +			type = <SOC_ARCH_EXYNOS3250>;
> 
> Why do we need a 'type' property here? Can't we reuse compatible?

It is doable to reuse "compatibles" for this purpose. We can do away
with "type" here.

I will do this for v3.

> 
> > +			#include "exynos4412-tmu-sensor-conf.dtsi"
> >  			status = "disabled";
> >  		};
> >  
> > diff --git a/arch/arm/boot/dts/exynos4.dtsi
> > b/arch/arm/boot/dts/exynos4.dtsi index e0278ec..1735bb3 100644
> > --- a/arch/arm/boot/dts/exynos4.dtsi
> > +++ b/arch/arm/boot/dts/exynos4.dtsi
> > @@ -21,6 +21,7 @@
> >  
> >  #include <dt-bindings/clock/exynos4.h>
> >  #include <dt-bindings/clock/exynos-audss-clk.h>
> > +#include <dt-bindings/thermal/thermal_exynos.h>
> >  #include "skeleton.dtsi"
> >  
> >  / {
> > @@ -645,4 +646,8 @@
> >  		samsung,sysreg = <&sys_reg>;
> >  		status = "disabled";
> >  	};
> > +
> > +	tmu: tmu@100C0000 {
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> > +	};
> >  };
> > diff --git a/arch/arm/boot/dts/exynos4210.dtsi
> > b/arch/arm/boot/dts/exynos4210.dtsi index 10e8915..1c52681 100644
> > --- a/arch/arm/boot/dts/exynos4210.dtsi
> > +++ b/arch/arm/boot/dts/exynos4210.dtsi
> > @@ -21,6 +21,8 @@
> >  
> >  #include "exynos4.dtsi"
> >  #include "exynos4210-pinctrl.dtsi"
> > +#include "exynos4-cpu-thermal.dtsi"
> > +#include <dt-bindings/thermal/thermal_exynos.h>
> >  
> >  / {
> >  	compatible = "samsung,exynos4210", "samsung,exynos4";
> > @@ -146,16 +148,35 @@
> >  		reg = <0x03860000 0x1000>;
> >  	};
> >  
> > -	tmu@100C0000 {
> > +	tmu: tmu@100C0000 {
> >  		compatible = "samsung,exynos4210-tmu";
> >  		interrupt-parent = <&combiner>;
> >  		reg = <0x100C0000 0x100>;
> >  		interrupts = <2 4>;
> >  		clocks = <&clock CLK_TMU_APBIF>;
> >  		clock-names = "tmu_apbif";
> > +		gain = <15>;
> > +		reference_voltage = <7>;
> > +		type = <SOC_ARCH_EXYNOS4210>;
> >  		status = "disabled";
> >  	};
> >  
> > +	thermal-zones {
> > +		cpu_thermal: cpu-thermal {
> > +			trips {
> > +			      cpu_alert0: cpu-alert-0 {
> > +				      temperature = <85000>; /*
> > millicelsius */
> > +			      };
> > +			      cpu_alert1: cpu-alert-1 {
> > +				      temperature = <100000>; /*
> > millicelsius */
> > +			      };
> > +			      cpu_alert2: cpu-alert-2 {
> > +				      temperature = <110000>; /*
> > millicelsius */
> > +			      };
> > +			};
> > +		};
> > +	};
> > +
> >  	g2d@12800000 {
> >  		compatible = "samsung,s5pv210-g2d";
> >  		reg = <0x12800000 0x1000>;
> > diff --git a/arch/arm/boot/dts/exynos4x12.dtsi
> > b/arch/arm/boot/dts/exynos4x12.dtsi index 2e9f1f7..ee24d83 100644
> > --- a/arch/arm/boot/dts/exynos4x12.dtsi
> > +++ b/arch/arm/boot/dts/exynos4x12.dtsi
> > @@ -19,6 +19,8 @@
> >  
> >  #include "exynos4.dtsi"
> >  #include "exynos4x12-pinctrl.dtsi"
> > +#include "exynos4-cpu-thermal.dtsi"
> > +#include <dt-bindings/thermal/thermal_exynos.h>
> >  
> >  / {
> >  	aliases {
> > @@ -279,6 +281,7 @@
> >  		reg = <0x100C0000 0x100>;
> >  		clocks = <&clock 383>;
> >  		clock-names = "tmu_apbif";
> > +		type = <SOC_ARCH_EXYNOS4412>;
> >  		status = "disabled";
> >  	};
> >  };
> > diff --git a/arch/arm/boot/dts/exynos5250.dtsi
> > b/arch/arm/boot/dts/exynos5250.dtsi index a5bbc1a..2167394 100644
> > --- a/arch/arm/boot/dts/exynos5250.dtsi
> > +++ b/arch/arm/boot/dts/exynos5250.dtsi
> > @@ -20,8 +20,9 @@
> >  #include <dt-bindings/clock/exynos5250.h>
> >  #include "exynos5.dtsi"
> >  #include "exynos5250-pinctrl.dtsi"
> > -
> > +#include "exynos4-cpu-thermal.dtsi"
> >  #include <dt-bindings/clock/exynos-audss-clk.h>
> > +#include <dt-bindings/thermal/thermal_exynos.h>
> >  
> >  / {
> >  	compatible = "samsung,exynos5250", "samsung,exynos5";
> > @@ -236,12 +237,14 @@
> >  		status = "disabled";
> >  	};
> >  
> > -	tmu@10060000 {
> > +	tmu: tmu@10060000 {
> >  		compatible = "samsung,exynos5250-tmu";
> >  		reg = <0x10060000 0x100>;
> >  		interrupts = <0 65 0>;
> >  		clocks = <&clock CLK_TMU>;
> >  		clock-names = "tmu_apbif";
> > +		type = <SOC_ARCH_EXYNOS5250>;
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> >  	};
> >  
> >  	thermal-zones {
> > diff --git a/arch/arm/boot/dts/exynos5420.dtsi
> > b/arch/arm/boot/dts/exynos5420.dtsi index 8617a03..23d488b 100644
> > --- a/arch/arm/boot/dts/exynos5420.dtsi
> > +++ b/arch/arm/boot/dts/exynos5420.dtsi
> > @@ -756,6 +756,8 @@
> >  		interrupts = <0 65 0>;
> >  		clocks = <&clock CLK_TMU>;
> >  		clock-names = "tmu_apbif";
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> > +		type = <SOC_ARCH_EXYNOS5420>;
> >  	};
> >  
> >  	tmu_cpu1: tmu@10064000 {
> > @@ -764,6 +766,8 @@
> >  		interrupts = <0 183 0>;
> >  		clocks = <&clock CLK_TMU>;
> >  		clock-names = "tmu_apbif";
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> > +		type = <SOC_ARCH_EXYNOS5420>;
> >  	};
> >  
> >  	tmu_cpu2: tmu@10068000 {
> > @@ -772,6 +776,8 @@
> >  		interrupts = <0 184 0>;
> >  		clocks = <&clock CLK_TMU>, <&clock CLK_TMU>;
> >  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> > +		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
> >  	};
> >  
> >  	tmu_cpu3: tmu@1006c000 {
> > @@ -780,6 +786,8 @@
> >  		interrupts = <0 185 0>;
> >  		clocks = <&clock CLK_TMU>, <&clock CLK_TMU_GPU>;
> >  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> > +		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
> >  	};
> >  
> >  	tmu_gpu: tmu@100a0000 {
> > @@ -788,6 +796,31 @@
> >  		interrupts = <0 215 0>;
> >  		clocks = <&clock CLK_TMU_GPU>, <&clock CLK_TMU>;
> >  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> > +		type = <SOC_ARCH_EXYNOS5420_TRIMINFO>;
> > +	};
> > +
> > +	thermal-zones {
> > +		cpu0_thermal: cpu0-thermal {
> > +			thermal-sensors = <&tmu_cpu0>;
> > +			#include "exynos5420-trip-points.dtsi"
> > +		};
> > +		cpu1_thermal: cpu1-thermal {
> > +		       thermal-sensors = <&tmu_cpu1>;
> > +		       #include "exynos5420-trip-points.dtsi"
> > +		};
> > +		cpu2_thermal: cpu2-thermal {
> > +		       thermal-sensors = <&tmu_cpu2>;
> > +		       #include "exynos5420-trip-points.dtsi"
> > +		};
> > +		cpu3_thermal: cpu3-thermal {
> > +		       thermal-sensors = <&tmu_cpu3>;
> > +		       #include "exynos5420-trip-points.dtsi"
> > +		};
> > +		gpu_thermal: gpu-thermal {
> > +		       thermal-sensors = <&tmu_gpu>;
> > +		       #include "exynos5420-trip-points.dtsi"
> > +		};
> >  	};
> >  
> >          watchdog: watchdog@101D0000 {
> > diff --git a/arch/arm/boot/dts/exynos5440.dtsi
> > b/arch/arm/boot/dts/exynos5440.dtsi index 8f3373c..59d9416 100644
> > --- a/arch/arm/boot/dts/exynos5440.dtsi
> > +++ b/arch/arm/boot/dts/exynos5440.dtsi
> > @@ -219,6 +219,7 @@
> >  		interrupts = <0 58 0>;
> >  		clocks = <&clock CLK_B_125>;
> >  		clock-names = "tmu_apbif";
> > +		#include "exynos5440-tmu-sensor-conf.dtsi"
> >  	};
> >  
> >  	tmuctrl_1: tmuctrl@16011C {
> > @@ -227,6 +228,7 @@
> >  		interrupts = <0 58 0>;
> >  		clocks = <&clock CLK_B_125>;
> >  		clock-names = "tmu_apbif";
> > +		#include "exynos5440-tmu-sensor-conf.dtsi"
> >  	};
> >  
> >  	tmuctrl_2: tmuctrl@160120 {
> > @@ -235,6 +237,22 @@
> >  		interrupts = <0 58 0>;
> >  		clocks = <&clock CLK_B_125>;
> >  		clock-names = "tmu_apbif";
> > +		#include "exynos5440-tmu-sensor-conf.dtsi"
> > +	};
> > +
> > +	thermal-zones {
> > +		cpu0_thermal: cpu0-thermal {
> > +			thermal-sensors = <&tmuctrl_0>;
> > +			#include "exynos5440-trip-points.dtsi"
> > +		};
> > +		cpu1_thermal: cpu1-thermal {
> > +		       thermal-sensors = <&tmuctrl_1>;
> > +		       #include "exynos5440-trip-points.dtsi"
> > +		};
> > +		cpu2_thermal: cpu2-thermal {
> > +		       thermal-sensors = <&tmuctrl_2>;
> > +		       #include "exynos5440-trip-points.dtsi"
> > +		};
> >  	};
> >  
> >  	sata@210000 {
> > -- 
> > 2.0.0.rc2
> > 


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 07/17] thermal: cpu_cooling: Modify exynos thermal code to use device tree for cpu cooling configuration
  2015-01-02 18:18     ` Eduardo Valentin
@ 2015-01-12 17:08       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-12 17:08 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

Hi Eduardo,

> On Wed, Dec 10, 2014 at 01:09:46PM +0100, Lukasz Majewski wrote:
> > Up till now exynos_tmu_data.c was used for storing CPU cooling
> > configuration data. Now the Exynos thermal core code uses device
> > tree to get this data. For this purpose generic thermal code for
> > configuring CPU cooling was used.
> 
> Title prefix also does not help here, I would use 'thermal:
> exynos: ....'

Ok.

> 
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - None
> > ---
> >  drivers/cpufreq/exynos-cpufreq.c                |  23 ++++-
> >  drivers/thermal/samsung/exynos_thermal_common.c | 122
> > ++++++++++++++----------
> > drivers/thermal/samsung/exynos_tmu.c            |   7 --
> > drivers/thermal/samsung/exynos_tmu.h            |   5 -
> > drivers/thermal/samsung/exynos_tmu_data.c       |  42 +------- 5
> > files changed, 94 insertions(+), 105 deletions(-)
> > 
> > diff --git a/drivers/cpufreq/exynos-cpufreq.c
> > b/drivers/cpufreq/exynos-cpufreq.c index 1e0ec57..fdedb8d 100644
> > --- a/drivers/cpufreq/exynos-cpufreq.c
> > +++ b/drivers/cpufreq/exynos-cpufreq.c
> > @@ -18,10 +18,13 @@
> >  #include <linux/cpufreq.h>
> >  #include <linux/platform_device.h>
> >  #include <linux/of.h>
> > +#include <linux/cpu_cooling.h>
> > +#include <linux/cpu.h>
> >  
> >  #include "exynos-cpufreq.h"
> >  
> >  static struct exynos_dvfs_info *exynos_info;
> > +static struct thermal_cooling_device *cdev;
> >  static struct regulator *arm_regulator;
> >  static unsigned int locking_frequency;
> >  
> > @@ -156,6 +159,7 @@ static struct cpufreq_driver exynos_driver = {
> >  
> >  static int exynos_cpufreq_probe(struct platform_device *pdev)
> >  {
> > +	struct device_node *np;
> >  	int ret = -EINVAL;
> >  
> >  	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
> > @@ -198,9 +202,24 @@ static int exynos_cpufreq_probe(struct
> > platform_device *pdev) /* Done here as we want to capture boot
> > frequency */ locking_frequency =
> > clk_get_rate(exynos_info->cpu_clk) / 1000; 
> > -	if (!cpufreq_register_driver(&exynos_driver))
> > -		return 0;
> > +	if (cpufreq_register_driver(&exynos_driver))
> > +		goto err;
> >  
> > +	np = of_find_node_by_path("/cpus/cpu@0");
> > +	if (!np) {
> > +		pr_err("failed to find cpu0 node\n");
> > +		return -ENOENT;
> > +	}
> > +	if (of_find_property(np, "#cooling-cells", NULL)) {
> > +		cdev = of_cpufreq_cooling_register(np,
> > cpu_present_mask);
> > +		if (IS_ERR(cdev))
> > +			pr_err("running cpufreq without cooling
> > device: %ld\n",
> > +			       PTR_ERR(cdev));
> > +	}
> > +	of_node_put(np);
> > +
> > +	return 0;
> > + err:
> >  	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
> >  	regulator_put(arm_regulator);
> >  err_vdd_arm:
> > diff --git a/drivers/thermal/samsung/exynos_thermal_common.c
> > b/drivers/thermal/samsung/exynos_thermal_common.c index
> > 6dc3815..00aa688 100644 ---
> > a/drivers/thermal/samsung/exynos_thermal_common.c +++
> > b/drivers/thermal/samsung/exynos_thermal_common.c @@ -133,47
> > +133,62 @@ static int exynos_get_crit_temp(struct
> > thermal_zone_device *thermal, static int exynos_bind(struct
> > thermal_zone_device *thermal, struct thermal_cooling_device *cdev) {
> > -	int ret = 0, i, tab_size, level;
> > -	struct freq_clip_table *tab_ptr, *clip_data;
> >  	struct exynos_thermal_zone *th_zone = thermal->devdata;
> >  	struct thermal_sensor_conf *data = th_zone->sensor_conf;
> > +	struct device_node *child, *gchild, *np;
> > +	struct of_phandle_args cooling_spec;
> > +	unsigned long max, state = 0;
> > +	int ret = 0, i = 0;
> >  
> > -	tab_ptr = (struct freq_clip_table
> > *)data->cooling_data.freq_data;
> > -	tab_size = data->cooling_data.freq_clip_count;
> > -
> > -	if (tab_ptr == NULL || tab_size == 0)
> > +	/*
> > +	 * Below code is necessary to skip binding when cpufreq's
> > +	 * frequency table is not yet initialized.
> > +	 */
> > +	cdev->ops->get_max_state(cdev, &state);
> > +	if (!state && !th_zone->cool_dev_size) {
> > +		th_zone->cool_dev_size = 1;
> > +		th_zone->cool_dev[0] = cdev;
> > +		th_zone->bind = false;
> >  		return 0;
> > +	}
> >  
> > -	/* find the cooling device registered*/
> > -	for (i = 0; i < th_zone->cool_dev_size; i++)
> > -		if (cdev == th_zone->cool_dev[i])
> > -			break;
> > +	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
> > +	if (!np) {
> > +		pr_err("failed to find thmerla-zones/cpu-thermal
> > node\n");
> > +		return -ENOENT;
> > +	}
> >  
> > -	/* No matching cooling device */
> > -	if (i == th_zone->cool_dev_size)
> > -		return 0;
> > +	child = of_get_child_by_name(np, "cooling-maps");
> >  
> > -	/* Bind the thermal zone to the cpufreq cooling device */
> > -	for (i = 0; i < tab_size; i++) {
> > -		clip_data = (struct freq_clip_table
> > *)&(tab_ptr[i]);
> > -		level = cpufreq_cooling_get_level(0,
> > clip_data->freq_clip_max);
> > -		if (level == THERMAL_CSTATE_INVALID)
> > -			return 0;
> > -		switch (GET_ZONE(i)) {
> > -		case MONITOR_ZONE:
> > -		case WARN_ZONE:
> > -			if
> > (thermal_zone_bind_cooling_device(thermal, i, cdev,
> > -
> > level, 0)) {
> > -				dev_err(data->dev,
> > -					"error unbinding cdev
> > inst=%d\n", i);
> > -				ret = -EINVAL;
> > -			}
> > -			th_zone->bind = true;
> > -			break;
> > -		default:
> > +	for_each_child_of_node(child, gchild) {
> > +		ret = of_parse_phandle_with_args(gchild,
> > "cooling-device",
> > +						 "#cooling-cells",
> > +						 0, &cooling_spec);
> 
> 
> hmm.. Why do we need to duplicate the same parsing found at
> of-thermal? Can you please help me understand the reasoning?

This hack is to provide thermal functionality between commits.

Please note that this file - exynos_thermal_common.c - is removed in
[PATCH 14/17], so this code is not present after applying the whole
series.

> 
> > +		if (ret < 0) {
> > +			pr_err("missing cooling_device
> > property\n");
> > +			goto end;
> > +		}
> > +
> > +		if (cooling_spec.args_count < 2) {
> >  			ret = -EINVAL;
> > +			goto end;
> >  		}
> > +
> > +		max = cooling_spec.args[0];
> > +		if (thermal_zone_bind_cooling_device(thermal, i,
> > cdev,
> > +						     max, 0)) {
> > +			dev_err(data->dev,
> > +				"thermal error unbinding cdev
> > inst=%d\n", i); +
> > +			ret = -EINVAL;
> > +			goto end;
> > +		}
> > +		i++;
> >  	}
> > +	th_zone->bind = true;
> > +end:
> > +	of_node_put(child);
> > +	of_node_put(np);
> >  
> >  	return ret;
> >  }
> > @@ -182,16 +197,12 @@ static int exynos_bind(struct
> > thermal_zone_device *thermal, static int exynos_unbind(struct
> > thermal_zone_device *thermal, struct thermal_cooling_device *cdev)
> >  {
> > -	int ret = 0, i, tab_size;
> > +	int ret = 0, i;
> >  	struct exynos_thermal_zone *th_zone = thermal->devdata;
> >  	struct thermal_sensor_conf *data = th_zone->sensor_conf;
> > +	struct device_node *child, *gchild, *np;
> >  
> > -	if (th_zone->bind == false)
> > -		return 0;
> > -
> > -	tab_size = data->cooling_data.freq_clip_count;
> > -
> > -	if (tab_size == 0)
> > +	if (th_zone->bind == false || !th_zone->cool_dev_size)
> >  		return 0;
> >  
> >  	/* find the cooling device registered*/
> > @@ -203,23 +214,30 @@ static int exynos_unbind(struct
> > thermal_zone_device *thermal, if (i == th_zone->cool_dev_size)
> >  		return 0;
> >  
> > -	/* Bind the thermal zone to the cpufreq cooling device */
> > -	for (i = 0; i < tab_size; i++) {
> > -		switch (GET_ZONE(i)) {
> > -		case MONITOR_ZONE:
> > -		case WARN_ZONE:
> > -			if
> > (thermal_zone_unbind_cooling_device(thermal, i,
> > -
> > cdev)) {
> > -				dev_err(data->dev,
> > -					"error unbinding cdev
> > inst=%d\n", i);
> > -				ret = -EINVAL;
> > -			}
> > -			th_zone->bind = false;
> > -			break;
> > -		default:
> > +	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
> > +	if (!np) {
> > +		pr_err("failed to find thmerla-zones/cpu-thermal
> > node\n");
> > +		return -ENOENT;
> > +	}
> > +
> > +	child = of_get_child_by_name(np, "cooling-maps");
> > +
> > +	i = 0;
> > +	for_each_child_of_node(child, gchild) {
> > +		if (thermal_zone_unbind_cooling_device(thermal, i,
> > +						       cdev)) {
> > +			dev_err(data->dev,
> > +				"error unbinding cdev inst=%d\n",
> > i); ret = -EINVAL;
> > +			goto end;
> >  		}
> > +		i++;
> >  	}
> > +	th_zone->bind = false;
> > +end:
> > +	of_node_put(child);
> > +	of_node_put(np);
> > +
> >  	return ret;
> >  }
> >  
> > diff --git a/drivers/thermal/samsung/exynos_tmu.c
> > b/drivers/thermal/samsung/exynos_tmu.c index 936d16f..d2d6b53 100644
> > --- a/drivers/thermal/samsung/exynos_tmu.c
> > +++ b/drivers/thermal/samsung/exynos_tmu.c
> > @@ -916,13 +916,6 @@ static int exynos_tmu_probe(struct
> > platform_device *pdev) 
> >  	sensor_conf->trip_data.trigger_falling =
> > pdata->threshold_falling; 
> > -	sensor_conf->cooling_data.freq_clip_count =
> > pdata->freq_tab_count;
> > -	for (i = 0; i < pdata->freq_tab_count; i++) {
> > -
> > sensor_conf->cooling_data.freq_data[i].freq_clip_max =
> > -
> > pdata->freq_tab[i].freq_clip_max;
> > -		sensor_conf->cooling_data.freq_data[i].temp_level =
> > -
> > pdata->freq_tab[i].temp_level;
> > -	}
> >  	sensor_conf->dev = &pdev->dev;
> >  	/* Register the sensor with thermal management interface */
> >  	ret = exynos_register_thermal(sensor_conf);
> > diff --git a/drivers/thermal/samsung/exynos_tmu.h
> > b/drivers/thermal/samsung/exynos_tmu.h index 03ebdd0..fcdb2fc 100644
> > --- a/drivers/thermal/samsung/exynos_tmu.h
> > +++ b/drivers/thermal/samsung/exynos_tmu.h
> > @@ -73,9 +73,6 @@
> >   * @second_point_trim: temp value of the second point trimming
> >   * @default_temp_offset: default temperature offset in case of no
> > trimming
> >   * @cal_type: calibration type for temperature
> > - * @freq_clip_table: Table representing frequency reduction
> > percentage.
> > - * @freq_tab_count: Count of the above table as frequency
> > reduction may
> > - *	applicable to only some of the trigger levels.
> >   *
> >   * This structure is required for configuration of exynos_tmu
> > driver. */
> > @@ -101,8 +98,6 @@ struct exynos_tmu_platform_data {
> >  	u32 cal_type;
> >  	u32 cal_mode;
> >  	u32 type;
> > -	struct freq_clip_table freq_tab[4];
> > -	unsigned int freq_tab_count;
> >  };
> >  
> >  /**
> > diff --git a/drivers/thermal/samsung/exynos_tmu_data.c
> > b/drivers/thermal/samsung/exynos_tmu_data.c index b239100..a993f3d
> > 100644 --- a/drivers/thermal/samsung/exynos_tmu_data.c
> > +++ b/drivers/thermal/samsung/exynos_tmu_data.c
> > @@ -47,15 +47,6 @@ struct exynos_tmu_init_data const
> > exynos4210_default_tmu_data = { .first_point_trim = 25,
> >  		.second_point_trim = 85,
> >  		.default_temp_offset = 50,
> > -		.freq_tab[0] = {
> > -			.freq_clip_max = 800 * 1000,
> > -			.temp_level = 85,
> > -			},
> > -		.freq_tab[1] = {
> > -			.freq_clip_max = 200 * 1000,
> > -			.temp_level = 100,
> > -		},
> > -		.freq_tab_count = 2,
> >  		.type = SOC_ARCH_EXYNOS4210,
> >  		},
> >  	},
> > @@ -87,16 +78,7 @@ struct exynos_tmu_init_data const
> > exynos4210_default_tmu_data = { .max_efuse_value = 100, \
> >  	.first_point_trim = 25, \
> >  	.second_point_trim = 85, \
> > -	.default_temp_offset = 50, \
> > -	.freq_tab[0] = { \
> > -		.freq_clip_max = 800 * 1000, \
> > -		.temp_level = 70, \
> > -	}, \
> > -	.freq_tab[1] = { \
> > -		.freq_clip_max = 400 * 1000, \
> > -		.temp_level = 95, \
> > -	}, \
> > -	.freq_tab_count = 2
> > +	.default_temp_offset = 50
> >  
> >  struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
> >  	.tmu_data = {
> > @@ -133,16 +115,7 @@ struct exynos_tmu_init_data const
> > exynos3250_default_tmu_data = { .max_efuse_value = 100, \
> >  	.first_point_trim = 25, \
> >  	.second_point_trim = 85, \
> > -	.default_temp_offset = 50, \
> > -	.freq_tab[0] = { \
> > -		.freq_clip_max = 1400 * 1000, \
> > -		.temp_level = 70, \
> > -	}, \
> > -	.freq_tab[1] = { \
> > -		.freq_clip_max = 400 * 1000, \
> > -		.temp_level = 95, \
> > -	}, \
> > -	.freq_tab_count = 2
> > +	.default_temp_offset = 50
> >  
> >  struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
> >  	.tmu_data = {
> > @@ -189,16 +162,7 @@ struct exynos_tmu_init_data const
> > exynos5250_default_tmu_data = { .max_efuse_value = 100, \
> >  	.first_point_trim = 25, \
> >  	.second_point_trim = 85, \
> > -	.default_temp_offset = 50, \
> > -	.freq_tab[0] = { \
> > -		.freq_clip_max = 800 * 1000, \
> > -		.temp_level = 85, \
> > -	}, \
> > -	.freq_tab[1] = { \
> > -		.freq_clip_max = 200 * 1000, \
> > -		.temp_level = 103, \
> > -	}, \
> > -	.freq_tab_count = 2, \
> > +	.default_temp_offset = 50,
> >  
> >  #define EXYNOS5260_TMU_DATA \
> >  	__EXYNOS5260_TMU_DATA \
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2 06/17] thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu cooling functionality
  2015-01-12 14:24         ` Eduardo Valentin
@ 2015-01-13  8:22           ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-13  8:22 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

Hi Eduardo,

> 
> On Mon, Jan 12, 2015 at 03:09:16PM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > > Presented patch aims to move data necessary for correct CPU
> > > > cooling device configuration from exynos_tmu_data.c to device
> > > > tree.  
> > > 
> > > I believe the patch title is misleading. Looks like you are
> > > changing something at cpu cooling, but in fact, you are changing
> > > DTS files. I would suggest you to use a prefix like 'arm:
> > > dts: ....'
> > 
> > Now this patch name is:
> > thermal: cpu_cooling: dts: ......
> > 
> > All the code in this patch adds bindings for 'thermal-zone' to map
> > cooling device to proper trip points.
> > In fact this is solely related to cpu_cooling...
> > 
> > From the above, I think that the already provided convention is more
> > suitable and "arm: dts: cpu_cooling: thermal" seems a bit awkward
> > for me.
> > 
> > If you don't regard my justification as valid, then I will fix this.
> 
> Still, the naming is confusing. With that prefix you are saying this
> patch is something generic about cpu cooling and thermal dts. And that
> is not what this patch is about.
> 
> Saying "arm: dts: add cpu cooling bindings for Exynos" is a short and
> direct subject. Besides, you have the plus to call the attention of
> the ARM and device tree maintainers. It will be also in my radar.

Fair enough. Thanks for clarification.

> 
> 
> The original subject also makes me think you are dealing with C code,
> while the former says already upfront that you are talking about arm
> dts bindings. 
> 
> Cheers,
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v3 00/16] thermal: exynos: Thermal code rework to use device tree
  2014-10-09 16:38 ` Lukasz Majewski
                   ` (24 preceding siblings ...)
  (?)
@ 2015-01-14 13:40 ` Lukasz Majewski
  2015-01-14 13:40   ` [PATCH v3 01/16] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
                     ` (16 more replies)
  -1 siblings, 17 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:40 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

1. Introduction

Following patches aim to clean up the current implementation of the thermal
framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration
(of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which
is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal 
subsystem.

2. Patch-set structure

Then the cpu_cooling functionality has been preserved to allow cooling
devices by reducing operating frequency. Definition of trip points and
cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to
the Exynos thermal subsystem was performed. Now device tree is used for
configuration.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c 
file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those
SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality
has been preserved in the code, but not tested on the hardware. I would
be grateful for help in testing.


5. This work apply on the following tree:

kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
SHA1: 1813d80874699145f04af6b05ebab0a6419001fb

Lukasz Majewski (16):
  thermal: exynos: cosmetic: Correct comment format
  thermal: exynos: Provide thermal_exynos.h file to be included in
    device tree files
  arm: dts: trats: Enable TMU on the Exynos4210 trats device
  arm: dts: odroid: Add LD010 regulator node necessary for TMU on Odroid
  thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device
  arm: dts: Adding CPU cooling binding for Exynos SoCs
  thermal: exynos: Modify exynos thermal code to use device tree for cpu
    cooling configuration
  thermal: exynos: dts: Add default definition of the TMU sensor
    parameter
  dts: Documentation: Extending documentation entry for exynos-thermal
  thermal: dts: Default trip points definition for Exynos5420 SoCs
  thermal: exynos: dts: Define default thermal-zones for Exynos4
  thermal: dts: exynos: Trip points and sensor configuration data for
    Exynos5440
  thermal: exynos: dts: Provide device tree bindings identical to the
    one in exynos_tmu_data.c
  thermal: samsung: core: Exynos TMU rework to use device tree for
    configuration
  thermal: exynos: Remove exynos_thermal_common.[c|h] files
  thermal: exynos: Remove exynos_tmu_data.c file

 .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
 arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   4 +
 arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
 arch/arm/boot/dts/exynos4210.dtsi                  |  26 +-
 arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
 arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
 arch/arm/boot/dts/exynos5250.dtsi                  |  25 +-
 arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
 arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
 arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
 drivers/cpufreq/exynos-cpufreq.c                   |  30 +-
 drivers/thermal/samsung/Makefile                   |   2 -
 drivers/thermal/samsung/exynos_thermal_common.c    | 427 ---------------------
 drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
 drivers/thermal/samsung/exynos_tmu.c               | 354 +++++++++++------
 drivers/thermal/samsung/exynos_tmu.h               |  68 +---
 drivers/thermal/samsung/exynos_tmu_data.c          | 264 -------------
 include/dt-bindings/thermal/thermal_exynos.h       |  28 ++
 26 files changed, 630 insertions(+), 1001 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

-- 
2.0.0.rc2

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v3 01/16] thermal: exynos: cosmetic: Correct comment format
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
@ 2015-01-14 13:40   ` Lukasz Majewski
  2015-01-14 13:41   ` [PATCH v3 02/16] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:40 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
---
 drivers/thermal/samsung/exynos_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index d2f1e62..5000727 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -576,7 +576,7 @@ out:
 #define exynos5440_tmu_set_emulation NULL
 static int exynos_tmu_set_emulation(void *drv_data,	unsigned long temp)
 	{ return -EINVAL; }
-#endif/*CONFIG_THERMAL_EMULATION*/
+#endif /* CONFIG_THERMAL_EMULATION */
 
 static int exynos4210_tmu_read(struct exynos_tmu_data *data)
 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 02/16] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
  2015-01-14 13:40   ` [PATCH v3 01/16] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-14 13:41   ` [PATCH v3 03/16] arm: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
                     ` (14 subsequent siblings)
  16 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This patch is a preparatory patch to be able to read Exynos thermal
configuration from the device tree.

It turned out that DTC is not able to interpret enums properly and hence
it is necessary to #define those values explicitly.

For this reason the ./include/dt-bindings/thermal/thermal_exynos.h file
has been introduced.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Restore 'enum soc_type type' since TMU sensor type will be extracted from
  device tree compatible
---
 drivers/thermal/samsung/exynos_tmu.h         | 12 +++---------
 include/dt-bindings/thermal/thermal_exynos.h | 28 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 9 deletions(-)
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index da3009b..7f880d2 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -26,14 +26,6 @@
 
 #include "exynos_thermal_common.h"
 
-enum calibration_type {
-	TYPE_ONE_POINT_TRIMMING,
-	TYPE_ONE_POINT_TRIMMING_25,
-	TYPE_ONE_POINT_TRIMMING_85,
-	TYPE_TWO_POINT_TRIMMING,
-	TYPE_NONE,
-};
-
 enum soc_type {
 	SOC_ARCH_EXYNOS3250 = 1,
 	SOC_ARCH_EXYNOS4210,
@@ -44,6 +36,7 @@ enum soc_type {
 	SOC_ARCH_EXYNOS5420_TRIMINFO,
 	SOC_ARCH_EXYNOS5440,
 };
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
@@ -115,8 +108,9 @@ struct exynos_tmu_platform_data {
 	u8 second_point_trim;
 	u8 default_temp_offset;
 
-	enum calibration_type cal_type;
 	enum soc_type type;
+	u32 cal_type;
+	u32 cal_mode;
 	struct freq_clip_table freq_tab[4];
 	unsigned int freq_tab_count;
 };
diff --git a/include/dt-bindings/thermal/thermal_exynos.h b/include/dt-bindings/thermal/thermal_exynos.h
new file mode 100644
index 0000000..0646500
--- /dev/null
+++ b/include/dt-bindings/thermal/thermal_exynos.h
@@ -0,0 +1,28 @@
+/*
+ * thermal_exynos.h - Samsung EXYNOS TMU device tree definitions
+ *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef _EXYNOS_THERMAL_TMU_DT_H
+#define _EXYNOS_THERMAL_TMU_DT_H
+
+#define TYPE_ONE_POINT_TRIMMING 0
+#define TYPE_ONE_POINT_TRIMMING_25 1
+#define TYPE_ONE_POINT_TRIMMING_85 2
+#define TYPE_TWO_POINT_TRIMMING 3
+#define TYPE_NONE 4
+
+#endif /* _EXYNOS_THERMAL_TMU_DT_H */
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 03/16] arm: dts: trats: Enable TMU on the Exynos4210 trats device
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
  2015-01-14 13:40   ` [PATCH v3 01/16] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
  2015-01-14 13:41   ` [PATCH v3 02/16] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-14 13:41   ` [PATCH v3 04/16] arm: dts: odroid: Add LD010 regulator node necessary for TMU on Odroid Lukasz Majewski
                     ` (13 subsequent siblings)
  16 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

The thermal IP block (Thermal Management Unit) called TMU has been enabled
in this device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Patch title has been changed from thermal: dts: arm to arm: dts: trats
---
 arch/arm/boot/dts/exynos4210-trats.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index 7208362..61009f4 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -424,6 +424,10 @@
 		status = "okay";
 	};
 
+	tmu@100C0000 {
+		status = "okay";
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 04/16] arm: dts: odroid: Add LD010 regulator node necessary for TMU on Odroid
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
                     ` (2 preceding siblings ...)
  2015-01-14 13:41   ` [PATCH v3 03/16] arm: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-14 13:41   ` [PATCH v3 05/16] thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
                     ` (12 subsequent siblings)
  16 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Patch title has been changed from thermal: dts: exynos to arm: dts: Odroid
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 3fbf588..0adb57c 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -231,6 +231,13 @@
 					regulator-always-on;
 				};
 
+				ldo10_reg: LDO10 {
+					regulator-name = "VDD18_MIPIHSI_1.8V";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <1800000>;
+					regulator-always-on;
+				};
+
 				ldo11_reg: LDO11 {
 					regulator-name = "VDD18_ABB1_1.8V";
 					regulator-min-microvolt = <1800000>;
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 05/16] thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
                     ` (3 preceding siblings ...)
  2015-01-14 13:41   ` [PATCH v3 04/16] arm: dts: odroid: Add LD010 regulator node necessary for TMU on Odroid Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-14 18:48     ` Eduardo Valentin
  2015-01-14 13:41   ` [PATCH v3 06/16] arm: dts: Adding CPU cooling binding for Exynos SoCs Lukasz Majewski
                     ` (11 subsequent siblings)
  16 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This commit enables TMU IP block on the Exynos4412 Odroid U3
device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 0adb57c..c7517fc 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -396,6 +396,11 @@
 	ehci: ehci@12580000 {
 		status = "okay";
 	};
+
+	tmu@100C0000 {
+		vtmu-supply = <&ldo10_reg>;
+		status = "okay";
+	};
 };
 
 &pinctrl_1 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 06/16] arm: dts: Adding CPU cooling binding for Exynos SoCs
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
                     ` (4 preceding siblings ...)
  2015-01-14 13:41   ` [PATCH v3 05/16] thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-14 18:57     ` Eduardo Valentin
  2015-01-14 13:41   ` [PATCH v3 07/16] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
                     ` (10 subsequent siblings)
  16 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Presented patch aims to move data necessary for correct CPU cooling device
configuration from exynos_tmu_data.c to device tree.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Adjust CPU's DT nodes to work with newest ti-soc-thermal/next branch
- Patch title has been changed from "thermal: cpu_cooling: dts: ..."
---
 arch/arm/boot/dts/exynos4210-trats.dts          | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4210.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos4212.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4412-trats2.dts         | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4412.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos5250.dtsi               | 20 +++++++++++++++++++-
 7 files changed, 76 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index 61009f4..4cd8926 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -428,6 +428,21 @@
 		status = "okay";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				    /* Corresponds to 800MHz at freq_table */
+				    cooling-device = <&cpu0 2 2>;
+				};
+				map1 {
+				   /* Corresponds to 200MHz at freq_table */
+				   cooling-device = <&cpu0 4 4>;
+			       };
+		       };
+		};
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index bcc9e63..2e66df8 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -35,10 +35,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@900 {
+		cpu0: cpu@900 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0x900>;
+			cooling-min-level = <4>;
+			cooling-max-level = <2>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@901 {
diff --git a/arch/arm/boot/dts/exynos4212.dtsi b/arch/arm/boot/dts/exynos4212.dtsi
index dd0a43e..5be03288 100644
--- a/arch/arm/boot/dts/exynos4212.dtsi
+++ b/arch/arm/boot/dts/exynos4212.dtsi
@@ -26,10 +26,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@A00 {
+		cpu0: cpu@A00 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@A01 {
diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index c7517fc..4838a2a 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -401,6 +401,21 @@
 		vtmu-supply = <&ldo10_reg>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				    /* Corresponds to 800MHz at freq_table */
+				    cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				   /* Corresponds to 200MHz at freq_table */
+				   cooling-device = <&cpu0 13 13>;
+			       };
+		       };
+		};
+	};
 };
 
 &pinctrl_1 {
diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts b/arch/arm/boot/dts/exynos4412-trats2.dts
index 29231b4..8c2c584 100644
--- a/arch/arm/boot/dts/exynos4412-trats2.dts
+++ b/arch/arm/boot/dts/exynos4412-trats2.dts
@@ -863,6 +863,21 @@
 		pulldown-ohm = <100000>; /* 100K */
 		io-channels = <&adc 2>;  /* Battery temperature */
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				    /* Corresponds to 800MHz at freq_table */
+				    cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				   /* Corresponds to 200MHz at freq_table */
+				   cooling-device = <&cpu0 13 13>;
+			       };
+		       };
+		};
+	};
 };
 
 &pinctrl_0 {
diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
index 0f6ec93..68ad43b 100644
--- a/arch/arm/boot/dts/exynos4412.dtsi
+++ b/arch/arm/boot/dts/exynos4412.dtsi
@@ -26,10 +26,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@A00 {
+		cpu0: cpu@A00 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@A01 {
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index 0a229fc..dd5c3a0 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -58,11 +58,14 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@0 {
+		cpu0: cpu@0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a15";
 			reg = <0>;
 			clock-frequency = <1700000000>;
+			cooling-min-level = <15>;
+			cooling-max-level = <9>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 		cpu@1 {
 			device_type = "cpu";
@@ -241,6 +244,21 @@
 		clock-names = "tmu_apbif";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				    /* Corresponds to 800MHz at freq_table */
+				    cooling-device = <&cpu0 9 9>;
+				};
+				map1 {
+				   /* Corresponds to 200MHz at freq_table */
+				   cooling-device = <&cpu0 15 15>;
+			       };
+		       };
+		};
+	};
+
 	serial@12C00000 {
 		clocks = <&clock CLK_UART0>, <&clock CLK_SCLK_UART0>;
 		clock-names = "uart", "clk_uart_baud0";
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 07/16] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
                     ` (5 preceding siblings ...)
  2015-01-14 13:41   ` [PATCH v3 06/16] arm: dts: Adding CPU cooling binding for Exynos SoCs Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-14 13:41   ` [PATCH v3 08/16] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
                     ` (9 subsequent siblings)
  16 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Up till now exynos_tmu_data.c was used for storing CPU cooling configuration
data. Now the Exynos thermal core code uses device tree to get this data.
For this purpose generic thermal code for configuring CPU cooling was
used.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Rewrite code responsible for registering CPU cooling device to not depend
  on explicit "/cpus/cpu@0" path since now Exynos SoCs use new cpu node
  names (e.g. cpu@A00). New approach iterates over "cpus" node children.
- Patch title changed to thermal: exynos

---
 drivers/cpufreq/exynos-cpufreq.c                |  30 +++++-
 drivers/thermal/samsung/exynos_thermal_common.c | 122 ++++++++++++++----------
 drivers/thermal/samsung/exynos_tmu.c            |   7 --
 drivers/thermal/samsung/exynos_tmu.h            |   5 -
 drivers/thermal/samsung/exynos_tmu_data.c       |  42 +-------
 5 files changed, 101 insertions(+), 105 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index f99a0b0..32bc64d 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -18,10 +18,13 @@
 #include <linux/cpufreq.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/cpu_cooling.h>
+#include <linux/cpu.h>
 
 #include "exynos-cpufreq.h"
 
 static struct exynos_dvfs_info *exynos_info;
+static struct thermal_cooling_device *cdev;
 static struct regulator *arm_regulator;
 static unsigned int locking_frequency;
 
@@ -156,6 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
+	struct device_node *cpus, *np;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -198,9 +202,31 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	/* Done here as we want to capture boot frequency */
 	locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;
 
-	if (!cpufreq_register_driver(&exynos_driver))
-		return 0;
+	if (cpufreq_register_driver(&exynos_driver))
+		goto err;
 
+	cpus = of_find_node_by_path("/cpus");
+	if (!cpus) {
+		pr_err("failed to find cpus node\n");
+		return -ENOENT;
+	}
+
+	for (np = of_get_next_child(cpus, NULL); np;
+	     of_node_put(np), np = of_get_next_child(cpus, np)) {
+		if (of_find_property(np, "#cooling-cells", NULL)) {
+			cdev = of_cpufreq_cooling_register(np,
+							   cpu_present_mask);
+			if (IS_ERR(cdev))
+				pr_err("running cpufreq without cooling device: %ld\n",
+				       PTR_ERR(cdev));
+			break;
+		}
+	}
+	of_node_put(np);
+	of_node_put(cpus);
+
+	return 0;
+ err:
 	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
 	regulator_put(arm_regulator);
 err_vdd_arm:
diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 6dc3815..00aa688 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -133,47 +133,62 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
 static int exynos_bind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size, level;
-	struct freq_clip_table *tab_ptr, *clip_data;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
+	struct of_phandle_args cooling_spec;
+	unsigned long max, state = 0;
+	int ret = 0, i = 0;
 
-	tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data;
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_ptr == NULL || tab_size == 0)
+	/*
+	 * Below code is necessary to skip binding when cpufreq's
+	 * frequency table is not yet initialized.
+	 */
+	cdev->ops->get_max_state(cdev, &state);
+	if (!state && !th_zone->cool_dev_size) {
+		th_zone->cool_dev_size = 1;
+		th_zone->cool_dev[0] = cdev;
+		th_zone->bind = false;
 		return 0;
+	}
 
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
 
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
+	child = of_get_child_by_name(np, "cooling-maps");
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		clip_data = (struct freq_clip_table *)&(tab_ptr[i]);
-		level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max);
-		if (level == THERMAL_CSTATE_INVALID)
-			return 0;
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-								level, 0)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = true;
-			break;
-		default:
+	for_each_child_of_node(child, gchild) {
+		ret = of_parse_phandle_with_args(gchild, "cooling-device",
+						 "#cooling-cells",
+						 0, &cooling_spec);
+		if (ret < 0) {
+			pr_err("missing cooling_device property\n");
+			goto end;
+		}
+
+		if (cooling_spec.args_count < 2) {
 			ret = -EINVAL;
+			goto end;
 		}
+
+		max = cooling_spec.args[0];
+		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
+						     max, 0)) {
+			dev_err(data->dev,
+				"thermal error unbinding cdev inst=%d\n", i);
+
+			ret = -EINVAL;
+			goto end;
+		}
+		i++;
 	}
+	th_zone->bind = true;
+end:
+	of_node_put(child);
+	of_node_put(np);
 
 	return ret;
 }
@@ -182,16 +197,12 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 static int exynos_unbind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size;
+	int ret = 0, i;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
 
-	if (th_zone->bind == false)
-		return 0;
-
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_size == 0)
+	if (th_zone->bind == false || !th_zone->cool_dev_size)
 		return 0;
 
 	/* find the cooling device registered*/
@@ -203,23 +214,30 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
 	if (i == th_zone->cool_dev_size)
 		return 0;
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_unbind_cooling_device(thermal, i,
-								cdev)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = false;
-			break;
-		default:
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
+
+	child = of_get_child_by_name(np, "cooling-maps");
+
+	i = 0;
+	for_each_child_of_node(child, gchild) {
+		if (thermal_zone_unbind_cooling_device(thermal, i,
+						       cdev)) {
+			dev_err(data->dev,
+				"error unbinding cdev inst=%d\n", i);
 			ret = -EINVAL;
+			goto end;
 		}
+		i++;
 	}
+	th_zone->bind = false;
+end:
+	of_node_put(child);
+	of_node_put(np);
+
 	return ret;
 }
 
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 5000727..ae30f6a 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -916,13 +916,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 
 	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
 
-	sensor_conf->cooling_data.freq_clip_count = pdata->freq_tab_count;
-	for (i = 0; i < pdata->freq_tab_count; i++) {
-		sensor_conf->cooling_data.freq_data[i].freq_clip_max =
-					pdata->freq_tab[i].freq_clip_max;
-		sensor_conf->cooling_data.freq_data[i].temp_level =
-					pdata->freq_tab[i].temp_level;
-	}
 	sensor_conf->dev = &pdev->dev;
 	/* Register the sensor with thermal management interface */
 	ret = exynos_register_thermal(sensor_conf);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 7f880d2..627dec9 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -83,9 +83,6 @@ enum soc_type {
  * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
- * @freq_clip_table: Table representing frequency reduction percentage.
- * @freq_tab_count: Count of the above table as frequency reduction may
- *	applicable to only some of the trigger levels.
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
@@ -111,8 +108,6 @@ struct exynos_tmu_platform_data {
 	enum soc_type type;
 	u32 cal_type;
 	u32 cal_mode;
-	struct freq_clip_table freq_tab[4];
-	unsigned int freq_tab_count;
 };
 
 /**
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
index b239100..a993f3d 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -47,15 +47,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 		.first_point_trim = 25,
 		.second_point_trim = 85,
 		.default_temp_offset = 50,
-		.freq_tab[0] = {
-			.freq_clip_max = 800 * 1000,
-			.temp_level = 85,
-			},
-		.freq_tab[1] = {
-			.freq_clip_max = 200 * 1000,
-			.temp_level = 100,
-		},
-		.freq_tab_count = 2,
 		.type = SOC_ARCH_EXYNOS4210,
 		},
 	},
@@ -87,16 +78,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 800 * 1000, \
-		.temp_level = 70, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 400 * 1000, \
-		.temp_level = 95, \
-	}, \
-	.freq_tab_count = 2
+	.default_temp_offset = 50
 
 struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 	.tmu_data = {
@@ -133,16 +115,7 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 1400 * 1000, \
-		.temp_level = 70, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 400 * 1000, \
-		.temp_level = 95, \
-	}, \
-	.freq_tab_count = 2
+	.default_temp_offset = 50
 
 struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
 	.tmu_data = {
@@ -189,16 +162,7 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 800 * 1000, \
-		.temp_level = 85, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 200 * 1000, \
-		.temp_level = 103, \
-	}, \
-	.freq_tab_count = 2, \
+	.default_temp_offset = 50,
 
 #define EXYNOS5260_TMU_DATA \
 	__EXYNOS5260_TMU_DATA \
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 08/16] thermal: exynos: dts: Add default definition of the TMU sensor parameter
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
                     ` (6 preceding siblings ...)
  2015-01-14 13:41   ` [PATCH v3 07/16] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-14 13:41   ` [PATCH v3 09/16] dts: Documentation: Extending documentation entry for exynos-thermal Lukasz Majewski
                     ` (8 subsequent siblings)
  16 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Exynos 4 and 5 family of SoCs uses almost identical TMU sensor to measure the
on chip temperature. For this reason it is possible to group TMU configuration
parameters in one dts file.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- "samsung,tmu_" prefix for TMU specific properties has been added

---
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi | 24 +++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi

diff --git a/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
new file mode 100644
index 0000000..e3f7934
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
@@ -0,0 +1,24 @@
+/*
+ * Device tree sources for Exynos4412 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+samsung,tmu_gain = <8>;
+samsung,tmu_reference_voltage = <16>;
+samsung,tmu_noise_cancel_mode = <4>;
+samsung,tmu_efuse_value = <55>;
+samsung,tmu_min_efuse_value = <40>;
+samsung,tmu_max_efuse_value = <100>;
+samsung,tmu_first_point_trim = <25>;
+samsung,tmu_second_point_trim = <85>;
+samsung,tmu_default_temp_offset = <50>;
+samsung,tmu_cal_type = <TYPE_ONE_POINT_TRIMMING>;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 09/16] dts: Documentation: Extending documentation entry for exynos-thermal
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
                     ` (7 preceding siblings ...)
  2015-01-14 13:41   ` [PATCH v3 08/16] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-14 18:52     ` Eduardo Valentin
  2015-01-14 13:41   ` [PATCH v3 10/16] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
                     ` (7 subsequent siblings)
  16 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Properties necessary for providing Exynos thermal configuration via device
tree.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v3:
- New patch

---
 .../devicetree/bindings/thermal/exynos-thermal.txt      | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
index ae738f5..0f44932 100644
--- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
@@ -39,6 +39,18 @@
 - vtmu-supply: This entry is optional and provides the regulator node supplying
 		voltage to TMU. If needed this entry can be placed inside
 		board/platform specific dts file.
+Following properties are mandatory (depending on SoC):
+- samsung,tmu_gain: Gain value for internal TMU operation.
+- samsung,tmu_reference_voltage: Value of TMU IP block's reference voltage
+- samsung,tmu_noise_cancel_mode: Mode for noise cancellation
+- samsung,tmu_efuse_value: Default level of temperature - it is needed when
+			   in factory fusing produced wrong value
+- samsung,tmu_min_efuse_value: Minimum temperature fused value
+- samsung,tmu_max_efuse_value: Maximum temperature fused value
+- samsung,tmu_first_point_trim: First point trimming value
+- samsung,tmu_second_point_trim: Second point trimming value
+- samsung,tmu_default_temp_offset: Default temperature offset
+- samsung,tmu_cal_type: Callibration type
 
 Example 1):
 
@@ -51,6 +63,7 @@ Example 1):
 		clock-names = "tmu_apbif";
 		status = "disabled";
 		vtmu-supply = <&tmu_regulator_node>;
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 Example 2):
@@ -61,6 +74,7 @@ Example 2):
 		interrupts = <0 58 0>;
 		clocks = <&clock 21>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
@@ -70,6 +84,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 184 0>;
 		clocks = <&clock 318>, <&clock 318>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu3: tmu@1006c000 {
@@ -78,6 +93,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 185 0>;
 		clocks = <&clock 318>, <&clock 319>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_gpu: tmu@100a0000 {
@@ -86,6 +102,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 215 0>;
 		clocks = <&clock 319>, <&clock 318>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 Note: For multi-instance tmu each instance should have an alias correctly
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 10/16] thermal: dts: Default trip points definition for Exynos5420 SoCs
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
                     ` (8 preceding siblings ...)
  2015-01-14 13:41   ` [PATCH v3 09/16] dts: Documentation: Extending documentation entry for exynos-thermal Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-14 13:41   ` [PATCH v3 11/16] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
                     ` (6 subsequent siblings)
  16 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This code groups in one place default settings of trip points. It is used
in SoCs with multiple instances of TMU sensor.

Separate device tree file prevents from multiple copying of the same data.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
---
 arch/arm/boot/dts/exynos5420-trip-points.dtsi | 35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi

diff --git a/arch/arm/boot/dts/exynos5420-trip-points.dtsi b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
new file mode 100644
index 0000000..09d6c56
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
@@ -0,0 +1,35 @@
+/*
+ * Device tree sources for default Exynos 5420 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <85000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-1 {
+		temperature = <103000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-2 {
+		temperature = <110000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1200000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 11/16] thermal: exynos: dts: Define default thermal-zones for Exynos4
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
                     ` (9 preceding siblings ...)
  2015-01-14 13:41   ` [PATCH v3 10/16] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-14 13:41   ` [PATCH v3 12/16] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
                     ` (5 subsequent siblings)
  16 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Trip points corresponding to the one defined in the exynos_tmu_data.c
for Exynos4 have been included.
This thermal-zones attribute is afterwards reused for Exynos4210, Exynos4412
and Exynos5250.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
---
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi | 52 ++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi

diff --git a/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
new file mode 100644
index 0000000..506600a
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
@@ -0,0 +1,52 @@
+/*
+ * Device tree sources for Exynos4 thermal zone
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal.h>
+
+/ {
+  thermal-zones {
+	cpu_thermal: cpu-thermal {
+		thermal-sensors = <&tmu 0>;
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		trips {
+			cpu_alert0: cpu-alert-0 {
+				temperature = <70000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert1: cpu-alert-1 {
+				temperature = <95000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert2: cpu-alert-2 {
+				temperature = <110000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_crit0: cpu-crit-0 {
+				temperature = <120000>; /* millicelsius */
+				hysteresis = <0>; /* millicelsius */
+				type = "critical";
+			};
+		};
+		cooling-maps {
+			map0 {
+			    trip = <&cpu_alert0>;
+			};
+			map1 {
+			    trip = <&cpu_alert1>;
+			};
+		};
+	};
+  };
+};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 12/16] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
                     ` (10 preceding siblings ...)
  2015-01-14 13:41   ` [PATCH v3 11/16] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-14 13:41   ` [PATCH v3 13/16] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c Lukasz Majewski
                     ` (4 subsequent siblings)
  16 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This commit provides information about Exynos5440 device configuration.
Previously this information was available in exynos_tmu_data.c file.
Now it is available in the device tree.
Such approach allows reusing some common code for thermal.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- "type" property removed
- "samsung,tmu_" prefix for TMU specific properties has been added

---
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi | 24 ++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi     | 25 +++++++++++++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi

diff --git a/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
new file mode 100644
index 0000000..7b2fba0
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
@@ -0,0 +1,24 @@
+/*
+ * Device tree sources for Exynos5440 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+samsung,tmu_gain = <5>;
+samsung,tmu_reference_voltage = <16>;
+samsung,tmu_noise_cancel_mode = <4>;
+samsung,tmu_efuse_value = <0x5d2d>;
+samsung,tmu_min_efuse_value = <16>;
+samsung,tmu_max_efuse_value = <76>;
+samsung,tmu_first_point_trim = <25>;
+samsung,tmu_second_point_trim = <70>;
+samsung,tmu_default_temp_offset = <25>;
+samsung,tmu_cal_type = <TYPE_ONE_POINT_TRIMMING>;
diff --git a/arch/arm/boot/dts/exynos5440-trip-points.dtsi b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
new file mode 100644
index 0000000..48adfa8
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
@@ -0,0 +1,25 @@
+/*
+ * Device tree sources for default Exynos5440 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <100000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1050000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 13/16] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
                     ` (11 preceding siblings ...)
  2015-01-14 13:41   ` [PATCH v3 12/16] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-14 19:05     ` Eduardo Valentin
  2015-01-14 13:41   ` [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
                     ` (3 subsequent siblings)
  16 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Presented device tree bindings provide data already hardcoded in the
exynos_tmu_data.c file.
After this commit, it should be possible to reuse common thermal core
framework in Exynos SoCs.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Add proper TMU entries for exynos3250.dtsi
Changes for v3:
- Remove "type" DT properties, which will be extracted from compatible
- "samsung,tmu_" prefix for TMU specific properties has been added

---
 arch/arm/boot/dts/exynos3250.dtsi |  2 ++
 arch/arm/boot/dts/exynos4.dtsi    |  4 ++++
 arch/arm/boot/dts/exynos4210.dtsi | 21 ++++++++++++++++++++-
 arch/arm/boot/dts/exynos4x12.dtsi |  1 +
 arch/arm/boot/dts/exynos5250.dtsi |  5 +++--
 arch/arm/boot/dts/exynos5420.dtsi | 28 ++++++++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440.dtsi | 18 ++++++++++++++++++
 7 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/exynos3250.dtsi b/arch/arm/boot/dts/exynos3250.dtsi
index 2246549..8cc078c 100644
--- a/arch/arm/boot/dts/exynos3250.dtsi
+++ b/arch/arm/boot/dts/exynos3250.dtsi
@@ -18,6 +18,7 @@
  */
 
 #include "skeleton.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 #include <dt-bindings/clock/exynos3250.h>
 
 / {
@@ -188,6 +189,7 @@
 			interrupts = <0 216 0>;
 			clocks = <&cmu CLK_TMU_APBIF>;
 			clock-names = "tmu_apbif";
+			#include "exynos4412-tmu-sensor-conf.dtsi"
 			status = "disabled";
 		};
 
diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index b8168f1..f18d746 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -645,4 +645,8 @@
 		samsung,sysreg = <&sys_reg>;
 		status = "disabled";
 	};
+
+	tmu: tmu@100C0000 {
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+	};
 };
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index 2e66df8..7f0e012 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -21,6 +21,7 @@
 
 #include "exynos4.dtsi"
 #include "exynos4210-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 
 / {
 	compatible = "samsung,exynos4210", "samsung,exynos4";
@@ -146,16 +147,34 @@
 		reg = <0x03860000 0x1000>;
 	};
 
-	tmu@100C0000 {
+	tmu: tmu@100C0000 {
 		compatible = "samsung,exynos4210-tmu";
 		interrupt-parent = <&combiner>;
 		reg = <0x100C0000 0x100>;
 		interrupts = <2 4>;
 		clocks = <&clock CLK_TMU_APBIF>;
 		clock-names = "tmu_apbif";
+		samsung,tmu_gain = <15>;
+		samsung,tmu_reference_voltage = <7>;
 		status = "disabled";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			trips {
+			      cpu_alert0: cpu-alert-0 {
+				      temperature = <85000>; /* millicelsius */
+			      };
+			      cpu_alert1: cpu-alert-1 {
+				      temperature = <100000>; /* millicelsius */
+			      };
+			      cpu_alert2: cpu-alert-2 {
+				      temperature = <110000>; /* millicelsius */
+			      };
+			};
+		};
+	};
+
 	g2d@12800000 {
 		compatible = "samsung,s5pv210-g2d";
 		reg = <0x12800000 0x1000>;
diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi
index 93b7040..3ee2031 100644
--- a/arch/arm/boot/dts/exynos4x12.dtsi
+++ b/arch/arm/boot/dts/exynos4x12.dtsi
@@ -19,6 +19,7 @@
 
 #include "exynos4.dtsi"
 #include "exynos4x12-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 
 / {
 	aliases {
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index dd5c3a0..07fd73a 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -20,7 +20,7 @@
 #include <dt-bindings/clock/exynos5250.h>
 #include "exynos5.dtsi"
 #include "exynos5250-pinctrl.dtsi"
-
+#include "exynos4-cpu-thermal.dtsi"
 #include <dt-bindings/clock/exynos-audss-clk.h>
 
 / {
@@ -236,12 +236,13 @@
 		status = "disabled";
 	};
 
-	tmu@10060000 {
+	tmu: tmu@10060000 {
 		compatible = "samsung,exynos5250-tmu";
 		reg = <0x10060000 0x100>;
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	thermal-zones {
diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
index 517e50f..f5771e5 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -761,6 +761,7 @@
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu1: tmu@10064000 {
@@ -769,6 +770,7 @@
 		interrupts = <0 183 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu2: tmu@10068000 {
@@ -777,6 +779,7 @@
 		interrupts = <0 184 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu3: tmu@1006c000 {
@@ -785,6 +788,7 @@
 		interrupts = <0 185 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU_GPU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_gpu: tmu@100a0000 {
@@ -793,6 +797,30 @@
 		interrupts = <0 215 0>;
 		clocks = <&clock CLK_TMU_GPU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmu_cpu0>;
+			#include "exynos5420-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmu_cpu1>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmu_cpu2>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu3_thermal: cpu3-thermal {
+		       thermal-sensors = <&tmu_cpu3>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		gpu_thermal: gpu-thermal {
+		       thermal-sensors = <&tmu_gpu>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
 	};
 
         watchdog: watchdog@101D0000 {
diff --git a/arch/arm/boot/dts/exynos5440.dtsi b/arch/arm/boot/dts/exynos5440.dtsi
index 8f3373c..59d9416 100644
--- a/arch/arm/boot/dts/exynos5440.dtsi
+++ b/arch/arm/boot/dts/exynos5440.dtsi
@@ -219,6 +219,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_1: tmuctrl@16011C {
@@ -227,6 +228,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_2: tmuctrl@160120 {
@@ -235,6 +237,22 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmuctrl_0>;
+			#include "exynos5440-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmuctrl_1>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmuctrl_2>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
 	};
 
 	sata@210000 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
                     ` (12 preceding siblings ...)
  2015-01-14 13:41   ` [PATCH v3 13/16] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-14 18:46     ` Eduardo Valentin
  2015-01-14 13:41   ` [PATCH v3 15/16] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
                     ` (2 subsequent siblings)
  16 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This patch brings support for providing configuration via device tree.
Previously this data has been hardcoded in the exynos_tmu_data.c file.
Such approach was not scalable and very often required copying the whole
data.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
- Usage of of-thermal.c exported trip points table
Changes for v3:
- Adding exynos_of_get_soc_type() method to set SOC type from device's
  compatible string
- "samsung,tmu_" prefix for TMU specific properties has been added

---
 drivers/thermal/samsung/Makefile     |   2 -
 drivers/thermal/samsung/exynos_tmu.c | 345 +++++++++++++++++++++++------------
 drivers/thermal/samsung/exynos_tmu.h |  53 +-----
 3 files changed, 226 insertions(+), 174 deletions(-)

diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile
index c09d830..1e47d0d 100644
--- a/drivers/thermal/samsung/Makefile
+++ b/drivers/thermal/samsung/Makefile
@@ -3,5 +3,3 @@
 #
 obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_thermal.o
 exynos_thermal-y				:= exynos_tmu.o
-exynos_thermal-y				+= exynos_tmu_data.o
-exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+= exynos_thermal_common.o
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index ae30f6a..633a9e2 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -1,6 +1,10 @@
 /*
  * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
  *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
  *  Copyright (C) 2011 Samsung Electronics
  *  Donggeun Kim <dg77.kim@samsung.com>
  *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
@@ -31,8 +35,8 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 
-#include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
+#include "../thermal_core.h"
 
 /* Exynos generic registers */
 #define EXYNOS_TMU_REG_TRIMINFO		0x0
@@ -115,6 +119,7 @@
 #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
 #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
 
+#define MCELSIUS	1000
 /**
  * struct exynos_tmu_data : A structure to hold the private data of the TMU
 	driver
@@ -150,7 +155,8 @@ struct exynos_tmu_data {
 	struct clk *clk, *clk_sec;
 	u8 temp_error1, temp_error2;
 	struct regulator *regulator;
-	struct thermal_sensor_conf *reg_conf;
+	struct thermal_zone_device *tzd;
+
 	int (*tmu_initialize)(struct platform_device *pdev);
 	void (*tmu_control)(struct platform_device *pdev, bool on);
 	int (*tmu_read)(struct exynos_tmu_data *data);
@@ -159,6 +165,33 @@ struct exynos_tmu_data {
 	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
 };
 
+static void exynos_report_trigger(struct exynos_tmu_data *p)
+{
+	char data[10], *envp[] = { data, NULL };
+	struct thermal_zone_device *tz = p->tzd;
+	unsigned long temp;
+	unsigned int i;
+
+	if (!p) {
+		pr_err("Wrong temperature configuration data\n");
+		return;
+	}
+
+	thermal_zone_device_update(tz);
+
+	mutex_lock(&tz->lock);
+	/* Find the level for which trip happened */
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		tz->ops->get_trip_temp(tz, i, &temp);
+		if (tz->last_temperature < temp)
+			break;
+	}
+
+	snprintf(data, sizeof(data), "%u", i);
+	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
+	mutex_unlock(&tz->lock);
+}
+
 /*
  * TMU treats temperature as a mapped temperature code.
  * The temperature is converted differently depending on the calibration type.
@@ -234,14 +267,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
 
 static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling)
 {
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
+	unsigned long temp;
 	int i;
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
-		u8 temp = pdata->trigger_levels[i];
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
+		       __func__);
+		return 0;
+	}
+
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL)
+			continue;
 
+		temp = trips[i].temperature / MCELSIUS;
 		if (falling)
-			temp -= pdata->threshold_falling;
+			temp -= (trips[i].hysteresis / MCELSIUS);
 		else
 			threshold &= ~(0xff << 8 * i);
 
@@ -305,9 +349,19 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 static int exynos4210_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
-	unsigned int status;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
 	int ret = 0, threshold_code, i;
+	unsigned long reference, temp;
+	unsigned int status;
+
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
+		       __func__);
+		ret = -ENODEV;
+		goto out;
+	}
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct platform_device *pdev)
 	sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));
 
 	/* Write temperature code for threshold */
-	threshold_code = temp_to_code(data, pdata->threshold);
+	reference = trips[0].temperature / MCELSIUS;
+	threshold_code = temp_to_code(data, reference);
+	if (threshold_code < 0) {
+		ret = threshold_code;
+		goto out;
+	}
 	writeb(threshold_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
-		writeb(pdata->trigger_levels[i], data->base +
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		temp = trips[i].temperature / MCELSIUS;
+		writeb(temp - reference, data->base +
 		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
+	}
 
 	data->tmu_clear_irqs(data);
 out:
@@ -333,9 +394,11 @@ out:
 static int exynos4412_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(data->tzd);
 	unsigned int status, trim_info, con, ctrl, rising_threshold;
 	int ret = 0, threshold_code, i;
+	unsigned long crit_temp = 0;
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
 	data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
-		/* 1-4 level to be assigned in th0 reg */
-		rising_threshold &= ~(0xff << 8 * i);
-		rising_threshold |= threshold_code << 8 * i;
-		writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
-		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
-		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
-		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
+			crit_temp = trips[i].temperature;
+			break;
+		}
 	}
+
+	if (i == of_thermal_get_ntrips(data->tzd)) {
+		pr_err("%s: No CRITICAL trip point defined at of-thermal.c!\n",
+		       __func__);
+		ret = -EINVAL;
+		goto out;
+	}
+
+	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
+	/* 1-4 level to be assigned in th0 reg */
+	rising_threshold &= ~(0xff << 8 * i);
+	rising_threshold |= threshold_code << 8 * i;
+	writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
+	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
+	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
+	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+
 out:
 	return ret;
 }
@@ -391,9 +466,9 @@ out:
 static int exynos5440_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
 	unsigned int trim_info = 0, con, rising_threshold;
-	int ret = 0, threshold_code, i;
+	int ret = 0, threshold_code;
+	unsigned long crit_temp = 0;
 
 	/*
 	 * For exynos5440 soc triminfo value is swapped between TMU0 and
@@ -422,9 +497,8 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 	data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
+	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp)) {
+		threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
 		/* 5th level to be assigned in th2 reg */
 		rising_threshold =
 			threshold_code << EXYNOS5440_TMU_TH_RISE4_SHIFT;
@@ -442,7 +516,7 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
@@ -450,10 +524,15 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS_TMU_INTEN_RISE0_SHIFT;
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
+
 		if (data->soc != SOC_ARCH_EXYNOS4210)
 			interrupt_en |=
 				interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
@@ -468,7 +547,7 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS5440_TMU_S0_7_CTRL));
@@ -476,11 +555,16 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
-		interrupt_en |= interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
+		interrupt_en |=
+			interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
 	} else {
 		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en = 0; /* Disable all interrupts */
@@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL);
 }
 
-static int exynos_tmu_read(struct exynos_tmu_data *data)
+int exynos_get_temp(void *p, long *temp)
 {
-	int ret;
+	struct exynos_tmu_data *data = p;
+
+	if (!data)
+		return -EINVAL;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
-	ret = data->tmu_read(data);
-	if (ret >= 0)
-		ret = code_to_temp(data, ret);
+
+	*temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS;
+
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
 
-	return ret;
+	return 0;
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
@@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct *work)
 	if (!IS_ERR(data->clk_sec))
 		clk_disable(data->clk_sec);
 
-	exynos_report_trigger(data->reg_conf);
+	exynos_report_trigger(data);
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
@@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 static const struct of_device_id exynos_tmu_match[] = {
 	{
 		.compatible = "samsung,exynos3250-tmu",
-		.data = &exynos3250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4210-tmu",
-		.data = &exynos4210_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4412-tmu",
-		.data = &exynos4412_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5250-tmu",
-		.data = &exynos5250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5260-tmu",
-		.data = &exynos5260_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu-ext-triminfo",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5440-tmu",
-		.data = &exynos5440_default_tmu_data,
 	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 
-static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
-			struct platform_device *pdev, int id)
+static int exynos_of_get_soc_type(struct device_node *np)
 {
-	struct  exynos_tmu_init_data *data_table;
-	struct exynos_tmu_platform_data *tmu_data;
-	const struct of_device_id *match;
+	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
+		return SOC_ARCH_EXYNOS3250;
+	else if (of_device_is_compatible(np, "samsung,exynos4210-tmu"))
+		return SOC_ARCH_EXYNOS4210;
+	else if (of_device_is_compatible(np, "samsung,exynos4412-tmu"))
+		return SOC_ARCH_EXYNOS4412;
+	else if (of_device_is_compatible(np, "samsung,exynos5250-tmu"))
+		return SOC_ARCH_EXYNOS5250;
+	else if (of_device_is_compatible(np, "samsung,exynos5260-tmu"))
+		return SOC_ARCH_EXYNOS5260;
+	else if (of_device_is_compatible(np, "samsung,exynos5420-tmu"))
+		return SOC_ARCH_EXYNOS5420;
+	else if (of_device_is_compatible(np,
+					 "samsung,exynos5420-tmu-ext-triminfo"))
+		return SOC_ARCH_EXYNOS5420_TRIMINFO;
+	else if (of_device_is_compatible(np, "samsung,exynos5440-tmu"))
+		return SOC_ARCH_EXYNOS5440;
+
+	return -EINVAL;
+}
 
-	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
-	if (!match)
-		return NULL;
-	data_table = (struct exynos_tmu_init_data *) match->data;
-	if (!data_table || id >= data_table->tmu_count)
-		return NULL;
-	tmu_data = data_table->tmu_data;
-	return (struct exynos_tmu_platform_data *) (tmu_data + id);
+static int exynos_of_sensor_conf(struct device_node *np,
+				 struct exynos_tmu_platform_data *pdata)
+{
+	u32 value;
+	int ret;
+
+	of_node_get(np);
+
+	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
+	pdata->gain = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_reference_voltage", &value);
+	pdata->reference_voltage = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode", &value);
+	pdata->noise_cancel_mode = (u8) value;
+
+	of_property_read_u32(np, "samsung,tmu_efuse_value",
+			     &pdata->efuse_value);
+	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
+			     &pdata->min_efuse_value);
+	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
+			     &pdata->max_efuse_value);
+
+	of_property_read_u32(np, "samsung,tmu_first_point_trim", &value);
+	pdata->first_point_trim = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_second_point_trim", &value);
+	pdata->second_point_trim = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_default_temp_offset", &value);
+	pdata->default_temp_offset = (u8) value;
+
+	of_property_read_u32(np, "samsung,tmu_cal_type", &pdata->cal_type);
+	of_property_read_u32(np, "samsung,tmu_cal_mode", &pdata->cal_mode);
+
+	of_node_put(np);
+	return 0;
 }
 
 static int exynos_map_dt_data(struct platform_device *pdev)
@@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 		return -EADDRNOTAVAIL;
 	}
 
-	pdata = exynos_get_driver_data(pdev, data->id);
-	if (!pdata) {
-		dev_err(&pdev->dev, "No platform init data supplied.\n");
-		return -ENODEV;
-	}
+	pdata = devm_kzalloc(&pdev->dev,
+			     sizeof(struct exynos_tmu_platform_data),
+			     GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
 
+	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
 	data->pdata = pdata;
-	data->soc = pdata->type;
+	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
 
 	switch (data->soc) {
 	case SOC_ARCH_EXYNOS4210:
@@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 	return 0;
 }
 
+static struct thermal_zone_of_device_ops exynos_sensor_ops = {
+	.get_temp = exynos_get_temp,
+	.set_emul_temp = exynos_tmu_set_emulation,
+};
+
 static int exynos_tmu_probe(struct platform_device *pdev)
 {
-	struct exynos_tmu_data *data;
 	struct exynos_tmu_platform_data *pdata;
-	struct thermal_sensor_conf *sensor_conf;
-	int ret, i;
+	struct exynos_tmu_data *data;
+	int ret;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
 					GFP_KERNEL);
@@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, data);
 	mutex_init(&data->lock);
 
+	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
+						    &exynos_sensor_ops);
+	if (IS_ERR(data->tzd)) {
+		pr_err("thermal: tz: %p ERROR\n", data->tzd);
+		return PTR_ERR(data->tzd);
+	}
 	ret = exynos_map_dt_data(pdev);
 	if (ret)
-		return ret;
+		goto err_sensor;
 
 	pdata = data->pdata;
 
@@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
 	if (IS_ERR(data->clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
-		return  PTR_ERR(data->clk);
+		ret = PTR_ERR(data->clk);
+		goto err_sensor;
 	}
 
 	data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
 	if (IS_ERR(data->clk_sec)) {
 		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
 			dev_err(&pdev->dev, "Failed to get triminfo clock\n");
-			return PTR_ERR(data->clk_sec);
+			ret = PTR_ERR(data->clk_sec);
+			goto err_sensor;
 		}
 	} else {
 		ret = clk_prepare(data->clk_sec);
 		if (ret) {
 			dev_err(&pdev->dev, "Failed to get clock\n");
-			return ret;
+			goto err_sensor;
 		}
 	}
 
@@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	exynos_tmu_control(pdev, true);
-
-	/* Allocate a structure to register with the exynos core thermal */
-	sensor_conf = devm_kzalloc(&pdev->dev,
-				sizeof(struct thermal_sensor_conf), GFP_KERNEL);
-	if (!sensor_conf) {
-		ret = -ENOMEM;
-		goto err_clk;
-	}
-	sprintf(sensor_conf->name, "therm_zone%d", data->id);
-	sensor_conf->read_temperature = (int (*)(void *))exynos_tmu_read;
-	sensor_conf->write_emul_temp =
-		(int (*)(void *, unsigned long))exynos_tmu_set_emulation;
-	sensor_conf->driver_data = data;
-	sensor_conf->trip_data.trip_count = pdata->trigger_enable[0] +
-			pdata->trigger_enable[1] + pdata->trigger_enable[2]+
-			pdata->trigger_enable[3];
-
-	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
-		sensor_conf->trip_data.trip_val[i] =
-			pdata->threshold + pdata->trigger_levels[i];
-		sensor_conf->trip_data.trip_type[i] =
-					pdata->trigger_type[i];
-	}
-
-	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
-
-	sensor_conf->dev = &pdev->dev;
-	/* Register the sensor with thermal management interface */
-	ret = exynos_register_thermal(sensor_conf);
-	if (ret) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"Failed to register thermal interface: %d\n",
-				ret);
-		goto err_clk;
-	}
-	data->reg_conf = sensor_conf;
-
 	ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
 		IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
 	if (ret) {
@@ -935,21 +1030,31 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
+	ret = exynos_tmu_initialize(pdev);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to initialize TMU\n");
+		goto err_clk;
+	}
+	exynos_tmu_control(pdev, true);
 	return 0;
+
 err_clk:
 	clk_unprepare(data->clk);
 err_clk_sec:
 	if (!IS_ERR(data->clk_sec))
 		clk_unprepare(data->clk_sec);
+err_sensor:
+	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
+
 	return ret;
 }
 
 static int exynos_tmu_remove(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	struct thermal_zone_device *tzd = data->tzd;
 
-	exynos_unregister_thermal(data->reg_conf);
-
+	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
 	exynos_tmu_control(pdev, false);
 
 	clk_unprepare(data->clk);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 627dec9..d876d4c 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -23,8 +23,7 @@
 #ifndef _EXYNOS_TMU_H
 #define _EXYNOS_TMU_H
 #include <linux/cpu_cooling.h>
-
-#include "exynos_thermal_common.h"
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 enum soc_type {
 	SOC_ARCH_EXYNOS3250 = 1,
@@ -36,38 +35,9 @@ enum soc_type {
 	SOC_ARCH_EXYNOS5420_TRIMINFO,
 	SOC_ARCH_EXYNOS5440,
 };
-#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
- * @threshold: basic temperature for generating interrupt
- *	       25 <= threshold <= 125 [unit: degree Celsius]
- * @threshold_falling: differntial value for setting threshold
- *		       of temperature falling interrupt.
- * @trigger_levels: array for each interrupt levels
- *	[unit: degree Celsius]
- *	0: temperature for trigger_level0 interrupt
- *	   condition for trigger_level0 interrupt:
- *		current temperature > threshold + trigger_levels[0]
- *	1: temperature for trigger_level1 interrupt
- *	   condition for trigger_level1 interrupt:
- *		current temperature > threshold + trigger_levels[1]
- *	2: temperature for trigger_level2 interrupt
- *	   condition for trigger_level2 interrupt:
- *		current temperature > threshold + trigger_levels[2]
- *	3: temperature for trigger_level3 interrupt
- *	   condition for trigger_level3 interrupt:
- *		current temperature > threshold + trigger_levels[3]
- * @trigger_type: defines the type of trigger. Possible values are,
- *	THROTTLE_ACTIVE trigger type
- *	THROTTLE_PASSIVE trigger type
- *	SW_TRIP trigger type
- *	HW_TRIP
- * @trigger_enable[]: array to denote which trigger levels are enabled.
- *	1 = enable trigger_level[] interrupt,
- *	0 = disable trigger_level[] interrupt
- * @max_trigger_level: max trigger level supported by the TMU
- * @non_hw_trigger_levels: number of defined non-hardware trigger levels
  * @gain: gain of amplifier in the positive-TC generator block
  *	0 < gain <= 15
  * @reference_voltage: reference voltage of amplifier
@@ -79,21 +49,12 @@ enum soc_type {
  * @efuse_value: platform defined fuse value
  * @min_efuse_value: minimum valid trimming data
  * @max_efuse_value: maximum valid trimming data
- * @first_point_trim: temp value of the first point trimming
- * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
 struct exynos_tmu_platform_data {
-	u8 threshold;
-	u8 threshold_falling;
-	u8 trigger_levels[MAX_TRIP_COUNT];
-	enum trigger_type trigger_type[MAX_TRIP_COUNT];
-	bool trigger_enable[MAX_TRIP_COUNT];
-	u8 max_trigger_level;
-	u8 non_hw_trigger_levels;
 	u8 gain;
 	u8 reference_voltage;
 	u8 noise_cancel_mode;
@@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
 	u32 cal_mode;
 };
 
-/**
- * struct exynos_tmu_init_data
- * @tmu_count: number of TMU instances.
- * @tmu_data: platform data of all TMU instances.
- * This structure is required to store data for multi-instance exynos tmu
- * driver.
- */
-struct exynos_tmu_init_data {
-	int tmu_count;
-	struct exynos_tmu_platform_data tmu_data[];
-};
-
 extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
 extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
 extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 15/16] thermal: exynos: Remove exynos_thermal_common.[c|h] files
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
                     ` (13 preceding siblings ...)
  2015-01-14 13:41   ` [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-14 13:41   ` [PATCH v3 16/16] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
  2015-01-16  0:00   ` [PATCH v3 00/16] thermal: exynos: Thermal code rework to use device tree Tobias Jakobi
  16 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

After defining all necessary Exynos data in the device tree and heavy
reusage of the of-thermal.c those files can be removed.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
---
 drivers/thermal/samsung/exynos_thermal_common.c | 445 ------------------------
 drivers/thermal/samsung/exynos_thermal_common.h | 106 ------
 2 files changed, 551 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
deleted file mode 100644
index 00aa688..0000000
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ /dev/null
@@ -1,445 +0,0 @@
-/*
- * exynos_thermal_common.c - Samsung EXYNOS common thermal file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include <linux/cpu_cooling.h>
-#include <linux/err.h>
-#include <linux/slab.h>
-#include <linux/thermal.h>
-
-#include "exynos_thermal_common.h"
-
-struct exynos_thermal_zone {
-	enum thermal_device_mode mode;
-	struct thermal_zone_device *therm_dev;
-	struct thermal_cooling_device *cool_dev[MAX_COOLING_DEVICE];
-	unsigned int cool_dev_size;
-	struct platform_device *exynos4_dev;
-	struct thermal_sensor_conf *sensor_conf;
-	bool bind;
-};
-
-/* Get mode callback functions for thermal zone */
-static int exynos_get_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode *mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (th_zone)
-		*mode = th_zone->mode;
-	return 0;
-}
-
-/* Set mode callback functions for thermal zone */
-static int exynos_set_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (!th_zone) {
-		dev_err(&thermal->device,
-			"thermal zone not registered\n");
-		return 0;
-	}
-
-	mutex_lock(&thermal->lock);
-
-	if (mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling)
-		thermal->polling_delay = IDLE_INTERVAL;
-	else
-		thermal->polling_delay = 0;
-
-	mutex_unlock(&thermal->lock);
-
-	th_zone->mode = mode;
-	thermal_zone_device_update(thermal);
-	dev_dbg(th_zone->sensor_conf->dev,
-		"thermal polling set for duration=%d msec\n",
-		thermal->polling_delay);
-	return 0;
-}
-
-
-/* Get trip type callback functions for thermal zone */
-static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
-				 enum thermal_trip_type *type)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	int trip_type;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	trip_type = th_zone->sensor_conf->trip_data.trip_type[trip];
-
-	if (trip_type == SW_TRIP)
-		*type = THERMAL_TRIP_CRITICAL;
-	else if (trip_type == THROTTLE_ACTIVE)
-		*type = THERMAL_TRIP_ACTIVE;
-	else if (trip_type == THROTTLE_PASSIVE)
-		*type = THERMAL_TRIP_PASSIVE;
-	else
-		return -EINVAL;
-
-	return 0;
-}
-
-/* Get trip temperature callback functions for thermal zone */
-static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	*temp = th_zone->sensor_conf->trip_data.trip_val[trip];
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-
-	return 0;
-}
-
-/* Get critical temperature callback functions for thermal zone */
-static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	/* Get the temp of highest trip*/
-	return exynos_get_trip_temp(thermal, max_trip - 1, temp);
-}
-
-/* Bind callback functions for thermal zone */
-static int exynos_bind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-	struct of_phandle_args cooling_spec;
-	unsigned long max, state = 0;
-	int ret = 0, i = 0;
-
-	/*
-	 * Below code is necessary to skip binding when cpufreq's
-	 * frequency table is not yet initialized.
-	 */
-	cdev->ops->get_max_state(cdev, &state);
-	if (!state && !th_zone->cool_dev_size) {
-		th_zone->cool_dev_size = 1;
-		th_zone->cool_dev[0] = cdev;
-		th_zone->bind = false;
-		return 0;
-	}
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	for_each_child_of_node(child, gchild) {
-		ret = of_parse_phandle_with_args(gchild, "cooling-device",
-						 "#cooling-cells",
-						 0, &cooling_spec);
-		if (ret < 0) {
-			pr_err("missing cooling_device property\n");
-			goto end;
-		}
-
-		if (cooling_spec.args_count < 2) {
-			ret = -EINVAL;
-			goto end;
-		}
-
-		max = cooling_spec.args[0];
-		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-						     max, 0)) {
-			dev_err(data->dev,
-				"thermal error unbinding cdev inst=%d\n", i);
-
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = true;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Unbind callback functions for thermal zone */
-static int exynos_unbind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	int ret = 0, i;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-
-	if (th_zone->bind == false || !th_zone->cool_dev_size)
-		return 0;
-
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
-
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	i = 0;
-	for_each_child_of_node(child, gchild) {
-		if (thermal_zone_unbind_cooling_device(thermal, i,
-						       cdev)) {
-			dev_err(data->dev,
-				"error unbinding cdev inst=%d\n", i);
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = false;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_get_temp(struct thermal_zone_device *thermal,
-			unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	void *data;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	*temp = th_zone->sensor_conf->read_temperature(data);
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-	return 0;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
-						unsigned long temp)
-{
-	void *data;
-	int ret = -EINVAL;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	if (th_zone->sensor_conf->write_emul_temp)
-		ret = th_zone->sensor_conf->write_emul_temp(data, temp);
-	return ret;
-}
-
-/* Get the temperature trend */
-static int exynos_get_trend(struct thermal_zone_device *thermal,
-			int trip, enum thermal_trend *trend)
-{
-	int ret;
-	unsigned long trip_temp;
-
-	ret = exynos_get_trip_temp(thermal, trip, &trip_temp);
-	if (ret < 0)
-		return ret;
-
-	if (thermal->temperature >= trip_temp)
-		*trend = THERMAL_TREND_RAISE_FULL;
-	else
-		*trend = THERMAL_TREND_DROP_FULL;
-
-	return 0;
-}
-/* Operation callback functions for thermal zone */
-static struct thermal_zone_device_ops exynos_dev_ops = {
-	.bind = exynos_bind,
-	.unbind = exynos_unbind,
-	.get_temp = exynos_get_temp,
-	.set_emul_temp = exynos_set_emul_temp,
-	.get_trend = exynos_get_trend,
-	.get_mode = exynos_get_mode,
-	.set_mode = exynos_set_mode,
-	.get_trip_type = exynos_get_trip_type,
-	.get_trip_temp = exynos_get_trip_temp,
-	.get_crit_temp = exynos_get_crit_temp,
-};
-
-/*
- * This function may be called from interrupt based temperature sensor
- * when threshold is changed.
- */
-void exynos_report_trigger(struct thermal_sensor_conf *conf)
-{
-	unsigned int i;
-	char data[10];
-	char *envp[] = { data, NULL };
-	struct exynos_thermal_zone *th_zone;
-
-	if (!conf || !conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = conf->pzone_data;
-
-	if (th_zone->bind == false) {
-		for (i = 0; i < th_zone->cool_dev_size; i++) {
-			if (!th_zone->cool_dev[i])
-				continue;
-			exynos_bind(th_zone->therm_dev,
-					th_zone->cool_dev[i]);
-		}
-	}
-
-	thermal_zone_device_update(th_zone->therm_dev);
-
-	mutex_lock(&th_zone->therm_dev->lock);
-	/* Find the level for which trip happened */
-	for (i = 0; i < th_zone->sensor_conf->trip_data.trip_count; i++) {
-		if (th_zone->therm_dev->last_temperature <
-			th_zone->sensor_conf->trip_data.trip_val[i] * MCELSIUS)
-			break;
-	}
-
-	if (th_zone->mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling) {
-		if (i > 0)
-			th_zone->therm_dev->polling_delay = ACTIVE_INTERVAL;
-		else
-			th_zone->therm_dev->polling_delay = IDLE_INTERVAL;
-	}
-
-	snprintf(data, sizeof(data), "%u", i);
-	kobject_uevent_env(&th_zone->therm_dev->device.kobj, KOBJ_CHANGE, envp);
-	mutex_unlock(&th_zone->therm_dev->lock);
-}
-
-/* Register with the in-kernel thermal management */
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int ret;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->read_temperature) {
-		pr_err("Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-
-	th_zone = devm_kzalloc(sensor_conf->dev,
-				sizeof(struct exynos_thermal_zone), GFP_KERNEL);
-	if (!th_zone)
-		return -ENOMEM;
-
-	th_zone->sensor_conf = sensor_conf;
-	/*
-	 * TODO: 1) Handle multiple cooling devices in a thermal zone
-	 *	 2) Add a flag/name in cooling info to map to specific
-	 *	 sensor
-	 */
-	if (sensor_conf->cooling_data.freq_clip_count > 0) {
-		th_zone->cool_dev[th_zone->cool_dev_size] =
-				cpufreq_cooling_register(cpu_present_mask);
-		if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
-			ret = PTR_ERR(th_zone->cool_dev[th_zone->cool_dev_size]);
-			if (ret != -EPROBE_DEFER)
-				dev_err(sensor_conf->dev,
-					"Failed to register cpufreq cooling device: %d\n",
-					ret);
-			goto err_unregister;
-		}
-		th_zone->cool_dev_size++;
-	}
-
-	th_zone->therm_dev = thermal_zone_device_register(
-			sensor_conf->name, sensor_conf->trip_data.trip_count,
-			0, th_zone, &exynos_dev_ops, NULL, 0,
-			sensor_conf->trip_data.trigger_falling ? 0 :
-			IDLE_INTERVAL);
-
-	if (IS_ERR(th_zone->therm_dev)) {
-		dev_err(sensor_conf->dev,
-			"Failed to register thermal zone device\n");
-		ret = PTR_ERR(th_zone->therm_dev);
-		goto err_unregister;
-	}
-	th_zone->mode = THERMAL_DEVICE_ENABLED;
-	sensor_conf->pzone_data = th_zone;
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Thermal zone(%s) registered\n", sensor_conf->name);
-
-	return 0;
-
-err_unregister:
-	exynos_unregister_thermal(sensor_conf);
-	return ret;
-}
-
-/* Un-Register with the in-kernel thermal management */
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int i;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = sensor_conf->pzone_data;
-
-	thermal_zone_device_unregister(th_zone->therm_dev);
-
-	for (i = 0; i < th_zone->cool_dev_size; ++i)
-		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Kernel Thermal management unregistered\n");
-}
diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h
deleted file mode 100644
index cd44719..0000000
--- a/drivers/thermal/samsung/exynos_thermal_common.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * exynos_thermal_common.h - Samsung EXYNOS common header file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#ifndef _EXYNOS_THERMAL_COMMON_H
-#define _EXYNOS_THERMAL_COMMON_H
-
-/* In-kernel thermal framework related macros & definations */
-#define SENSOR_NAME_LEN	16
-#define MAX_TRIP_COUNT	8
-#define MAX_COOLING_DEVICE 4
-
-#define ACTIVE_INTERVAL 500
-#define IDLE_INTERVAL 10000
-#define MCELSIUS	1000
-
-/* CPU Zone information */
-#define PANIC_ZONE      4
-#define WARN_ZONE       3
-#define MONITOR_ZONE    2
-#define SAFE_ZONE       1
-
-#define GET_ZONE(trip) (trip + 2)
-#define GET_TRIP(zone) (zone - 2)
-
-enum trigger_type {
-	THROTTLE_ACTIVE = 1,
-	THROTTLE_PASSIVE,
-	SW_TRIP,
-	HW_TRIP,
-};
-
-/**
- * struct freq_clip_table
- * @freq_clip_max: maximum frequency allowed for this cooling state.
- * @temp_level: Temperature level at which the temperature clipping will
- *	happen.
- * @mask_val: cpumask of the allowed cpu's where the clipping will take place.
- *
- * This structure is required to be filled and passed to the
- * cpufreq_cooling_unregister function.
- */
-struct freq_clip_table {
-	unsigned int freq_clip_max;
-	unsigned int temp_level;
-	const struct cpumask *mask_val;
-};
-
-struct	thermal_trip_point_conf {
-	int trip_val[MAX_TRIP_COUNT];
-	int trip_type[MAX_TRIP_COUNT];
-	int trip_count;
-	unsigned char trigger_falling;
-};
-
-struct	thermal_cooling_conf {
-	struct freq_clip_table freq_data[MAX_TRIP_COUNT];
-	int freq_clip_count;
-};
-
-struct thermal_sensor_conf {
-	char name[SENSOR_NAME_LEN];
-	int (*read_temperature)(void *data);
-	int (*write_emul_temp)(void *drv_data, unsigned long temp);
-	struct thermal_trip_point_conf trip_data;
-	struct thermal_cooling_conf cooling_data;
-	void *driver_data;
-	void *pzone_data;
-	struct device *dev;
-};
-
-/*Functions used exynos based thermal sensor driver*/
-#ifdef CONFIG_EXYNOS_THERMAL_CORE
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf);
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf);
-void exynos_report_trigger(struct thermal_sensor_conf *sensor_conf);
-#else
-static inline void
-exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf) { return; }
-
-static inline int
-exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) { return 0; }
-
-static inline void
-exynos_report_trigger(struct thermal_sensor_conf *sensor_conf) { return; }
-
-#endif /* CONFIG_EXYNOS_THERMAL_CORE */
-#endif /* _EXYNOS_THERMAL_COMMON_H */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v3 16/16] thermal: exynos: Remove exynos_tmu_data.c file
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
                     ` (14 preceding siblings ...)
  2015-01-14 13:41   ` [PATCH v3 15/16] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
@ 2015-01-14 13:41   ` Lukasz Majewski
  2015-01-16  0:00   ` [PATCH v3 00/16] thermal: exynos: Thermal code rework to use device tree Tobias Jakobi
  16 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:41 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Data already present in the exynos_tmu_data.c file has been moved to the
appropriate device tree files.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
---
 drivers/thermal/samsung/exynos_tmu_data.c | 228 ------------------------------
 1 file changed, 228 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c

diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
deleted file mode 100644
index a993f3d..0000000
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * exynos_tmu_data.c - Samsung EXYNOS tmu data file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include "exynos_thermal_common.h"
-#include "exynos_tmu.h"
-
-struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
-	.tmu_data = {
-		{
-		.threshold = 80,
-		.trigger_levels[0] = 5,
-		.trigger_levels[1] = 20,
-		.trigger_levels[2] = 30,
-		.trigger_enable[0] = true,
-		.trigger_enable[1] = true,
-		.trigger_enable[2] = true,
-		.trigger_enable[3] = false,
-		.trigger_type[0] = THROTTLE_ACTIVE,
-		.trigger_type[1] = THROTTLE_ACTIVE,
-		.trigger_type[2] = SW_TRIP,
-		.max_trigger_level = 4,
-		.non_hw_trigger_levels = 3,
-		.gain = 15,
-		.reference_voltage = 7,
-		.cal_type = TYPE_ONE_POINT_TRIMMING,
-		.min_efuse_value = 40,
-		.max_efuse_value = 100,
-		.first_point_trim = 25,
-		.second_point_trim = 85,
-		.default_temp_offset = 50,
-		.type = SOC_ARCH_EXYNOS4210,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS3250_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_TWO_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS3250_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS3250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS4412_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS4412,
-		},
-	},
-	.tmu_count = 1,
-};
-
-struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS5250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define __EXYNOS5260_TMU_DATA	\
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 85, \
-	.trigger_levels[1] = 103, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50,
-
-#define EXYNOS5260_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5260
-
-struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5420_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420
-
-#define EXYNOS5420_TMU_DATA_SHARED \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420_TRIMINFO
-
-struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5440_TMU_DATA \
-	.trigger_levels[0] = 100, \
-	.trigger_levels[4] = 105, \
-	.trigger_enable[0] = 1, \
-	.trigger_type[0] = SW_TRIP, \
-	.trigger_type[4] = HW_TRIP, \
-	.max_trigger_level = 5, \
-	.non_hw_trigger_levels = 1, \
-	.gain = 5, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 0x5b2d, \
-	.min_efuse_value = 16, \
-	.max_efuse_value = 76, \
-	.first_point_trim = 25, \
-	.second_point_trim = 70, \
-	.default_temp_offset = 25, \
-	.type = SOC_ARCH_EXYNOS5440
-
-struct exynos_tmu_init_data const exynos5440_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-	},
-	.tmu_count = 3,
-};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-14 13:41   ` [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
@ 2015-01-14 18:46     ` Eduardo Valentin
  2015-01-15 15:17       ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-14 18:46 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Kyungmin Park,
	Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 27192 bytes --]

On Wed, Jan 14, 2015 at 02:41:12PM +0100, Lukasz Majewski wrote:
> This patch brings support for providing configuration via device tree.
> Previously this data has been hardcoded in the exynos_tmu_data.c file.
> Such approach was not scalable and very often required copying the whole
> data.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
> - Usage of of-thermal.c exported trip points table
> Changes for v3:
> - Adding exynos_of_get_soc_type() method to set SOC type from device's
>   compatible string
> - "samsung,tmu_" prefix for TMU specific properties has been added
> 
> ---
>  drivers/thermal/samsung/Makefile     |   2 -
>  drivers/thermal/samsung/exynos_tmu.c | 345 +++++++++++++++++++++++------------
>  drivers/thermal/samsung/exynos_tmu.h |  53 +-----
>  3 files changed, 226 insertions(+), 174 deletions(-)
> 
> diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile
> index c09d830..1e47d0d 100644
> --- a/drivers/thermal/samsung/Makefile
> +++ b/drivers/thermal/samsung/Makefile
> @@ -3,5 +3,3 @@
>  #
>  obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_thermal.o
>  exynos_thermal-y				:= exynos_tmu.o
> -exynos_thermal-y				+= exynos_tmu_data.o

Can this makefile change be part of the patch that removes
exynos_tmu_data.c?

> -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+= exynos_thermal_common.o

Can this makefile change be part of the patch that removes
exynos_thermal_common.c?

> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index ae30f6a..633a9e2 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -1,6 +1,10 @@
>  /*
>   * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
>   *
> + *  Copyright (C) 2014 Samsung Electronics
> + *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> + *  Lukasz Majewski <l.majewski@samsung.com>
> + *
>   *  Copyright (C) 2011 Samsung Electronics
>   *  Donggeun Kim <dg77.kim@samsung.com>
>   *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
> @@ -31,8 +35,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/regulator/consumer.h>
>  
> -#include "exynos_thermal_common.h"
>  #include "exynos_tmu.h"
> +#include "../thermal_core.h"
>  
>  /* Exynos generic registers */
>  #define EXYNOS_TMU_REG_TRIMINFO		0x0
> @@ -115,6 +119,7 @@
>  #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
>  #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
>  
> +#define MCELSIUS	1000
>  /**
>   * struct exynos_tmu_data : A structure to hold the private data of the TMU
>  	driver
> @@ -150,7 +155,8 @@ struct exynos_tmu_data {
>  	struct clk *clk, *clk_sec;
>  	u8 temp_error1, temp_error2;
>  	struct regulator *regulator;
> -	struct thermal_sensor_conf *reg_conf;
> +	struct thermal_zone_device *tzd;
> +
>  	int (*tmu_initialize)(struct platform_device *pdev);
>  	void (*tmu_control)(struct platform_device *pdev, bool on);
>  	int (*tmu_read)(struct exynos_tmu_data *data);
> @@ -159,6 +165,33 @@ struct exynos_tmu_data {
>  	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
>  };
>  
> +static void exynos_report_trigger(struct exynos_tmu_data *p)
> +{
> +	char data[10], *envp[] = { data, NULL };
> +	struct thermal_zone_device *tz = p->tzd;
> +	unsigned long temp;
> +	unsigned int i;
> +
> +	if (!p) {
> +		pr_err("Wrong temperature configuration data\n");
> +		return;
> +	}
> +
> +	thermal_zone_device_update(tz);
> +
> +	mutex_lock(&tz->lock);
> +	/* Find the level for which trip happened */
> +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> +		tz->ops->get_trip_temp(tz, i, &temp);
> +		if (tz->last_temperature < temp)
> +			break;
> +	}
> +
> +	snprintf(data, sizeof(data), "%u", i);
> +	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
> +	mutex_unlock(&tz->lock);
> +}
> +
>  /*
>   * TMU treats temperature as a mapped temperature code.
>   * The temperature is converted differently depending on the calibration type.
> @@ -234,14 +267,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
>  
>  static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling)
>  {
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> +	struct thermal_zone_device *tz = data->tzd;
> +	const struct thermal_trip * const trips =
> +		of_thermal_get_trip_points(tz);
> +	unsigned long temp;
>  	int i;
>  
> -	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
> -		u8 temp = pdata->trigger_levels[i];
> +	if (!trips) {
> +		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
> +		       __func__);
> +		return 0;
> +	}
> +
> +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> +		if (trips[i].type == THERMAL_TRIP_CRITICAL)
> +			continue;
>  
> +		temp = trips[i].temperature / MCELSIUS;
>  		if (falling)
> -			temp -= pdata->threshold_falling;
> +			temp -= (trips[i].hysteresis / MCELSIUS);
>  		else
>  			threshold &= ~(0xff << 8 * i);
>  
> @@ -305,9 +349,19 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
>  static int exynos4210_tmu_initialize(struct platform_device *pdev)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> -	unsigned int status;
> +	struct thermal_zone_device *tz = data->tzd;
> +	const struct thermal_trip * const trips =
> +		of_thermal_get_trip_points(tz);
>  	int ret = 0, threshold_code, i;
> +	unsigned long reference, temp;
> +	unsigned int status;
> +
> +	if (!trips) {
> +		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
> +		       __func__);
> +		ret = -ENODEV;
> +		goto out;
> +	}
>  
>  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
>  	if (!status) {
> @@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct platform_device *pdev)
>  	sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));
>  
>  	/* Write temperature code for threshold */
> -	threshold_code = temp_to_code(data, pdata->threshold);
> +	reference = trips[0].temperature / MCELSIUS;
> +	threshold_code = temp_to_code(data, reference);
> +	if (threshold_code < 0) {
> +		ret = threshold_code;
> +		goto out;
> +	}
>  	writeb(threshold_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
>  
> -	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
> -		writeb(pdata->trigger_levels[i], data->base +
> +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> +		temp = trips[i].temperature / MCELSIUS;
> +		writeb(temp - reference, data->base +
>  		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
> +	}
>  
>  	data->tmu_clear_irqs(data);
>  out:
> @@ -333,9 +394,11 @@ out:
>  static int exynos4412_tmu_initialize(struct platform_device *pdev)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> +	const struct thermal_trip * const trips =
> +		of_thermal_get_trip_points(data->tzd);
>  	unsigned int status, trim_info, con, ctrl, rising_threshold;
>  	int ret = 0, threshold_code, i;
> +	unsigned long crit_temp = 0;
>  
>  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
>  	if (!status) {
> @@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
>  	data->tmu_clear_irqs(data);
>  
>  	/* if last threshold limit is also present */
> -	i = pdata->max_trigger_level - 1;
> -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
> -		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
> -		/* 1-4 level to be assigned in th0 reg */
> -		rising_threshold &= ~(0xff << 8 * i);
> -		rising_threshold |= threshold_code << 8 * i;
> -		writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
> -		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> -		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> -		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> +	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
> +		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
> +			crit_temp = trips[i].temperature;
> +			break;
> +		}
>  	}
> +
> +	if (i == of_thermal_get_ntrips(data->tzd)) {
> +		pr_err("%s: No CRITICAL trip point defined at of-thermal.c!\n",
> +		       __func__);
> +		ret = -EINVAL;
> +		goto out;
> +	}
> +
> +	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
> +	/* 1-4 level to be assigned in th0 reg */
> +	rising_threshold &= ~(0xff << 8 * i);
> +	rising_threshold |= threshold_code << 8 * i;
> +	writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
> +	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> +	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> +	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> +
>  out:
>  	return ret;
>  }
> @@ -391,9 +466,9 @@ out:
>  static int exynos5440_tmu_initialize(struct platform_device *pdev)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
>  	unsigned int trim_info = 0, con, rising_threshold;
> -	int ret = 0, threshold_code, i;
> +	int ret = 0, threshold_code;
> +	unsigned long crit_temp = 0;
>  
>  	/*
>  	 * For exynos5440 soc triminfo value is swapped between TMU0 and
> @@ -422,9 +497,8 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
>  	data->tmu_clear_irqs(data);
>  
>  	/* if last threshold limit is also present */
> -	i = pdata->max_trigger_level - 1;
> -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
> -		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
> +	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp)) {
> +		threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
>  		/* 5th level to be assigned in th2 reg */
>  		rising_threshold =
>  			threshold_code << EXYNOS5440_TMU_TH_RISE4_SHIFT;
> @@ -442,7 +516,7 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
>  static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> +	struct thermal_zone_device *tz = data->tzd;
>  	unsigned int con, interrupt_en;
>  
>  	con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
> @@ -450,10 +524,15 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
>  	if (on) {
>  		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
>  		interrupt_en =
> -			pdata->trigger_enable[3] << EXYNOS_TMU_INTEN_RISE3_SHIFT |
> -			pdata->trigger_enable[2] << EXYNOS_TMU_INTEN_RISE2_SHIFT |
> -			pdata->trigger_enable[1] << EXYNOS_TMU_INTEN_RISE1_SHIFT |
> -			pdata->trigger_enable[0] << EXYNOS_TMU_INTEN_RISE0_SHIFT;
> +			(of_thermal_is_trip_valid(tz, 3)
> +			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 2)
> +			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 1)
> +			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 0)
> +			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
> +
>  		if (data->soc != SOC_ARCH_EXYNOS4210)
>  			interrupt_en |=
>  				interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
> @@ -468,7 +547,7 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
>  static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> +	struct thermal_zone_device *tz = data->tzd;
>  	unsigned int con, interrupt_en;
>  
>  	con = get_con_reg(data, readl(data->base + EXYNOS5440_TMU_S0_7_CTRL));
> @@ -476,11 +555,16 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
>  	if (on) {
>  		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
>  		interrupt_en =
> -			pdata->trigger_enable[3] << EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
> -			pdata->trigger_enable[2] << EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
> -			pdata->trigger_enable[1] << EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
> -			pdata->trigger_enable[0] << EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
> -		interrupt_en |= interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
> +			(of_thermal_is_trip_valid(tz, 3)
> +			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 2)
> +			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 1)
> +			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 0)
> +			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
> +		interrupt_en |=
> +			interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
>  	} else {
>  		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
>  		interrupt_en = 0; /* Disable all interrupts */
> @@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
>  	writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL);
>  }
>  
> -static int exynos_tmu_read(struct exynos_tmu_data *data)
> +int exynos_get_temp(void *p, long *temp)
>  {
> -	int ret;
> +	struct exynos_tmu_data *data = p;
> +
> +	if (!data)
> +		return -EINVAL;
>  
>  	mutex_lock(&data->lock);
>  	clk_enable(data->clk);
> -	ret = data->tmu_read(data);
> -	if (ret >= 0)
> -		ret = code_to_temp(data, ret);
> +
> +	*temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS;
> +
>  	clk_disable(data->clk);
>  	mutex_unlock(&data->lock);
>  
> -	return ret;
> +	return 0;
>  }
>  
>  #ifdef CONFIG_THERMAL_EMULATION
> @@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct *work)
>  	if (!IS_ERR(data->clk_sec))
>  		clk_disable(data->clk_sec);
>  
> -	exynos_report_trigger(data->reg_conf);
> +	exynos_report_trigger(data);
>  	mutex_lock(&data->lock);
>  	clk_enable(data->clk);
>  
> @@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
>  static const struct of_device_id exynos_tmu_match[] = {
>  	{
>  		.compatible = "samsung,exynos3250-tmu",
> -		.data = &exynos3250_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos4210-tmu",
> -		.data = &exynos4210_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos4412-tmu",
> -		.data = &exynos4412_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5250-tmu",
> -		.data = &exynos5250_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5260-tmu",
> -		.data = &exynos5260_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5420-tmu",
> -		.data = &exynos5420_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5420-tmu-ext-triminfo",
> -		.data = &exynos5420_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5440-tmu",
> -		.data = &exynos5440_default_tmu_data,
>  	},
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, exynos_tmu_match);
>  
> -static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
> -			struct platform_device *pdev, int id)
> +static int exynos_of_get_soc_type(struct device_node *np)
>  {
> -	struct  exynos_tmu_init_data *data_table;
> -	struct exynos_tmu_platform_data *tmu_data;
> -	const struct of_device_id *match;
> +	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
> +		return SOC_ARCH_EXYNOS3250;
> +	else if (of_device_is_compatible(np, "samsung,exynos4210-tmu"))
> +		return SOC_ARCH_EXYNOS4210;
> +	else if (of_device_is_compatible(np, "samsung,exynos4412-tmu"))
> +		return SOC_ARCH_EXYNOS4412;
> +	else if (of_device_is_compatible(np, "samsung,exynos5250-tmu"))
> +		return SOC_ARCH_EXYNOS5250;
> +	else if (of_device_is_compatible(np, "samsung,exynos5260-tmu"))
> +		return SOC_ARCH_EXYNOS5260;
> +	else if (of_device_is_compatible(np, "samsung,exynos5420-tmu"))
> +		return SOC_ARCH_EXYNOS5420;
> +	else if (of_device_is_compatible(np,
> +					 "samsung,exynos5420-tmu-ext-triminfo"))
> +		return SOC_ARCH_EXYNOS5420_TRIMINFO;
> +	else if (of_device_is_compatible(np, "samsung,exynos5440-tmu"))
> +		return SOC_ARCH_EXYNOS5440;
> +
> +	return -EINVAL;
> +}
>  
> -	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
> -	if (!match)
> -		return NULL;
> -	data_table = (struct exynos_tmu_init_data *) match->data;
> -	if (!data_table || id >= data_table->tmu_count)
> -		return NULL;
> -	tmu_data = data_table->tmu_data;
> -	return (struct exynos_tmu_platform_data *) (tmu_data + id);
> +static int exynos_of_sensor_conf(struct device_node *np,
> +				 struct exynos_tmu_platform_data *pdata)
> +{
> +	u32 value;
> +	int ret;
> +
> +	of_node_get(np);
> +
> +	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
> +	pdata->gain = (u8) value;
> +	of_property_read_u32(np, "samsung,tmu_reference_voltage", &value);
> +	pdata->reference_voltage = (u8) value;
> +	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode", &value);
> +	pdata->noise_cancel_mode = (u8) value;
> +
> +	of_property_read_u32(np, "samsung,tmu_efuse_value",
> +			     &pdata->efuse_value);
> +	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
> +			     &pdata->min_efuse_value);
> +	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
> +			     &pdata->max_efuse_value);
> +
> +	of_property_read_u32(np, "samsung,tmu_first_point_trim", &value);
> +	pdata->first_point_trim = (u8) value;
> +	of_property_read_u32(np, "samsung,tmu_second_point_trim", &value);
> +	pdata->second_point_trim = (u8) value;
> +	of_property_read_u32(np, "samsung,tmu_default_temp_offset", &value);
> +	pdata->default_temp_offset = (u8) value;
> +
> +	of_property_read_u32(np, "samsung,tmu_cal_type", &pdata->cal_type);
> +	of_property_read_u32(np, "samsung,tmu_cal_mode", &pdata->cal_mode);
> +
> +	of_node_put(np);
> +	return 0;
>  }
>  
>  static int exynos_map_dt_data(struct platform_device *pdev)
> @@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct platform_device *pdev)
>  		return -EADDRNOTAVAIL;
>  	}
>  
> -	pdata = exynos_get_driver_data(pdev, data->id);
> -	if (!pdata) {
> -		dev_err(&pdev->dev, "No platform init data supplied.\n");
> -		return -ENODEV;
> -	}
> +	pdata = devm_kzalloc(&pdev->dev,
> +			     sizeof(struct exynos_tmu_platform_data),
> +			     GFP_KERNEL);
> +	if (!pdata)
> +		return -ENOMEM;
>  
> +	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
>  	data->pdata = pdata;
> -	data->soc = pdata->type;
> +	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
>  
>  	switch (data->soc) {
>  	case SOC_ARCH_EXYNOS4210:
> @@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static struct thermal_zone_of_device_ops exynos_sensor_ops = {
> +	.get_temp = exynos_get_temp,
> +	.set_emul_temp = exynos_tmu_set_emulation,
> +};
> +
>  static int exynos_tmu_probe(struct platform_device *pdev)
>  {
> -	struct exynos_tmu_data *data;
>  	struct exynos_tmu_platform_data *pdata;
> -	struct thermal_sensor_conf *sensor_conf;
> -	int ret, i;
> +	struct exynos_tmu_data *data;
> +	int ret;
>  
>  	data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
>  					GFP_KERNEL);
> @@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, data);
>  	mutex_init(&data->lock);
>  
> +	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
> +						    &exynos_sensor_ops);
> +	if (IS_ERR(data->tzd)) {
> +		pr_err("thermal: tz: %p ERROR\n", data->tzd);
> +		return PTR_ERR(data->tzd);
> +	}
>  	ret = exynos_map_dt_data(pdev);
>  	if (ret)
> -		return ret;
> +		goto err_sensor;
>  
>  	pdata = data->pdata;
>  
> @@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  	data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
>  	if (IS_ERR(data->clk)) {
>  		dev_err(&pdev->dev, "Failed to get clock\n");
> -		return  PTR_ERR(data->clk);
> +		ret = PTR_ERR(data->clk);
> +		goto err_sensor;
>  	}
>  
>  	data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
>  	if (IS_ERR(data->clk_sec)) {
>  		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
>  			dev_err(&pdev->dev, "Failed to get triminfo clock\n");
> -			return PTR_ERR(data->clk_sec);
> +			ret = PTR_ERR(data->clk_sec);
> +			goto err_sensor;
>  		}
>  	} else {
>  		ret = clk_prepare(data->clk_sec);
>  		if (ret) {
>  			dev_err(&pdev->dev, "Failed to get clock\n");
> -			return ret;
> +			goto err_sensor;
>  		}
>  	}
>  
> @@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  		goto err_clk;
>  	}
>  
> -	exynos_tmu_control(pdev, true);
> -
> -	/* Allocate a structure to register with the exynos core thermal */
> -	sensor_conf = devm_kzalloc(&pdev->dev,
> -				sizeof(struct thermal_sensor_conf), GFP_KERNEL);
> -	if (!sensor_conf) {
> -		ret = -ENOMEM;
> -		goto err_clk;
> -	}
> -	sprintf(sensor_conf->name, "therm_zone%d", data->id);
> -	sensor_conf->read_temperature = (int (*)(void *))exynos_tmu_read;
> -	sensor_conf->write_emul_temp =
> -		(int (*)(void *, unsigned long))exynos_tmu_set_emulation;
> -	sensor_conf->driver_data = data;
> -	sensor_conf->trip_data.trip_count = pdata->trigger_enable[0] +
> -			pdata->trigger_enable[1] + pdata->trigger_enable[2]+
> -			pdata->trigger_enable[3];
> -
> -	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
> -		sensor_conf->trip_data.trip_val[i] =
> -			pdata->threshold + pdata->trigger_levels[i];
> -		sensor_conf->trip_data.trip_type[i] =
> -					pdata->trigger_type[i];
> -	}
> -
> -	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
> -
> -	sensor_conf->dev = &pdev->dev;
> -	/* Register the sensor with thermal management interface */
> -	ret = exynos_register_thermal(sensor_conf);
> -	if (ret) {
> -		if (ret != -EPROBE_DEFER)
> -			dev_err(&pdev->dev,
> -				"Failed to register thermal interface: %d\n",
> -				ret);
> -		goto err_clk;
> -	}
> -	data->reg_conf = sensor_conf;
> -
>  	ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
>  		IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
>  	if (ret) {
> @@ -935,21 +1030,31 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  		goto err_clk;
>  	}
>  
> +	ret = exynos_tmu_initialize(pdev);
> +	if (ret) {
> +		dev_err(&pdev->dev, "Failed to initialize TMU\n");
> +		goto err_clk;
> +	}
> +	exynos_tmu_control(pdev, true);
>  	return 0;
> +
>  err_clk:
>  	clk_unprepare(data->clk);
>  err_clk_sec:
>  	if (!IS_ERR(data->clk_sec))
>  		clk_unprepare(data->clk_sec);
> +err_sensor:
> +	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
> +
>  	return ret;
>  }
>  
>  static int exynos_tmu_remove(struct platform_device *pdev)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> +	struct thermal_zone_device *tzd = data->tzd;
>  
> -	exynos_unregister_thermal(data->reg_conf);
> -
> +	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
>  	exynos_tmu_control(pdev, false);
>  
>  	clk_unprepare(data->clk);
> diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
> index 627dec9..d876d4c 100644
> --- a/drivers/thermal/samsung/exynos_tmu.h
> +++ b/drivers/thermal/samsung/exynos_tmu.h
> @@ -23,8 +23,7 @@
>  #ifndef _EXYNOS_TMU_H
>  #define _EXYNOS_TMU_H
>  #include <linux/cpu_cooling.h>
> -
> -#include "exynos_thermal_common.h"
> +#include <dt-bindings/thermal/thermal_exynos.h>
>  
>  enum soc_type {
>  	SOC_ARCH_EXYNOS3250 = 1,
> @@ -36,38 +35,9 @@ enum soc_type {
>  	SOC_ARCH_EXYNOS5420_TRIMINFO,
>  	SOC_ARCH_EXYNOS5440,
>  };
> -#include <dt-bindings/thermal/thermal_exynos.h>
>  
>  /**
>   * struct exynos_tmu_platform_data
> - * @threshold: basic temperature for generating interrupt
> - *	       25 <= threshold <= 125 [unit: degree Celsius]
> - * @threshold_falling: differntial value for setting threshold
> - *		       of temperature falling interrupt.
> - * @trigger_levels: array for each interrupt levels
> - *	[unit: degree Celsius]
> - *	0: temperature for trigger_level0 interrupt
> - *	   condition for trigger_level0 interrupt:
> - *		current temperature > threshold + trigger_levels[0]
> - *	1: temperature for trigger_level1 interrupt
> - *	   condition for trigger_level1 interrupt:
> - *		current temperature > threshold + trigger_levels[1]
> - *	2: temperature for trigger_level2 interrupt
> - *	   condition for trigger_level2 interrupt:
> - *		current temperature > threshold + trigger_levels[2]
> - *	3: temperature for trigger_level3 interrupt
> - *	   condition for trigger_level3 interrupt:
> - *		current temperature > threshold + trigger_levels[3]
> - * @trigger_type: defines the type of trigger. Possible values are,
> - *	THROTTLE_ACTIVE trigger type
> - *	THROTTLE_PASSIVE trigger type
> - *	SW_TRIP trigger type
> - *	HW_TRIP
> - * @trigger_enable[]: array to denote which trigger levels are enabled.
> - *	1 = enable trigger_level[] interrupt,
> - *	0 = disable trigger_level[] interrupt
> - * @max_trigger_level: max trigger level supported by the TMU
> - * @non_hw_trigger_levels: number of defined non-hardware trigger levels
>   * @gain: gain of amplifier in the positive-TC generator block
>   *	0 < gain <= 15
>   * @reference_voltage: reference voltage of amplifier
> @@ -79,21 +49,12 @@ enum soc_type {
>   * @efuse_value: platform defined fuse value
>   * @min_efuse_value: minimum valid trimming data
>   * @max_efuse_value: maximum valid trimming data
> - * @first_point_trim: temp value of the first point trimming
> - * @second_point_trim: temp value of the second point trimming
>   * @default_temp_offset: default temperature offset in case of no trimming
>   * @cal_type: calibration type for temperature
>   *
>   * This structure is required for configuration of exynos_tmu driver.
>   */
>  struct exynos_tmu_platform_data {
> -	u8 threshold;
> -	u8 threshold_falling;
> -	u8 trigger_levels[MAX_TRIP_COUNT];
> -	enum trigger_type trigger_type[MAX_TRIP_COUNT];
> -	bool trigger_enable[MAX_TRIP_COUNT];
> -	u8 max_trigger_level;
> -	u8 non_hw_trigger_levels;
>  	u8 gain;
>  	u8 reference_voltage;
>  	u8 noise_cancel_mode;
> @@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
>  	u32 cal_mode;
>  };
>  
> -/**
> - * struct exynos_tmu_init_data
> - * @tmu_count: number of TMU instances.
> - * @tmu_data: platform data of all TMU instances.
> - * This structure is required to store data for multi-instance exynos tmu
> - * driver.
> - */
> -struct exynos_tmu_init_data {
> -	int tmu_count;
> -	struct exynos_tmu_platform_data tmu_data[];
> -};
> -
>  extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
>  extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
>  extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 05/16] thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device
  2015-01-14 13:41   ` [PATCH v3 05/16] thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
@ 2015-01-14 18:48     ` Eduardo Valentin
  0 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-14 18:48 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Kyungmin Park,
	Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 984 bytes --]

On Wed, Jan 14, 2015 at 02:41:03PM +0100, Lukasz Majewski wrote:
> This commit enables TMU IP block on the Exynos4412 Odroid U3
> device.
> 

The comment about the patch subject applies here too. I would use "arm:
dts: ..." instead of "thermal: dts" ...".

> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - None
> Changes for v3:
> - None
> ---
>  arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
> index 0adb57c..c7517fc 100644
> --- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
> +++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
> @@ -396,6 +396,11 @@
>  	ehci: ehci@12580000 {
>  		status = "okay";
>  	};
> +
> +	tmu@100C0000 {
> +		vtmu-supply = <&ldo10_reg>;
> +		status = "okay";
> +	};
>  };
>  
>  &pinctrl_1 {
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 09/16] dts: Documentation: Extending documentation entry for exynos-thermal
  2015-01-14 13:41   ` [PATCH v3 09/16] dts: Documentation: Extending documentation entry for exynos-thermal Lukasz Majewski
@ 2015-01-14 18:52     ` Eduardo Valentin
  2015-01-14 19:01       ` Eduardo Valentin
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-14 18:52 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Kyungmin Park,
	Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 3352 bytes --]

On Wed, Jan 14, 2015 at 02:41:07PM +0100, Lukasz Majewski wrote:
> Properties necessary for providing Exynos thermal configuration via device
> tree.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v3:
> - New patch
> 
> ---
>  .../devicetree/bindings/thermal/exynos-thermal.txt      | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
> index ae738f5..0f44932 100644
> --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
> +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
> @@ -39,6 +39,18 @@
>  - vtmu-supply: This entry is optional and provides the regulator node supplying
>  		voltage to TMU. If needed this entry can be placed inside
>  		board/platform specific dts file.
> +Following properties are mandatory (depending on SoC):
> +- samsung,tmu_gain: Gain value for internal TMU operation.
> +- samsung,tmu_reference_voltage: Value of TMU IP block's reference voltage
> +- samsung,tmu_noise_cancel_mode: Mode for noise cancellation
> +- samsung,tmu_efuse_value: Default level of temperature - it is needed when
> +			   in factory fusing produced wrong value
> +- samsung,tmu_min_efuse_value: Minimum temperature fused value
> +- samsung,tmu_max_efuse_value: Maximum temperature fused value
> +- samsung,tmu_first_point_trim: First point trimming value
> +- samsung,tmu_second_point_trim: Second point trimming value
> +- samsung,tmu_default_temp_offset: Default temperature offset
> +- samsung,tmu_cal_type: Callibration type
>  
>  Example 1):
>  
> @@ -51,6 +63,7 @@ Example 1):
>  		clock-names = "tmu_apbif";
>  		status = "disabled";
>  		vtmu-supply = <&tmu_regulator_node>;
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
>  	};
>  
>  Example 2):
> @@ -61,6 +74,7 @@ Example 2):
>  		interrupts = <0 58 0>;
>  		clocks = <&clock 21>;
>  		clock-names = "tmu_apbif";
> +		#include "exynos5440-tmu-sensor-conf.dtsi"

Did I miss something or at this point the above file does not exist yet?

Please make sure each commit / patch is in a compilable/usable/working
state.

>  	};
>  
>  Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
> @@ -70,6 +84,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
>  		interrupts = <0 184 0>;
>  		clocks = <&clock 318>, <&clock 318>;
>  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
>  	};
>  
>  	tmu_cpu3: tmu@1006c000 {
> @@ -78,6 +93,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
>  		interrupts = <0 185 0>;
>  		clocks = <&clock 318>, <&clock 319>;
>  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
>  	};
>  
>  	tmu_gpu: tmu@100a0000 {
> @@ -86,6 +102,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
>  		interrupts = <0 215 0>;
>  		clocks = <&clock 319>, <&clock 318>;
>  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
>  	};
>  
>  Note: For multi-instance tmu each instance should have an alias correctly
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 06/16] arm: dts: Adding CPU cooling binding for Exynos SoCs
  2015-01-14 13:41   ` [PATCH v3 06/16] arm: dts: Adding CPU cooling binding for Exynos SoCs Lukasz Majewski
@ 2015-01-14 18:57     ` Eduardo Valentin
  0 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-14 18:57 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Kyungmin Park,
	Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 6355 bytes --]

On Wed, Jan 14, 2015 at 02:41:04PM +0100, Lukasz Majewski wrote:
> Presented patch aims to move data necessary for correct CPU cooling device
> configuration from exynos_tmu_data.c to device tree.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - None
> Changes for v3:
> - Adjust CPU's DT nodes to work with newest ti-soc-thermal/next branch
> - Patch title has been changed from "thermal: cpu_cooling: dts: ..."
> ---
>  arch/arm/boot/dts/exynos4210-trats.dts          | 15 +++++++++++++++
>  arch/arm/boot/dts/exynos4210.dtsi               |  5 ++++-
>  arch/arm/boot/dts/exynos4212.dtsi               |  5 ++++-
>  arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 15 +++++++++++++++
>  arch/arm/boot/dts/exynos4412-trats2.dts         | 15 +++++++++++++++
>  arch/arm/boot/dts/exynos4412.dtsi               |  5 ++++-
>  arch/arm/boot/dts/exynos5250.dtsi               | 20 +++++++++++++++++++-
>  7 files changed, 76 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
> index 61009f4..4cd8926 100644
> --- a/arch/arm/boot/dts/exynos4210-trats.dts
> +++ b/arch/arm/boot/dts/exynos4210-trats.dts
> @@ -428,6 +428,21 @@
>  		status = "okay";
>  	};
>  
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				    /* Corresponds to 800MHz at freq_table */
> +				    cooling-device = <&cpu0 2 2>;
> +				};
> +				map1 {
> +				   /* Corresponds to 200MHz at freq_table */
> +				   cooling-device = <&cpu0 4 4>;
> +			       };
> +		       };
> +		};

The cpu_thermal zone above is incomplete. It is missing the following
mandatory properties (according to
Documentation/devicetree/bindings/thermal/thermal.txt):
- polling-delay: 
- polling-delay-passive:
- thermal-sensors:
- trips: 

> +	};
> +
>  	camera {
>  		pinctrl-names = "default";
>  		pinctrl-0 = <>;
> diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
> index bcc9e63..2e66df8 100644
> --- a/arch/arm/boot/dts/exynos4210.dtsi
> +++ b/arch/arm/boot/dts/exynos4210.dtsi
> @@ -35,10 +35,13 @@
>  		#address-cells = <1>;
>  		#size-cells = <0>;
>  
> -		cpu@900 {
> +		cpu0: cpu@900 {
>  			device_type = "cpu";
>  			compatible = "arm,cortex-a9";
>  			reg = <0x900>;
> +			cooling-min-level = <4>;
> +			cooling-max-level = <2>;
> +			#cooling-cells = <2>; /* min followed by max */
>  		};
>  
>  		cpu@901 {
> diff --git a/arch/arm/boot/dts/exynos4212.dtsi b/arch/arm/boot/dts/exynos4212.dtsi
> index dd0a43e..5be03288 100644
> --- a/arch/arm/boot/dts/exynos4212.dtsi
> +++ b/arch/arm/boot/dts/exynos4212.dtsi
> @@ -26,10 +26,13 @@
>  		#address-cells = <1>;
>  		#size-cells = <0>;
>  
> -		cpu@A00 {
> +		cpu0: cpu@A00 {
>  			device_type = "cpu";
>  			compatible = "arm,cortex-a9";
>  			reg = <0xA00>;
> +			cooling-min-level = <13>;
> +			cooling-max-level = <7>;
> +			#cooling-cells = <2>; /* min followed by max */
>  		};
>  
>  		cpu@A01 {
> diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
> index c7517fc..4838a2a 100644
> --- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
> +++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
> @@ -401,6 +401,21 @@
>  		vtmu-supply = <&ldo10_reg>;
>  		status = "okay";
>  	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				    /* Corresponds to 800MHz at freq_table */
> +				    cooling-device = <&cpu0 7 7>;
> +				};
> +				map1 {
> +				   /* Corresponds to 200MHz at freq_table */
> +				   cooling-device = <&cpu0 13 13>;
> +			       };
> +		       };
> +		};
> +	};
>  };
>  
>  &pinctrl_1 {
> diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts b/arch/arm/boot/dts/exynos4412-trats2.dts
> index 29231b4..8c2c584 100644
> --- a/arch/arm/boot/dts/exynos4412-trats2.dts
> +++ b/arch/arm/boot/dts/exynos4412-trats2.dts
> @@ -863,6 +863,21 @@
>  		pulldown-ohm = <100000>; /* 100K */
>  		io-channels = <&adc 2>;  /* Battery temperature */
>  	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				    /* Corresponds to 800MHz at freq_table */
> +				    cooling-device = <&cpu0 7 7>;
> +				};
> +				map1 {
> +				   /* Corresponds to 200MHz at freq_table */
> +				   cooling-device = <&cpu0 13 13>;
> +			       };
> +		       };
> +		};
> +	};
>  };
>  
>  &pinctrl_0 {
> diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
> index 0f6ec93..68ad43b 100644
> --- a/arch/arm/boot/dts/exynos4412.dtsi
> +++ b/arch/arm/boot/dts/exynos4412.dtsi
> @@ -26,10 +26,13 @@
>  		#address-cells = <1>;
>  		#size-cells = <0>;
>  
> -		cpu@A00 {
> +		cpu0: cpu@A00 {
>  			device_type = "cpu";
>  			compatible = "arm,cortex-a9";
>  			reg = <0xA00>;
> +			cooling-min-level = <13>;
> +			cooling-max-level = <7>;
> +			#cooling-cells = <2>; /* min followed by max */
>  		};
>  
>  		cpu@A01 {
> diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
> index 0a229fc..dd5c3a0 100644
> --- a/arch/arm/boot/dts/exynos5250.dtsi
> +++ b/arch/arm/boot/dts/exynos5250.dtsi
> @@ -58,11 +58,14 @@
>  		#address-cells = <1>;
>  		#size-cells = <0>;
>  
> -		cpu@0 {
> +		cpu0: cpu@0 {
>  			device_type = "cpu";
>  			compatible = "arm,cortex-a15";
>  			reg = <0>;
>  			clock-frequency = <1700000000>;
> +			cooling-min-level = <15>;
> +			cooling-max-level = <9>;
> +			#cooling-cells = <2>; /* min followed by max */
>  		};
>  		cpu@1 {
>  			device_type = "cpu";
> @@ -241,6 +244,21 @@
>  		clock-names = "tmu_apbif";
>  	};
>  
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				    /* Corresponds to 800MHz at freq_table */
> +				    cooling-device = <&cpu0 9 9>;
> +				};
> +				map1 {
> +				   /* Corresponds to 200MHz at freq_table */
> +				   cooling-device = <&cpu0 15 15>;
> +			       };
> +		       };
> +		};
> +	};
> +
>  	serial@12C00000 {
>  		clocks = <&clock CLK_UART0>, <&clock CLK_SCLK_UART0>;
>  		clock-names = "uart", "clk_uart_baud0";
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 09/16] dts: Documentation: Extending documentation entry for exynos-thermal
  2015-01-14 18:52     ` Eduardo Valentin
@ 2015-01-14 19:01       ` Eduardo Valentin
  0 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-14 19:01 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Kyungmin Park,
	Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 3673 bytes --]

On Wed, Jan 14, 2015 at 02:52:25PM -0400, Eduardo Valentin wrote:
> On Wed, Jan 14, 2015 at 02:41:07PM +0100, Lukasz Majewski wrote:
> > Properties necessary for providing Exynos thermal configuration via device
> > tree.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v3:
> > - New patch
> > 
> > ---
> >  .../devicetree/bindings/thermal/exynos-thermal.txt      | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
> > index ae738f5..0f44932 100644
> > --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
> > +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
> > @@ -39,6 +39,18 @@
> >  - vtmu-supply: This entry is optional and provides the regulator node supplying
> >  		voltage to TMU. If needed this entry can be placed inside
> >  		board/platform specific dts file.
> > +Following properties are mandatory (depending on SoC):
> > +- samsung,tmu_gain: Gain value for internal TMU operation.
> > +- samsung,tmu_reference_voltage: Value of TMU IP block's reference voltage
> > +- samsung,tmu_noise_cancel_mode: Mode for noise cancellation
> > +- samsung,tmu_efuse_value: Default level of temperature - it is needed when
> > +			   in factory fusing produced wrong value
> > +- samsung,tmu_min_efuse_value: Minimum temperature fused value
> > +- samsung,tmu_max_efuse_value: Maximum temperature fused value
> > +- samsung,tmu_first_point_trim: First point trimming value
> > +- samsung,tmu_second_point_trim: Second point trimming value
> > +- samsung,tmu_default_temp_offset: Default temperature offset
> > +- samsung,tmu_cal_type: Callibration type
> >  
> >  Example 1):
> >  
> > @@ -51,6 +63,7 @@ Example 1):
> >  		clock-names = "tmu_apbif";
> >  		status = "disabled";
> >  		vtmu-supply = <&tmu_regulator_node>;
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> >  	};
> >  
> >  Example 2):
> > @@ -61,6 +74,7 @@ Example 2):
> >  		interrupts = <0 58 0>;
> >  		clocks = <&clock 21>;
> >  		clock-names = "tmu_apbif";
> > +		#include "exynos5440-tmu-sensor-conf.dtsi"
> 
> Did I miss something or at this point the above file does not exist yet?
> 
> Please make sure each commit / patch is in a compilable/usable/working
> state.

I know this is a Documentation file, but the comment above still
applies.

> 
> >  	};
> >  
> >  Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
> > @@ -70,6 +84,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
> >  		interrupts = <0 184 0>;
> >  		clocks = <&clock 318>, <&clock 318>;
> >  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> >  	};
> >  
> >  	tmu_cpu3: tmu@1006c000 {
> > @@ -78,6 +93,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
> >  		interrupts = <0 185 0>;
> >  		clocks = <&clock 318>, <&clock 319>;
> >  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> >  	};
> >  
> >  	tmu_gpu: tmu@100a0000 {
> > @@ -86,6 +102,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
> >  		interrupts = <0 215 0>;
> >  		clocks = <&clock 319>, <&clock 318>;
> >  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> >  	};
> >  
> >  Note: For multi-instance tmu each instance should have an alias correctly
> > -- 
> > 2.0.0.rc2
> > 



[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 13/16] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c
  2015-01-14 13:41   ` [PATCH v3 13/16] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c Lukasz Majewski
@ 2015-01-14 19:05     ` Eduardo Valentin
  2015-01-15 16:03       ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-14 19:05 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Kyungmin Park,
	Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 8088 bytes --]

On Wed, Jan 14, 2015 at 02:41:11PM +0100, Lukasz Majewski wrote:
> Presented device tree bindings provide data already hardcoded in the
> exynos_tmu_data.c file.
> After this commit, it should be possible to reuse common thermal core
> framework in Exynos SoCs.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Add proper TMU entries for exynos3250.dtsi
> Changes for v3:
> - Remove "type" DT properties, which will be extracted from compatible
> - "samsung,tmu_" prefix for TMU specific properties has been added
> 
> ---
>  arch/arm/boot/dts/exynos3250.dtsi |  2 ++
>  arch/arm/boot/dts/exynos4.dtsi    |  4 ++++
>  arch/arm/boot/dts/exynos4210.dtsi | 21 ++++++++++++++++++++-
>  arch/arm/boot/dts/exynos4x12.dtsi |  1 +
>  arch/arm/boot/dts/exynos5250.dtsi |  5 +++--
>  arch/arm/boot/dts/exynos5420.dtsi | 28 ++++++++++++++++++++++++++++
>  arch/arm/boot/dts/exynos5440.dtsi | 18 ++++++++++++++++++
>  7 files changed, 76 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/exynos3250.dtsi b/arch/arm/boot/dts/exynos3250.dtsi
> index 2246549..8cc078c 100644
> --- a/arch/arm/boot/dts/exynos3250.dtsi
> +++ b/arch/arm/boot/dts/exynos3250.dtsi
> @@ -18,6 +18,7 @@
>   */
>  
>  #include "skeleton.dtsi"
> +#include "exynos4-cpu-thermal.dtsi"
>  #include <dt-bindings/clock/exynos3250.h>
>  
>  / {
> @@ -188,6 +189,7 @@
>  			interrupts = <0 216 0>;
>  			clocks = <&cmu CLK_TMU_APBIF>;
>  			clock-names = "tmu_apbif";
> +			#include "exynos4412-tmu-sensor-conf.dtsi"
>  			status = "disabled";
>  		};
>  
> diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
> index b8168f1..f18d746 100644
> --- a/arch/arm/boot/dts/exynos4.dtsi
> +++ b/arch/arm/boot/dts/exynos4.dtsi
> @@ -645,4 +645,8 @@
>  		samsung,sysreg = <&sys_reg>;
>  		status = "disabled";
>  	};
> +
> +	tmu: tmu@100C0000 {
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
> +	};
>  };
> diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
> index 2e66df8..7f0e012 100644
> --- a/arch/arm/boot/dts/exynos4210.dtsi
> +++ b/arch/arm/boot/dts/exynos4210.dtsi
> @@ -21,6 +21,7 @@
>  
>  #include "exynos4.dtsi"
>  #include "exynos4210-pinctrl.dtsi"
> +#include "exynos4-cpu-thermal.dtsi"
>  
>  / {
>  	compatible = "samsung,exynos4210", "samsung,exynos4";
> @@ -146,16 +147,34 @@
>  		reg = <0x03860000 0x1000>;
>  	};
>  
> -	tmu@100C0000 {
> +	tmu: tmu@100C0000 {
>  		compatible = "samsung,exynos4210-tmu";
>  		interrupt-parent = <&combiner>;
>  		reg = <0x100C0000 0x100>;
>  		interrupts = <2 4>;
>  		clocks = <&clock CLK_TMU_APBIF>;
>  		clock-names = "tmu_apbif";
> +		samsung,tmu_gain = <15>;
> +		samsung,tmu_reference_voltage = <7>;
>  		status = "disabled";
>  	};
>  
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			trips {
> +			      cpu_alert0: cpu-alert-0 {
> +				      temperature = <85000>; /* millicelsius */
> +			      };
> +			      cpu_alert1: cpu-alert-1 {
> +				      temperature = <100000>; /* millicelsius */
> +			      };
> +			      cpu_alert2: cpu-alert-2 {
> +				      temperature = <110000>; /* millicelsius */
> +			      };
> +			};
> +		};
> +	};
> +
>  	g2d@12800000 {
>  		compatible = "samsung,s5pv210-g2d";
>  		reg = <0x12800000 0x1000>;
> diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi
> index 93b7040..3ee2031 100644
> --- a/arch/arm/boot/dts/exynos4x12.dtsi
> +++ b/arch/arm/boot/dts/exynos4x12.dtsi
> @@ -19,6 +19,7 @@
>  
>  #include "exynos4.dtsi"
>  #include "exynos4x12-pinctrl.dtsi"
> +#include "exynos4-cpu-thermal.dtsi"
>  
>  / {
>  	aliases {
> diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
> index dd5c3a0..07fd73a 100644
> --- a/arch/arm/boot/dts/exynos5250.dtsi
> +++ b/arch/arm/boot/dts/exynos5250.dtsi
> @@ -20,7 +20,7 @@
>  #include <dt-bindings/clock/exynos5250.h>
>  #include "exynos5.dtsi"
>  #include "exynos5250-pinctrl.dtsi"
> -
> +#include "exynos4-cpu-thermal.dtsi"
>  #include <dt-bindings/clock/exynos-audss-clk.h>
>  
>  / {
> @@ -236,12 +236,13 @@
>  		status = "disabled";
>  	};
>  
> -	tmu@10060000 {
> +	tmu: tmu@10060000 {
>  		compatible = "samsung,exynos5250-tmu";
>  		reg = <0x10060000 0x100>;
>  		interrupts = <0 65 0>;
>  		clocks = <&clock CLK_TMU>;
>  		clock-names = "tmu_apbif";
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
>  	};
>  
>  	thermal-zones {
> diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
> index 517e50f..f5771e5 100644
> --- a/arch/arm/boot/dts/exynos5420.dtsi
> +++ b/arch/arm/boot/dts/exynos5420.dtsi
> @@ -761,6 +761,7 @@
>  		interrupts = <0 65 0>;
>  		clocks = <&clock CLK_TMU>;
>  		clock-names = "tmu_apbif";
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
>  	};
>  
>  	tmu_cpu1: tmu@10064000 {
> @@ -769,6 +770,7 @@
>  		interrupts = <0 183 0>;
>  		clocks = <&clock CLK_TMU>;
>  		clock-names = "tmu_apbif";
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
>  	};
>  
>  	tmu_cpu2: tmu@10068000 {
> @@ -777,6 +779,7 @@
>  		interrupts = <0 184 0>;
>  		clocks = <&clock CLK_TMU>, <&clock CLK_TMU>;
>  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
>  	};
>  
>  	tmu_cpu3: tmu@1006c000 {
> @@ -785,6 +788,7 @@
>  		interrupts = <0 185 0>;
>  		clocks = <&clock CLK_TMU>, <&clock CLK_TMU_GPU>;
>  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
>  	};
>  
>  	tmu_gpu: tmu@100a0000 {
> @@ -793,6 +797,30 @@
>  		interrupts = <0 215 0>;
>  		clocks = <&clock CLK_TMU_GPU>, <&clock CLK_TMU>;
>  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> +		#include "exynos4412-tmu-sensor-conf.dtsi"
> +	};
> +
> +	thermal-zones {
> +		cpu0_thermal: cpu0-thermal {
> +			thermal-sensors = <&tmu_cpu0>;
> +			#include "exynos5420-trip-points.dtsi"
> +		};
> +		cpu1_thermal: cpu1-thermal {
> +		       thermal-sensors = <&tmu_cpu1>;
> +		       #include "exynos5420-trip-points.dtsi"
> +		};
> +		cpu2_thermal: cpu2-thermal {
> +		       thermal-sensors = <&tmu_cpu2>;
> +		       #include "exynos5420-trip-points.dtsi"
> +		};
> +		cpu3_thermal: cpu3-thermal {
> +		       thermal-sensors = <&tmu_cpu3>;
> +		       #include "exynos5420-trip-points.dtsi"
> +		};
> +		gpu_thermal: gpu-thermal {
> +		       thermal-sensors = <&tmu_gpu>;
> +		       #include "exynos5420-trip-points.dtsi"
> +		};
>  	};
>  
>          watchdog: watchdog@101D0000 {
> diff --git a/arch/arm/boot/dts/exynos5440.dtsi b/arch/arm/boot/dts/exynos5440.dtsi
> index 8f3373c..59d9416 100644
> --- a/arch/arm/boot/dts/exynos5440.dtsi
> +++ b/arch/arm/boot/dts/exynos5440.dtsi
> @@ -219,6 +219,7 @@
>  		interrupts = <0 58 0>;
>  		clocks = <&clock CLK_B_125>;
>  		clock-names = "tmu_apbif";
> +		#include "exynos5440-tmu-sensor-conf.dtsi"
>  	};
>  
>  	tmuctrl_1: tmuctrl@16011C {
> @@ -227,6 +228,7 @@
>  		interrupts = <0 58 0>;
>  		clocks = <&clock CLK_B_125>;
>  		clock-names = "tmu_apbif";
> +		#include "exynos5440-tmu-sensor-conf.dtsi"
>  	};
>  
>  	tmuctrl_2: tmuctrl@160120 {
> @@ -235,6 +237,22 @@
>  		interrupts = <0 58 0>;
>  		clocks = <&clock CLK_B_125>;
>  		clock-names = "tmu_apbif";
> +		#include "exynos5440-tmu-sensor-conf.dtsi"
> +	};
> +
> +	thermal-zones {
> +		cpu0_thermal: cpu0-thermal {
> +			thermal-sensors = <&tmuctrl_0>;
> +			#include "exynos5440-trip-points.dtsi"
> +		};
> +		cpu1_thermal: cpu1-thermal {
> +		       thermal-sensors = <&tmuctrl_1>;
> +		       #include "exynos5440-trip-points.dtsi"
> +		};
> +		cpu2_thermal: cpu2-thermal {
> +		       thermal-sensors = <&tmuctrl_2>;
> +		       #include "exynos5440-trip-points.dtsi"
> +		};

For all thermal zones added in this patch, can you please make sure they
all've got the mandatory fields?

>  	};
>  
>  	sata@210000 {
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-14 18:46     ` Eduardo Valentin
@ 2015-01-15 15:17       ` Lukasz Majewski
  2015-01-21  1:23         ` Eduardo Valentin
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-15 15:17 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Kyungmin Park,
	Chanwoo Choi

Hi Eduardo,

> On Wed, Jan 14, 2015 at 02:41:12PM +0100, Lukasz Majewski wrote:
> > This patch brings support for providing configuration via device
> > tree. Previously this data has been hardcoded in the
> > exynos_tmu_data.c file. Such approach was not scalable and very
> > often required copying the whole data.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
> > - Usage of of-thermal.c exported trip points table
> > Changes for v3:
> > - Adding exynos_of_get_soc_type() method to set SOC type from
> > device's compatible string
> > - "samsung,tmu_" prefix for TMU specific properties has been added
> > 
> > ---
> >  drivers/thermal/samsung/Makefile     |   2 -
> >  drivers/thermal/samsung/exynos_tmu.c | 345
> > +++++++++++++++++++++++------------
> > drivers/thermal/samsung/exynos_tmu.h |  53 +----- 3 files changed,
> > 226 insertions(+), 174 deletions(-)
> > 
> > diff --git a/drivers/thermal/samsung/Makefile
> > b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644
> > --- a/drivers/thermal/samsung/Makefile
> > +++ b/drivers/thermal/samsung/Makefile
> > @@ -3,5 +3,3 @@
> >  #
> >  obj-$(CONFIG_EXYNOS_THERMAL)			+=
> > exynos_thermal.o exynos_thermal-y				:=
> > exynos_tmu.o -exynos_thermal-y				+=
> > exynos_tmu_data.o
> 
> Can this makefile change be part of the patch that removes
> exynos_tmu_data.c?
> 
> > -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+=
> > exynos_thermal_common.o
> 
> Can this makefile change be part of the patch that removes
> exynos_thermal_common.c?

Unfortunately, this code cannot be moved to the next patch, in which I
remove the files, since this causes build break of the series.

The code structure as is, provides working, bisectable thermal
solution - thermal and cpu_cooling functionality is preserved across
all commits in the series.

> 
> > diff --git a/drivers/thermal/samsung/exynos_tmu.c
> > b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..633a9e2 100644
> > --- a/drivers/thermal/samsung/exynos_tmu.c
> > +++ b/drivers/thermal/samsung/exynos_tmu.c
> > @@ -1,6 +1,10 @@
> >  /*
> >   * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
> >   *
> > + *  Copyright (C) 2014 Samsung Electronics
> > + *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> > + *  Lukasz Majewski <l.majewski@samsung.com>
> > + *
> >   *  Copyright (C) 2011 Samsung Electronics
> >   *  Donggeun Kim <dg77.kim@samsung.com>
> >   *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
> > @@ -31,8 +35,8 @@
> >  #include <linux/platform_device.h>
> >  #include <linux/regulator/consumer.h>
> >  
> > -#include "exynos_thermal_common.h"
> >  #include "exynos_tmu.h"
> > +#include "../thermal_core.h"
> >  
> >  /* Exynos generic registers */
> >  #define EXYNOS_TMU_REG_TRIMINFO		0x0
> > @@ -115,6 +119,7 @@
> >  #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
> >  #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
> >  
> > +#define MCELSIUS	1000
> >  /**
> >   * struct exynos_tmu_data : A structure to hold the private data
> > of the TMU driver
> > @@ -150,7 +155,8 @@ struct exynos_tmu_data {
> >  	struct clk *clk, *clk_sec;
> >  	u8 temp_error1, temp_error2;
> >  	struct regulator *regulator;
> > -	struct thermal_sensor_conf *reg_conf;
> > +	struct thermal_zone_device *tzd;
> > +
> >  	int (*tmu_initialize)(struct platform_device *pdev);
> >  	void (*tmu_control)(struct platform_device *pdev, bool on);
> >  	int (*tmu_read)(struct exynos_tmu_data *data);
> > @@ -159,6 +165,33 @@ struct exynos_tmu_data {
> >  	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
> >  };
> >  
> > +static void exynos_report_trigger(struct exynos_tmu_data *p)
> > +{
> > +	char data[10], *envp[] = { data, NULL };
> > +	struct thermal_zone_device *tz = p->tzd;
> > +	unsigned long temp;
> > +	unsigned int i;
> > +
> > +	if (!p) {
> > +		pr_err("Wrong temperature configuration data\n");
> > +		return;
> > +	}
> > +
> > +	thermal_zone_device_update(tz);
> > +
> > +	mutex_lock(&tz->lock);
> > +	/* Find the level for which trip happened */
> > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > +		tz->ops->get_trip_temp(tz, i, &temp);
> > +		if (tz->last_temperature < temp)
> > +			break;
> > +	}
> > +
> > +	snprintf(data, sizeof(data), "%u", i);
> > +	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
> > +	mutex_unlock(&tz->lock);
> > +}
> > +
> >  /*
> >   * TMU treats temperature as a mapped temperature code.
> >   * The temperature is converted differently depending on the
> > calibration type. @@ -234,14 +267,25 @@ static void
> > sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info) 
> >  static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold,
> > bool falling) {
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > +	struct thermal_zone_device *tz = data->tzd;
> > +	const struct thermal_trip * const trips =
> > +		of_thermal_get_trip_points(tz);
> > +	unsigned long temp;
> >  	int i;
> >  
> > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
> > -		u8 temp = pdata->trigger_levels[i];
> > +	if (!trips) {
> > +		pr_err("%s: Cannot get trip points from
> > of-thermal.c!\n",
> > +		       __func__);
> > +		return 0;
> > +	}
> > +
> > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > +		if (trips[i].type == THERMAL_TRIP_CRITICAL)
> > +			continue;
> >  
> > +		temp = trips[i].temperature / MCELSIUS;
> >  		if (falling)
> > -			temp -= pdata->threshold_falling;
> > +			temp -= (trips[i].hysteresis / MCELSIUS);
> >  		else
> >  			threshold &= ~(0xff << 8 * i);
> >  
> > @@ -305,9 +349,19 @@ static void exynos_tmu_control(struct
> > platform_device *pdev, bool on) static int
> > exynos4210_tmu_initialize(struct platform_device *pdev) {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > -	unsigned int status;
> > +	struct thermal_zone_device *tz = data->tzd;
> > +	const struct thermal_trip * const trips =
> > +		of_thermal_get_trip_points(tz);
> >  	int ret = 0, threshold_code, i;
> > +	unsigned long reference, temp;
> > +	unsigned int status;
> > +
> > +	if (!trips) {
> > +		pr_err("%s: Cannot get trip points from
> > of-thermal.c!\n",
> > +		       __func__);
> > +		ret = -ENODEV;
> > +		goto out;
> > +	}
> >  
> >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> >  	if (!status) {
> > @@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct
> > platform_device *pdev) sanitize_temp_error(data, readl(data->base +
> > EXYNOS_TMU_REG_TRIMINFO)); 
> >  	/* Write temperature code for threshold */
> > -	threshold_code = temp_to_code(data, pdata->threshold);
> > +	reference = trips[0].temperature / MCELSIUS;
> > +	threshold_code = temp_to_code(data, reference);
> > +	if (threshold_code < 0) {
> > +		ret = threshold_code;
> > +		goto out;
> > +	}
> >  	writeb(threshold_code, data->base +
> > EXYNOS4210_TMU_REG_THRESHOLD_TEMP); 
> > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
> > -		writeb(pdata->trigger_levels[i], data->base +
> > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > +		temp = trips[i].temperature / MCELSIUS;
> > +		writeb(temp - reference, data->base +
> >  		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
> > +	}
> >  
> >  	data->tmu_clear_irqs(data);
> >  out:
> > @@ -333,9 +394,11 @@ out:
> >  static int exynos4412_tmu_initialize(struct platform_device *pdev)
> >  {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > +	const struct thermal_trip * const trips =
> > +		of_thermal_get_trip_points(data->tzd);
> >  	unsigned int status, trim_info, con, ctrl,
> > rising_threshold; int ret = 0, threshold_code, i;
> > +	unsigned long crit_temp = 0;
> >  
> >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> >  	if (!status) {
> > @@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct
> > platform_device *pdev) data->tmu_clear_irqs(data);
> >  
> >  	/* if last threshold limit is also present */
> > -	i = pdata->max_trigger_level - 1;
> > -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==
> > HW_TRIP) {
> > -		threshold_code = temp_to_code(data,
> > pdata->trigger_levels[i]);
> > -		/* 1-4 level to be assigned in th0 reg */
> > -		rising_threshold &= ~(0xff << 8 * i);
> > -		rising_threshold |= threshold_code << 8 * i;
> > -		writel(rising_threshold, data->base +
> > EXYNOS_THD_TEMP_RISE);
> > -		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> > -		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > -		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> > +	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
> > +		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
> > +			crit_temp = trips[i].temperature;
> > +			break;
> > +		}
> >  	}
> > +
> > +	if (i == of_thermal_get_ntrips(data->tzd)) {
> > +		pr_err("%s: No CRITICAL trip point defined at
> > of-thermal.c!\n",
> > +		       __func__);
> > +		ret = -EINVAL;
> > +		goto out;
> > +	}
> > +
> > +	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
> > +	/* 1-4 level to be assigned in th0 reg */
> > +	rising_threshold &= ~(0xff << 8 * i);
> > +	rising_threshold |= threshold_code << 8 * i;
> > +	writel(rising_threshold, data->base +
> > EXYNOS_THD_TEMP_RISE);
> > +	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> > +	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > +	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> > +
> >  out:
> >  	return ret;
> >  }
> > @@ -391,9 +466,9 @@ out:
> >  static int exynos5440_tmu_initialize(struct platform_device *pdev)
> >  {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> >  	unsigned int trim_info = 0, con, rising_threshold;
> > -	int ret = 0, threshold_code, i;
> > +	int ret = 0, threshold_code;
> > +	unsigned long crit_temp = 0;
> >  
> >  	/*
> >  	 * For exynos5440 soc triminfo value is swapped between
> > TMU0 and @@ -422,9 +497,8 @@ static int
> > exynos5440_tmu_initialize(struct platform_device *pdev)
> > data->tmu_clear_irqs(data); 
> >  	/* if last threshold limit is also present */
> > -	i = pdata->max_trigger_level - 1;
> > -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==
> > HW_TRIP) {
> > -		threshold_code = temp_to_code(data,
> > pdata->trigger_levels[i]);
> > +	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp))
> > {
> > +		threshold_code = temp_to_code(data, crit_temp /
> > MCELSIUS); /* 5th level to be assigned in th2 reg */
> >  		rising_threshold =
> >  			threshold_code <<
> > EXYNOS5440_TMU_TH_RISE4_SHIFT; @@ -442,7 +516,7 @@ static int
> > exynos5440_tmu_initialize(struct platform_device *pdev) static void
> > exynos4210_tmu_control(struct platform_device *pdev, bool on) {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > +	struct thermal_zone_device *tz = data->tzd;
> >  	unsigned int con, interrupt_en;
> >  
> >  	con = get_con_reg(data, readl(data->base +
> > EXYNOS_TMU_REG_CONTROL)); @@ -450,10 +524,15 @@ static void
> > exynos4210_tmu_control(struct platform_device *pdev, bool on) if
> > (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> >  		interrupt_en =
> > -			pdata->trigger_enable[3] <<
> > EXYNOS_TMU_INTEN_RISE3_SHIFT |
> > -			pdata->trigger_enable[2] <<
> > EXYNOS_TMU_INTEN_RISE2_SHIFT |
> > -			pdata->trigger_enable[1] <<
> > EXYNOS_TMU_INTEN_RISE1_SHIFT |
> > -			pdata->trigger_enable[0] <<
> > EXYNOS_TMU_INTEN_RISE0_SHIFT;
> > +			(of_thermal_is_trip_valid(tz, 3)
> > +			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 2)
> > +			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 1)
> > +			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 0)
> > +			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
> > +
> >  		if (data->soc != SOC_ARCH_EXYNOS4210)
> >  			interrupt_en |=
> >  				interrupt_en <<
> > EXYNOS_TMU_INTEN_FALL0_SHIFT; @@ -468,7 +547,7 @@ static void
> > exynos4210_tmu_control(struct platform_device *pdev, bool on)
> > static void exynos5440_tmu_control(struct platform_device *pdev,
> > bool on) { struct exynos_tmu_data *data =
> > platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > +	struct thermal_zone_device *tz = data->tzd;
> >  	unsigned int con, interrupt_en;
> >  
> >  	con = get_con_reg(data, readl(data->base +
> > EXYNOS5440_TMU_S0_7_CTRL)); @@ -476,11 +555,16 @@ static void
> > exynos5440_tmu_control(struct platform_device *pdev, bool on) if
> > (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> >  		interrupt_en =
> > -			pdata->trigger_enable[3] <<
> > EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
> > -			pdata->trigger_enable[2] <<
> > EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
> > -			pdata->trigger_enable[1] <<
> > EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
> > -			pdata->trigger_enable[0] <<
> > EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
> > -		interrupt_en |= interrupt_en <<
> > EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
> > +			(of_thermal_is_trip_valid(tz, 3)
> > +			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 2)
> > +			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 1)
> > +			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 0)
> > +			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
> > +		interrupt_en |=
> > +			interrupt_en <<
> > EXYNOS5440_TMU_INTEN_FALL0_SHIFT; } else {
> >  		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
> >  		interrupt_en = 0; /* Disable all interrupts */
> > @@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct
> > platform_device *pdev, bool on) writel(con, data->base +
> > EXYNOS5440_TMU_S0_7_CTRL); }
> >  
> > -static int exynos_tmu_read(struct exynos_tmu_data *data)
> > +int exynos_get_temp(void *p, long *temp)
> >  {
> > -	int ret;
> > +	struct exynos_tmu_data *data = p;
> > +
> > +	if (!data)
> > +		return -EINVAL;
> >  
> >  	mutex_lock(&data->lock);
> >  	clk_enable(data->clk);
> > -	ret = data->tmu_read(data);
> > -	if (ret >= 0)
> > -		ret = code_to_temp(data, ret);
> > +
> > +	*temp = code_to_temp(data, data->tmu_read(data)) *
> > MCELSIUS; +
> >  	clk_disable(data->clk);
> >  	mutex_unlock(&data->lock);
> >  
> > -	return ret;
> > +	return 0;
> >  }
> >  
> >  #ifdef CONFIG_THERMAL_EMULATION
> > @@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct
> > *work) if (!IS_ERR(data->clk_sec))
> >  		clk_disable(data->clk_sec);
> >  
> > -	exynos_report_trigger(data->reg_conf);
> > +	exynos_report_trigger(data);
> >  	mutex_lock(&data->lock);
> >  	clk_enable(data->clk);
> >  
> > @@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq,
> > void *id) static const struct of_device_id exynos_tmu_match[] = {
> >  	{
> >  		.compatible = "samsung,exynos3250-tmu",
> > -		.data = &exynos3250_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos4210-tmu",
> > -		.data = &exynos4210_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos4412-tmu",
> > -		.data = &exynos4412_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos5250-tmu",
> > -		.data = &exynos5250_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos5260-tmu",
> > -		.data = &exynos5260_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos5420-tmu",
> > -		.data = &exynos5420_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible =
> > "samsung,exynos5420-tmu-ext-triminfo",
> > -		.data = &exynos5420_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos5440-tmu",
> > -		.data = &exynos5440_default_tmu_data,
> >  	},
> >  	{},
> >  };
> >  MODULE_DEVICE_TABLE(of, exynos_tmu_match);
> >  
> > -static inline struct  exynos_tmu_platform_data
> > *exynos_get_driver_data(
> > -			struct platform_device *pdev, int id)
> > +static int exynos_of_get_soc_type(struct device_node *np)
> >  {
> > -	struct  exynos_tmu_init_data *data_table;
> > -	struct exynos_tmu_platform_data *tmu_data;
> > -	const struct of_device_id *match;
> > +	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
> > +		return SOC_ARCH_EXYNOS3250;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos4210-tmu"))
> > +		return SOC_ARCH_EXYNOS4210;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos4412-tmu"))
> > +		return SOC_ARCH_EXYNOS4412;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos5250-tmu"))
> > +		return SOC_ARCH_EXYNOS5250;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos5260-tmu"))
> > +		return SOC_ARCH_EXYNOS5260;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos5420-tmu"))
> > +		return SOC_ARCH_EXYNOS5420;
> > +	else if (of_device_is_compatible(np,
> > +
> > "samsung,exynos5420-tmu-ext-triminfo"))
> > +		return SOC_ARCH_EXYNOS5420_TRIMINFO;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos5440-tmu"))
> > +		return SOC_ARCH_EXYNOS5440;
> > +
> > +	return -EINVAL;
> > +}
> >  
> > -	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
> > -	if (!match)
> > -		return NULL;
> > -	data_table = (struct exynos_tmu_init_data *) match->data;
> > -	if (!data_table || id >= data_table->tmu_count)
> > -		return NULL;
> > -	tmu_data = data_table->tmu_data;
> > -	return (struct exynos_tmu_platform_data *) (tmu_data + id);
> > +static int exynos_of_sensor_conf(struct device_node *np,
> > +				 struct exynos_tmu_platform_data
> > *pdata) +{
> > +	u32 value;
> > +	int ret;
> > +
> > +	of_node_get(np);
> > +
> > +	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
> > +	pdata->gain = (u8) value;
> > +	of_property_read_u32(np, "samsung,tmu_reference_voltage",
> > &value);
> > +	pdata->reference_voltage = (u8) value;
> > +	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode",
> > &value);
> > +	pdata->noise_cancel_mode = (u8) value;
> > +
> > +	of_property_read_u32(np, "samsung,tmu_efuse_value",
> > +			     &pdata->efuse_value);
> > +	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
> > +			     &pdata->min_efuse_value);
> > +	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
> > +			     &pdata->max_efuse_value);
> > +
> > +	of_property_read_u32(np, "samsung,tmu_first_point_trim",
> > &value);
> > +	pdata->first_point_trim = (u8) value;
> > +	of_property_read_u32(np, "samsung,tmu_second_point_trim",
> > &value);
> > +	pdata->second_point_trim = (u8) value;
> > +	of_property_read_u32(np,
> > "samsung,tmu_default_temp_offset", &value);
> > +	pdata->default_temp_offset = (u8) value;
> > +
> > +	of_property_read_u32(np, "samsung,tmu_cal_type",
> > &pdata->cal_type);
> > +	of_property_read_u32(np, "samsung,tmu_cal_mode",
> > &pdata->cal_mode); +
> > +	of_node_put(np);
> > +	return 0;
> >  }
> >  
> >  static int exynos_map_dt_data(struct platform_device *pdev)
> > @@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct
> > platform_device *pdev) return -EADDRNOTAVAIL;
> >  	}
> >  
> > -	pdata = exynos_get_driver_data(pdev, data->id);
> > -	if (!pdata) {
> > -		dev_err(&pdev->dev, "No platform init data
> > supplied.\n");
> > -		return -ENODEV;
> > -	}
> > +	pdata = devm_kzalloc(&pdev->dev,
> > +			     sizeof(struct
> > exynos_tmu_platform_data),
> > +			     GFP_KERNEL);
> > +	if (!pdata)
> > +		return -ENOMEM;
> >  
> > +	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
> >  	data->pdata = pdata;
> > -	data->soc = pdata->type;
> > +	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
> >  
> >  	switch (data->soc) {
> >  	case SOC_ARCH_EXYNOS4210:
> > @@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct
> > platform_device *pdev) return 0;
> >  }
> >  
> > +static struct thermal_zone_of_device_ops exynos_sensor_ops = {
> > +	.get_temp = exynos_get_temp,
> > +	.set_emul_temp = exynos_tmu_set_emulation,
> > +};
> > +
> >  static int exynos_tmu_probe(struct platform_device *pdev)
> >  {
> > -	struct exynos_tmu_data *data;
> >  	struct exynos_tmu_platform_data *pdata;
> > -	struct thermal_sensor_conf *sensor_conf;
> > -	int ret, i;
> > +	struct exynos_tmu_data *data;
> > +	int ret;
> >  
> >  	data = devm_kzalloc(&pdev->dev, sizeof(struct
> > exynos_tmu_data), GFP_KERNEL);
> > @@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct
> > platform_device *pdev) platform_set_drvdata(pdev, data);
> >  	mutex_init(&data->lock);
> >  
> > +	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0,
> > data,
> > +
> > &exynos_sensor_ops);
> > +	if (IS_ERR(data->tzd)) {
> > +		pr_err("thermal: tz: %p ERROR\n", data->tzd);
> > +		return PTR_ERR(data->tzd);
> > +	}
> >  	ret = exynos_map_dt_data(pdev);
> >  	if (ret)
> > -		return ret;
> > +		goto err_sensor;
> >  
> >  	pdata = data->pdata;
> >  
> > @@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct
> > platform_device *pdev) data->clk = devm_clk_get(&pdev->dev,
> > "tmu_apbif"); if (IS_ERR(data->clk)) {
> >  		dev_err(&pdev->dev, "Failed to get clock\n");
> > -		return  PTR_ERR(data->clk);
> > +		ret = PTR_ERR(data->clk);
> > +		goto err_sensor;
> >  	}
> >  
> >  	data->clk_sec = devm_clk_get(&pdev->dev,
> > "tmu_triminfo_apbif"); if (IS_ERR(data->clk_sec)) {
> >  		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
> >  			dev_err(&pdev->dev, "Failed to get
> > triminfo clock\n");
> > -			return PTR_ERR(data->clk_sec);
> > +			ret = PTR_ERR(data->clk_sec);
> > +			goto err_sensor;
> >  		}
> >  	} else {
> >  		ret = clk_prepare(data->clk_sec);
> >  		if (ret) {
> >  			dev_err(&pdev->dev, "Failed to get
> > clock\n");
> > -			return ret;
> > +			goto err_sensor;
> >  		}
> >  	}
> >  
> > @@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct
> > platform_device *pdev) goto err_clk;
> >  	}
> >  
> > -	exynos_tmu_control(pdev, true);
> > -
> > -	/* Allocate a structure to register with the exynos core
> > thermal */
> > -	sensor_conf = devm_kzalloc(&pdev->dev,
> > -				sizeof(struct
> > thermal_sensor_conf), GFP_KERNEL);
> > -	if (!sensor_conf) {
> > -		ret = -ENOMEM;
> > -		goto err_clk;
> > -	}
> > -	sprintf(sensor_conf->name, "therm_zone%d", data->id);
> > -	sensor_conf->read_temperature = (int (*)(void
> > *))exynos_tmu_read;
> > -	sensor_conf->write_emul_temp =
> > -		(int (*)(void *, unsigned
> > long))exynos_tmu_set_emulation;
> > -	sensor_conf->driver_data = data;
> > -	sensor_conf->trip_data.trip_count =
> > pdata->trigger_enable[0] +
> > -			pdata->trigger_enable[1] +
> > pdata->trigger_enable[2]+
> > -			pdata->trigger_enable[3];
> > -
> > -	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
> > -		sensor_conf->trip_data.trip_val[i] =
> > -			pdata->threshold +
> > pdata->trigger_levels[i];
> > -		sensor_conf->trip_data.trip_type[i] =
> > -					pdata->trigger_type[i];
> > -	}
> > -
> > -	sensor_conf->trip_data.trigger_falling =
> > pdata->threshold_falling; -
> > -	sensor_conf->dev = &pdev->dev;
> > -	/* Register the sensor with thermal management interface */
> > -	ret = exynos_register_thermal(sensor_conf);
> > -	if (ret) {
> > -		if (ret != -EPROBE_DEFER)
> > -			dev_err(&pdev->dev,
> > -				"Failed to register thermal
> > interface: %d\n",
> > -				ret);
> > -		goto err_clk;
> > -	}
> > -	data->reg_conf = sensor_conf;
> > -
> >  	ret = devm_request_irq(&pdev->dev, data->irq,
> > exynos_tmu_irq, IRQF_TRIGGER_RISING | IRQF_SHARED,
> > dev_name(&pdev->dev), data); if (ret) {
> > @@ -935,21 +1030,31 @@ static int exynos_tmu_probe(struct
> > platform_device *pdev) goto err_clk;
> >  	}
> >  
> > +	ret = exynos_tmu_initialize(pdev);
> > +	if (ret) {
> > +		dev_err(&pdev->dev, "Failed to initialize TMU\n");
> > +		goto err_clk;
> > +	}
> > +	exynos_tmu_control(pdev, true);
> >  	return 0;
> > +
> >  err_clk:
> >  	clk_unprepare(data->clk);
> >  err_clk_sec:
> >  	if (!IS_ERR(data->clk_sec))
> >  		clk_unprepare(data->clk_sec);
> > +err_sensor:
> > +	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
> > +
> >  	return ret;
> >  }
> >  
> >  static int exynos_tmu_remove(struct platform_device *pdev)
> >  {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > +	struct thermal_zone_device *tzd = data->tzd;
> >  
> > -	exynos_unregister_thermal(data->reg_conf);
> > -
> > +	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
> >  	exynos_tmu_control(pdev, false);
> >  
> >  	clk_unprepare(data->clk);
> > diff --git a/drivers/thermal/samsung/exynos_tmu.h
> > b/drivers/thermal/samsung/exynos_tmu.h index 627dec9..d876d4c 100644
> > --- a/drivers/thermal/samsung/exynos_tmu.h
> > +++ b/drivers/thermal/samsung/exynos_tmu.h
> > @@ -23,8 +23,7 @@
> >  #ifndef _EXYNOS_TMU_H
> >  #define _EXYNOS_TMU_H
> >  #include <linux/cpu_cooling.h>
> > -
> > -#include "exynos_thermal_common.h"
> > +#include <dt-bindings/thermal/thermal_exynos.h>
> >  
> >  enum soc_type {
> >  	SOC_ARCH_EXYNOS3250 = 1,
> > @@ -36,38 +35,9 @@ enum soc_type {
> >  	SOC_ARCH_EXYNOS5420_TRIMINFO,
> >  	SOC_ARCH_EXYNOS5440,
> >  };
> > -#include <dt-bindings/thermal/thermal_exynos.h>
> >  
> >  /**
> >   * struct exynos_tmu_platform_data
> > - * @threshold: basic temperature for generating interrupt
> > - *	       25 <= threshold <= 125 [unit: degree Celsius]
> > - * @threshold_falling: differntial value for setting threshold
> > - *		       of temperature falling interrupt.
> > - * @trigger_levels: array for each interrupt levels
> > - *	[unit: degree Celsius]
> > - *	0: temperature for trigger_level0 interrupt
> > - *	   condition for trigger_level0 interrupt:
> > - *		current temperature > threshold +
> > trigger_levels[0]
> > - *	1: temperature for trigger_level1 interrupt
> > - *	   condition for trigger_level1 interrupt:
> > - *		current temperature > threshold +
> > trigger_levels[1]
> > - *	2: temperature for trigger_level2 interrupt
> > - *	   condition for trigger_level2 interrupt:
> > - *		current temperature > threshold +
> > trigger_levels[2]
> > - *	3: temperature for trigger_level3 interrupt
> > - *	   condition for trigger_level3 interrupt:
> > - *		current temperature > threshold +
> > trigger_levels[3]
> > - * @trigger_type: defines the type of trigger. Possible values are,
> > - *	THROTTLE_ACTIVE trigger type
> > - *	THROTTLE_PASSIVE trigger type
> > - *	SW_TRIP trigger type
> > - *	HW_TRIP
> > - * @trigger_enable[]: array to denote which trigger levels are
> > enabled.
> > - *	1 = enable trigger_level[] interrupt,
> > - *	0 = disable trigger_level[] interrupt
> > - * @max_trigger_level: max trigger level supported by the TMU
> > - * @non_hw_trigger_levels: number of defined non-hardware trigger
> > levels
> >   * @gain: gain of amplifier in the positive-TC generator block
> >   *	0 < gain <= 15
> >   * @reference_voltage: reference voltage of amplifier
> > @@ -79,21 +49,12 @@ enum soc_type {
> >   * @efuse_value: platform defined fuse value
> >   * @min_efuse_value: minimum valid trimming data
> >   * @max_efuse_value: maximum valid trimming data
> > - * @first_point_trim: temp value of the first point trimming
> > - * @second_point_trim: temp value of the second point trimming
> >   * @default_temp_offset: default temperature offset in case of no
> > trimming
> >   * @cal_type: calibration type for temperature
> >   *
> >   * This structure is required for configuration of exynos_tmu
> > driver. */
> >  struct exynos_tmu_platform_data {
> > -	u8 threshold;
> > -	u8 threshold_falling;
> > -	u8 trigger_levels[MAX_TRIP_COUNT];
> > -	enum trigger_type trigger_type[MAX_TRIP_COUNT];
> > -	bool trigger_enable[MAX_TRIP_COUNT];
> > -	u8 max_trigger_level;
> > -	u8 non_hw_trigger_levels;
> >  	u8 gain;
> >  	u8 reference_voltage;
> >  	u8 noise_cancel_mode;
> > @@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
> >  	u32 cal_mode;
> >  };
> >  
> > -/**
> > - * struct exynos_tmu_init_data
> > - * @tmu_count: number of TMU instances.
> > - * @tmu_data: platform data of all TMU instances.
> > - * This structure is required to store data for multi-instance
> > exynos tmu
> > - * driver.
> > - */
> > -struct exynos_tmu_init_data {
> > -	int tmu_count;
> > -	struct exynos_tmu_platform_data tmu_data[];
> > -};
> > -
> >  extern struct exynos_tmu_init_data const
> > exynos3250_default_tmu_data; extern struct exynos_tmu_init_data
> > const exynos4210_default_tmu_data; extern struct
> > exynos_tmu_init_data const exynos4412_default_tmu_data; -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 13/16] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c
  2015-01-14 19:05     ` Eduardo Valentin
@ 2015-01-15 16:03       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-15 16:03 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Kyungmin Park,
	Chanwoo Choi

Hi Eduardo,

> On Wed, Jan 14, 2015 at 02:41:11PM +0100, Lukasz Majewski wrote:
> > Presented device tree bindings provide data already hardcoded in the
> > exynos_tmu_data.c file.
> > After this commit, it should be possible to reuse common thermal
> > core framework in Exynos SoCs.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Add proper TMU entries for exynos3250.dtsi
> > Changes for v3:
> > - Remove "type" DT properties, which will be extracted from
> > compatible
> > - "samsung,tmu_" prefix for TMU specific properties has been added
> > 
> > ---
> >  arch/arm/boot/dts/exynos3250.dtsi |  2 ++
> >  arch/arm/boot/dts/exynos4.dtsi    |  4 ++++
> >  arch/arm/boot/dts/exynos4210.dtsi | 21 ++++++++++++++++++++-
> >  arch/arm/boot/dts/exynos4x12.dtsi |  1 +
> >  arch/arm/boot/dts/exynos5250.dtsi |  5 +++--
> >  arch/arm/boot/dts/exynos5420.dtsi | 28 ++++++++++++++++++++++++++++
> >  arch/arm/boot/dts/exynos5440.dtsi | 18 ++++++++++++++++++
> >  7 files changed, 76 insertions(+), 3 deletions(-)
> > 
> > diff --git a/arch/arm/boot/dts/exynos3250.dtsi
> > b/arch/arm/boot/dts/exynos3250.dtsi index 2246549..8cc078c 100644
> > --- a/arch/arm/boot/dts/exynos3250.dtsi
> > +++ b/arch/arm/boot/dts/exynos3250.dtsi
> > @@ -18,6 +18,7 @@
> >   */
> >  
> >  #include "skeleton.dtsi"
> > +#include "exynos4-cpu-thermal.dtsi"
> >  #include <dt-bindings/clock/exynos3250.h>
> >  
> >  / {
> > @@ -188,6 +189,7 @@
> >  			interrupts = <0 216 0>;
> >  			clocks = <&cmu CLK_TMU_APBIF>;
> >  			clock-names = "tmu_apbif";
> > +			#include "exynos4412-tmu-sensor-conf.dtsi"
> >  			status = "disabled";
> >  		};
> >  
> > diff --git a/arch/arm/boot/dts/exynos4.dtsi
> > b/arch/arm/boot/dts/exynos4.dtsi index b8168f1..f18d746 100644
> > --- a/arch/arm/boot/dts/exynos4.dtsi
> > +++ b/arch/arm/boot/dts/exynos4.dtsi
> > @@ -645,4 +645,8 @@
> >  		samsung,sysreg = <&sys_reg>;
> >  		status = "disabled";
> >  	};
> > +
> > +	tmu: tmu@100C0000 {
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> > +	};
> >  };
> > diff --git a/arch/arm/boot/dts/exynos4210.dtsi
> > b/arch/arm/boot/dts/exynos4210.dtsi index 2e66df8..7f0e012 100644
> > --- a/arch/arm/boot/dts/exynos4210.dtsi
> > +++ b/arch/arm/boot/dts/exynos4210.dtsi
> > @@ -21,6 +21,7 @@
> >  
> >  #include "exynos4.dtsi"
> >  #include "exynos4210-pinctrl.dtsi"
> > +#include "exynos4-cpu-thermal.dtsi"
> >  
> >  / {
> >  	compatible = "samsung,exynos4210", "samsung,exynos4";
> > @@ -146,16 +147,34 @@
> >  		reg = <0x03860000 0x1000>;
> >  	};
> >  
> > -	tmu@100C0000 {
> > +	tmu: tmu@100C0000 {
> >  		compatible = "samsung,exynos4210-tmu";
> >  		interrupt-parent = <&combiner>;
> >  		reg = <0x100C0000 0x100>;
> >  		interrupts = <2 4>;
> >  		clocks = <&clock CLK_TMU_APBIF>;
> >  		clock-names = "tmu_apbif";
> > +		samsung,tmu_gain = <15>;
> > +		samsung,tmu_reference_voltage = <7>;
> >  		status = "disabled";
> >  	};
> >  
> > +	thermal-zones {
> > +		cpu_thermal: cpu-thermal {
> > +			trips {
> > +			      cpu_alert0: cpu-alert-0 {
> > +				      temperature = <85000>; /*
> > millicelsius */
> > +			      };
> > +			      cpu_alert1: cpu-alert-1 {
> > +				      temperature = <100000>; /*
> > millicelsius */
> > +			      };
> > +			      cpu_alert2: cpu-alert-2 {
> > +				      temperature = <110000>; /*
> > millicelsius */
> > +			      };
> > +			};
> > +		};
> > +	};
> > +
> >  	g2d@12800000 {
> >  		compatible = "samsung,s5pv210-g2d";
> >  		reg = <0x12800000 0x1000>;
> > diff --git a/arch/arm/boot/dts/exynos4x12.dtsi
> > b/arch/arm/boot/dts/exynos4x12.dtsi index 93b7040..3ee2031 100644
> > --- a/arch/arm/boot/dts/exynos4x12.dtsi
> > +++ b/arch/arm/boot/dts/exynos4x12.dtsi
> > @@ -19,6 +19,7 @@
> >  
> >  #include "exynos4.dtsi"
> >  #include "exynos4x12-pinctrl.dtsi"
> > +#include "exynos4-cpu-thermal.dtsi"
> >  
> >  / {
> >  	aliases {
> > diff --git a/arch/arm/boot/dts/exynos5250.dtsi
> > b/arch/arm/boot/dts/exynos5250.dtsi index dd5c3a0..07fd73a 100644
> > --- a/arch/arm/boot/dts/exynos5250.dtsi
> > +++ b/arch/arm/boot/dts/exynos5250.dtsi
> > @@ -20,7 +20,7 @@
> >  #include <dt-bindings/clock/exynos5250.h>
> >  #include "exynos5.dtsi"
> >  #include "exynos5250-pinctrl.dtsi"
> > -
> > +#include "exynos4-cpu-thermal.dtsi"
> >  #include <dt-bindings/clock/exynos-audss-clk.h>
> >  
> >  / {
> > @@ -236,12 +236,13 @@
> >  		status = "disabled";
> >  	};
> >  
> > -	tmu@10060000 {
> > +	tmu: tmu@10060000 {
> >  		compatible = "samsung,exynos5250-tmu";
> >  		reg = <0x10060000 0x100>;
> >  		interrupts = <0 65 0>;
> >  		clocks = <&clock CLK_TMU>;
> >  		clock-names = "tmu_apbif";
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> >  	};
> >  
> >  	thermal-zones {
> > diff --git a/arch/arm/boot/dts/exynos5420.dtsi
> > b/arch/arm/boot/dts/exynos5420.dtsi index 517e50f..f5771e5 100644
> > --- a/arch/arm/boot/dts/exynos5420.dtsi
> > +++ b/arch/arm/boot/dts/exynos5420.dtsi
> > @@ -761,6 +761,7 @@
> >  		interrupts = <0 65 0>;
> >  		clocks = <&clock CLK_TMU>;
> >  		clock-names = "tmu_apbif";
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> >  	};
> >  
> >  	tmu_cpu1: tmu@10064000 {
> > @@ -769,6 +770,7 @@
> >  		interrupts = <0 183 0>;
> >  		clocks = <&clock CLK_TMU>;
> >  		clock-names = "tmu_apbif";
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> >  	};
> >  
> >  	tmu_cpu2: tmu@10068000 {
> > @@ -777,6 +779,7 @@
> >  		interrupts = <0 184 0>;
> >  		clocks = <&clock CLK_TMU>, <&clock CLK_TMU>;
> >  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> >  	};
> >  
> >  	tmu_cpu3: tmu@1006c000 {
> > @@ -785,6 +788,7 @@
> >  		interrupts = <0 185 0>;
> >  		clocks = <&clock CLK_TMU>, <&clock CLK_TMU_GPU>;
> >  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> >  	};
> >  
> >  	tmu_gpu: tmu@100a0000 {
> > @@ -793,6 +797,30 @@
> >  		interrupts = <0 215 0>;
> >  		clocks = <&clock CLK_TMU_GPU>, <&clock CLK_TMU>;
> >  		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
> > +		#include "exynos4412-tmu-sensor-conf.dtsi"
> > +	};
> > +
> > +	thermal-zones {
> > +		cpu0_thermal: cpu0-thermal {
> > +			thermal-sensors = <&tmu_cpu0>;
> > +			#include "exynos5420-trip-points.dtsi"
> > +		};
> > +		cpu1_thermal: cpu1-thermal {
> > +		       thermal-sensors = <&tmu_cpu1>;
> > +		       #include "exynos5420-trip-points.dtsi"
> > +		};
> > +		cpu2_thermal: cpu2-thermal {
> > +		       thermal-sensors = <&tmu_cpu2>;
> > +		       #include "exynos5420-trip-points.dtsi"
> > +		};
> > +		cpu3_thermal: cpu3-thermal {
> > +		       thermal-sensors = <&tmu_cpu3>;
> > +		       #include "exynos5420-trip-points.dtsi"
> > +		};
> > +		gpu_thermal: gpu-thermal {
> > +		       thermal-sensors = <&tmu_gpu>;
> > +		       #include "exynos5420-trip-points.dtsi"
> > +		};
> >  	};
> >  
> >          watchdog: watchdog@101D0000 {
> > diff --git a/arch/arm/boot/dts/exynos5440.dtsi
> > b/arch/arm/boot/dts/exynos5440.dtsi index 8f3373c..59d9416 100644
> > --- a/arch/arm/boot/dts/exynos5440.dtsi
> > +++ b/arch/arm/boot/dts/exynos5440.dtsi
> > @@ -219,6 +219,7 @@
> >  		interrupts = <0 58 0>;
> >  		clocks = <&clock CLK_B_125>;
> >  		clock-names = "tmu_apbif";
> > +		#include "exynos5440-tmu-sensor-conf.dtsi"
> >  	};
> >  
> >  	tmuctrl_1: tmuctrl@16011C {
> > @@ -227,6 +228,7 @@
> >  		interrupts = <0 58 0>;
> >  		clocks = <&clock CLK_B_125>;
> >  		clock-names = "tmu_apbif";
> > +		#include "exynos5440-tmu-sensor-conf.dtsi"
> >  	};
> >  
> >  	tmuctrl_2: tmuctrl@160120 {
> > @@ -235,6 +237,22 @@
> >  		interrupts = <0 58 0>;
> >  		clocks = <&clock CLK_B_125>;
> >  		clock-names = "tmu_apbif";
> > +		#include "exynos5440-tmu-sensor-conf.dtsi"
> > +	};
> > +
> > +	thermal-zones {
> > +		cpu0_thermal: cpu0-thermal {
> > +			thermal-sensors = <&tmuctrl_0>;
> > +			#include "exynos5440-trip-points.dtsi"
> > +		};
> > +		cpu1_thermal: cpu1-thermal {
> > +		       thermal-sensors = <&tmuctrl_1>;
> > +		       #include "exynos5440-trip-points.dtsi"
> > +		};
> > +		cpu2_thermal: cpu2-thermal {
> > +		       thermal-sensors = <&tmuctrl_2>;
> > +		       #include "exynos5440-trip-points.dtsi"
> > +		};
> 
> For all thermal zones added in this patch, can you please make sure
> they all've got the mandatory fields?

This is a better place to put all mandatory fields - not the patch
06/16 - for two reasons:

1. tmu alias (as the sensor) is defined here
2. Here the "real" support (not only for cpu cooling) for thermal-zones
is added.

> 
> >  	};
> >  
> >  	sata@210000 {
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 00/16] thermal: exynos: Thermal code rework to use device tree
  2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
                     ` (15 preceding siblings ...)
  2015-01-14 13:41   ` [PATCH v3 16/16] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
@ 2015-01-16  0:00   ` Tobias Jakobi
  2015-01-16  8:29     ` Lukasz Majewski
  16 siblings, 1 reply; 288+ messages in thread
From: Tobias Jakobi @ 2015-01-16  0:00 UTC (permalink / raw)
  To: Lukasz Majewski, Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

Hello,

while looking through the patchset I noticed the following. In patch
07/16 code is added to drivers/cpufreq/exynos-cpufreq.c, which reminded
me of the cpufreq patchset by Thomas Abraham. If I remember correctly
then the ultimate goal of the cpufreq 'conversion' is to get rid of the
exynos-cpufreq driver is use the cpufreq-cpu0 (now cpufreq-dt) driver
for everything.

Now, this cpufreq patchset hasn't been updated in a while, so I'm not
sure if maybe plans have changed already. But if the goal still is to
remove exynos-cpufreq in the end, wouldn't it be better to not add new
(functionality-providing) code to it, like this series does?

With best wishes,
Tobias


Lukasz Majewski wrote:
> 1. Introduction
> 
> Following patches aim to clean up the current implementation of the thermal
> framework on Exynos devices.
> 
> The main goal was to use a generic code for reading thermal configuration
> (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
> were removed.
> 
> Around 400 lines of code (LOC) were removed directly by this patch, which
> is around 20% of the Exynos thermal code base.
> 
> This work should NOT bring any functional changes to Exynos thermal 
> subsystem.
> 
> 2. Patch-set structure
> 
> Then the cpu_cooling functionality has been preserved to allow cooling
> devices by reducing operating frequency. Definition of trip points and
> cpufreq's cooling properties were moved to device tree.
> 
> Then the rework of the way in which configuration data is provided to
> the Exynos thermal subsystem was performed. Now device tree is used for
> configuration.
> 
> 3. Dead code removal
> 
> Thermal support for some SoCs, previously available in the exynos_tmu_data.c 
> file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.
> 
> Moreover, support for cpu_cooling devices was preserved only on those
> SoCs which had available and working cpufreq driver.
> 
> 4. Testing
> 
> Test devices:
> - Exynos4210 - Trats (TMU zone + cpu_cooling)
> - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> - Exynos5420 - Arndale-octa (only TMU zones)
> 
> Unfortunately, I don't posses Exynos5440 for testing. Its functionality
> has been preserved in the code, but not tested on the hardware. I would
> be grateful for help in testing.
> 
> 
> 5. This work apply on the following tree:
> 
> kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
> 
> Lukasz Majewski (16):
>   thermal: exynos: cosmetic: Correct comment format
>   thermal: exynos: Provide thermal_exynos.h file to be included in
>     device tree files
>   arm: dts: trats: Enable TMU on the Exynos4210 trats device
>   arm: dts: odroid: Add LD010 regulator node necessary for TMU on Odroid
>   thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device
>   arm: dts: Adding CPU cooling binding for Exynos SoCs
>   thermal: exynos: Modify exynos thermal code to use device tree for cpu
>     cooling configuration
>   thermal: exynos: dts: Add default definition of the TMU sensor
>     parameter
>   dts: Documentation: Extending documentation entry for exynos-thermal
>   thermal: dts: Default trip points definition for Exynos5420 SoCs
>   thermal: exynos: dts: Define default thermal-zones for Exynos4
>   thermal: dts: exynos: Trip points and sensor configuration data for
>     Exynos5440
>   thermal: exynos: dts: Provide device tree bindings identical to the
>     one in exynos_tmu_data.c
>   thermal: samsung: core: Exynos TMU rework to use device tree for
>     configuration
>   thermal: exynos: Remove exynos_thermal_common.[c|h] files
>   thermal: exynos: Remove exynos_tmu_data.c file
> 
>  .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
>  arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
>  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
>  arch/arm/boot/dts/exynos4.dtsi                     |   4 +
>  arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
>  arch/arm/boot/dts/exynos4210.dtsi                  |  26 +-
>  arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
>  arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
>  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
>  arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
>  arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
>  arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
>  arch/arm/boot/dts/exynos5250.dtsi                  |  25 +-
>  arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
>  arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
>  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
>  arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
>  arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
>  drivers/cpufreq/exynos-cpufreq.c                   |  30 +-
>  drivers/thermal/samsung/Makefile                   |   2 -
>  drivers/thermal/samsung/exynos_thermal_common.c    | 427 ---------------------
>  drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
>  drivers/thermal/samsung/exynos_tmu.c               | 354 +++++++++++------
>  drivers/thermal/samsung/exynos_tmu.h               |  68 +---
>  drivers/thermal/samsung/exynos_tmu_data.c          | 264 -------------
>  include/dt-bindings/thermal/thermal_exynos.h       |  28 ++
>  26 files changed, 630 insertions(+), 1001 deletions(-)
>  create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
>  delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
>  create mode 100644 include/dt-bindings/thermal/thermal_exynos.h
> 


^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 00/16] thermal: exynos: Thermal code rework to use device tree
  2015-01-16  0:00   ` [PATCH v3 00/16] thermal: exynos: Thermal code rework to use device tree Tobias Jakobi
@ 2015-01-16  8:29     ` Lukasz Majewski
  2015-01-19 23:29       ` Tobias Jakobi
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16  8:29 UTC (permalink / raw)
  To: Tobias Jakobi
  Cc: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim,
	Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Thomas Abraham, tomasz.figa

Hi Tobias,

> Hello,
> 
> while looking through the patchset I noticed the following. In patch
> 07/16 code is added to drivers/cpufreq/exynos-cpufreq.c, which
> reminded me of the cpufreq patchset by Thomas Abraham. 

We all know that this code is floating around - early version of this
work was posted in the Q3 2013.

To be fair - this code is both needed and welcome, but new problems
with it are found (please search for recent comment from Kevin
Hilman).

>From my side, I focus on the code which is in Eduardo Valentin's next
(3.19-rc3), since I don't know when and if eventually cpufreq rework
would be merged.

> If I remember
> correctly then the ultimate goal of the cpufreq 'conversion' is to
> get rid of the exynos-cpufreq driver is use the cpufreq-cpu0 (now
> cpufreq-dt) driver for everything.

The code which touches exynos-cpufreq.c is around 30 LOC, only for
preserving cpu cooling functionality.

Is it worth to wait for code developed for so long to happily apply 30
LOC and delay removal of around 400 LOC in other subsystem (thermal)?

I rise my hand as a volunteer to fix any thermal related issues which
show up after cpufreq rework code applying to Exynos.

> 
> Now, this cpufreq patchset hasn't been updated in a while, 

As I've stated before, development of this code is done for long time.

> so I'm not
> sure if maybe plans have changed already. But if the goal still is to
> remove exynos-cpufreq in the end, wouldn't it be better to not add new
> (functionality-providing) code to it, like this series does?

This series is NOT providing any NEW functionality. It in fact
preserves functionality, which allows using CPU frequency as a mean to
cool the device.

> 
> With best wishes,
> Tobias
> 
> 
> Lukasz Majewski wrote:
> > 1. Introduction
> > 
> > Following patches aim to clean up the current implementation of the
> > thermal framework on Exynos devices.
> > 
> > The main goal was to use a generic code for reading thermal
> > configuration (of-thermal.c). Due to that redundant
> > exynos_thermal_common.[h|c] files were removed.
> > 
> > Around 400 lines of code (LOC) were removed directly by this patch,
> > which is around 20% of the Exynos thermal code base.
> > 
> > This work should NOT bring any functional changes to Exynos thermal 
> > subsystem.
> > 
> > 2. Patch-set structure
> > 
> > Then the cpu_cooling functionality has been preserved to allow
> > cooling devices by reducing operating frequency. Definition of trip
> > points and cpufreq's cooling properties were moved to device tree.
> > 
> > Then the rework of the way in which configuration data is provided
> > to the Exynos thermal subsystem was performed. Now device tree is
> > used for configuration.
> > 
> > 3. Dead code removal
> > 
> > Thermal support for some SoCs, previously available in the
> > exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3,
> > they didn't have TMU bindings.
> > 
> > Moreover, support for cpu_cooling devices was preserved only on
> > those SoCs which had available and working cpufreq driver.
> > 
> > 4. Testing
> > 
> > Test devices:
> > - Exynos4210 - Trats (TMU zone + cpu_cooling)
> > - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> > - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> > - Exynos5420 - Arndale-octa (only TMU zones)
> > 
> > Unfortunately, I don't posses Exynos5440 for testing. Its
> > functionality has been preserved in the code, but not tested on the
> > hardware. I would be grateful for help in testing.
> > 
> > 
> > 5. This work apply on the following tree:
> > 
> > kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> > SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
> > 
> > Lukasz Majewski (16):
> >   thermal: exynos: cosmetic: Correct comment format
> >   thermal: exynos: Provide thermal_exynos.h file to be included in
> >     device tree files
> >   arm: dts: trats: Enable TMU on the Exynos4210 trats device
> >   arm: dts: odroid: Add LD010 regulator node necessary for TMU on
> > Odroid thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device
> >   arm: dts: Adding CPU cooling binding for Exynos SoCs
> >   thermal: exynos: Modify exynos thermal code to use device tree
> > for cpu cooling configuration
> >   thermal: exynos: dts: Add default definition of the TMU sensor
> >     parameter
> >   dts: Documentation: Extending documentation entry for
> > exynos-thermal thermal: dts: Default trip points definition for
> > Exynos5420 SoCs thermal: exynos: dts: Define default thermal-zones
> > for Exynos4 thermal: dts: exynos: Trip points and sensor
> > configuration data for Exynos5440
> >   thermal: exynos: dts: Provide device tree bindings identical to
> > the one in exynos_tmu_data.c
> >   thermal: samsung: core: Exynos TMU rework to use device tree for
> >     configuration
> >   thermal: exynos: Remove exynos_thermal_common.[c|h] files
> >   thermal: exynos: Remove exynos_tmu_data.c file
> > 
> >  .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
> >  arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
> >  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
> >  arch/arm/boot/dts/exynos4.dtsi                     |   4 +
> >  arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
> >  arch/arm/boot/dts/exynos4210.dtsi                  |  26 +-
> >  arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
> >  arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
> >  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
> >  arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
> >  arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
> >  arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
> >  arch/arm/boot/dts/exynos5250.dtsi                  |  25 +-
> >  arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
> >  arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
> >  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
> >  arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
> >  arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
> >  drivers/cpufreq/exynos-cpufreq.c                   |  30 +-
> >  drivers/thermal/samsung/Makefile                   |   2 -
> >  drivers/thermal/samsung/exynos_thermal_common.c    | 427
> > ---------------------
> > drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
> > drivers/thermal/samsung/exynos_tmu.c               | 354
> > +++++++++++------
> > drivers/thermal/samsung/exynos_tmu.h               |  68 +---
> > drivers/thermal/samsung/exynos_tmu_data.c          | 264
> > ------------- include/dt-bindings/thermal/thermal_exynos.h       |
> > 28 ++ 26 files changed, 630 insertions(+), 1001 deletions(-) create
> > mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi create mode
> > 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi create
> > mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi create
> > mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
> > create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
> > delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
> > delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
> > delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c create
> > mode 100644 include/dt-bindings/thermal/thermal_exynos.h
> > 
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v4 00/17] thermal: exynos: Thermal code rework to use device tree
  2014-10-09 16:38 ` Lukasz Majewski
                   ` (25 preceding siblings ...)
  (?)
@ 2015-01-16 11:30 ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 01/17] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
                     ` (18 more replies)
  -1 siblings, 19 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

1. Introduction

Following patches aim to clean up the current implementation of the thermal
framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration
(of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which
is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal 
subsystem.

2. Patch-set structure

Then the cpu_cooling functionality has been preserved to allow cooling
devices by reducing operating frequency. Definition of trip points and
cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to
the Exynos thermal subsystem was performed. Now device tree is used for
configuration.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c 
file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those
SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality
has been preserved in the code, but not tested on the hardware. I would
be grateful for help in testing.


5. This work apply on the following tree:

kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
SHA1: 1813d80874699145f04af6b05ebab0a6419001fb


Lukasz Majewski (17):
  thermal: exynos: cosmetic: Correct comment format
  thermal: exynos: Provide thermal_exynos.h file to be included in
    device tree files
  arm: dts: trats: Enable TMU on the Exynos4210 trats device
  arm: dts: odroid: Add LD010 regulator node necessary for TMU on Odroid
  arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
  arm: dts: Adding CPU cooling binding for Exynos SoCs
  thermal: exynos: Modify exynos thermal code to use device tree for cpu
    cooling configuration
  thermal: exynos: dts: Add default definition of the TMU sensor
    parameter
  dts: Documentation: Extending documentation entry for exynos-thermal
  thermal: dts: Default trip points definition for Exynos5420 SoCs
  thermal: exynos: dts: Define default thermal-zones for Exynos4
  thermal: dts: exynos: Trip points and sensor configuration data for
    Exynos5440
  dts: Documentation: Update exynos-thermal.txt example for Exynos5440
  thermal: exynos: dts: Provide device tree bindings identical to the
    one in exynos_tmu_data.c
  thermal: samsung: core: Exynos TMU rework to use device tree for
    configuration
  thermal: exynos: Remove exynos_thermal_common.[c|h] files
  thermal: exynos: Remove exynos_tmu_data.c file

 .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
 arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   4 +
 arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
 arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
 arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
 arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
 arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
 arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
 arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
 arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
 drivers/cpufreq/exynos-cpufreq.c                   |  30 +-
 drivers/thermal/samsung/Makefile                   |   2 -
 drivers/thermal/samsung/exynos_thermal_common.c    | 427 ---------------------
 drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
 drivers/thermal/samsung/exynos_tmu.c               | 354 +++++++++++------
 drivers/thermal/samsung/exynos_tmu.h               |  68 +---
 drivers/thermal/samsung/exynos_tmu_data.c          | 264 -------------
 include/dt-bindings/thermal/thermal_exynos.h       |  28 ++
 26 files changed, 638 insertions(+), 1001 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

-- 
2.0.0.rc2

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v4 01/17] thermal: exynos: cosmetic: Correct comment format
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 02/17] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
                     ` (17 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
---
 drivers/thermal/samsung/exynos_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index d2f1e62..5000727 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -576,7 +576,7 @@ out:
 #define exynos5440_tmu_set_emulation NULL
 static int exynos_tmu_set_emulation(void *drv_data,	unsigned long temp)
 	{ return -EINVAL; }
-#endif/*CONFIG_THERMAL_EMULATION*/
+#endif /* CONFIG_THERMAL_EMULATION */
 
 static int exynos4210_tmu_read(struct exynos_tmu_data *data)
 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 02/17] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 01/17] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 03/17] arm: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
                     ` (16 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

This patch is a preparatory patch to be able to read Exynos thermal
configuration from the device tree.

It turned out that DTC is not able to interpret enums properly and hence
it is necessary to #define those values explicitly.

For this reason the ./include/dt-bindings/thermal/thermal_exynos.h file
has been introduced.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Restore 'enum soc_type type' since TMU sensor type will be extracted from
  device tree compatible
Changes for v4:
- None
---
 drivers/thermal/samsung/exynos_tmu.h         | 12 +++---------
 include/dt-bindings/thermal/thermal_exynos.h | 28 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 9 deletions(-)
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index da3009b..7f880d2 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -26,14 +26,6 @@
 
 #include "exynos_thermal_common.h"
 
-enum calibration_type {
-	TYPE_ONE_POINT_TRIMMING,
-	TYPE_ONE_POINT_TRIMMING_25,
-	TYPE_ONE_POINT_TRIMMING_85,
-	TYPE_TWO_POINT_TRIMMING,
-	TYPE_NONE,
-};
-
 enum soc_type {
 	SOC_ARCH_EXYNOS3250 = 1,
 	SOC_ARCH_EXYNOS4210,
@@ -44,6 +36,7 @@ enum soc_type {
 	SOC_ARCH_EXYNOS5420_TRIMINFO,
 	SOC_ARCH_EXYNOS5440,
 };
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
@@ -115,8 +108,9 @@ struct exynos_tmu_platform_data {
 	u8 second_point_trim;
 	u8 default_temp_offset;
 
-	enum calibration_type cal_type;
 	enum soc_type type;
+	u32 cal_type;
+	u32 cal_mode;
 	struct freq_clip_table freq_tab[4];
 	unsigned int freq_tab_count;
 };
diff --git a/include/dt-bindings/thermal/thermal_exynos.h b/include/dt-bindings/thermal/thermal_exynos.h
new file mode 100644
index 0000000..0646500
--- /dev/null
+++ b/include/dt-bindings/thermal/thermal_exynos.h
@@ -0,0 +1,28 @@
+/*
+ * thermal_exynos.h - Samsung EXYNOS TMU device tree definitions
+ *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef _EXYNOS_THERMAL_TMU_DT_H
+#define _EXYNOS_THERMAL_TMU_DT_H
+
+#define TYPE_ONE_POINT_TRIMMING 0
+#define TYPE_ONE_POINT_TRIMMING_25 1
+#define TYPE_ONE_POINT_TRIMMING_85 2
+#define TYPE_TWO_POINT_TRIMMING 3
+#define TYPE_NONE 4
+
+#endif /* _EXYNOS_THERMAL_TMU_DT_H */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 03/17] arm: dts: trats: Enable TMU on the Exynos4210 trats device
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 01/17] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 02/17] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 04/17] arm: dts: odroid: Add LD010 regulator node necessary for TMU on Odroid Lukasz Majewski
                     ` (15 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

The thermal IP block (Thermal Management Unit) called TMU has been enabled
in this device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Patch title has been changed from thermal: dts: arm to arm: dts: trats
Changes for v4:
- None
---
 arch/arm/boot/dts/exynos4210-trats.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index 7208362..61009f4 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -424,6 +424,10 @@
 		status = "okay";
 	};
 
+	tmu@100C0000 {
+		status = "okay";
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 04/17] arm: dts: odroid: Add LD010 regulator node necessary for TMU on Odroid
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (2 preceding siblings ...)
  2015-01-16 11:30   ` [PATCH v4 03/17] arm: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 05/17] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
                     ` (14 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Patch title has been changed from thermal: dts: exynos to arm: dts: Odroid
Changes for v4:
- None
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 3fbf588..0adb57c 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -231,6 +231,13 @@
 					regulator-always-on;
 				};
 
+				ldo10_reg: LDO10 {
+					regulator-name = "VDD18_MIPIHSI_1.8V";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <1800000>;
+					regulator-always-on;
+				};
+
 				ldo11_reg: LDO11 {
 					regulator-name = "VDD18_ABB1_1.8V";
 					regulator-min-microvolt = <1800000>;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 05/17] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (3 preceding siblings ...)
  2015-01-16 11:30   ` [PATCH v4 04/17] arm: dts: odroid: Add LD010 regulator node necessary for TMU on Odroid Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 06/17] arm: dts: Adding CPU cooling binding for Exynos SoCs Lukasz Majewski
                     ` (13 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

This commit enables TMU IP block on the Exynos4412 Odroid U3
device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- Rename patch title from "thermal: dts:" to "arm: dts: odroid"
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 0adb57c..c7517fc 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -396,6 +396,11 @@
 	ehci: ehci@12580000 {
 		status = "okay";
 	};
+
+	tmu@100C0000 {
+		vtmu-supply = <&ldo10_reg>;
+		status = "okay";
+	};
 };
 
 &pinctrl_1 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 06/17] arm: dts: Adding CPU cooling binding for Exynos SoCs
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (4 preceding siblings ...)
  2015-01-16 11:30   ` [PATCH v4 05/17] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 07/17] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
                     ` (12 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

Presented patch aims to move data necessary for correct CPU cooling device
configuration from exynos_tmu_data.c to device tree.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Adjust CPU's DT nodes to work with newest ti-soc-thermal/next branch
- Patch title has been changed from "thermal: cpu_cooling: dts: ..."
Changes for v4:
- Spaces and tabs cleanup
---
 arch/arm/boot/dts/exynos4210-trats.dts          | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4210.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos4212.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4412-trats2.dts         | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4412.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos5250.dtsi               | 20 +++++++++++++++++++-
 7 files changed, 76 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index 61009f4..e3879c0 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -428,6 +428,21 @@
 		status = "okay";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 2 2>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 4 4>;
+			       };
+		       };
+		};
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index bcc9e63..2e66df8 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -35,10 +35,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@900 {
+		cpu0: cpu@900 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0x900>;
+			cooling-min-level = <4>;
+			cooling-max-level = <2>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@901 {
diff --git a/arch/arm/boot/dts/exynos4212.dtsi b/arch/arm/boot/dts/exynos4212.dtsi
index dd0a43e..5be03288 100644
--- a/arch/arm/boot/dts/exynos4212.dtsi
+++ b/arch/arm/boot/dts/exynos4212.dtsi
@@ -26,10 +26,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@A00 {
+		cpu0: cpu@A00 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@A01 {
diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index c7517fc..25b4f7d 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -401,6 +401,21 @@
 		vtmu-supply = <&ldo10_reg>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 13 13>;
+			       };
+		       };
+		};
+	};
 };
 
 &pinctrl_1 {
diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts b/arch/arm/boot/dts/exynos4412-trats2.dts
index 29231b4..52a7771 100644
--- a/arch/arm/boot/dts/exynos4412-trats2.dts
+++ b/arch/arm/boot/dts/exynos4412-trats2.dts
@@ -863,6 +863,21 @@
 		pulldown-ohm = <100000>; /* 100K */
 		io-channels = <&adc 2>;  /* Battery temperature */
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 13 13>;
+			       };
+		       };
+		};
+	};
 };
 
 &pinctrl_0 {
diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
index 0f6ec93..68ad43b 100644
--- a/arch/arm/boot/dts/exynos4412.dtsi
+++ b/arch/arm/boot/dts/exynos4412.dtsi
@@ -26,10 +26,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@A00 {
+		cpu0: cpu@A00 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@A01 {
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index 0a229fc..4641d3c 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -58,11 +58,14 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@0 {
+		cpu0: cpu@0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a15";
 			reg = <0>;
 			clock-frequency = <1700000000>;
+			cooling-min-level = <15>;
+			cooling-max-level = <9>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 		cpu@1 {
 			device_type = "cpu";
@@ -241,6 +244,21 @@
 		clock-names = "tmu_apbif";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 9 9>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 15 15>;
+			       };
+		       };
+		};
+	};
+
 	serial@12C00000 {
 		clocks = <&clock CLK_UART0>, <&clock CLK_SCLK_UART0>;
 		clock-names = "uart", "clk_uart_baud0";
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 07/17] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (5 preceding siblings ...)
  2015-01-16 11:30   ` [PATCH v4 06/17] arm: dts: Adding CPU cooling binding for Exynos SoCs Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 08/17] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
                     ` (11 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

Up till now exynos_tmu_data.c was used for storing CPU cooling configuration
data. Now the Exynos thermal core code uses device tree to get this data.
For this purpose generic thermal code for configuring CPU cooling was
used.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Rewrite code responsible for registering CPU cooling device to not depend
  on explicit "/cpus/cpu@0" path since now Exynos SoCs use new cpu node
  names (e.g. cpu@A00). New approach iterates over "cpus" node children.
- Patch title changed to thermal: exynos
Changes for v4:
- None

---
 drivers/cpufreq/exynos-cpufreq.c                |  30 +++++-
 drivers/thermal/samsung/exynos_thermal_common.c | 122 ++++++++++++++----------
 drivers/thermal/samsung/exynos_tmu.c            |   7 --
 drivers/thermal/samsung/exynos_tmu.h            |   5 -
 drivers/thermal/samsung/exynos_tmu_data.c       |  42 +-------
 5 files changed, 101 insertions(+), 105 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index f99a0b0..32bc64d 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -18,10 +18,13 @@
 #include <linux/cpufreq.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/cpu_cooling.h>
+#include <linux/cpu.h>
 
 #include "exynos-cpufreq.h"
 
 static struct exynos_dvfs_info *exynos_info;
+static struct thermal_cooling_device *cdev;
 static struct regulator *arm_regulator;
 static unsigned int locking_frequency;
 
@@ -156,6 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
+	struct device_node *cpus, *np;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -198,9 +202,31 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	/* Done here as we want to capture boot frequency */
 	locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;
 
-	if (!cpufreq_register_driver(&exynos_driver))
-		return 0;
+	if (cpufreq_register_driver(&exynos_driver))
+		goto err;
 
+	cpus = of_find_node_by_path("/cpus");
+	if (!cpus) {
+		pr_err("failed to find cpus node\n");
+		return -ENOENT;
+	}
+
+	for (np = of_get_next_child(cpus, NULL); np;
+	     of_node_put(np), np = of_get_next_child(cpus, np)) {
+		if (of_find_property(np, "#cooling-cells", NULL)) {
+			cdev = of_cpufreq_cooling_register(np,
+							   cpu_present_mask);
+			if (IS_ERR(cdev))
+				pr_err("running cpufreq without cooling device: %ld\n",
+				       PTR_ERR(cdev));
+			break;
+		}
+	}
+	of_node_put(np);
+	of_node_put(cpus);
+
+	return 0;
+ err:
 	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
 	regulator_put(arm_regulator);
 err_vdd_arm:
diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 6dc3815..00aa688 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -133,47 +133,62 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
 static int exynos_bind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size, level;
-	struct freq_clip_table *tab_ptr, *clip_data;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
+	struct of_phandle_args cooling_spec;
+	unsigned long max, state = 0;
+	int ret = 0, i = 0;
 
-	tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data;
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_ptr == NULL || tab_size == 0)
+	/*
+	 * Below code is necessary to skip binding when cpufreq's
+	 * frequency table is not yet initialized.
+	 */
+	cdev->ops->get_max_state(cdev, &state);
+	if (!state && !th_zone->cool_dev_size) {
+		th_zone->cool_dev_size = 1;
+		th_zone->cool_dev[0] = cdev;
+		th_zone->bind = false;
 		return 0;
+	}
 
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
 
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
+	child = of_get_child_by_name(np, "cooling-maps");
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		clip_data = (struct freq_clip_table *)&(tab_ptr[i]);
-		level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max);
-		if (level == THERMAL_CSTATE_INVALID)
-			return 0;
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-								level, 0)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = true;
-			break;
-		default:
+	for_each_child_of_node(child, gchild) {
+		ret = of_parse_phandle_with_args(gchild, "cooling-device",
+						 "#cooling-cells",
+						 0, &cooling_spec);
+		if (ret < 0) {
+			pr_err("missing cooling_device property\n");
+			goto end;
+		}
+
+		if (cooling_spec.args_count < 2) {
 			ret = -EINVAL;
+			goto end;
 		}
+
+		max = cooling_spec.args[0];
+		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
+						     max, 0)) {
+			dev_err(data->dev,
+				"thermal error unbinding cdev inst=%d\n", i);
+
+			ret = -EINVAL;
+			goto end;
+		}
+		i++;
 	}
+	th_zone->bind = true;
+end:
+	of_node_put(child);
+	of_node_put(np);
 
 	return ret;
 }
@@ -182,16 +197,12 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 static int exynos_unbind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size;
+	int ret = 0, i;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
 
-	if (th_zone->bind == false)
-		return 0;
-
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_size == 0)
+	if (th_zone->bind == false || !th_zone->cool_dev_size)
 		return 0;
 
 	/* find the cooling device registered*/
@@ -203,23 +214,30 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
 	if (i == th_zone->cool_dev_size)
 		return 0;
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_unbind_cooling_device(thermal, i,
-								cdev)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = false;
-			break;
-		default:
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
+
+	child = of_get_child_by_name(np, "cooling-maps");
+
+	i = 0;
+	for_each_child_of_node(child, gchild) {
+		if (thermal_zone_unbind_cooling_device(thermal, i,
+						       cdev)) {
+			dev_err(data->dev,
+				"error unbinding cdev inst=%d\n", i);
 			ret = -EINVAL;
+			goto end;
 		}
+		i++;
 	}
+	th_zone->bind = false;
+end:
+	of_node_put(child);
+	of_node_put(np);
+
 	return ret;
 }
 
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 5000727..ae30f6a 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -916,13 +916,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 
 	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
 
-	sensor_conf->cooling_data.freq_clip_count = pdata->freq_tab_count;
-	for (i = 0; i < pdata->freq_tab_count; i++) {
-		sensor_conf->cooling_data.freq_data[i].freq_clip_max =
-					pdata->freq_tab[i].freq_clip_max;
-		sensor_conf->cooling_data.freq_data[i].temp_level =
-					pdata->freq_tab[i].temp_level;
-	}
 	sensor_conf->dev = &pdev->dev;
 	/* Register the sensor with thermal management interface */
 	ret = exynos_register_thermal(sensor_conf);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 7f880d2..627dec9 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -83,9 +83,6 @@ enum soc_type {
  * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
- * @freq_clip_table: Table representing frequency reduction percentage.
- * @freq_tab_count: Count of the above table as frequency reduction may
- *	applicable to only some of the trigger levels.
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
@@ -111,8 +108,6 @@ struct exynos_tmu_platform_data {
 	enum soc_type type;
 	u32 cal_type;
 	u32 cal_mode;
-	struct freq_clip_table freq_tab[4];
-	unsigned int freq_tab_count;
 };
 
 /**
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
index b239100..a993f3d 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -47,15 +47,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 		.first_point_trim = 25,
 		.second_point_trim = 85,
 		.default_temp_offset = 50,
-		.freq_tab[0] = {
-			.freq_clip_max = 800 * 1000,
-			.temp_level = 85,
-			},
-		.freq_tab[1] = {
-			.freq_clip_max = 200 * 1000,
-			.temp_level = 100,
-		},
-		.freq_tab_count = 2,
 		.type = SOC_ARCH_EXYNOS4210,
 		},
 	},
@@ -87,16 +78,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 800 * 1000, \
-		.temp_level = 70, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 400 * 1000, \
-		.temp_level = 95, \
-	}, \
-	.freq_tab_count = 2
+	.default_temp_offset = 50
 
 struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 	.tmu_data = {
@@ -133,16 +115,7 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 1400 * 1000, \
-		.temp_level = 70, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 400 * 1000, \
-		.temp_level = 95, \
-	}, \
-	.freq_tab_count = 2
+	.default_temp_offset = 50
 
 struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
 	.tmu_data = {
@@ -189,16 +162,7 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 800 * 1000, \
-		.temp_level = 85, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 200 * 1000, \
-		.temp_level = 103, \
-	}, \
-	.freq_tab_count = 2, \
+	.default_temp_offset = 50,
 
 #define EXYNOS5260_TMU_DATA \
 	__EXYNOS5260_TMU_DATA \
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 08/17] thermal: exynos: dts: Add default definition of the TMU sensor parameter
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (6 preceding siblings ...)
  2015-01-16 11:30   ` [PATCH v4 07/17] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 09/17] dts: Documentation: Extending documentation entry for exynos-thermal Lukasz Majewski
                     ` (10 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

Exynos 4 and 5 family of SoCs uses almost identical TMU sensor to measure the
on chip temperature. For this reason it is possible to group TMU configuration
parameters in one dts file.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- "samsung,tmu_" prefix for TMU specific properties has been added
Changes for v4:
- None

---
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi | 24 +++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi

diff --git a/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
new file mode 100644
index 0000000..e3f7934
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
@@ -0,0 +1,24 @@
+/*
+ * Device tree sources for Exynos4412 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+samsung,tmu_gain = <8>;
+samsung,tmu_reference_voltage = <16>;
+samsung,tmu_noise_cancel_mode = <4>;
+samsung,tmu_efuse_value = <55>;
+samsung,tmu_min_efuse_value = <40>;
+samsung,tmu_max_efuse_value = <100>;
+samsung,tmu_first_point_trim = <25>;
+samsung,tmu_second_point_trim = <85>;
+samsung,tmu_default_temp_offset = <50>;
+samsung,tmu_cal_type = <TYPE_ONE_POINT_TRIMMING>;
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 09/17] dts: Documentation: Extending documentation entry for exynos-thermal
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (7 preceding siblings ...)
  2015-01-16 11:30   ` [PATCH v4 08/17] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 10/17] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
                     ` (9 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

Properties necessary for providing Exynos thermal configuration via device
tree.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v3:
- New patch
Changes for v4:
- Remove entry regarding Exynos5440

---
 .../devicetree/bindings/thermal/exynos-thermal.txt       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
index ae738f5..8497794 100644
--- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
@@ -39,6 +39,18 @@
 - vtmu-supply: This entry is optional and provides the regulator node supplying
 		voltage to TMU. If needed this entry can be placed inside
 		board/platform specific dts file.
+Following properties are mandatory (depending on SoC):
+- samsung,tmu_gain: Gain value for internal TMU operation.
+- samsung,tmu_reference_voltage: Value of TMU IP block's reference voltage
+- samsung,tmu_noise_cancel_mode: Mode for noise cancellation
+- samsung,tmu_efuse_value: Default level of temperature - it is needed when
+			   in factory fusing produced wrong value
+- samsung,tmu_min_efuse_value: Minimum temperature fused value
+- samsung,tmu_max_efuse_value: Maximum temperature fused value
+- samsung,tmu_first_point_trim: First point trimming value
+- samsung,tmu_second_point_trim: Second point trimming value
+- samsung,tmu_default_temp_offset: Default temperature offset
+- samsung,tmu_cal_type: Callibration type
 
 Example 1):
 
@@ -51,6 +63,7 @@ Example 1):
 		clock-names = "tmu_apbif";
 		status = "disabled";
 		vtmu-supply = <&tmu_regulator_node>;
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 Example 2):
@@ -70,6 +83,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 184 0>;
 		clocks = <&clock 318>, <&clock 318>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu3: tmu@1006c000 {
@@ -78,6 +92,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 185 0>;
 		clocks = <&clock 318>, <&clock 319>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_gpu: tmu@100a0000 {
@@ -86,6 +101,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 215 0>;
 		clocks = <&clock 319>, <&clock 318>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 Note: For multi-instance tmu each instance should have an alias correctly
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 10/17] thermal: dts: Default trip points definition for Exynos5420 SoCs
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (8 preceding siblings ...)
  2015-01-16 11:30   ` [PATCH v4 09/17] dts: Documentation: Extending documentation entry for exynos-thermal Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 11/17] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
                     ` (8 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

This code groups in one place default settings of trip points. It is used
in SoCs with multiple instances of TMU sensor.

Separate device tree file prevents from multiple copying of the same data.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
---
 arch/arm/boot/dts/exynos5420-trip-points.dtsi | 35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi

diff --git a/arch/arm/boot/dts/exynos5420-trip-points.dtsi b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
new file mode 100644
index 0000000..09d6c56
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
@@ -0,0 +1,35 @@
+/*
+ * Device tree sources for default Exynos 5420 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <85000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-1 {
+		temperature = <103000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-2 {
+		temperature = <110000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1200000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 11/17] thermal: exynos: dts: Define default thermal-zones for Exynos4
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (9 preceding siblings ...)
  2015-01-16 11:30   ` [PATCH v4 10/17] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 12/17] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
                     ` (7 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

Trip points corresponding to the one defined in the exynos_tmu_data.c
for Exynos4 have been included.
This thermal-zones attribute is afterwards reused for Exynos4210, Exynos4412
and Exynos5250.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
---
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi | 52 ++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi

diff --git a/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
new file mode 100644
index 0000000..506600a
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
@@ -0,0 +1,52 @@
+/*
+ * Device tree sources for Exynos4 thermal zone
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal.h>
+
+/ {
+  thermal-zones {
+	cpu_thermal: cpu-thermal {
+		thermal-sensors = <&tmu 0>;
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		trips {
+			cpu_alert0: cpu-alert-0 {
+				temperature = <70000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert1: cpu-alert-1 {
+				temperature = <95000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert2: cpu-alert-2 {
+				temperature = <110000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_crit0: cpu-crit-0 {
+				temperature = <120000>; /* millicelsius */
+				hysteresis = <0>; /* millicelsius */
+				type = "critical";
+			};
+		};
+		cooling-maps {
+			map0 {
+			    trip = <&cpu_alert0>;
+			};
+			map1 {
+			    trip = <&cpu_alert1>;
+			};
+		};
+	};
+  };
+};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 12/17] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (10 preceding siblings ...)
  2015-01-16 11:30   ` [PATCH v4 11/17] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 13/17] dts: Documentation: Update exynos-thermal.txt example " Lukasz Majewski
                     ` (6 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

This commit provides information about Exynos5440 device configuration.
Previously this information was available in exynos_tmu_data.c file.
Now it is available in the device tree.
Such approach allows reusing some common code for thermal.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- "type" property removed
- "samsung,tmu_" prefix for TMU specific properties has been added
Changes for v4:
- None

---
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi | 24 ++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi     | 25 +++++++++++++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi

diff --git a/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
new file mode 100644
index 0000000..7b2fba0
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
@@ -0,0 +1,24 @@
+/*
+ * Device tree sources for Exynos5440 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+samsung,tmu_gain = <5>;
+samsung,tmu_reference_voltage = <16>;
+samsung,tmu_noise_cancel_mode = <4>;
+samsung,tmu_efuse_value = <0x5d2d>;
+samsung,tmu_min_efuse_value = <16>;
+samsung,tmu_max_efuse_value = <76>;
+samsung,tmu_first_point_trim = <25>;
+samsung,tmu_second_point_trim = <70>;
+samsung,tmu_default_temp_offset = <25>;
+samsung,tmu_cal_type = <TYPE_ONE_POINT_TRIMMING>;
diff --git a/arch/arm/boot/dts/exynos5440-trip-points.dtsi b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
new file mode 100644
index 0000000..48adfa8
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
@@ -0,0 +1,25 @@
+/*
+ * Device tree sources for default Exynos5440 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <100000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1050000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 13/17] dts: Documentation: Update exynos-thermal.txt example for Exynos5440
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (11 preceding siblings ...)
  2015-01-16 11:30   ` [PATCH v4 12/17] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 14/17] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c Lukasz Majewski
                     ` (5 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

Updating exynos-thermal.txt documentation entry for Exynos5440

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v4:
- New patch
---
 Documentation/devicetree/bindings/thermal/exynos-thermal.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
index 8497794..0f44932 100644
--- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
@@ -74,6 +74,7 @@ Example 2):
 		interrupts = <0 58 0>;
 		clocks = <&clock 21>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 14/17] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (12 preceding siblings ...)
  2015-01-16 11:30   ` [PATCH v4 13/17] dts: Documentation: Update exynos-thermal.txt example " Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:30   ` [PATCH v4 15/17] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
                     ` (4 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

Presented device tree bindings provide data already hardcoded in the
exynos_tmu_data.c file.
After this commit, it should be possible to reuse common thermal core
framework in Exynos SoCs.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Add proper TMU entries for exynos3250.dtsi
Changes for v3:
- Remove "type" DT properties, which will be extracted from compatible
- "samsung,tmu_" prefix for TMU specific properties has been added
Changes for v4:
- Providing mandatory properties for thermal-zones (Exynos4210 and Exynos5250)

---
 arch/arm/boot/dts/exynos3250.dtsi |  2 ++
 arch/arm/boot/dts/exynos4.dtsi    |  4 ++++
 arch/arm/boot/dts/exynos4210.dtsi | 25 ++++++++++++++++++++++++-
 arch/arm/boot/dts/exynos4x12.dtsi |  1 +
 arch/arm/boot/dts/exynos5250.dtsi |  9 +++++++--
 arch/arm/boot/dts/exynos5420.dtsi | 28 ++++++++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440.dtsi | 18 ++++++++++++++++++
 7 files changed, 84 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/exynos3250.dtsi b/arch/arm/boot/dts/exynos3250.dtsi
index 2246549..8cc078c 100644
--- a/arch/arm/boot/dts/exynos3250.dtsi
+++ b/arch/arm/boot/dts/exynos3250.dtsi
@@ -18,6 +18,7 @@
  */
 
 #include "skeleton.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 #include <dt-bindings/clock/exynos3250.h>
 
 / {
@@ -188,6 +189,7 @@
 			interrupts = <0 216 0>;
 			clocks = <&cmu CLK_TMU_APBIF>;
 			clock-names = "tmu_apbif";
+			#include "exynos4412-tmu-sensor-conf.dtsi"
 			status = "disabled";
 		};
 
diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index b8168f1..f18d746 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -645,4 +645,8 @@
 		samsung,sysreg = <&sys_reg>;
 		status = "disabled";
 	};
+
+	tmu: tmu@100C0000 {
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+	};
 };
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index 2e66df8..78a43b0 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -21,6 +21,7 @@
 
 #include "exynos4.dtsi"
 #include "exynos4210-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 
 / {
 	compatible = "samsung,exynos4210", "samsung,exynos4";
@@ -146,16 +147,38 @@
 		reg = <0x03860000 0x1000>;
 	};
 
-	tmu@100C0000 {
+	tmu: tmu@100C0000 {
 		compatible = "samsung,exynos4210-tmu";
 		interrupt-parent = <&combiner>;
 		reg = <0x100C0000 0x100>;
 		interrupts = <2 4>;
 		clocks = <&clock CLK_TMU_APBIF>;
 		clock-names = "tmu_apbif";
+		samsung,tmu_gain = <15>;
+		samsung,tmu_reference_voltage = <7>;
 		status = "disabled";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&tmu 0>;
+
+			trips {
+			      cpu_alert0: cpu-alert-0 {
+				      temperature = <85000>; /* millicelsius */
+			      };
+			      cpu_alert1: cpu-alert-1 {
+				      temperature = <100000>; /* millicelsius */
+			      };
+			      cpu_alert2: cpu-alert-2 {
+				      temperature = <110000>; /* millicelsius */
+			      };
+			};
+		};
+	};
+
 	g2d@12800000 {
 		compatible = "samsung,s5pv210-g2d";
 		reg = <0x12800000 0x1000>;
diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi
index 93b7040..3ee2031 100644
--- a/arch/arm/boot/dts/exynos4x12.dtsi
+++ b/arch/arm/boot/dts/exynos4x12.dtsi
@@ -19,6 +19,7 @@
 
 #include "exynos4.dtsi"
 #include "exynos4x12-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 
 / {
 	aliases {
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index 4641d3c..90211c0 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -20,7 +20,7 @@
 #include <dt-bindings/clock/exynos5250.h>
 #include "exynos5.dtsi"
 #include "exynos5250-pinctrl.dtsi"
-
+#include "exynos4-cpu-thermal.dtsi"
 #include <dt-bindings/clock/exynos-audss-clk.h>
 
 / {
@@ -236,16 +236,21 @@
 		status = "disabled";
 	};
 
-	tmu@10060000 {
+	tmu: tmu@10060000 {
 		compatible = "samsung,exynos5250-tmu";
 		reg = <0x10060000 0x100>;
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	thermal-zones {
 		cpu_thermal: cpu-thermal {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&tmu 0>;
+
 			cooling-maps {
 				map0 {
 				     /* Corresponds to 800MHz at freq_table */
diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
index 517e50f..f5771e5 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -761,6 +761,7 @@
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu1: tmu@10064000 {
@@ -769,6 +770,7 @@
 		interrupts = <0 183 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu2: tmu@10068000 {
@@ -777,6 +779,7 @@
 		interrupts = <0 184 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu3: tmu@1006c000 {
@@ -785,6 +788,7 @@
 		interrupts = <0 185 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU_GPU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_gpu: tmu@100a0000 {
@@ -793,6 +797,30 @@
 		interrupts = <0 215 0>;
 		clocks = <&clock CLK_TMU_GPU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmu_cpu0>;
+			#include "exynos5420-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmu_cpu1>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmu_cpu2>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu3_thermal: cpu3-thermal {
+		       thermal-sensors = <&tmu_cpu3>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		gpu_thermal: gpu-thermal {
+		       thermal-sensors = <&tmu_gpu>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
 	};
 
         watchdog: watchdog@101D0000 {
diff --git a/arch/arm/boot/dts/exynos5440.dtsi b/arch/arm/boot/dts/exynos5440.dtsi
index 8f3373c..59d9416 100644
--- a/arch/arm/boot/dts/exynos5440.dtsi
+++ b/arch/arm/boot/dts/exynos5440.dtsi
@@ -219,6 +219,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_1: tmuctrl@16011C {
@@ -227,6 +228,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_2: tmuctrl@160120 {
@@ -235,6 +237,22 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmuctrl_0>;
+			#include "exynos5440-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmuctrl_1>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmuctrl_2>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
 	};
 
 	sata@210000 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 15/17] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (13 preceding siblings ...)
  2015-01-16 11:30   ` [PATCH v4 14/17] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c Lukasz Majewski
@ 2015-01-16 11:30   ` Lukasz Majewski
  2015-01-16 11:31   ` [PATCH v4 16/17] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
                     ` (3 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:30 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

This patch brings support for providing configuration via device tree.
Previously this data has been hardcoded in the exynos_tmu_data.c file.
Such approach was not scalable and very often required copying the whole
data.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
- Usage of of-thermal.c exported trip points table
Changes for v3:
- Adding exynos_of_get_soc_type() method to set SOC type from device's
  compatible string
- "samsung,tmu_" prefix for TMU specific properties has been added
Changes for v4:
- None

---
 drivers/thermal/samsung/Makefile     |   2 -
 drivers/thermal/samsung/exynos_tmu.c | 345 +++++++++++++++++++++++------------
 drivers/thermal/samsung/exynos_tmu.h |  53 +-----
 3 files changed, 226 insertions(+), 174 deletions(-)

diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile
index c09d830..1e47d0d 100644
--- a/drivers/thermal/samsung/Makefile
+++ b/drivers/thermal/samsung/Makefile
@@ -3,5 +3,3 @@
 #
 obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_thermal.o
 exynos_thermal-y				:= exynos_tmu.o
-exynos_thermal-y				+= exynos_tmu_data.o
-exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+= exynos_thermal_common.o
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index ae30f6a..633a9e2 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -1,6 +1,10 @@
 /*
  * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
  *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
  *  Copyright (C) 2011 Samsung Electronics
  *  Donggeun Kim <dg77.kim@samsung.com>
  *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
@@ -31,8 +35,8 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 
-#include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
+#include "../thermal_core.h"
 
 /* Exynos generic registers */
 #define EXYNOS_TMU_REG_TRIMINFO		0x0
@@ -115,6 +119,7 @@
 #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
 #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
 
+#define MCELSIUS	1000
 /**
  * struct exynos_tmu_data : A structure to hold the private data of the TMU
 	driver
@@ -150,7 +155,8 @@ struct exynos_tmu_data {
 	struct clk *clk, *clk_sec;
 	u8 temp_error1, temp_error2;
 	struct regulator *regulator;
-	struct thermal_sensor_conf *reg_conf;
+	struct thermal_zone_device *tzd;
+
 	int (*tmu_initialize)(struct platform_device *pdev);
 	void (*tmu_control)(struct platform_device *pdev, bool on);
 	int (*tmu_read)(struct exynos_tmu_data *data);
@@ -159,6 +165,33 @@ struct exynos_tmu_data {
 	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
 };
 
+static void exynos_report_trigger(struct exynos_tmu_data *p)
+{
+	char data[10], *envp[] = { data, NULL };
+	struct thermal_zone_device *tz = p->tzd;
+	unsigned long temp;
+	unsigned int i;
+
+	if (!p) {
+		pr_err("Wrong temperature configuration data\n");
+		return;
+	}
+
+	thermal_zone_device_update(tz);
+
+	mutex_lock(&tz->lock);
+	/* Find the level for which trip happened */
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		tz->ops->get_trip_temp(tz, i, &temp);
+		if (tz->last_temperature < temp)
+			break;
+	}
+
+	snprintf(data, sizeof(data), "%u", i);
+	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
+	mutex_unlock(&tz->lock);
+}
+
 /*
  * TMU treats temperature as a mapped temperature code.
  * The temperature is converted differently depending on the calibration type.
@@ -234,14 +267,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
 
 static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling)
 {
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
+	unsigned long temp;
 	int i;
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
-		u8 temp = pdata->trigger_levels[i];
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
+		       __func__);
+		return 0;
+	}
+
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL)
+			continue;
 
+		temp = trips[i].temperature / MCELSIUS;
 		if (falling)
-			temp -= pdata->threshold_falling;
+			temp -= (trips[i].hysteresis / MCELSIUS);
 		else
 			threshold &= ~(0xff << 8 * i);
 
@@ -305,9 +349,19 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 static int exynos4210_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
-	unsigned int status;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
 	int ret = 0, threshold_code, i;
+	unsigned long reference, temp;
+	unsigned int status;
+
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
+		       __func__);
+		ret = -ENODEV;
+		goto out;
+	}
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct platform_device *pdev)
 	sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));
 
 	/* Write temperature code for threshold */
-	threshold_code = temp_to_code(data, pdata->threshold);
+	reference = trips[0].temperature / MCELSIUS;
+	threshold_code = temp_to_code(data, reference);
+	if (threshold_code < 0) {
+		ret = threshold_code;
+		goto out;
+	}
 	writeb(threshold_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
-		writeb(pdata->trigger_levels[i], data->base +
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		temp = trips[i].temperature / MCELSIUS;
+		writeb(temp - reference, data->base +
 		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
+	}
 
 	data->tmu_clear_irqs(data);
 out:
@@ -333,9 +394,11 @@ out:
 static int exynos4412_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(data->tzd);
 	unsigned int status, trim_info, con, ctrl, rising_threshold;
 	int ret = 0, threshold_code, i;
+	unsigned long crit_temp = 0;
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
 	data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
-		/* 1-4 level to be assigned in th0 reg */
-		rising_threshold &= ~(0xff << 8 * i);
-		rising_threshold |= threshold_code << 8 * i;
-		writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
-		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
-		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
-		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
+			crit_temp = trips[i].temperature;
+			break;
+		}
 	}
+
+	if (i == of_thermal_get_ntrips(data->tzd)) {
+		pr_err("%s: No CRITICAL trip point defined at of-thermal.c!\n",
+		       __func__);
+		ret = -EINVAL;
+		goto out;
+	}
+
+	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
+	/* 1-4 level to be assigned in th0 reg */
+	rising_threshold &= ~(0xff << 8 * i);
+	rising_threshold |= threshold_code << 8 * i;
+	writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
+	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
+	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
+	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+
 out:
 	return ret;
 }
@@ -391,9 +466,9 @@ out:
 static int exynos5440_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
 	unsigned int trim_info = 0, con, rising_threshold;
-	int ret = 0, threshold_code, i;
+	int ret = 0, threshold_code;
+	unsigned long crit_temp = 0;
 
 	/*
 	 * For exynos5440 soc triminfo value is swapped between TMU0 and
@@ -422,9 +497,8 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 	data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
+	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp)) {
+		threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
 		/* 5th level to be assigned in th2 reg */
 		rising_threshold =
 			threshold_code << EXYNOS5440_TMU_TH_RISE4_SHIFT;
@@ -442,7 +516,7 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
@@ -450,10 +524,15 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS_TMU_INTEN_RISE0_SHIFT;
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
+
 		if (data->soc != SOC_ARCH_EXYNOS4210)
 			interrupt_en |=
 				interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
@@ -468,7 +547,7 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS5440_TMU_S0_7_CTRL));
@@ -476,11 +555,16 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
-		interrupt_en |= interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
+		interrupt_en |=
+			interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
 	} else {
 		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en = 0; /* Disable all interrupts */
@@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL);
 }
 
-static int exynos_tmu_read(struct exynos_tmu_data *data)
+int exynos_get_temp(void *p, long *temp)
 {
-	int ret;
+	struct exynos_tmu_data *data = p;
+
+	if (!data)
+		return -EINVAL;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
-	ret = data->tmu_read(data);
-	if (ret >= 0)
-		ret = code_to_temp(data, ret);
+
+	*temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS;
+
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
 
-	return ret;
+	return 0;
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
@@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct *work)
 	if (!IS_ERR(data->clk_sec))
 		clk_disable(data->clk_sec);
 
-	exynos_report_trigger(data->reg_conf);
+	exynos_report_trigger(data);
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
@@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 static const struct of_device_id exynos_tmu_match[] = {
 	{
 		.compatible = "samsung,exynos3250-tmu",
-		.data = &exynos3250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4210-tmu",
-		.data = &exynos4210_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4412-tmu",
-		.data = &exynos4412_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5250-tmu",
-		.data = &exynos5250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5260-tmu",
-		.data = &exynos5260_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu-ext-triminfo",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5440-tmu",
-		.data = &exynos5440_default_tmu_data,
 	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 
-static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
-			struct platform_device *pdev, int id)
+static int exynos_of_get_soc_type(struct device_node *np)
 {
-	struct  exynos_tmu_init_data *data_table;
-	struct exynos_tmu_platform_data *tmu_data;
-	const struct of_device_id *match;
+	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
+		return SOC_ARCH_EXYNOS3250;
+	else if (of_device_is_compatible(np, "samsung,exynos4210-tmu"))
+		return SOC_ARCH_EXYNOS4210;
+	else if (of_device_is_compatible(np, "samsung,exynos4412-tmu"))
+		return SOC_ARCH_EXYNOS4412;
+	else if (of_device_is_compatible(np, "samsung,exynos5250-tmu"))
+		return SOC_ARCH_EXYNOS5250;
+	else if (of_device_is_compatible(np, "samsung,exynos5260-tmu"))
+		return SOC_ARCH_EXYNOS5260;
+	else if (of_device_is_compatible(np, "samsung,exynos5420-tmu"))
+		return SOC_ARCH_EXYNOS5420;
+	else if (of_device_is_compatible(np,
+					 "samsung,exynos5420-tmu-ext-triminfo"))
+		return SOC_ARCH_EXYNOS5420_TRIMINFO;
+	else if (of_device_is_compatible(np, "samsung,exynos5440-tmu"))
+		return SOC_ARCH_EXYNOS5440;
+
+	return -EINVAL;
+}
 
-	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
-	if (!match)
-		return NULL;
-	data_table = (struct exynos_tmu_init_data *) match->data;
-	if (!data_table || id >= data_table->tmu_count)
-		return NULL;
-	tmu_data = data_table->tmu_data;
-	return (struct exynos_tmu_platform_data *) (tmu_data + id);
+static int exynos_of_sensor_conf(struct device_node *np,
+				 struct exynos_tmu_platform_data *pdata)
+{
+	u32 value;
+	int ret;
+
+	of_node_get(np);
+
+	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
+	pdata->gain = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_reference_voltage", &value);
+	pdata->reference_voltage = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode", &value);
+	pdata->noise_cancel_mode = (u8) value;
+
+	of_property_read_u32(np, "samsung,tmu_efuse_value",
+			     &pdata->efuse_value);
+	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
+			     &pdata->min_efuse_value);
+	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
+			     &pdata->max_efuse_value);
+
+	of_property_read_u32(np, "samsung,tmu_first_point_trim", &value);
+	pdata->first_point_trim = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_second_point_trim", &value);
+	pdata->second_point_trim = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_default_temp_offset", &value);
+	pdata->default_temp_offset = (u8) value;
+
+	of_property_read_u32(np, "samsung,tmu_cal_type", &pdata->cal_type);
+	of_property_read_u32(np, "samsung,tmu_cal_mode", &pdata->cal_mode);
+
+	of_node_put(np);
+	return 0;
 }
 
 static int exynos_map_dt_data(struct platform_device *pdev)
@@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 		return -EADDRNOTAVAIL;
 	}
 
-	pdata = exynos_get_driver_data(pdev, data->id);
-	if (!pdata) {
-		dev_err(&pdev->dev, "No platform init data supplied.\n");
-		return -ENODEV;
-	}
+	pdata = devm_kzalloc(&pdev->dev,
+			     sizeof(struct exynos_tmu_platform_data),
+			     GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
 
+	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
 	data->pdata = pdata;
-	data->soc = pdata->type;
+	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
 
 	switch (data->soc) {
 	case SOC_ARCH_EXYNOS4210:
@@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 	return 0;
 }
 
+static struct thermal_zone_of_device_ops exynos_sensor_ops = {
+	.get_temp = exynos_get_temp,
+	.set_emul_temp = exynos_tmu_set_emulation,
+};
+
 static int exynos_tmu_probe(struct platform_device *pdev)
 {
-	struct exynos_tmu_data *data;
 	struct exynos_tmu_platform_data *pdata;
-	struct thermal_sensor_conf *sensor_conf;
-	int ret, i;
+	struct exynos_tmu_data *data;
+	int ret;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
 					GFP_KERNEL);
@@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, data);
 	mutex_init(&data->lock);
 
+	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
+						    &exynos_sensor_ops);
+	if (IS_ERR(data->tzd)) {
+		pr_err("thermal: tz: %p ERROR\n", data->tzd);
+		return PTR_ERR(data->tzd);
+	}
 	ret = exynos_map_dt_data(pdev);
 	if (ret)
-		return ret;
+		goto err_sensor;
 
 	pdata = data->pdata;
 
@@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
 	if (IS_ERR(data->clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
-		return  PTR_ERR(data->clk);
+		ret = PTR_ERR(data->clk);
+		goto err_sensor;
 	}
 
 	data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
 	if (IS_ERR(data->clk_sec)) {
 		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
 			dev_err(&pdev->dev, "Failed to get triminfo clock\n");
-			return PTR_ERR(data->clk_sec);
+			ret = PTR_ERR(data->clk_sec);
+			goto err_sensor;
 		}
 	} else {
 		ret = clk_prepare(data->clk_sec);
 		if (ret) {
 			dev_err(&pdev->dev, "Failed to get clock\n");
-			return ret;
+			goto err_sensor;
 		}
 	}
 
@@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	exynos_tmu_control(pdev, true);
-
-	/* Allocate a structure to register with the exynos core thermal */
-	sensor_conf = devm_kzalloc(&pdev->dev,
-				sizeof(struct thermal_sensor_conf), GFP_KERNEL);
-	if (!sensor_conf) {
-		ret = -ENOMEM;
-		goto err_clk;
-	}
-	sprintf(sensor_conf->name, "therm_zone%d", data->id);
-	sensor_conf->read_temperature = (int (*)(void *))exynos_tmu_read;
-	sensor_conf->write_emul_temp =
-		(int (*)(void *, unsigned long))exynos_tmu_set_emulation;
-	sensor_conf->driver_data = data;
-	sensor_conf->trip_data.trip_count = pdata->trigger_enable[0] +
-			pdata->trigger_enable[1] + pdata->trigger_enable[2]+
-			pdata->trigger_enable[3];
-
-	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
-		sensor_conf->trip_data.trip_val[i] =
-			pdata->threshold + pdata->trigger_levels[i];
-		sensor_conf->trip_data.trip_type[i] =
-					pdata->trigger_type[i];
-	}
-
-	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
-
-	sensor_conf->dev = &pdev->dev;
-	/* Register the sensor with thermal management interface */
-	ret = exynos_register_thermal(sensor_conf);
-	if (ret) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"Failed to register thermal interface: %d\n",
-				ret);
-		goto err_clk;
-	}
-	data->reg_conf = sensor_conf;
-
 	ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
 		IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
 	if (ret) {
@@ -935,21 +1030,31 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
+	ret = exynos_tmu_initialize(pdev);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to initialize TMU\n");
+		goto err_clk;
+	}
+	exynos_tmu_control(pdev, true);
 	return 0;
+
 err_clk:
 	clk_unprepare(data->clk);
 err_clk_sec:
 	if (!IS_ERR(data->clk_sec))
 		clk_unprepare(data->clk_sec);
+err_sensor:
+	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
+
 	return ret;
 }
 
 static int exynos_tmu_remove(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	struct thermal_zone_device *tzd = data->tzd;
 
-	exynos_unregister_thermal(data->reg_conf);
-
+	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
 	exynos_tmu_control(pdev, false);
 
 	clk_unprepare(data->clk);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 627dec9..d876d4c 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -23,8 +23,7 @@
 #ifndef _EXYNOS_TMU_H
 #define _EXYNOS_TMU_H
 #include <linux/cpu_cooling.h>
-
-#include "exynos_thermal_common.h"
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 enum soc_type {
 	SOC_ARCH_EXYNOS3250 = 1,
@@ -36,38 +35,9 @@ enum soc_type {
 	SOC_ARCH_EXYNOS5420_TRIMINFO,
 	SOC_ARCH_EXYNOS5440,
 };
-#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
- * @threshold: basic temperature for generating interrupt
- *	       25 <= threshold <= 125 [unit: degree Celsius]
- * @threshold_falling: differntial value for setting threshold
- *		       of temperature falling interrupt.
- * @trigger_levels: array for each interrupt levels
- *	[unit: degree Celsius]
- *	0: temperature for trigger_level0 interrupt
- *	   condition for trigger_level0 interrupt:
- *		current temperature > threshold + trigger_levels[0]
- *	1: temperature for trigger_level1 interrupt
- *	   condition for trigger_level1 interrupt:
- *		current temperature > threshold + trigger_levels[1]
- *	2: temperature for trigger_level2 interrupt
- *	   condition for trigger_level2 interrupt:
- *		current temperature > threshold + trigger_levels[2]
- *	3: temperature for trigger_level3 interrupt
- *	   condition for trigger_level3 interrupt:
- *		current temperature > threshold + trigger_levels[3]
- * @trigger_type: defines the type of trigger. Possible values are,
- *	THROTTLE_ACTIVE trigger type
- *	THROTTLE_PASSIVE trigger type
- *	SW_TRIP trigger type
- *	HW_TRIP
- * @trigger_enable[]: array to denote which trigger levels are enabled.
- *	1 = enable trigger_level[] interrupt,
- *	0 = disable trigger_level[] interrupt
- * @max_trigger_level: max trigger level supported by the TMU
- * @non_hw_trigger_levels: number of defined non-hardware trigger levels
  * @gain: gain of amplifier in the positive-TC generator block
  *	0 < gain <= 15
  * @reference_voltage: reference voltage of amplifier
@@ -79,21 +49,12 @@ enum soc_type {
  * @efuse_value: platform defined fuse value
  * @min_efuse_value: minimum valid trimming data
  * @max_efuse_value: maximum valid trimming data
- * @first_point_trim: temp value of the first point trimming
- * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
 struct exynos_tmu_platform_data {
-	u8 threshold;
-	u8 threshold_falling;
-	u8 trigger_levels[MAX_TRIP_COUNT];
-	enum trigger_type trigger_type[MAX_TRIP_COUNT];
-	bool trigger_enable[MAX_TRIP_COUNT];
-	u8 max_trigger_level;
-	u8 non_hw_trigger_levels;
 	u8 gain;
 	u8 reference_voltage;
 	u8 noise_cancel_mode;
@@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
 	u32 cal_mode;
 };
 
-/**
- * struct exynos_tmu_init_data
- * @tmu_count: number of TMU instances.
- * @tmu_data: platform data of all TMU instances.
- * This structure is required to store data for multi-instance exynos tmu
- * driver.
- */
-struct exynos_tmu_init_data {
-	int tmu_count;
-	struct exynos_tmu_platform_data tmu_data[];
-};
-
 extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
 extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
 extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 16/17] thermal: exynos: Remove exynos_thermal_common.[c|h] files
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (14 preceding siblings ...)
  2015-01-16 11:30   ` [PATCH v4 15/17] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
@ 2015-01-16 11:31   ` Lukasz Majewski
  2015-01-16 11:31   ` [PATCH v4 17/17] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
                     ` (2 subsequent siblings)
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:31 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

After defining all necessary Exynos data in the device tree and heavy
reusage of the of-thermal.c those files can be removed.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
---
 drivers/thermal/samsung/exynos_thermal_common.c | 445 ------------------------
 drivers/thermal/samsung/exynos_thermal_common.h | 106 ------
 2 files changed, 551 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
deleted file mode 100644
index 00aa688..0000000
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ /dev/null
@@ -1,445 +0,0 @@
-/*
- * exynos_thermal_common.c - Samsung EXYNOS common thermal file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include <linux/cpu_cooling.h>
-#include <linux/err.h>
-#include <linux/slab.h>
-#include <linux/thermal.h>
-
-#include "exynos_thermal_common.h"
-
-struct exynos_thermal_zone {
-	enum thermal_device_mode mode;
-	struct thermal_zone_device *therm_dev;
-	struct thermal_cooling_device *cool_dev[MAX_COOLING_DEVICE];
-	unsigned int cool_dev_size;
-	struct platform_device *exynos4_dev;
-	struct thermal_sensor_conf *sensor_conf;
-	bool bind;
-};
-
-/* Get mode callback functions for thermal zone */
-static int exynos_get_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode *mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (th_zone)
-		*mode = th_zone->mode;
-	return 0;
-}
-
-/* Set mode callback functions for thermal zone */
-static int exynos_set_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (!th_zone) {
-		dev_err(&thermal->device,
-			"thermal zone not registered\n");
-		return 0;
-	}
-
-	mutex_lock(&thermal->lock);
-
-	if (mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling)
-		thermal->polling_delay = IDLE_INTERVAL;
-	else
-		thermal->polling_delay = 0;
-
-	mutex_unlock(&thermal->lock);
-
-	th_zone->mode = mode;
-	thermal_zone_device_update(thermal);
-	dev_dbg(th_zone->sensor_conf->dev,
-		"thermal polling set for duration=%d msec\n",
-		thermal->polling_delay);
-	return 0;
-}
-
-
-/* Get trip type callback functions for thermal zone */
-static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
-				 enum thermal_trip_type *type)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	int trip_type;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	trip_type = th_zone->sensor_conf->trip_data.trip_type[trip];
-
-	if (trip_type == SW_TRIP)
-		*type = THERMAL_TRIP_CRITICAL;
-	else if (trip_type == THROTTLE_ACTIVE)
-		*type = THERMAL_TRIP_ACTIVE;
-	else if (trip_type == THROTTLE_PASSIVE)
-		*type = THERMAL_TRIP_PASSIVE;
-	else
-		return -EINVAL;
-
-	return 0;
-}
-
-/* Get trip temperature callback functions for thermal zone */
-static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	*temp = th_zone->sensor_conf->trip_data.trip_val[trip];
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-
-	return 0;
-}
-
-/* Get critical temperature callback functions for thermal zone */
-static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	/* Get the temp of highest trip*/
-	return exynos_get_trip_temp(thermal, max_trip - 1, temp);
-}
-
-/* Bind callback functions for thermal zone */
-static int exynos_bind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-	struct of_phandle_args cooling_spec;
-	unsigned long max, state = 0;
-	int ret = 0, i = 0;
-
-	/*
-	 * Below code is necessary to skip binding when cpufreq's
-	 * frequency table is not yet initialized.
-	 */
-	cdev->ops->get_max_state(cdev, &state);
-	if (!state && !th_zone->cool_dev_size) {
-		th_zone->cool_dev_size = 1;
-		th_zone->cool_dev[0] = cdev;
-		th_zone->bind = false;
-		return 0;
-	}
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	for_each_child_of_node(child, gchild) {
-		ret = of_parse_phandle_with_args(gchild, "cooling-device",
-						 "#cooling-cells",
-						 0, &cooling_spec);
-		if (ret < 0) {
-			pr_err("missing cooling_device property\n");
-			goto end;
-		}
-
-		if (cooling_spec.args_count < 2) {
-			ret = -EINVAL;
-			goto end;
-		}
-
-		max = cooling_spec.args[0];
-		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-						     max, 0)) {
-			dev_err(data->dev,
-				"thermal error unbinding cdev inst=%d\n", i);
-
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = true;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Unbind callback functions for thermal zone */
-static int exynos_unbind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	int ret = 0, i;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-
-	if (th_zone->bind == false || !th_zone->cool_dev_size)
-		return 0;
-
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
-
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	i = 0;
-	for_each_child_of_node(child, gchild) {
-		if (thermal_zone_unbind_cooling_device(thermal, i,
-						       cdev)) {
-			dev_err(data->dev,
-				"error unbinding cdev inst=%d\n", i);
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = false;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_get_temp(struct thermal_zone_device *thermal,
-			unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	void *data;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	*temp = th_zone->sensor_conf->read_temperature(data);
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-	return 0;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
-						unsigned long temp)
-{
-	void *data;
-	int ret = -EINVAL;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	if (th_zone->sensor_conf->write_emul_temp)
-		ret = th_zone->sensor_conf->write_emul_temp(data, temp);
-	return ret;
-}
-
-/* Get the temperature trend */
-static int exynos_get_trend(struct thermal_zone_device *thermal,
-			int trip, enum thermal_trend *trend)
-{
-	int ret;
-	unsigned long trip_temp;
-
-	ret = exynos_get_trip_temp(thermal, trip, &trip_temp);
-	if (ret < 0)
-		return ret;
-
-	if (thermal->temperature >= trip_temp)
-		*trend = THERMAL_TREND_RAISE_FULL;
-	else
-		*trend = THERMAL_TREND_DROP_FULL;
-
-	return 0;
-}
-/* Operation callback functions for thermal zone */
-static struct thermal_zone_device_ops exynos_dev_ops = {
-	.bind = exynos_bind,
-	.unbind = exynos_unbind,
-	.get_temp = exynos_get_temp,
-	.set_emul_temp = exynos_set_emul_temp,
-	.get_trend = exynos_get_trend,
-	.get_mode = exynos_get_mode,
-	.set_mode = exynos_set_mode,
-	.get_trip_type = exynos_get_trip_type,
-	.get_trip_temp = exynos_get_trip_temp,
-	.get_crit_temp = exynos_get_crit_temp,
-};
-
-/*
- * This function may be called from interrupt based temperature sensor
- * when threshold is changed.
- */
-void exynos_report_trigger(struct thermal_sensor_conf *conf)
-{
-	unsigned int i;
-	char data[10];
-	char *envp[] = { data, NULL };
-	struct exynos_thermal_zone *th_zone;
-
-	if (!conf || !conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = conf->pzone_data;
-
-	if (th_zone->bind == false) {
-		for (i = 0; i < th_zone->cool_dev_size; i++) {
-			if (!th_zone->cool_dev[i])
-				continue;
-			exynos_bind(th_zone->therm_dev,
-					th_zone->cool_dev[i]);
-		}
-	}
-
-	thermal_zone_device_update(th_zone->therm_dev);
-
-	mutex_lock(&th_zone->therm_dev->lock);
-	/* Find the level for which trip happened */
-	for (i = 0; i < th_zone->sensor_conf->trip_data.trip_count; i++) {
-		if (th_zone->therm_dev->last_temperature <
-			th_zone->sensor_conf->trip_data.trip_val[i] * MCELSIUS)
-			break;
-	}
-
-	if (th_zone->mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling) {
-		if (i > 0)
-			th_zone->therm_dev->polling_delay = ACTIVE_INTERVAL;
-		else
-			th_zone->therm_dev->polling_delay = IDLE_INTERVAL;
-	}
-
-	snprintf(data, sizeof(data), "%u", i);
-	kobject_uevent_env(&th_zone->therm_dev->device.kobj, KOBJ_CHANGE, envp);
-	mutex_unlock(&th_zone->therm_dev->lock);
-}
-
-/* Register with the in-kernel thermal management */
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int ret;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->read_temperature) {
-		pr_err("Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-
-	th_zone = devm_kzalloc(sensor_conf->dev,
-				sizeof(struct exynos_thermal_zone), GFP_KERNEL);
-	if (!th_zone)
-		return -ENOMEM;
-
-	th_zone->sensor_conf = sensor_conf;
-	/*
-	 * TODO: 1) Handle multiple cooling devices in a thermal zone
-	 *	 2) Add a flag/name in cooling info to map to specific
-	 *	 sensor
-	 */
-	if (sensor_conf->cooling_data.freq_clip_count > 0) {
-		th_zone->cool_dev[th_zone->cool_dev_size] =
-				cpufreq_cooling_register(cpu_present_mask);
-		if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
-			ret = PTR_ERR(th_zone->cool_dev[th_zone->cool_dev_size]);
-			if (ret != -EPROBE_DEFER)
-				dev_err(sensor_conf->dev,
-					"Failed to register cpufreq cooling device: %d\n",
-					ret);
-			goto err_unregister;
-		}
-		th_zone->cool_dev_size++;
-	}
-
-	th_zone->therm_dev = thermal_zone_device_register(
-			sensor_conf->name, sensor_conf->trip_data.trip_count,
-			0, th_zone, &exynos_dev_ops, NULL, 0,
-			sensor_conf->trip_data.trigger_falling ? 0 :
-			IDLE_INTERVAL);
-
-	if (IS_ERR(th_zone->therm_dev)) {
-		dev_err(sensor_conf->dev,
-			"Failed to register thermal zone device\n");
-		ret = PTR_ERR(th_zone->therm_dev);
-		goto err_unregister;
-	}
-	th_zone->mode = THERMAL_DEVICE_ENABLED;
-	sensor_conf->pzone_data = th_zone;
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Thermal zone(%s) registered\n", sensor_conf->name);
-
-	return 0;
-
-err_unregister:
-	exynos_unregister_thermal(sensor_conf);
-	return ret;
-}
-
-/* Un-Register with the in-kernel thermal management */
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int i;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = sensor_conf->pzone_data;
-
-	thermal_zone_device_unregister(th_zone->therm_dev);
-
-	for (i = 0; i < th_zone->cool_dev_size; ++i)
-		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Kernel Thermal management unregistered\n");
-}
diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h
deleted file mode 100644
index cd44719..0000000
--- a/drivers/thermal/samsung/exynos_thermal_common.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * exynos_thermal_common.h - Samsung EXYNOS common header file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#ifndef _EXYNOS_THERMAL_COMMON_H
-#define _EXYNOS_THERMAL_COMMON_H
-
-/* In-kernel thermal framework related macros & definations */
-#define SENSOR_NAME_LEN	16
-#define MAX_TRIP_COUNT	8
-#define MAX_COOLING_DEVICE 4
-
-#define ACTIVE_INTERVAL 500
-#define IDLE_INTERVAL 10000
-#define MCELSIUS	1000
-
-/* CPU Zone information */
-#define PANIC_ZONE      4
-#define WARN_ZONE       3
-#define MONITOR_ZONE    2
-#define SAFE_ZONE       1
-
-#define GET_ZONE(trip) (trip + 2)
-#define GET_TRIP(zone) (zone - 2)
-
-enum trigger_type {
-	THROTTLE_ACTIVE = 1,
-	THROTTLE_PASSIVE,
-	SW_TRIP,
-	HW_TRIP,
-};
-
-/**
- * struct freq_clip_table
- * @freq_clip_max: maximum frequency allowed for this cooling state.
- * @temp_level: Temperature level at which the temperature clipping will
- *	happen.
- * @mask_val: cpumask of the allowed cpu's where the clipping will take place.
- *
- * This structure is required to be filled and passed to the
- * cpufreq_cooling_unregister function.
- */
-struct freq_clip_table {
-	unsigned int freq_clip_max;
-	unsigned int temp_level;
-	const struct cpumask *mask_val;
-};
-
-struct	thermal_trip_point_conf {
-	int trip_val[MAX_TRIP_COUNT];
-	int trip_type[MAX_TRIP_COUNT];
-	int trip_count;
-	unsigned char trigger_falling;
-};
-
-struct	thermal_cooling_conf {
-	struct freq_clip_table freq_data[MAX_TRIP_COUNT];
-	int freq_clip_count;
-};
-
-struct thermal_sensor_conf {
-	char name[SENSOR_NAME_LEN];
-	int (*read_temperature)(void *data);
-	int (*write_emul_temp)(void *drv_data, unsigned long temp);
-	struct thermal_trip_point_conf trip_data;
-	struct thermal_cooling_conf cooling_data;
-	void *driver_data;
-	void *pzone_data;
-	struct device *dev;
-};
-
-/*Functions used exynos based thermal sensor driver*/
-#ifdef CONFIG_EXYNOS_THERMAL_CORE
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf);
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf);
-void exynos_report_trigger(struct thermal_sensor_conf *sensor_conf);
-#else
-static inline void
-exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf) { return; }
-
-static inline int
-exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) { return 0; }
-
-static inline void
-exynos_report_trigger(struct thermal_sensor_conf *sensor_conf) { return; }
-
-#endif /* CONFIG_EXYNOS_THERMAL_CORE */
-#endif /* _EXYNOS_THERMAL_COMMON_H */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v4 17/17] thermal: exynos: Remove exynos_tmu_data.c file
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (15 preceding siblings ...)
  2015-01-16 11:31   ` [PATCH v4 16/17] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
@ 2015-01-16 11:31   ` Lukasz Majewski
  2015-01-17  7:17   ` [PATCH v4 00/17] thermal: exynos: Thermal code rework to use device tree Abhilash Kesavan
  2015-01-23  7:42   ` Kukjin Kim
  18 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-16 11:31 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Abhilash Kesavan, Lukasz Majewski

Data already present in the exynos_tmu_data.c file has been moved to the
appropriate device tree files.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
---
 drivers/thermal/samsung/exynos_tmu_data.c | 228 ------------------------------
 1 file changed, 228 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c

diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
deleted file mode 100644
index a993f3d..0000000
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * exynos_tmu_data.c - Samsung EXYNOS tmu data file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include "exynos_thermal_common.h"
-#include "exynos_tmu.h"
-
-struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
-	.tmu_data = {
-		{
-		.threshold = 80,
-		.trigger_levels[0] = 5,
-		.trigger_levels[1] = 20,
-		.trigger_levels[2] = 30,
-		.trigger_enable[0] = true,
-		.trigger_enable[1] = true,
-		.trigger_enable[2] = true,
-		.trigger_enable[3] = false,
-		.trigger_type[0] = THROTTLE_ACTIVE,
-		.trigger_type[1] = THROTTLE_ACTIVE,
-		.trigger_type[2] = SW_TRIP,
-		.max_trigger_level = 4,
-		.non_hw_trigger_levels = 3,
-		.gain = 15,
-		.reference_voltage = 7,
-		.cal_type = TYPE_ONE_POINT_TRIMMING,
-		.min_efuse_value = 40,
-		.max_efuse_value = 100,
-		.first_point_trim = 25,
-		.second_point_trim = 85,
-		.default_temp_offset = 50,
-		.type = SOC_ARCH_EXYNOS4210,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS3250_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_TWO_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS3250_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS3250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS4412_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS4412,
-		},
-	},
-	.tmu_count = 1,
-};
-
-struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS5250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define __EXYNOS5260_TMU_DATA	\
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 85, \
-	.trigger_levels[1] = 103, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50,
-
-#define EXYNOS5260_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5260
-
-struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5420_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420
-
-#define EXYNOS5420_TMU_DATA_SHARED \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420_TRIMINFO
-
-struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5440_TMU_DATA \
-	.trigger_levels[0] = 100, \
-	.trigger_levels[4] = 105, \
-	.trigger_enable[0] = 1, \
-	.trigger_type[0] = SW_TRIP, \
-	.trigger_type[4] = HW_TRIP, \
-	.max_trigger_level = 5, \
-	.non_hw_trigger_levels = 1, \
-	.gain = 5, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 0x5b2d, \
-	.min_efuse_value = 16, \
-	.max_efuse_value = 76, \
-	.first_point_trim = 25, \
-	.second_point_trim = 70, \
-	.default_temp_offset = 25, \
-	.type = SOC_ARCH_EXYNOS5440
-
-struct exynos_tmu_init_data const exynos5440_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-	},
-	.tmu_count = 3,
-};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* Re: [PATCH v4 00/17] thermal: exynos: Thermal code rework to use device tree
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (16 preceding siblings ...)
  2015-01-16 11:31   ` [PATCH v4 17/17] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
@ 2015-01-17  7:17   ` Abhilash Kesavan
  2015-01-19  7:57     ` Lukasz Majewski
  2015-01-23  7:42   ` Kukjin Kim
  18 siblings, 1 reply; 288+ messages in thread
From: Abhilash Kesavan @ 2015-01-17  7:17 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim,
	Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Kyungmin Park,
	Chanwoo Choi

Hi Lukasz,

On Fri, Jan 16, 2015 at 5:00 PM, Lukasz Majewski <l.majewski@samsung.com> wrote:
> 1. Introduction
>
> Following patches aim to clean up the current implementation of the thermal
> framework on Exynos devices.
>
> The main goal was to use a generic code for reading thermal configuration
> (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
> were removed.
>
> Around 400 lines of code (LOC) were removed directly by this patch, which
> is around 20% of the Exynos thermal code base.
>
> This work should NOT bring any functional changes to Exynos thermal
> subsystem.
>
> 2. Patch-set structure
>
> Then the cpu_cooling functionality has been preserved to allow cooling
> devices by reducing operating frequency. Definition of trip points and
> cpufreq's cooling properties were moved to device tree.
>
> Then the rework of the way in which configuration data is provided to
> the Exynos thermal subsystem was performed. Now device tree is used for
> configuration.
>
> 3. Dead code removal
>
> Thermal support for some SoCs, previously available in the exynos_tmu_data.c
> file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.
>
> Moreover, support for cpu_cooling devices was preserved only on those
> SoCs which had available and working cpufreq driver.
>
> 4. Testing
>
> Test devices:
> - Exynos4210 - Trats (TMU zone + cpu_cooling)
> - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> - Exynos5420 - Arndale-octa (only TMU zones)
>
> Unfortunately, I don't posses Exynos5440 for testing. Its functionality
> has been preserved in the code, but not tested on the hardware. I would
> be grateful for help in testing.
>
>
> 5. This work apply on the following tree:
>
> kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
>
>
> Lukasz Majewski (17):
>   thermal: exynos: cosmetic: Correct comment format
>   thermal: exynos: Provide thermal_exynos.h file to be included in
>     device tree files
>   arm: dts: trats: Enable TMU on the Exynos4210 trats device
>   arm: dts: odroid: Add LD010 regulator node necessary for TMU on Odroid
>   arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
>   arm: dts: Adding CPU cooling binding for Exynos SoCs
>   thermal: exynos: Modify exynos thermal code to use device tree for cpu
>     cooling configuration
>   thermal: exynos: dts: Add default definition of the TMU sensor
>     parameter
>   dts: Documentation: Extending documentation entry for exynos-thermal
>   thermal: dts: Default trip points definition for Exynos5420 SoCs
>   thermal: exynos: dts: Define default thermal-zones for Exynos4
>   thermal: dts: exynos: Trip points and sensor configuration data for
>     Exynos5440
>   dts: Documentation: Update exynos-thermal.txt example for Exynos5440
>   thermal: exynos: dts: Provide device tree bindings identical to the
>     one in exynos_tmu_data.c
>   thermal: samsung: core: Exynos TMU rework to use device tree for
>     configuration
>   thermal: exynos: Remove exynos_thermal_common.[c|h] files
>   thermal: exynos: Remove exynos_tmu_data.c file
>
>  .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
>  arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
>  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
>  arch/arm/boot/dts/exynos4.dtsi                     |   4 +
>  arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
>  arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
>  arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
>  arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
>  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
>  arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
>  arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
>  arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
>  arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
>  arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
>  arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
>  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
>  arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
>  arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
>  drivers/cpufreq/exynos-cpufreq.c                   |  30 +-
>  drivers/thermal/samsung/Makefile                   |   2 -
>  drivers/thermal/samsung/exynos_thermal_common.c    | 427 ---------------------
>  drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
>  drivers/thermal/samsung/exynos_tmu.c               | 354 +++++++++++------
>  drivers/thermal/samsung/exynos_tmu.h               |  68 +---
>  drivers/thermal/samsung/exynos_tmu_data.c          | 264 -------------
>  include/dt-bindings/thermal/thermal_exynos.h       |  28 ++
>  26 files changed, 638 insertions(+), 1001 deletions(-)
>  create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
>  delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
>  create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

Other than my earlier comments on the extra exynos_tmu_initialize()
and sysfs "mode" disabled entry, I noticed that there are some unused
extern declarations for default_tmu_data in exynos_tmu.h. Otherwise, I
have tested this on a 5420 and it look good.

I will be posting my exynos7 driver modifications based on this patch
set soon, do take a look.

Thanks,
Abhilash

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v4 00/17] thermal: exynos: Thermal code rework to use device tree
  2015-01-17  7:17   ` [PATCH v4 00/17] thermal: exynos: Thermal code rework to use device tree Abhilash Kesavan
@ 2015-01-19  7:57     ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19  7:57 UTC (permalink / raw)
  To: Abhilash Kesavan, Eduardo Valentin
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Kyungmin Park, Chanwoo Choi

Hi Abhilash,

> Hi Lukasz,
> 
> On Fri, Jan 16, 2015 at 5:00 PM, Lukasz Majewski
> <l.majewski@samsung.com> wrote:
> > 1. Introduction
> >
> > Following patches aim to clean up the current implementation of the
> > thermal framework on Exynos devices.
> >
> > The main goal was to use a generic code for reading thermal
> > configuration (of-thermal.c). Due to that redundant
> > exynos_thermal_common.[h|c] files were removed.
> >
> > Around 400 lines of code (LOC) were removed directly by this patch,
> > which is around 20% of the Exynos thermal code base.
> >
> > This work should NOT bring any functional changes to Exynos thermal
> > subsystem.
> >
> > 2. Patch-set structure
> >
> > Then the cpu_cooling functionality has been preserved to allow
> > cooling devices by reducing operating frequency. Definition of trip
> > points and cpufreq's cooling properties were moved to device tree.
> >
> > Then the rework of the way in which configuration data is provided
> > to the Exynos thermal subsystem was performed. Now device tree is
> > used for configuration.
> >
> > 3. Dead code removal
> >
> > Thermal support for some SoCs, previously available in the
> > exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3,
> > they didn't have TMU bindings.
> >
> > Moreover, support for cpu_cooling devices was preserved only on
> > those SoCs which had available and working cpufreq driver.
> >
> > 4. Testing
> >
> > Test devices:
> > - Exynos4210 - Trats (TMU zone + cpu_cooling)
> > - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> > - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> > - Exynos5420 - Arndale-octa (only TMU zones)
> >
> > Unfortunately, I don't posses Exynos5440 for testing. Its
> > functionality has been preserved in the code, but not tested on the
> > hardware. I would be grateful for help in testing.
> >
> >
> > 5. This work apply on the following tree:
> >
> > kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> > SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
> >
> >
> > Lukasz Majewski (17):
> >   thermal: exynos: cosmetic: Correct comment format
> >   thermal: exynos: Provide thermal_exynos.h file to be included in
> >     device tree files
> >   arm: dts: trats: Enable TMU on the Exynos4210 trats device
> >   arm: dts: odroid: Add LD010 regulator node necessary for TMU on
> > Odroid arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3
> > device arm: dts: Adding CPU cooling binding for Exynos SoCs
> >   thermal: exynos: Modify exynos thermal code to use device tree
> > for cpu cooling configuration
> >   thermal: exynos: dts: Add default definition of the TMU sensor
> >     parameter
> >   dts: Documentation: Extending documentation entry for
> > exynos-thermal thermal: dts: Default trip points definition for
> > Exynos5420 SoCs thermal: exynos: dts: Define default thermal-zones
> > for Exynos4 thermal: dts: exynos: Trip points and sensor
> > configuration data for Exynos5440
> >   dts: Documentation: Update exynos-thermal.txt example for
> > Exynos5440 thermal: exynos: dts: Provide device tree bindings
> > identical to the one in exynos_tmu_data.c
> >   thermal: samsung: core: Exynos TMU rework to use device tree for
> >     configuration
> >   thermal: exynos: Remove exynos_thermal_common.[c|h] files
> >   thermal: exynos: Remove exynos_tmu_data.c file
> >
> >  .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
> >  arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
> >  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
> >  arch/arm/boot/dts/exynos4.dtsi                     |   4 +
> >  arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
> >  arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
> >  arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
> >  arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
> >  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
> >  arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
> >  arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
> >  arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
> >  arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
> >  arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
> >  arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
> >  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
> >  arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
> >  arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
> >  drivers/cpufreq/exynos-cpufreq.c                   |  30 +-
> >  drivers/thermal/samsung/Makefile                   |   2 -
> >  drivers/thermal/samsung/exynos_thermal_common.c    | 427
> > ---------------------
> > drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
> > drivers/thermal/samsung/exynos_tmu.c               | 354
> > +++++++++++------
> > drivers/thermal/samsung/exynos_tmu.h               |  68 +---
> > drivers/thermal/samsung/exynos_tmu_data.c          | 264
> > ------------- include/dt-bindings/thermal/thermal_exynos.h       |
> > 28 ++ 26 files changed, 638 insertions(+), 1001 deletions(-) create
> > mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi create mode
> > 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi create
> > mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi create
> > mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
> > create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
> > delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
> > delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
> > delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c create
> > mode 100644 include/dt-bindings/thermal/thermal_exynos.h
> 
> Other than my earlier comments on the extra exynos_tmu_initialize()
> and sysfs "mode" disabled entry, I noticed that there are some unused
> extern declarations for default_tmu_data in exynos_tmu.h. Otherwise, I
> have tested this on a 5420 and it look good.

I will look into those problems and prepare another version of the
patch.

Regarding that those seems rather easy to fix, those shouldn't prevent
you from posting TMU support for Exynos7.

> 
> I will be posting my exynos7 driver modifications based on this patch
> set soon, do take a look.

If you don't mind, I will review your patch for Exynos7 and share some
thoughts.

> 
> Thanks,
> Abhilash



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v5 00/18] thermal: exynos: Thermal code rework to use device tree
  2014-10-09 16:38 ` Lukasz Majewski
                   ` (26 preceding siblings ...)
  (?)
@ 2015-01-19 11:20 ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 01/18] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
                     ` (20 more replies)
  -1 siblings, 21 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

1. Introduction

Following patches aim to clean up the current implementation of the thermal
framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration
(of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which
is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal 
subsystem.

2. Patch-set structure

Then the cpu_cooling functionality has been preserved to allow cooling
devices by reducing operating frequency. Definition of trip points and
cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to
the Exynos thermal subsystem was performed. Now device tree is used for
configuration.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c 
file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those
SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality
has been preserved in the code, but not tested on the hardware. I would
be grateful for help in testing.


5. This work apply on the following tree:

kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
SHA1: 1813d80874699145f04af6b05ebab0a6419001fb


Lukasz Majewski (18):
  thermal: exynos: cosmetic: Correct comment format
  thermal: exynos: Provide thermal_exynos.h file to be included in
    device tree files
  arm: dts: trats: Enable TMU on the Exynos4210 trats device
  arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid
  arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
  arm: dts: Adding CPU cooling binding for Exynos SoCs
  thermal: exynos: Modify exynos thermal code to use device tree for cpu
    cooling configuration
  thermal: exynos: dts: Add default definition of the TMU sensor
    parameter
  dts: Documentation: Extending documentation entry for exynos-thermal
  thermal: dts: Default trip points definition for Exynos5420 SoCs
  thermal: exynos: dts: Define default thermal-zones for Exynos4
  thermal: dts: exynos: Trip points and sensor configuration data for
    Exynos5440
  dts: Documentation: Update exynos-thermal.txt example for Exynos5440
  thermal: exynos: dts: Provide device tree bindings identical to the
    one in exynos_tmu_data.c
  thermal: samsung: core: Exynos TMU rework to use device tree for
    configuration
  thermal: exynos: Remove exynos_thermal_common.[c|h] files
  thermal: exynos: Remove exynos_tmu_data.c file
  thermal: exynos: Remove not needed exynos_tmu_init_data declarations
    from exynos_tmu.h

 .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
 arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   4 +
 arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
 arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
 arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
 arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
 arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
 arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
 arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
 arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
 drivers/cpufreq/exynos-cpufreq.c                   |  30 +-
 drivers/thermal/samsung/Makefile                   |   2 -
 drivers/thermal/samsung/exynos_thermal_common.c    | 427 ---------------------
 drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
 drivers/thermal/samsung/exynos_tmu.c               | 348 +++++++++++------
 drivers/thermal/samsung/exynos_tmu.h               |  76 +---
 drivers/thermal/samsung/exynos_tmu_data.c          | 264 -------------
 include/dt-bindings/thermal/thermal_exynos.h       |  28 ++
 26 files changed, 632 insertions(+), 1009 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v5 01/18] thermal: exynos: cosmetic: Correct comment format
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 02/18] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
                     ` (19 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
---
 drivers/thermal/samsung/exynos_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index d2f1e62..5000727 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -576,7 +576,7 @@ out:
 #define exynos5440_tmu_set_emulation NULL
 static int exynos_tmu_set_emulation(void *drv_data,	unsigned long temp)
 	{ return -EINVAL; }
-#endif/*CONFIG_THERMAL_EMULATION*/
+#endif /* CONFIG_THERMAL_EMULATION */
 
 static int exynos4210_tmu_read(struct exynos_tmu_data *data)
 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 02/18] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 01/18] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 03/18] arm: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
                     ` (18 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This patch is a preparatory patch to be able to read Exynos thermal
configuration from the device tree.

It turned out that DTC is not able to interpret enums properly and hence
it is necessary to #define those values explicitly.

For this reason the ./include/dt-bindings/thermal/thermal_exynos.h file
has been introduced.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Restore 'enum soc_type type' since TMU sensor type will be extracted from
  device tree compatible
Changes for v4:
- None
Changes for v5:
- None
---
 drivers/thermal/samsung/exynos_tmu.h         | 12 +++---------
 include/dt-bindings/thermal/thermal_exynos.h | 28 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 9 deletions(-)
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index da3009b..7f880d2 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -26,14 +26,6 @@
 
 #include "exynos_thermal_common.h"
 
-enum calibration_type {
-	TYPE_ONE_POINT_TRIMMING,
-	TYPE_ONE_POINT_TRIMMING_25,
-	TYPE_ONE_POINT_TRIMMING_85,
-	TYPE_TWO_POINT_TRIMMING,
-	TYPE_NONE,
-};
-
 enum soc_type {
 	SOC_ARCH_EXYNOS3250 = 1,
 	SOC_ARCH_EXYNOS4210,
@@ -44,6 +36,7 @@ enum soc_type {
 	SOC_ARCH_EXYNOS5420_TRIMINFO,
 	SOC_ARCH_EXYNOS5440,
 };
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
@@ -115,8 +108,9 @@ struct exynos_tmu_platform_data {
 	u8 second_point_trim;
 	u8 default_temp_offset;
 
-	enum calibration_type cal_type;
 	enum soc_type type;
+	u32 cal_type;
+	u32 cal_mode;
 	struct freq_clip_table freq_tab[4];
 	unsigned int freq_tab_count;
 };
diff --git a/include/dt-bindings/thermal/thermal_exynos.h b/include/dt-bindings/thermal/thermal_exynos.h
new file mode 100644
index 0000000..0646500
--- /dev/null
+++ b/include/dt-bindings/thermal/thermal_exynos.h
@@ -0,0 +1,28 @@
+/*
+ * thermal_exynos.h - Samsung EXYNOS TMU device tree definitions
+ *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef _EXYNOS_THERMAL_TMU_DT_H
+#define _EXYNOS_THERMAL_TMU_DT_H
+
+#define TYPE_ONE_POINT_TRIMMING 0
+#define TYPE_ONE_POINT_TRIMMING_25 1
+#define TYPE_ONE_POINT_TRIMMING_85 2
+#define TYPE_TWO_POINT_TRIMMING 3
+#define TYPE_NONE 4
+
+#endif /* _EXYNOS_THERMAL_TMU_DT_H */
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 03/18] arm: dts: trats: Enable TMU on the Exynos4210 trats device
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 01/18] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 02/18] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 04/18] arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid Lukasz Majewski
                     ` (17 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

The thermal IP block (Thermal Management Unit) called TMU has been enabled
in this device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Patch title has been changed from thermal: dts: arm to arm: dts: trats
Changes for v4:
- None
Changes for v5:
- None
---
 arch/arm/boot/dts/exynos4210-trats.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index 7208362..61009f4 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -424,6 +424,10 @@
 		status = "okay";
 	};
 
+	tmu@100C0000 {
+		status = "okay";
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 04/18] arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (2 preceding siblings ...)
  2015-01-19 11:20   ` [PATCH v5 03/18] arm: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 05/18] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
                     ` (16 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Patch title has been changed from thermal: dts: exynos to arm: dts: Odroid
Changes for v4:
- None
Changes for v5:
- None
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 3fbf588..0adb57c 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -231,6 +231,13 @@
 					regulator-always-on;
 				};
 
+				ldo10_reg: LDO10 {
+					regulator-name = "VDD18_MIPIHSI_1.8V";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <1800000>;
+					regulator-always-on;
+				};
+
 				ldo11_reg: LDO11 {
 					regulator-name = "VDD18_ABB1_1.8V";
 					regulator-min-microvolt = <1800000>;
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 05/18] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (3 preceding siblings ...)
  2015-01-19 11:20   ` [PATCH v5 04/18] arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 06/18] arm: dts: Adding CPU cooling binding for Exynos SoCs Lukasz Majewski
                     ` (15 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This commit enables TMU IP block on the Exynos4412 Odroid U3
device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- Rename patch title from "thermal: dts:" to "arm: dts: odroid"
Changes for v5:
- None
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 0adb57c..c7517fc 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -396,6 +396,11 @@
 	ehci: ehci@12580000 {
 		status = "okay";
 	};
+
+	tmu@100C0000 {
+		vtmu-supply = <&ldo10_reg>;
+		status = "okay";
+	};
 };
 
 &pinctrl_1 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 06/18] arm: dts: Adding CPU cooling binding for Exynos SoCs
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (4 preceding siblings ...)
  2015-01-19 11:20   ` [PATCH v5 05/18] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
                     ` (14 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Presented patch aims to move data necessary for correct CPU cooling device
configuration from exynos_tmu_data.c to device tree.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Adjust CPU's DT nodes to work with newest ti-soc-thermal/next branch
- Patch title has been changed from "thermal: cpu_cooling: dts: ..."
Changes for v4:
- Spaces and tabs cleanup
Changes for v5:
- None
---
 arch/arm/boot/dts/exynos4210-trats.dts          | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4210.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos4212.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4412-trats2.dts         | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4412.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos5250.dtsi               | 20 +++++++++++++++++++-
 7 files changed, 76 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index 61009f4..e3879c0 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -428,6 +428,21 @@
 		status = "okay";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 2 2>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 4 4>;
+			       };
+		       };
+		};
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index bcc9e63..2e66df8 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -35,10 +35,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@900 {
+		cpu0: cpu@900 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0x900>;
+			cooling-min-level = <4>;
+			cooling-max-level = <2>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@901 {
diff --git a/arch/arm/boot/dts/exynos4212.dtsi b/arch/arm/boot/dts/exynos4212.dtsi
index dd0a43e..5be03288 100644
--- a/arch/arm/boot/dts/exynos4212.dtsi
+++ b/arch/arm/boot/dts/exynos4212.dtsi
@@ -26,10 +26,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@A00 {
+		cpu0: cpu@A00 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@A01 {
diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index c7517fc..25b4f7d 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -401,6 +401,21 @@
 		vtmu-supply = <&ldo10_reg>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 13 13>;
+			       };
+		       };
+		};
+	};
 };
 
 &pinctrl_1 {
diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts b/arch/arm/boot/dts/exynos4412-trats2.dts
index 29231b4..52a7771 100644
--- a/arch/arm/boot/dts/exynos4412-trats2.dts
+++ b/arch/arm/boot/dts/exynos4412-trats2.dts
@@ -863,6 +863,21 @@
 		pulldown-ohm = <100000>; /* 100K */
 		io-channels = <&adc 2>;  /* Battery temperature */
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 13 13>;
+			       };
+		       };
+		};
+	};
 };
 
 &pinctrl_0 {
diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
index 0f6ec93..68ad43b 100644
--- a/arch/arm/boot/dts/exynos4412.dtsi
+++ b/arch/arm/boot/dts/exynos4412.dtsi
@@ -26,10 +26,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@A00 {
+		cpu0: cpu@A00 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@A01 {
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index 0a229fc..4641d3c 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -58,11 +58,14 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@0 {
+		cpu0: cpu@0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a15";
 			reg = <0>;
 			clock-frequency = <1700000000>;
+			cooling-min-level = <15>;
+			cooling-max-level = <9>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 		cpu@1 {
 			device_type = "cpu";
@@ -241,6 +244,21 @@
 		clock-names = "tmu_apbif";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 9 9>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 15 15>;
+			       };
+		       };
+		};
+	};
+
 	serial@12C00000 {
 		clocks = <&clock CLK_UART0>, <&clock CLK_SCLK_UART0>;
 		clock-names = "uart", "clk_uart_baud0";
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (5 preceding siblings ...)
  2015-01-19 11:20   ` [PATCH v5 06/18] arm: dts: Adding CPU cooling binding for Exynos SoCs Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-21  2:18     ` Eduardo Valentin
  2015-01-21  8:33     ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 08/18] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
                     ` (13 subsequent siblings)
  20 siblings, 2 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Up till now exynos_tmu_data.c was used for storing CPU cooling configuration
data. Now the Exynos thermal core code uses device tree to get this data.
For this purpose generic thermal code for configuring CPU cooling was
used.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Rewrite code responsible for registering CPU cooling device to not depend
  on explicit "/cpus/cpu@0" path since now Exynos SoCs use new cpu node
  names (e.g. cpu@A00). New approach iterates over "cpus" node children.
- Patch title changed to thermal: exynos
Changes for v4:
- None
Changes for v5:
- None

---
 drivers/cpufreq/exynos-cpufreq.c                |  30 +++++-
 drivers/thermal/samsung/exynos_thermal_common.c | 122 ++++++++++++++----------
 drivers/thermal/samsung/exynos_tmu.c            |   7 --
 drivers/thermal/samsung/exynos_tmu.h            |   5 -
 drivers/thermal/samsung/exynos_tmu_data.c       |  42 +-------
 5 files changed, 101 insertions(+), 105 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index f99a0b0..32bc64d 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -18,10 +18,13 @@
 #include <linux/cpufreq.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/cpu_cooling.h>
+#include <linux/cpu.h>
 
 #include "exynos-cpufreq.h"
 
 static struct exynos_dvfs_info *exynos_info;
+static struct thermal_cooling_device *cdev;
 static struct regulator *arm_regulator;
 static unsigned int locking_frequency;
 
@@ -156,6 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
+	struct device_node *cpus, *np;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -198,9 +202,31 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	/* Done here as we want to capture boot frequency */
 	locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;
 
-	if (!cpufreq_register_driver(&exynos_driver))
-		return 0;
+	if (cpufreq_register_driver(&exynos_driver))
+		goto err;
 
+	cpus = of_find_node_by_path("/cpus");
+	if (!cpus) {
+		pr_err("failed to find cpus node\n");
+		return -ENOENT;
+	}
+
+	for (np = of_get_next_child(cpus, NULL); np;
+	     of_node_put(np), np = of_get_next_child(cpus, np)) {
+		if (of_find_property(np, "#cooling-cells", NULL)) {
+			cdev = of_cpufreq_cooling_register(np,
+							   cpu_present_mask);
+			if (IS_ERR(cdev))
+				pr_err("running cpufreq without cooling device: %ld\n",
+				       PTR_ERR(cdev));
+			break;
+		}
+	}
+	of_node_put(np);
+	of_node_put(cpus);
+
+	return 0;
+ err:
 	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
 	regulator_put(arm_regulator);
 err_vdd_arm:
diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 6dc3815..00aa688 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -133,47 +133,62 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
 static int exynos_bind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size, level;
-	struct freq_clip_table *tab_ptr, *clip_data;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
+	struct of_phandle_args cooling_spec;
+	unsigned long max, state = 0;
+	int ret = 0, i = 0;
 
-	tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data;
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_ptr == NULL || tab_size == 0)
+	/*
+	 * Below code is necessary to skip binding when cpufreq's
+	 * frequency table is not yet initialized.
+	 */
+	cdev->ops->get_max_state(cdev, &state);
+	if (!state && !th_zone->cool_dev_size) {
+		th_zone->cool_dev_size = 1;
+		th_zone->cool_dev[0] = cdev;
+		th_zone->bind = false;
 		return 0;
+	}
 
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
 
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
+	child = of_get_child_by_name(np, "cooling-maps");
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		clip_data = (struct freq_clip_table *)&(tab_ptr[i]);
-		level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max);
-		if (level == THERMAL_CSTATE_INVALID)
-			return 0;
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-								level, 0)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = true;
-			break;
-		default:
+	for_each_child_of_node(child, gchild) {
+		ret = of_parse_phandle_with_args(gchild, "cooling-device",
+						 "#cooling-cells",
+						 0, &cooling_spec);
+		if (ret < 0) {
+			pr_err("missing cooling_device property\n");
+			goto end;
+		}
+
+		if (cooling_spec.args_count < 2) {
 			ret = -EINVAL;
+			goto end;
 		}
+
+		max = cooling_spec.args[0];
+		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
+						     max, 0)) {
+			dev_err(data->dev,
+				"thermal error unbinding cdev inst=%d\n", i);
+
+			ret = -EINVAL;
+			goto end;
+		}
+		i++;
 	}
+	th_zone->bind = true;
+end:
+	of_node_put(child);
+	of_node_put(np);
 
 	return ret;
 }
@@ -182,16 +197,12 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 static int exynos_unbind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size;
+	int ret = 0, i;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
 
-	if (th_zone->bind == false)
-		return 0;
-
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_size == 0)
+	if (th_zone->bind == false || !th_zone->cool_dev_size)
 		return 0;
 
 	/* find the cooling device registered*/
@@ -203,23 +214,30 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
 	if (i == th_zone->cool_dev_size)
 		return 0;
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_unbind_cooling_device(thermal, i,
-								cdev)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = false;
-			break;
-		default:
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
+
+	child = of_get_child_by_name(np, "cooling-maps");
+
+	i = 0;
+	for_each_child_of_node(child, gchild) {
+		if (thermal_zone_unbind_cooling_device(thermal, i,
+						       cdev)) {
+			dev_err(data->dev,
+				"error unbinding cdev inst=%d\n", i);
 			ret = -EINVAL;
+			goto end;
 		}
+		i++;
 	}
+	th_zone->bind = false;
+end:
+	of_node_put(child);
+	of_node_put(np);
+
 	return ret;
 }
 
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 5000727..ae30f6a 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -916,13 +916,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 
 	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
 
-	sensor_conf->cooling_data.freq_clip_count = pdata->freq_tab_count;
-	for (i = 0; i < pdata->freq_tab_count; i++) {
-		sensor_conf->cooling_data.freq_data[i].freq_clip_max =
-					pdata->freq_tab[i].freq_clip_max;
-		sensor_conf->cooling_data.freq_data[i].temp_level =
-					pdata->freq_tab[i].temp_level;
-	}
 	sensor_conf->dev = &pdev->dev;
 	/* Register the sensor with thermal management interface */
 	ret = exynos_register_thermal(sensor_conf);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 7f880d2..627dec9 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -83,9 +83,6 @@ enum soc_type {
  * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
- * @freq_clip_table: Table representing frequency reduction percentage.
- * @freq_tab_count: Count of the above table as frequency reduction may
- *	applicable to only some of the trigger levels.
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
@@ -111,8 +108,6 @@ struct exynos_tmu_platform_data {
 	enum soc_type type;
 	u32 cal_type;
 	u32 cal_mode;
-	struct freq_clip_table freq_tab[4];
-	unsigned int freq_tab_count;
 };
 
 /**
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
index b239100..a993f3d 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -47,15 +47,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 		.first_point_trim = 25,
 		.second_point_trim = 85,
 		.default_temp_offset = 50,
-		.freq_tab[0] = {
-			.freq_clip_max = 800 * 1000,
-			.temp_level = 85,
-			},
-		.freq_tab[1] = {
-			.freq_clip_max = 200 * 1000,
-			.temp_level = 100,
-		},
-		.freq_tab_count = 2,
 		.type = SOC_ARCH_EXYNOS4210,
 		},
 	},
@@ -87,16 +78,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 800 * 1000, \
-		.temp_level = 70, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 400 * 1000, \
-		.temp_level = 95, \
-	}, \
-	.freq_tab_count = 2
+	.default_temp_offset = 50
 
 struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 	.tmu_data = {
@@ -133,16 +115,7 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 1400 * 1000, \
-		.temp_level = 70, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 400 * 1000, \
-		.temp_level = 95, \
-	}, \
-	.freq_tab_count = 2
+	.default_temp_offset = 50
 
 struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
 	.tmu_data = {
@@ -189,16 +162,7 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 800 * 1000, \
-		.temp_level = 85, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 200 * 1000, \
-		.temp_level = 103, \
-	}, \
-	.freq_tab_count = 2, \
+	.default_temp_offset = 50,
 
 #define EXYNOS5260_TMU_DATA \
 	__EXYNOS5260_TMU_DATA \
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 08/18] thermal: exynos: dts: Add default definition of the TMU sensor parameter
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (6 preceding siblings ...)
  2015-01-19 11:20   ` [PATCH v5 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 09/18] dts: Documentation: Extending documentation entry for exynos-thermal Lukasz Majewski
                     ` (12 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Exynos 4 and 5 family of SoCs uses almost identical TMU sensor to measure the
on chip temperature. For this reason it is possible to group TMU configuration
parameters in one dts file.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- "samsung,tmu_" prefix for TMU specific properties has been added
Changes for v4:
- None
Changes for v5:
- None

---
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi | 24 +++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi

diff --git a/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
new file mode 100644
index 0000000..e3f7934
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
@@ -0,0 +1,24 @@
+/*
+ * Device tree sources for Exynos4412 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+samsung,tmu_gain = <8>;
+samsung,tmu_reference_voltage = <16>;
+samsung,tmu_noise_cancel_mode = <4>;
+samsung,tmu_efuse_value = <55>;
+samsung,tmu_min_efuse_value = <40>;
+samsung,tmu_max_efuse_value = <100>;
+samsung,tmu_first_point_trim = <25>;
+samsung,tmu_second_point_trim = <85>;
+samsung,tmu_default_temp_offset = <50>;
+samsung,tmu_cal_type = <TYPE_ONE_POINT_TRIMMING>;
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 09/18] dts: Documentation: Extending documentation entry for exynos-thermal
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (7 preceding siblings ...)
  2015-01-19 11:20   ` [PATCH v5 08/18] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 10/18] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
                     ` (11 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Properties necessary for providing Exynos thermal configuration via device
tree.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v3:
- New patch
Changes for v4:
- Remove entry regarding Exynos5440
Changes for v5:
- None

---
 .../devicetree/bindings/thermal/exynos-thermal.txt       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
index ae738f5..8497794 100644
--- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
@@ -39,6 +39,18 @@
 - vtmu-supply: This entry is optional and provides the regulator node supplying
 		voltage to TMU. If needed this entry can be placed inside
 		board/platform specific dts file.
+Following properties are mandatory (depending on SoC):
+- samsung,tmu_gain: Gain value for internal TMU operation.
+- samsung,tmu_reference_voltage: Value of TMU IP block's reference voltage
+- samsung,tmu_noise_cancel_mode: Mode for noise cancellation
+- samsung,tmu_efuse_value: Default level of temperature - it is needed when
+			   in factory fusing produced wrong value
+- samsung,tmu_min_efuse_value: Minimum temperature fused value
+- samsung,tmu_max_efuse_value: Maximum temperature fused value
+- samsung,tmu_first_point_trim: First point trimming value
+- samsung,tmu_second_point_trim: Second point trimming value
+- samsung,tmu_default_temp_offset: Default temperature offset
+- samsung,tmu_cal_type: Callibration type
 
 Example 1):
 
@@ -51,6 +63,7 @@ Example 1):
 		clock-names = "tmu_apbif";
 		status = "disabled";
 		vtmu-supply = <&tmu_regulator_node>;
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 Example 2):
@@ -70,6 +83,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 184 0>;
 		clocks = <&clock 318>, <&clock 318>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu3: tmu@1006c000 {
@@ -78,6 +92,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 185 0>;
 		clocks = <&clock 318>, <&clock 319>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_gpu: tmu@100a0000 {
@@ -86,6 +101,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 215 0>;
 		clocks = <&clock 319>, <&clock 318>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 Note: For multi-instance tmu each instance should have an alias correctly
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 10/18] thermal: dts: Default trip points definition for Exynos5420 SoCs
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (8 preceding siblings ...)
  2015-01-19 11:20   ` [PATCH v5 09/18] dts: Documentation: Extending documentation entry for exynos-thermal Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 11/18] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
                     ` (10 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This code groups in one place default settings of trip points. It is used
in SoCs with multiple instances of TMU sensor.

Separate device tree file prevents from multiple copying of the same data.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
---
 arch/arm/boot/dts/exynos5420-trip-points.dtsi | 35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi

diff --git a/arch/arm/boot/dts/exynos5420-trip-points.dtsi b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
new file mode 100644
index 0000000..09d6c56
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
@@ -0,0 +1,35 @@
+/*
+ * Device tree sources for default Exynos 5420 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <85000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-1 {
+		temperature = <103000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-2 {
+		temperature = <110000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1200000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 11/18] thermal: exynos: dts: Define default thermal-zones for Exynos4
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (9 preceding siblings ...)
  2015-01-19 11:20   ` [PATCH v5 10/18] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 12/18] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
                     ` (9 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Trip points corresponding to the one defined in the exynos_tmu_data.c
for Exynos4 have been included.
This thermal-zones attribute is afterwards reused for Exynos4210, Exynos4412
and Exynos5250.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
---
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi | 52 ++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi

diff --git a/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
new file mode 100644
index 0000000..506600a
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
@@ -0,0 +1,52 @@
+/*
+ * Device tree sources for Exynos4 thermal zone
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal.h>
+
+/ {
+  thermal-zones {
+	cpu_thermal: cpu-thermal {
+		thermal-sensors = <&tmu 0>;
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		trips {
+			cpu_alert0: cpu-alert-0 {
+				temperature = <70000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert1: cpu-alert-1 {
+				temperature = <95000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert2: cpu-alert-2 {
+				temperature = <110000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_crit0: cpu-crit-0 {
+				temperature = <120000>; /* millicelsius */
+				hysteresis = <0>; /* millicelsius */
+				type = "critical";
+			};
+		};
+		cooling-maps {
+			map0 {
+			    trip = <&cpu_alert0>;
+			};
+			map1 {
+			    trip = <&cpu_alert1>;
+			};
+		};
+	};
+  };
+};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 12/18] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (10 preceding siblings ...)
  2015-01-19 11:20   ` [PATCH v5 11/18] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 13/18] dts: Documentation: Update exynos-thermal.txt example " Lukasz Majewski
                     ` (8 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This commit provides information about Exynos5440 device configuration.
Previously this information was available in exynos_tmu_data.c file.
Now it is available in the device tree.
Such approach allows reusing some common code for thermal.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- "type" property removed
- "samsung,tmu_" prefix for TMU specific properties has been added
Changes for v4:
- None
Changes for v5:
- None

---
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi | 24 ++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi     | 25 +++++++++++++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi

diff --git a/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
new file mode 100644
index 0000000..7b2fba0
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
@@ -0,0 +1,24 @@
+/*
+ * Device tree sources for Exynos5440 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+samsung,tmu_gain = <5>;
+samsung,tmu_reference_voltage = <16>;
+samsung,tmu_noise_cancel_mode = <4>;
+samsung,tmu_efuse_value = <0x5d2d>;
+samsung,tmu_min_efuse_value = <16>;
+samsung,tmu_max_efuse_value = <76>;
+samsung,tmu_first_point_trim = <25>;
+samsung,tmu_second_point_trim = <70>;
+samsung,tmu_default_temp_offset = <25>;
+samsung,tmu_cal_type = <TYPE_ONE_POINT_TRIMMING>;
diff --git a/arch/arm/boot/dts/exynos5440-trip-points.dtsi b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
new file mode 100644
index 0000000..48adfa8
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
@@ -0,0 +1,25 @@
+/*
+ * Device tree sources for default Exynos5440 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <100000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1050000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 13/18] dts: Documentation: Update exynos-thermal.txt example for Exynos5440
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (11 preceding siblings ...)
  2015-01-19 11:20   ` [PATCH v5 12/18] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 14/18] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c Lukasz Majewski
                     ` (7 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Updating exynos-thermal.txt documentation entry for Exynos5440

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v4:
- New patch
Changes for v5:
- None
---
 Documentation/devicetree/bindings/thermal/exynos-thermal.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
index 8497794..0f44932 100644
--- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
@@ -74,6 +74,7 @@ Example 2):
 		interrupts = <0 58 0>;
 		clocks = <&clock 21>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 14/18] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (12 preceding siblings ...)
  2015-01-19 11:20   ` [PATCH v5 13/18] dts: Documentation: Update exynos-thermal.txt example " Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-19 11:20   ` [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
                     ` (6 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Presented device tree bindings provide data already hardcoded in the
exynos_tmu_data.c file.
After this commit, it should be possible to reuse common thermal core
framework in Exynos SoCs.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Add proper TMU entries for exynos3250.dtsi
Changes for v3:
- Remove "type" DT properties, which will be extracted from compatible
- "samsung,tmu_" prefix for TMU specific properties has been added
Changes for v4:
- Providing mandatory properties for thermal-zones (Exynos4210 and Exynos5250)
Changes for v5:
- None

---
 arch/arm/boot/dts/exynos3250.dtsi |  2 ++
 arch/arm/boot/dts/exynos4.dtsi    |  4 ++++
 arch/arm/boot/dts/exynos4210.dtsi | 25 ++++++++++++++++++++++++-
 arch/arm/boot/dts/exynos4x12.dtsi |  1 +
 arch/arm/boot/dts/exynos5250.dtsi |  9 +++++++--
 arch/arm/boot/dts/exynos5420.dtsi | 28 ++++++++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440.dtsi | 18 ++++++++++++++++++
 7 files changed, 84 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/exynos3250.dtsi b/arch/arm/boot/dts/exynos3250.dtsi
index 2246549..8cc078c 100644
--- a/arch/arm/boot/dts/exynos3250.dtsi
+++ b/arch/arm/boot/dts/exynos3250.dtsi
@@ -18,6 +18,7 @@
  */
 
 #include "skeleton.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 #include <dt-bindings/clock/exynos3250.h>
 
 / {
@@ -188,6 +189,7 @@
 			interrupts = <0 216 0>;
 			clocks = <&cmu CLK_TMU_APBIF>;
 			clock-names = "tmu_apbif";
+			#include "exynos4412-tmu-sensor-conf.dtsi"
 			status = "disabled";
 		};
 
diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index b8168f1..f18d746 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -645,4 +645,8 @@
 		samsung,sysreg = <&sys_reg>;
 		status = "disabled";
 	};
+
+	tmu: tmu@100C0000 {
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+	};
 };
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index 2e66df8..78a43b0 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -21,6 +21,7 @@
 
 #include "exynos4.dtsi"
 #include "exynos4210-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 
 / {
 	compatible = "samsung,exynos4210", "samsung,exynos4";
@@ -146,16 +147,38 @@
 		reg = <0x03860000 0x1000>;
 	};
 
-	tmu@100C0000 {
+	tmu: tmu@100C0000 {
 		compatible = "samsung,exynos4210-tmu";
 		interrupt-parent = <&combiner>;
 		reg = <0x100C0000 0x100>;
 		interrupts = <2 4>;
 		clocks = <&clock CLK_TMU_APBIF>;
 		clock-names = "tmu_apbif";
+		samsung,tmu_gain = <15>;
+		samsung,tmu_reference_voltage = <7>;
 		status = "disabled";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&tmu 0>;
+
+			trips {
+			      cpu_alert0: cpu-alert-0 {
+				      temperature = <85000>; /* millicelsius */
+			      };
+			      cpu_alert1: cpu-alert-1 {
+				      temperature = <100000>; /* millicelsius */
+			      };
+			      cpu_alert2: cpu-alert-2 {
+				      temperature = <110000>; /* millicelsius */
+			      };
+			};
+		};
+	};
+
 	g2d@12800000 {
 		compatible = "samsung,s5pv210-g2d";
 		reg = <0x12800000 0x1000>;
diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi
index 93b7040..3ee2031 100644
--- a/arch/arm/boot/dts/exynos4x12.dtsi
+++ b/arch/arm/boot/dts/exynos4x12.dtsi
@@ -19,6 +19,7 @@
 
 #include "exynos4.dtsi"
 #include "exynos4x12-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 
 / {
 	aliases {
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index 4641d3c..90211c0 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -20,7 +20,7 @@
 #include <dt-bindings/clock/exynos5250.h>
 #include "exynos5.dtsi"
 #include "exynos5250-pinctrl.dtsi"
-
+#include "exynos4-cpu-thermal.dtsi"
 #include <dt-bindings/clock/exynos-audss-clk.h>
 
 / {
@@ -236,16 +236,21 @@
 		status = "disabled";
 	};
 
-	tmu@10060000 {
+	tmu: tmu@10060000 {
 		compatible = "samsung,exynos5250-tmu";
 		reg = <0x10060000 0x100>;
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	thermal-zones {
 		cpu_thermal: cpu-thermal {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&tmu 0>;
+
 			cooling-maps {
 				map0 {
 				     /* Corresponds to 800MHz at freq_table */
diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
index 517e50f..f5771e5 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -761,6 +761,7 @@
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu1: tmu@10064000 {
@@ -769,6 +770,7 @@
 		interrupts = <0 183 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu2: tmu@10068000 {
@@ -777,6 +779,7 @@
 		interrupts = <0 184 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu3: tmu@1006c000 {
@@ -785,6 +788,7 @@
 		interrupts = <0 185 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU_GPU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_gpu: tmu@100a0000 {
@@ -793,6 +797,30 @@
 		interrupts = <0 215 0>;
 		clocks = <&clock CLK_TMU_GPU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmu_cpu0>;
+			#include "exynos5420-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmu_cpu1>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmu_cpu2>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu3_thermal: cpu3-thermal {
+		       thermal-sensors = <&tmu_cpu3>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		gpu_thermal: gpu-thermal {
+		       thermal-sensors = <&tmu_gpu>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
 	};
 
         watchdog: watchdog@101D0000 {
diff --git a/arch/arm/boot/dts/exynos5440.dtsi b/arch/arm/boot/dts/exynos5440.dtsi
index 8f3373c..59d9416 100644
--- a/arch/arm/boot/dts/exynos5440.dtsi
+++ b/arch/arm/boot/dts/exynos5440.dtsi
@@ -219,6 +219,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_1: tmuctrl@16011C {
@@ -227,6 +228,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_2: tmuctrl@160120 {
@@ -235,6 +237,22 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmuctrl_0>;
+			#include "exynos5440-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmuctrl_1>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmuctrl_2>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
 	};
 
 	sata@210000 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (13 preceding siblings ...)
  2015-01-19 11:20   ` [PATCH v5 14/18] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c Lukasz Majewski
@ 2015-01-19 11:20   ` Lukasz Majewski
  2015-01-21  3:18     ` Eduardo Valentin
  2015-01-21  3:25     ` Eduardo Valentin
  2015-01-19 11:21   ` [PATCH v5 16/18] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
                     ` (5 subsequent siblings)
  20 siblings, 2 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:20 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

This patch brings support for providing configuration via device tree.
Previously this data has been hardcoded in the exynos_tmu_data.c file.
Such approach was not scalable and very often required copying the whole
data.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
- Usage of of-thermal.c exported trip points table
Changes for v3:
- Adding exynos_of_get_soc_type() method to set SOC type from device's
  compatible string
- "samsung,tmu_" prefix for TMU specific properties has been added
Changes for v4:
- None
Changes for v5:
- Remove duplicated exynos_tmu_initialize() - reported by Abhilash Kesavan
 <a.kesavan@samsung.com>

---
 drivers/thermal/samsung/Makefile     |   2 -
 drivers/thermal/samsung/exynos_tmu.c | 339 ++++++++++++++++++++++-------------
 drivers/thermal/samsung/exynos_tmu.h |  53 +-----
 3 files changed, 220 insertions(+), 174 deletions(-)

diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile
index c09d830..1e47d0d 100644
--- a/drivers/thermal/samsung/Makefile
+++ b/drivers/thermal/samsung/Makefile
@@ -3,5 +3,3 @@
 #
 obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_thermal.o
 exynos_thermal-y				:= exynos_tmu.o
-exynos_thermal-y				+= exynos_tmu_data.o
-exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+= exynos_thermal_common.o
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index ae30f6a..9d2d685 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -1,6 +1,10 @@
 /*
  * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
  *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
  *  Copyright (C) 2011 Samsung Electronics
  *  Donggeun Kim <dg77.kim@samsung.com>
  *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
@@ -31,8 +35,8 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 
-#include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
+#include "../thermal_core.h"
 
 /* Exynos generic registers */
 #define EXYNOS_TMU_REG_TRIMINFO		0x0
@@ -115,6 +119,7 @@
 #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
 #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
 
+#define MCELSIUS	1000
 /**
  * struct exynos_tmu_data : A structure to hold the private data of the TMU
 	driver
@@ -150,7 +155,8 @@ struct exynos_tmu_data {
 	struct clk *clk, *clk_sec;
 	u8 temp_error1, temp_error2;
 	struct regulator *regulator;
-	struct thermal_sensor_conf *reg_conf;
+	struct thermal_zone_device *tzd;
+
 	int (*tmu_initialize)(struct platform_device *pdev);
 	void (*tmu_control)(struct platform_device *pdev, bool on);
 	int (*tmu_read)(struct exynos_tmu_data *data);
@@ -159,6 +165,33 @@ struct exynos_tmu_data {
 	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
 };
 
+static void exynos_report_trigger(struct exynos_tmu_data *p)
+{
+	char data[10], *envp[] = { data, NULL };
+	struct thermal_zone_device *tz = p->tzd;
+	unsigned long temp;
+	unsigned int i;
+
+	if (!p) {
+		pr_err("Wrong temperature configuration data\n");
+		return;
+	}
+
+	thermal_zone_device_update(tz);
+
+	mutex_lock(&tz->lock);
+	/* Find the level for which trip happened */
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		tz->ops->get_trip_temp(tz, i, &temp);
+		if (tz->last_temperature < temp)
+			break;
+	}
+
+	snprintf(data, sizeof(data), "%u", i);
+	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
+	mutex_unlock(&tz->lock);
+}
+
 /*
  * TMU treats temperature as a mapped temperature code.
  * The temperature is converted differently depending on the calibration type.
@@ -234,14 +267,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
 
 static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling)
 {
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
+	unsigned long temp;
 	int i;
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
-		u8 temp = pdata->trigger_levels[i];
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
+		       __func__);
+		return 0;
+	}
 
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL)
+			continue;
+
+		temp = trips[i].temperature / MCELSIUS;
 		if (falling)
-			temp -= pdata->threshold_falling;
+			temp -= (trips[i].hysteresis / MCELSIUS);
 		else
 			threshold &= ~(0xff << 8 * i);
 
@@ -305,9 +349,19 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 static int exynos4210_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
-	unsigned int status;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
 	int ret = 0, threshold_code, i;
+	unsigned long reference, temp;
+	unsigned int status;
+
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
+		       __func__);
+		ret = -ENODEV;
+		goto out;
+	}
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct platform_device *pdev)
 	sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));
 
 	/* Write temperature code for threshold */
-	threshold_code = temp_to_code(data, pdata->threshold);
+	reference = trips[0].temperature / MCELSIUS;
+	threshold_code = temp_to_code(data, reference);
+	if (threshold_code < 0) {
+		ret = threshold_code;
+		goto out;
+	}
 	writeb(threshold_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
-		writeb(pdata->trigger_levels[i], data->base +
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		temp = trips[i].temperature / MCELSIUS;
+		writeb(temp - reference, data->base +
 		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
+	}
 
 	data->tmu_clear_irqs(data);
 out:
@@ -333,9 +394,11 @@ out:
 static int exynos4412_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(data->tzd);
 	unsigned int status, trim_info, con, ctrl, rising_threshold;
 	int ret = 0, threshold_code, i;
+	unsigned long crit_temp = 0;
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
 	data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
-		/* 1-4 level to be assigned in th0 reg */
-		rising_threshold &= ~(0xff << 8 * i);
-		rising_threshold |= threshold_code << 8 * i;
-		writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
-		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
-		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
-		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
+			crit_temp = trips[i].temperature;
+			break;
+		}
+	}
+
+	if (i == of_thermal_get_ntrips(data->tzd)) {
+		pr_err("%s: No CRITICAL trip point defined at of-thermal.c!\n",
+		       __func__);
+		ret = -EINVAL;
+		goto out;
 	}
+
+	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
+	/* 1-4 level to be assigned in th0 reg */
+	rising_threshold &= ~(0xff << 8 * i);
+	rising_threshold |= threshold_code << 8 * i;
+	writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
+	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
+	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
+	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+
 out:
 	return ret;
 }
@@ -391,9 +466,9 @@ out:
 static int exynos5440_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
 	unsigned int trim_info = 0, con, rising_threshold;
-	int ret = 0, threshold_code, i;
+	int ret = 0, threshold_code;
+	unsigned long crit_temp = 0;
 
 	/*
 	 * For exynos5440 soc triminfo value is swapped between TMU0 and
@@ -422,9 +497,8 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 	data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
+	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp)) {
+		threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
 		/* 5th level to be assigned in th2 reg */
 		rising_threshold =
 			threshold_code << EXYNOS5440_TMU_TH_RISE4_SHIFT;
@@ -442,7 +516,7 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
@@ -450,10 +524,15 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS_TMU_INTEN_RISE0_SHIFT;
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
+
 		if (data->soc != SOC_ARCH_EXYNOS4210)
 			interrupt_en |=
 				interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
@@ -468,7 +547,7 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS5440_TMU_S0_7_CTRL));
@@ -476,11 +555,16 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
-		interrupt_en |= interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
+		interrupt_en |=
+			interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
 	} else {
 		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en = 0; /* Disable all interrupts */
@@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL);
 }
 
-static int exynos_tmu_read(struct exynos_tmu_data *data)
+int exynos_get_temp(void *p, long *temp)
 {
-	int ret;
+	struct exynos_tmu_data *data = p;
+
+	if (!data)
+		return -EINVAL;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
-	ret = data->tmu_read(data);
-	if (ret >= 0)
-		ret = code_to_temp(data, ret);
+
+	*temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS;
+
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
 
-	return ret;
+	return 0;
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
@@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct *work)
 	if (!IS_ERR(data->clk_sec))
 		clk_disable(data->clk_sec);
 
-	exynos_report_trigger(data->reg_conf);
+	exynos_report_trigger(data);
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
@@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 static const struct of_device_id exynos_tmu_match[] = {
 	{
 		.compatible = "samsung,exynos3250-tmu",
-		.data = &exynos3250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4210-tmu",
-		.data = &exynos4210_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4412-tmu",
-		.data = &exynos4412_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5250-tmu",
-		.data = &exynos5250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5260-tmu",
-		.data = &exynos5260_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu-ext-triminfo",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5440-tmu",
-		.data = &exynos5440_default_tmu_data,
 	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 
-static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
-			struct platform_device *pdev, int id)
+static int exynos_of_get_soc_type(struct device_node *np)
 {
-	struct  exynos_tmu_init_data *data_table;
-	struct exynos_tmu_platform_data *tmu_data;
-	const struct of_device_id *match;
+	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
+		return SOC_ARCH_EXYNOS3250;
+	else if (of_device_is_compatible(np, "samsung,exynos4210-tmu"))
+		return SOC_ARCH_EXYNOS4210;
+	else if (of_device_is_compatible(np, "samsung,exynos4412-tmu"))
+		return SOC_ARCH_EXYNOS4412;
+	else if (of_device_is_compatible(np, "samsung,exynos5250-tmu"))
+		return SOC_ARCH_EXYNOS5250;
+	else if (of_device_is_compatible(np, "samsung,exynos5260-tmu"))
+		return SOC_ARCH_EXYNOS5260;
+	else if (of_device_is_compatible(np, "samsung,exynos5420-tmu"))
+		return SOC_ARCH_EXYNOS5420;
+	else if (of_device_is_compatible(np,
+					 "samsung,exynos5420-tmu-ext-triminfo"))
+		return SOC_ARCH_EXYNOS5420_TRIMINFO;
+	else if (of_device_is_compatible(np, "samsung,exynos5440-tmu"))
+		return SOC_ARCH_EXYNOS5440;
+
+	return -EINVAL;
+}
 
-	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
-	if (!match)
-		return NULL;
-	data_table = (struct exynos_tmu_init_data *) match->data;
-	if (!data_table || id >= data_table->tmu_count)
-		return NULL;
-	tmu_data = data_table->tmu_data;
-	return (struct exynos_tmu_platform_data *) (tmu_data + id);
+static int exynos_of_sensor_conf(struct device_node *np,
+				 struct exynos_tmu_platform_data *pdata)
+{
+	u32 value;
+	int ret;
+
+	of_node_get(np);
+
+	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
+	pdata->gain = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_reference_voltage", &value);
+	pdata->reference_voltage = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode", &value);
+	pdata->noise_cancel_mode = (u8) value;
+
+	of_property_read_u32(np, "samsung,tmu_efuse_value",
+			     &pdata->efuse_value);
+	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
+			     &pdata->min_efuse_value);
+	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
+			     &pdata->max_efuse_value);
+
+	of_property_read_u32(np, "samsung,tmu_first_point_trim", &value);
+	pdata->first_point_trim = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_second_point_trim", &value);
+	pdata->second_point_trim = (u8) value;
+	of_property_read_u32(np, "samsung,tmu_default_temp_offset", &value);
+	pdata->default_temp_offset = (u8) value;
+
+	of_property_read_u32(np, "samsung,tmu_cal_type", &pdata->cal_type);
+	of_property_read_u32(np, "samsung,tmu_cal_mode", &pdata->cal_mode);
+
+	of_node_put(np);
+	return 0;
 }
 
 static int exynos_map_dt_data(struct platform_device *pdev)
@@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 		return -EADDRNOTAVAIL;
 	}
 
-	pdata = exynos_get_driver_data(pdev, data->id);
-	if (!pdata) {
-		dev_err(&pdev->dev, "No platform init data supplied.\n");
-		return -ENODEV;
-	}
+	pdata = devm_kzalloc(&pdev->dev,
+			     sizeof(struct exynos_tmu_platform_data),
+			     GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
 
+	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
 	data->pdata = pdata;
-	data->soc = pdata->type;
+	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
 
 	switch (data->soc) {
 	case SOC_ARCH_EXYNOS4210:
@@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 	return 0;
 }
 
+static struct thermal_zone_of_device_ops exynos_sensor_ops = {
+	.get_temp = exynos_get_temp,
+	.set_emul_temp = exynos_tmu_set_emulation,
+};
+
 static int exynos_tmu_probe(struct platform_device *pdev)
 {
-	struct exynos_tmu_data *data;
 	struct exynos_tmu_platform_data *pdata;
-	struct thermal_sensor_conf *sensor_conf;
-	int ret, i;
+	struct exynos_tmu_data *data;
+	int ret;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
 					GFP_KERNEL);
@@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, data);
 	mutex_init(&data->lock);
 
+	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
+						    &exynos_sensor_ops);
+	if (IS_ERR(data->tzd)) {
+		pr_err("thermal: tz: %p ERROR\n", data->tzd);
+		return PTR_ERR(data->tzd);
+	}
 	ret = exynos_map_dt_data(pdev);
 	if (ret)
-		return ret;
+		goto err_sensor;
 
 	pdata = data->pdata;
 
@@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
 	if (IS_ERR(data->clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
-		return  PTR_ERR(data->clk);
+		ret = PTR_ERR(data->clk);
+		goto err_sensor;
 	}
 
 	data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
 	if (IS_ERR(data->clk_sec)) {
 		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
 			dev_err(&pdev->dev, "Failed to get triminfo clock\n");
-			return PTR_ERR(data->clk_sec);
+			ret = PTR_ERR(data->clk_sec);
+			goto err_sensor;
 		}
 	} else {
 		ret = clk_prepare(data->clk_sec);
 		if (ret) {
 			dev_err(&pdev->dev, "Failed to get clock\n");
-			return ret;
+			goto err_sensor;
 		}
 	}
 
@@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	exynos_tmu_control(pdev, true);
-
-	/* Allocate a structure to register with the exynos core thermal */
-	sensor_conf = devm_kzalloc(&pdev->dev,
-				sizeof(struct thermal_sensor_conf), GFP_KERNEL);
-	if (!sensor_conf) {
-		ret = -ENOMEM;
-		goto err_clk;
-	}
-	sprintf(sensor_conf->name, "therm_zone%d", data->id);
-	sensor_conf->read_temperature = (int (*)(void *))exynos_tmu_read;
-	sensor_conf->write_emul_temp =
-		(int (*)(void *, unsigned long))exynos_tmu_set_emulation;
-	sensor_conf->driver_data = data;
-	sensor_conf->trip_data.trip_count = pdata->trigger_enable[0] +
-			pdata->trigger_enable[1] + pdata->trigger_enable[2]+
-			pdata->trigger_enable[3];
-
-	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
-		sensor_conf->trip_data.trip_val[i] =
-			pdata->threshold + pdata->trigger_levels[i];
-		sensor_conf->trip_data.trip_type[i] =
-					pdata->trigger_type[i];
-	}
-
-	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
-
-	sensor_conf->dev = &pdev->dev;
-	/* Register the sensor with thermal management interface */
-	ret = exynos_register_thermal(sensor_conf);
-	if (ret) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"Failed to register thermal interface: %d\n",
-				ret);
-		goto err_clk;
-	}
-	data->reg_conf = sensor_conf;
-
 	ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
 		IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
 	if (ret) {
@@ -935,21 +1030,25 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
+	exynos_tmu_control(pdev, true);
 	return 0;
 err_clk:
 	clk_unprepare(data->clk);
 err_clk_sec:
 	if (!IS_ERR(data->clk_sec))
 		clk_unprepare(data->clk_sec);
+err_sensor:
+	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
+
 	return ret;
 }
 
 static int exynos_tmu_remove(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	struct thermal_zone_device *tzd = data->tzd;
 
-	exynos_unregister_thermal(data->reg_conf);
-
+	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
 	exynos_tmu_control(pdev, false);
 
 	clk_unprepare(data->clk);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 627dec9..d876d4c 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -23,8 +23,7 @@
 #ifndef _EXYNOS_TMU_H
 #define _EXYNOS_TMU_H
 #include <linux/cpu_cooling.h>
-
-#include "exynos_thermal_common.h"
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 enum soc_type {
 	SOC_ARCH_EXYNOS3250 = 1,
@@ -36,38 +35,9 @@ enum soc_type {
 	SOC_ARCH_EXYNOS5420_TRIMINFO,
 	SOC_ARCH_EXYNOS5440,
 };
-#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
- * @threshold: basic temperature for generating interrupt
- *	       25 <= threshold <= 125 [unit: degree Celsius]
- * @threshold_falling: differntial value for setting threshold
- *		       of temperature falling interrupt.
- * @trigger_levels: array for each interrupt levels
- *	[unit: degree Celsius]
- *	0: temperature for trigger_level0 interrupt
- *	   condition for trigger_level0 interrupt:
- *		current temperature > threshold + trigger_levels[0]
- *	1: temperature for trigger_level1 interrupt
- *	   condition for trigger_level1 interrupt:
- *		current temperature > threshold + trigger_levels[1]
- *	2: temperature for trigger_level2 interrupt
- *	   condition for trigger_level2 interrupt:
- *		current temperature > threshold + trigger_levels[2]
- *	3: temperature for trigger_level3 interrupt
- *	   condition for trigger_level3 interrupt:
- *		current temperature > threshold + trigger_levels[3]
- * @trigger_type: defines the type of trigger. Possible values are,
- *	THROTTLE_ACTIVE trigger type
- *	THROTTLE_PASSIVE trigger type
- *	SW_TRIP trigger type
- *	HW_TRIP
- * @trigger_enable[]: array to denote which trigger levels are enabled.
- *	1 = enable trigger_level[] interrupt,
- *	0 = disable trigger_level[] interrupt
- * @max_trigger_level: max trigger level supported by the TMU
- * @non_hw_trigger_levels: number of defined non-hardware trigger levels
  * @gain: gain of amplifier in the positive-TC generator block
  *	0 < gain <= 15
  * @reference_voltage: reference voltage of amplifier
@@ -79,21 +49,12 @@ enum soc_type {
  * @efuse_value: platform defined fuse value
  * @min_efuse_value: minimum valid trimming data
  * @max_efuse_value: maximum valid trimming data
- * @first_point_trim: temp value of the first point trimming
- * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
 struct exynos_tmu_platform_data {
-	u8 threshold;
-	u8 threshold_falling;
-	u8 trigger_levels[MAX_TRIP_COUNT];
-	enum trigger_type trigger_type[MAX_TRIP_COUNT];
-	bool trigger_enable[MAX_TRIP_COUNT];
-	u8 max_trigger_level;
-	u8 non_hw_trigger_levels;
 	u8 gain;
 	u8 reference_voltage;
 	u8 noise_cancel_mode;
@@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
 	u32 cal_mode;
 };
 
-/**
- * struct exynos_tmu_init_data
- * @tmu_count: number of TMU instances.
- * @tmu_data: platform data of all TMU instances.
- * This structure is required to store data for multi-instance exynos tmu
- * driver.
- */
-struct exynos_tmu_init_data {
-	int tmu_count;
-	struct exynos_tmu_platform_data tmu_data[];
-};
-
 extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
 extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
 extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 16/18] thermal: exynos: Remove exynos_thermal_common.[c|h] files
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (14 preceding siblings ...)
  2015-01-19 11:20   ` [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
@ 2015-01-19 11:21   ` Lukasz Majewski
  2015-01-19 11:21   ` [PATCH v5 17/18] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
                     ` (4 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:21 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

After defining all necessary Exynos data in the device tree and heavy
reusage of the of-thermal.c those files can be removed.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
---
 drivers/thermal/samsung/exynos_thermal_common.c | 445 ------------------------
 drivers/thermal/samsung/exynos_thermal_common.h | 106 ------
 2 files changed, 551 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
deleted file mode 100644
index 00aa688..0000000
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ /dev/null
@@ -1,445 +0,0 @@
-/*
- * exynos_thermal_common.c - Samsung EXYNOS common thermal file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include <linux/cpu_cooling.h>
-#include <linux/err.h>
-#include <linux/slab.h>
-#include <linux/thermal.h>
-
-#include "exynos_thermal_common.h"
-
-struct exynos_thermal_zone {
-	enum thermal_device_mode mode;
-	struct thermal_zone_device *therm_dev;
-	struct thermal_cooling_device *cool_dev[MAX_COOLING_DEVICE];
-	unsigned int cool_dev_size;
-	struct platform_device *exynos4_dev;
-	struct thermal_sensor_conf *sensor_conf;
-	bool bind;
-};
-
-/* Get mode callback functions for thermal zone */
-static int exynos_get_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode *mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (th_zone)
-		*mode = th_zone->mode;
-	return 0;
-}
-
-/* Set mode callback functions for thermal zone */
-static int exynos_set_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (!th_zone) {
-		dev_err(&thermal->device,
-			"thermal zone not registered\n");
-		return 0;
-	}
-
-	mutex_lock(&thermal->lock);
-
-	if (mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling)
-		thermal->polling_delay = IDLE_INTERVAL;
-	else
-		thermal->polling_delay = 0;
-
-	mutex_unlock(&thermal->lock);
-
-	th_zone->mode = mode;
-	thermal_zone_device_update(thermal);
-	dev_dbg(th_zone->sensor_conf->dev,
-		"thermal polling set for duration=%d msec\n",
-		thermal->polling_delay);
-	return 0;
-}
-
-
-/* Get trip type callback functions for thermal zone */
-static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
-				 enum thermal_trip_type *type)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	int trip_type;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	trip_type = th_zone->sensor_conf->trip_data.trip_type[trip];
-
-	if (trip_type == SW_TRIP)
-		*type = THERMAL_TRIP_CRITICAL;
-	else if (trip_type == THROTTLE_ACTIVE)
-		*type = THERMAL_TRIP_ACTIVE;
-	else if (trip_type == THROTTLE_PASSIVE)
-		*type = THERMAL_TRIP_PASSIVE;
-	else
-		return -EINVAL;
-
-	return 0;
-}
-
-/* Get trip temperature callback functions for thermal zone */
-static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	*temp = th_zone->sensor_conf->trip_data.trip_val[trip];
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-
-	return 0;
-}
-
-/* Get critical temperature callback functions for thermal zone */
-static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	/* Get the temp of highest trip*/
-	return exynos_get_trip_temp(thermal, max_trip - 1, temp);
-}
-
-/* Bind callback functions for thermal zone */
-static int exynos_bind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-	struct of_phandle_args cooling_spec;
-	unsigned long max, state = 0;
-	int ret = 0, i = 0;
-
-	/*
-	 * Below code is necessary to skip binding when cpufreq's
-	 * frequency table is not yet initialized.
-	 */
-	cdev->ops->get_max_state(cdev, &state);
-	if (!state && !th_zone->cool_dev_size) {
-		th_zone->cool_dev_size = 1;
-		th_zone->cool_dev[0] = cdev;
-		th_zone->bind = false;
-		return 0;
-	}
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	for_each_child_of_node(child, gchild) {
-		ret = of_parse_phandle_with_args(gchild, "cooling-device",
-						 "#cooling-cells",
-						 0, &cooling_spec);
-		if (ret < 0) {
-			pr_err("missing cooling_device property\n");
-			goto end;
-		}
-
-		if (cooling_spec.args_count < 2) {
-			ret = -EINVAL;
-			goto end;
-		}
-
-		max = cooling_spec.args[0];
-		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-						     max, 0)) {
-			dev_err(data->dev,
-				"thermal error unbinding cdev inst=%d\n", i);
-
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = true;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Unbind callback functions for thermal zone */
-static int exynos_unbind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	int ret = 0, i;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-
-	if (th_zone->bind == false || !th_zone->cool_dev_size)
-		return 0;
-
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
-
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	i = 0;
-	for_each_child_of_node(child, gchild) {
-		if (thermal_zone_unbind_cooling_device(thermal, i,
-						       cdev)) {
-			dev_err(data->dev,
-				"error unbinding cdev inst=%d\n", i);
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = false;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_get_temp(struct thermal_zone_device *thermal,
-			unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	void *data;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	*temp = th_zone->sensor_conf->read_temperature(data);
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-	return 0;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
-						unsigned long temp)
-{
-	void *data;
-	int ret = -EINVAL;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	if (th_zone->sensor_conf->write_emul_temp)
-		ret = th_zone->sensor_conf->write_emul_temp(data, temp);
-	return ret;
-}
-
-/* Get the temperature trend */
-static int exynos_get_trend(struct thermal_zone_device *thermal,
-			int trip, enum thermal_trend *trend)
-{
-	int ret;
-	unsigned long trip_temp;
-
-	ret = exynos_get_trip_temp(thermal, trip, &trip_temp);
-	if (ret < 0)
-		return ret;
-
-	if (thermal->temperature >= trip_temp)
-		*trend = THERMAL_TREND_RAISE_FULL;
-	else
-		*trend = THERMAL_TREND_DROP_FULL;
-
-	return 0;
-}
-/* Operation callback functions for thermal zone */
-static struct thermal_zone_device_ops exynos_dev_ops = {
-	.bind = exynos_bind,
-	.unbind = exynos_unbind,
-	.get_temp = exynos_get_temp,
-	.set_emul_temp = exynos_set_emul_temp,
-	.get_trend = exynos_get_trend,
-	.get_mode = exynos_get_mode,
-	.set_mode = exynos_set_mode,
-	.get_trip_type = exynos_get_trip_type,
-	.get_trip_temp = exynos_get_trip_temp,
-	.get_crit_temp = exynos_get_crit_temp,
-};
-
-/*
- * This function may be called from interrupt based temperature sensor
- * when threshold is changed.
- */
-void exynos_report_trigger(struct thermal_sensor_conf *conf)
-{
-	unsigned int i;
-	char data[10];
-	char *envp[] = { data, NULL };
-	struct exynos_thermal_zone *th_zone;
-
-	if (!conf || !conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = conf->pzone_data;
-
-	if (th_zone->bind == false) {
-		for (i = 0; i < th_zone->cool_dev_size; i++) {
-			if (!th_zone->cool_dev[i])
-				continue;
-			exynos_bind(th_zone->therm_dev,
-					th_zone->cool_dev[i]);
-		}
-	}
-
-	thermal_zone_device_update(th_zone->therm_dev);
-
-	mutex_lock(&th_zone->therm_dev->lock);
-	/* Find the level for which trip happened */
-	for (i = 0; i < th_zone->sensor_conf->trip_data.trip_count; i++) {
-		if (th_zone->therm_dev->last_temperature <
-			th_zone->sensor_conf->trip_data.trip_val[i] * MCELSIUS)
-			break;
-	}
-
-	if (th_zone->mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling) {
-		if (i > 0)
-			th_zone->therm_dev->polling_delay = ACTIVE_INTERVAL;
-		else
-			th_zone->therm_dev->polling_delay = IDLE_INTERVAL;
-	}
-
-	snprintf(data, sizeof(data), "%u", i);
-	kobject_uevent_env(&th_zone->therm_dev->device.kobj, KOBJ_CHANGE, envp);
-	mutex_unlock(&th_zone->therm_dev->lock);
-}
-
-/* Register with the in-kernel thermal management */
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int ret;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->read_temperature) {
-		pr_err("Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-
-	th_zone = devm_kzalloc(sensor_conf->dev,
-				sizeof(struct exynos_thermal_zone), GFP_KERNEL);
-	if (!th_zone)
-		return -ENOMEM;
-
-	th_zone->sensor_conf = sensor_conf;
-	/*
-	 * TODO: 1) Handle multiple cooling devices in a thermal zone
-	 *	 2) Add a flag/name in cooling info to map to specific
-	 *	 sensor
-	 */
-	if (sensor_conf->cooling_data.freq_clip_count > 0) {
-		th_zone->cool_dev[th_zone->cool_dev_size] =
-				cpufreq_cooling_register(cpu_present_mask);
-		if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
-			ret = PTR_ERR(th_zone->cool_dev[th_zone->cool_dev_size]);
-			if (ret != -EPROBE_DEFER)
-				dev_err(sensor_conf->dev,
-					"Failed to register cpufreq cooling device: %d\n",
-					ret);
-			goto err_unregister;
-		}
-		th_zone->cool_dev_size++;
-	}
-
-	th_zone->therm_dev = thermal_zone_device_register(
-			sensor_conf->name, sensor_conf->trip_data.trip_count,
-			0, th_zone, &exynos_dev_ops, NULL, 0,
-			sensor_conf->trip_data.trigger_falling ? 0 :
-			IDLE_INTERVAL);
-
-	if (IS_ERR(th_zone->therm_dev)) {
-		dev_err(sensor_conf->dev,
-			"Failed to register thermal zone device\n");
-		ret = PTR_ERR(th_zone->therm_dev);
-		goto err_unregister;
-	}
-	th_zone->mode = THERMAL_DEVICE_ENABLED;
-	sensor_conf->pzone_data = th_zone;
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Thermal zone(%s) registered\n", sensor_conf->name);
-
-	return 0;
-
-err_unregister:
-	exynos_unregister_thermal(sensor_conf);
-	return ret;
-}
-
-/* Un-Register with the in-kernel thermal management */
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int i;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = sensor_conf->pzone_data;
-
-	thermal_zone_device_unregister(th_zone->therm_dev);
-
-	for (i = 0; i < th_zone->cool_dev_size; ++i)
-		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Kernel Thermal management unregistered\n");
-}
diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h
deleted file mode 100644
index cd44719..0000000
--- a/drivers/thermal/samsung/exynos_thermal_common.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * exynos_thermal_common.h - Samsung EXYNOS common header file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#ifndef _EXYNOS_THERMAL_COMMON_H
-#define _EXYNOS_THERMAL_COMMON_H
-
-/* In-kernel thermal framework related macros & definations */
-#define SENSOR_NAME_LEN	16
-#define MAX_TRIP_COUNT	8
-#define MAX_COOLING_DEVICE 4
-
-#define ACTIVE_INTERVAL 500
-#define IDLE_INTERVAL 10000
-#define MCELSIUS	1000
-
-/* CPU Zone information */
-#define PANIC_ZONE      4
-#define WARN_ZONE       3
-#define MONITOR_ZONE    2
-#define SAFE_ZONE       1
-
-#define GET_ZONE(trip) (trip + 2)
-#define GET_TRIP(zone) (zone - 2)
-
-enum trigger_type {
-	THROTTLE_ACTIVE = 1,
-	THROTTLE_PASSIVE,
-	SW_TRIP,
-	HW_TRIP,
-};
-
-/**
- * struct freq_clip_table
- * @freq_clip_max: maximum frequency allowed for this cooling state.
- * @temp_level: Temperature level at which the temperature clipping will
- *	happen.
- * @mask_val: cpumask of the allowed cpu's where the clipping will take place.
- *
- * This structure is required to be filled and passed to the
- * cpufreq_cooling_unregister function.
- */
-struct freq_clip_table {
-	unsigned int freq_clip_max;
-	unsigned int temp_level;
-	const struct cpumask *mask_val;
-};
-
-struct	thermal_trip_point_conf {
-	int trip_val[MAX_TRIP_COUNT];
-	int trip_type[MAX_TRIP_COUNT];
-	int trip_count;
-	unsigned char trigger_falling;
-};
-
-struct	thermal_cooling_conf {
-	struct freq_clip_table freq_data[MAX_TRIP_COUNT];
-	int freq_clip_count;
-};
-
-struct thermal_sensor_conf {
-	char name[SENSOR_NAME_LEN];
-	int (*read_temperature)(void *data);
-	int (*write_emul_temp)(void *drv_data, unsigned long temp);
-	struct thermal_trip_point_conf trip_data;
-	struct thermal_cooling_conf cooling_data;
-	void *driver_data;
-	void *pzone_data;
-	struct device *dev;
-};
-
-/*Functions used exynos based thermal sensor driver*/
-#ifdef CONFIG_EXYNOS_THERMAL_CORE
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf);
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf);
-void exynos_report_trigger(struct thermal_sensor_conf *sensor_conf);
-#else
-static inline void
-exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf) { return; }
-
-static inline int
-exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) { return 0; }
-
-static inline void
-exynos_report_trigger(struct thermal_sensor_conf *sensor_conf) { return; }
-
-#endif /* CONFIG_EXYNOS_THERMAL_CORE */
-#endif /* _EXYNOS_THERMAL_COMMON_H */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 17/18] thermal: exynos: Remove exynos_tmu_data.c file
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (15 preceding siblings ...)
  2015-01-19 11:21   ` [PATCH v5 16/18] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
@ 2015-01-19 11:21   ` Lukasz Majewski
  2015-01-19 11:21   ` [PATCH v5 18/18] thermal: exynos: Remove not needed exynos_tmu_init_data declarations from exynos_tmu.h Lukasz Majewski
                     ` (3 subsequent siblings)
  20 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:21 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

Data already present in the exynos_tmu_data.c file has been moved to the
appropriate device tree files.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
---
 drivers/thermal/samsung/exynos_tmu_data.c | 228 ------------------------------
 1 file changed, 228 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c

diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
deleted file mode 100644
index a993f3d..0000000
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * exynos_tmu_data.c - Samsung EXYNOS tmu data file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include "exynos_thermal_common.h"
-#include "exynos_tmu.h"
-
-struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
-	.tmu_data = {
-		{
-		.threshold = 80,
-		.trigger_levels[0] = 5,
-		.trigger_levels[1] = 20,
-		.trigger_levels[2] = 30,
-		.trigger_enable[0] = true,
-		.trigger_enable[1] = true,
-		.trigger_enable[2] = true,
-		.trigger_enable[3] = false,
-		.trigger_type[0] = THROTTLE_ACTIVE,
-		.trigger_type[1] = THROTTLE_ACTIVE,
-		.trigger_type[2] = SW_TRIP,
-		.max_trigger_level = 4,
-		.non_hw_trigger_levels = 3,
-		.gain = 15,
-		.reference_voltage = 7,
-		.cal_type = TYPE_ONE_POINT_TRIMMING,
-		.min_efuse_value = 40,
-		.max_efuse_value = 100,
-		.first_point_trim = 25,
-		.second_point_trim = 85,
-		.default_temp_offset = 50,
-		.type = SOC_ARCH_EXYNOS4210,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS3250_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_TWO_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS3250_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS3250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS4412_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS4412,
-		},
-	},
-	.tmu_count = 1,
-};
-
-struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS5250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define __EXYNOS5260_TMU_DATA	\
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 85, \
-	.trigger_levels[1] = 103, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50,
-
-#define EXYNOS5260_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5260
-
-struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5420_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420
-
-#define EXYNOS5420_TMU_DATA_SHARED \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420_TRIMINFO
-
-struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5440_TMU_DATA \
-	.trigger_levels[0] = 100, \
-	.trigger_levels[4] = 105, \
-	.trigger_enable[0] = 1, \
-	.trigger_type[0] = SW_TRIP, \
-	.trigger_type[4] = HW_TRIP, \
-	.max_trigger_level = 5, \
-	.non_hw_trigger_levels = 1, \
-	.gain = 5, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 0x5b2d, \
-	.min_efuse_value = 16, \
-	.max_efuse_value = 76, \
-	.first_point_trim = 25, \
-	.second_point_trim = 70, \
-	.default_temp_offset = 25, \
-	.type = SOC_ARCH_EXYNOS5440
-
-struct exynos_tmu_init_data const exynos5440_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-	},
-	.tmu_count = 3,
-};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v5 18/18] thermal: exynos: Remove not needed exynos_tmu_init_data declarations from exynos_tmu.h
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (16 preceding siblings ...)
  2015-01-19 11:21   ` [PATCH v5 17/18] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
@ 2015-01-19 11:21   ` Lukasz Majewski
  2015-01-21  3:30     ` Eduardo Valentin
  2015-01-21  1:55   ` [PATCH v5 00/18] thermal: exynos: Thermal code rework to use device tree Eduardo Valentin
                     ` (2 subsequent siblings)
  20 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-19 11:21 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi, Lukasz Majewski

After switching to device tree based configuration those declarations are
not needed anymore.

Reported-by: Abhilash Kesavan <a.kesavan@samsung.com>
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v5:
- New patch
---
 drivers/thermal/samsung/exynos_tmu.h | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index d876d4c..9f9b1b8 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -71,12 +71,4 @@ struct exynos_tmu_platform_data {
 	u32 cal_mode;
 };
 
-extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5250_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5260_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5420_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5440_default_tmu_data;
-
 #endif /* _EXYNOS_TMU_H */
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 00/16] thermal: exynos: Thermal code rework to use device tree
  2015-01-16  8:29     ` Lukasz Majewski
@ 2015-01-19 23:29       ` Tobias Jakobi
  2015-01-20  8:17         ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Tobias Jakobi @ 2015-01-19 23:29 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim,
	Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Thomas Abraham, tomasz.figa

Hello!

Lukasz Majewski wrote:
> We all know that this code is floating around - early version of this
> work was posted in the Q3 2013.
> 
> To be fair - this code is both needed and welcome, but new problems
> with it are found (please search for recent comment from Kevin
> Hilman).
> 
> From my side, I focus on the code which is in Eduardo Valentin's next
> (3.19-rc3), since I don't know when and if eventually cpufreq rework
> would be merged.
I'm sorry, my wording wasn't the best here. I'm not critizing the work
done here, merely voicing my concern (and also interest!) about how the
new stuff interacts with code that may eventually get merged.
You're aware of it, that's enough for me to know.


> The code which touches exynos-cpufreq.c is around 30 LOC, only for
> preserving cpu cooling functionality.
> 
> Is it worth to wait for code developed for so long to happily apply 30
> LOC and delay removal of around 400 LOC in other subsystem (thermal)?
No, of course not. That was pretty stupid of me :(


> I rise my hand as a volunteer to fix any thermal related issues which
> show up after cpufreq rework code applying to Exynos.
That's certainly good to hear!


> This series is NOT providing any NEW functionality. It in fact
> preserves functionality, which allows using CPU frequency as a mean to
> cool the device.
I've got a question concerning this. Is this only needed for
exynos-cpufreq, or does cpufreq-dt also need something like that.

The point is that I'm still working with a rather old version of the
cpufreq series, a version which still had the Exynos4x12 code in it
(this was removed later, if I remember correctly because of problems
with how to properly describe boost configuration in DT).


Anyway, to not get completly off-topic here, I noticed some small issue
with v3 of the thermal series. I've enabled CONFIG_THERMAL_HWMON so that
I can use lm_sensors to query temperature of the board. However while
the thermal_zone is created, there is no hwmon node to be found. This
was working properly without the thermal series.


With best wishes,
Tobias


^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 00/16] thermal: exynos: Thermal code rework to use device tree
  2015-01-19 23:29       ` Tobias Jakobi
@ 2015-01-20  8:17         ` Lukasz Majewski
  2015-01-22  1:06           ` Tobias Jakobi
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-20  8:17 UTC (permalink / raw)
  To: Tobias Jakobi
  Cc: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim,
	Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Thomas Abraham, tomasz.figa

Hi Tobias,

> Hello!
> 
> Lukasz Majewski wrote:
> > We all know that this code is floating around - early version of
> > this work was posted in the Q3 2013.
> > 
> > To be fair - this code is both needed and welcome, but new problems
> > with it are found (please search for recent comment from Kevin
> > Hilman).
> > 
> > From my side, I focus on the code which is in Eduardo Valentin's
> > next (3.19-rc3), since I don't know when and if eventually cpufreq
> > rework would be merged.
> I'm sorry, my wording wasn't the best here. I'm not critizing the work
> done here, merely voicing my concern (and also interest!) about how
> the new stuff interacts with code that may eventually get merged.
> You're aware of it, that's enough for me to know.

I'm aware of Thomas work and probably will integrate it when finally it
is merged.

> 
> 
> > The code which touches exynos-cpufreq.c is around 30 LOC, only for
> > preserving cpu cooling functionality.
> > 
> > Is it worth to wait for code developed for so long to happily apply
> > 30 LOC and delay removal of around 400 LOC in other subsystem
> > (thermal)?
> No, of course not. That was pretty stupid of me :(
> 
> 
> > I rise my hand as a volunteer to fix any thermal related issues
> > which show up after cpufreq rework code applying to Exynos.
> That's certainly good to hear!
> 
> 
> > This series is NOT providing any NEW functionality. It in fact
> > preserves functionality, which allows using CPU frequency as a mean
> > to cool the device.
> I've got a question concerning this. Is this only needed for
> exynos-cpufreq, or does cpufreq-dt also need something like that.

In the __cpufreq_add_dev() you have cpufreq_driver->ready() callback
which in the cpufreq-dt.c has call to of_cpufreq_cooling_register().

It seems like cpufreq-dt is ready for handling cpu cooling devices.

> 
> The point is that I'm still working with a rather old version of the
> cpufreq series, a version which still had the Exynos4x12 code in it
> (this was removed later, if I remember correctly because of problems
> with how to properly describe boost configuration in DT).

Is your board Odroid-U3/Trats2 ?

> 
> 
> Anyway, to not get completly off-topic here, I noticed some small
> issue with v3 of the thermal series. I've enabled
> CONFIG_THERMAL_HWMON so that I can use lm_sensors to query
> temperature of the board. However while the thermal_zone is created,
> there is no hwmon node to be found. 

I'm not surprised, that some use cases (about which I wasn't even
aware) show up. 
I've already fixed issues reported by Abhilash (with v5 and a following
patch) and look closer into the THERMAL_HWMON.

I've also done some work regarding FAN controlled by hwmon for Odroid
U3.
Could you look on following series:
http://www.spinics.net/lists/linux-samsung-soc/msg40471.html

I can only guess that your board might need similar entries for your
DTS file(s).

> This was working properly without
> the thermal series.

Thanks for testing the patch set :-)

> 
> 
> With best wishes,
> Tobias
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-15 15:17       ` Lukasz Majewski
@ 2015-01-21  1:23         ` Eduardo Valentin
  2015-01-21  8:10           ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-21  1:23 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Kyungmin Park,
	Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 31180 bytes --]

On Thu, Jan 15, 2015 at 04:17:52PM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > On Wed, Jan 14, 2015 at 02:41:12PM +0100, Lukasz Majewski wrote:
> > > This patch brings support for providing configuration via device
> > > tree. Previously this data has been hardcoded in the
> > > exynos_tmu_data.c file. Such approach was not scalable and very
> > > often required copying the whole data.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > > Changes for v2:
> > > - Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
> > > - Usage of of-thermal.c exported trip points table
> > > Changes for v3:
> > > - Adding exynos_of_get_soc_type() method to set SOC type from
> > > device's compatible string
> > > - "samsung,tmu_" prefix for TMU specific properties has been added
> > > 
> > > ---
> > >  drivers/thermal/samsung/Makefile     |   2 -
> > >  drivers/thermal/samsung/exynos_tmu.c | 345
> > > +++++++++++++++++++++++------------
> > > drivers/thermal/samsung/exynos_tmu.h |  53 +----- 3 files changed,
> > > 226 insertions(+), 174 deletions(-)
> > > 
> > > diff --git a/drivers/thermal/samsung/Makefile
> > > b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644
> > > --- a/drivers/thermal/samsung/Makefile
> > > +++ b/drivers/thermal/samsung/Makefile
> > > @@ -3,5 +3,3 @@
> > >  #
> > >  obj-$(CONFIG_EXYNOS_THERMAL)			+=
> > > exynos_thermal.o exynos_thermal-y				:=
> > > exynos_tmu.o -exynos_thermal-y				+=
> > > exynos_tmu_data.o
> > 
> > Can this makefile change be part of the patch that removes
> > exynos_tmu_data.c?
> > 
> > > -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+=
> > > exynos_thermal_common.o
> > 
> > Can this makefile change be part of the patch that removes
> > exynos_thermal_common.c?
> 
> Unfortunately, this code cannot be moved to the next patch, in which I
> remove the files, since this causes build break of the series.
> 
> The code structure as is, provides working, bisectable thermal
> solution - thermal and cpu_cooling functionality is preserved across
> all commits in the series.

My concern here is simply that this specific commit is leaving unused files in the tree.

One option would be to remove the files altogether in this specific
commit.

> 
> > 
> > > diff --git a/drivers/thermal/samsung/exynos_tmu.c
> > > b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..633a9e2 100644
> > > --- a/drivers/thermal/samsung/exynos_tmu.c
> > > +++ b/drivers/thermal/samsung/exynos_tmu.c
> > > @@ -1,6 +1,10 @@
> > >  /*
> > >   * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
> > >   *
> > > + *  Copyright (C) 2014 Samsung Electronics
> > > + *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> > > + *  Lukasz Majewski <l.majewski@samsung.com>
> > > + *
> > >   *  Copyright (C) 2011 Samsung Electronics
> > >   *  Donggeun Kim <dg77.kim@samsung.com>
> > >   *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
> > > @@ -31,8 +35,8 @@
> > >  #include <linux/platform_device.h>
> > >  #include <linux/regulator/consumer.h>
> > >  
> > > -#include "exynos_thermal_common.h"
> > >  #include "exynos_tmu.h"
> > > +#include "../thermal_core.h"
> > >  
> > >  /* Exynos generic registers */
> > >  #define EXYNOS_TMU_REG_TRIMINFO		0x0
> > > @@ -115,6 +119,7 @@
> > >  #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
> > >  #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
> > >  
> > > +#define MCELSIUS	1000
> > >  /**
> > >   * struct exynos_tmu_data : A structure to hold the private data
> > > of the TMU driver
> > > @@ -150,7 +155,8 @@ struct exynos_tmu_data {
> > >  	struct clk *clk, *clk_sec;
> > >  	u8 temp_error1, temp_error2;
> > >  	struct regulator *regulator;
> > > -	struct thermal_sensor_conf *reg_conf;
> > > +	struct thermal_zone_device *tzd;
> > > +
> > >  	int (*tmu_initialize)(struct platform_device *pdev);
> > >  	void (*tmu_control)(struct platform_device *pdev, bool on);
> > >  	int (*tmu_read)(struct exynos_tmu_data *data);
> > > @@ -159,6 +165,33 @@ struct exynos_tmu_data {
> > >  	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
> > >  };
> > >  
> > > +static void exynos_report_trigger(struct exynos_tmu_data *p)
> > > +{
> > > +	char data[10], *envp[] = { data, NULL };
> > > +	struct thermal_zone_device *tz = p->tzd;
> > > +	unsigned long temp;
> > > +	unsigned int i;
> > > +
> > > +	if (!p) {
> > > +		pr_err("Wrong temperature configuration data\n");
> > > +		return;
> > > +	}
> > > +
> > > +	thermal_zone_device_update(tz);
> > > +
> > > +	mutex_lock(&tz->lock);
> > > +	/* Find the level for which trip happened */
> > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > +		tz->ops->get_trip_temp(tz, i, &temp);
> > > +		if (tz->last_temperature < temp)
> > > +			break;
> > > +	}
> > > +
> > > +	snprintf(data, sizeof(data), "%u", i);
> > > +	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
> > > +	mutex_unlock(&tz->lock);
> > > +}
> > > +
> > >  /*
> > >   * TMU treats temperature as a mapped temperature code.
> > >   * The temperature is converted differently depending on the
> > > calibration type. @@ -234,14 +267,25 @@ static void
> > > sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info) 
> > >  static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold,
> > > bool falling) {
> > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > +	struct thermal_zone_device *tz = data->tzd;
> > > +	const struct thermal_trip * const trips =
> > > +		of_thermal_get_trip_points(tz);
> > > +	unsigned long temp;
> > >  	int i;
> > >  
> > > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
> > > -		u8 temp = pdata->trigger_levels[i];
> > > +	if (!trips) {
> > > +		pr_err("%s: Cannot get trip points from
> > > of-thermal.c!\n",
> > > +		       __func__);
> > > +		return 0;
> > > +	}
> > > +
> > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > +		if (trips[i].type == THERMAL_TRIP_CRITICAL)
> > > +			continue;
> > >  
> > > +		temp = trips[i].temperature / MCELSIUS;
> > >  		if (falling)
> > > -			temp -= pdata->threshold_falling;
> > > +			temp -= (trips[i].hysteresis / MCELSIUS);
> > >  		else
> > >  			threshold &= ~(0xff << 8 * i);
> > >  
> > > @@ -305,9 +349,19 @@ static void exynos_tmu_control(struct
> > > platform_device *pdev, bool on) static int
> > > exynos4210_tmu_initialize(struct platform_device *pdev) {
> > >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > -	unsigned int status;
> > > +	struct thermal_zone_device *tz = data->tzd;
> > > +	const struct thermal_trip * const trips =
> > > +		of_thermal_get_trip_points(tz);
> > >  	int ret = 0, threshold_code, i;
> > > +	unsigned long reference, temp;
> > > +	unsigned int status;
> > > +
> > > +	if (!trips) {
> > > +		pr_err("%s: Cannot get trip points from
> > > of-thermal.c!\n",
> > > +		       __func__);
> > > +		ret = -ENODEV;
> > > +		goto out;
> > > +	}
> > >  
> > >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> > >  	if (!status) {
> > > @@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct
> > > platform_device *pdev) sanitize_temp_error(data, readl(data->base +
> > > EXYNOS_TMU_REG_TRIMINFO)); 
> > >  	/* Write temperature code for threshold */
> > > -	threshold_code = temp_to_code(data, pdata->threshold);
> > > +	reference = trips[0].temperature / MCELSIUS;
> > > +	threshold_code = temp_to_code(data, reference);
> > > +	if (threshold_code < 0) {
> > > +		ret = threshold_code;
> > > +		goto out;
> > > +	}
> > >  	writeb(threshold_code, data->base +
> > > EXYNOS4210_TMU_REG_THRESHOLD_TEMP); 
> > > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
> > > -		writeb(pdata->trigger_levels[i], data->base +
> > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > +		temp = trips[i].temperature / MCELSIUS;
> > > +		writeb(temp - reference, data->base +
> > >  		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
> > > +	}
> > >  
> > >  	data->tmu_clear_irqs(data);
> > >  out:
> > > @@ -333,9 +394,11 @@ out:
> > >  static int exynos4412_tmu_initialize(struct platform_device *pdev)
> > >  {
> > >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > +	const struct thermal_trip * const trips =
> > > +		of_thermal_get_trip_points(data->tzd);
> > >  	unsigned int status, trim_info, con, ctrl,
> > > rising_threshold; int ret = 0, threshold_code, i;
> > > +	unsigned long crit_temp = 0;
> > >  
> > >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> > >  	if (!status) {
> > > @@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct
> > > platform_device *pdev) data->tmu_clear_irqs(data);
> > >  
> > >  	/* if last threshold limit is also present */
> > > -	i = pdata->max_trigger_level - 1;
> > > -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==
> > > HW_TRIP) {
> > > -		threshold_code = temp_to_code(data,
> > > pdata->trigger_levels[i]);
> > > -		/* 1-4 level to be assigned in th0 reg */
> > > -		rising_threshold &= ~(0xff << 8 * i);
> > > -		rising_threshold |= threshold_code << 8 * i;
> > > -		writel(rising_threshold, data->base +
> > > EXYNOS_THD_TEMP_RISE);
> > > -		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> > > -		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > > -		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> > > +	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
> > > +		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
> > > +			crit_temp = trips[i].temperature;
> > > +			break;
> > > +		}
> > >  	}
> > > +
> > > +	if (i == of_thermal_get_ntrips(data->tzd)) {
> > > +		pr_err("%s: No CRITICAL trip point defined at
> > > of-thermal.c!\n",
> > > +		       __func__);
> > > +		ret = -EINVAL;
> > > +		goto out;
> > > +	}
> > > +
> > > +	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
> > > +	/* 1-4 level to be assigned in th0 reg */
> > > +	rising_threshold &= ~(0xff << 8 * i);
> > > +	rising_threshold |= threshold_code << 8 * i;
> > > +	writel(rising_threshold, data->base +
> > > EXYNOS_THD_TEMP_RISE);
> > > +	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> > > +	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > > +	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> > > +
> > >  out:
> > >  	return ret;
> > >  }
> > > @@ -391,9 +466,9 @@ out:
> > >  static int exynos5440_tmu_initialize(struct platform_device *pdev)
> > >  {
> > >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > >  	unsigned int trim_info = 0, con, rising_threshold;
> > > -	int ret = 0, threshold_code, i;
> > > +	int ret = 0, threshold_code;
> > > +	unsigned long crit_temp = 0;
> > >  
> > >  	/*
> > >  	 * For exynos5440 soc triminfo value is swapped between
> > > TMU0 and @@ -422,9 +497,8 @@ static int
> > > exynos5440_tmu_initialize(struct platform_device *pdev)
> > > data->tmu_clear_irqs(data); 
> > >  	/* if last threshold limit is also present */
> > > -	i = pdata->max_trigger_level - 1;
> > > -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==
> > > HW_TRIP) {
> > > -		threshold_code = temp_to_code(data,
> > > pdata->trigger_levels[i]);
> > > +	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp))
> > > {
> > > +		threshold_code = temp_to_code(data, crit_temp /
> > > MCELSIUS); /* 5th level to be assigned in th2 reg */
> > >  		rising_threshold =
> > >  			threshold_code <<
> > > EXYNOS5440_TMU_TH_RISE4_SHIFT; @@ -442,7 +516,7 @@ static int
> > > exynos5440_tmu_initialize(struct platform_device *pdev) static void
> > > exynos4210_tmu_control(struct platform_device *pdev, bool on) {
> > >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > +	struct thermal_zone_device *tz = data->tzd;
> > >  	unsigned int con, interrupt_en;
> > >  
> > >  	con = get_con_reg(data, readl(data->base +
> > > EXYNOS_TMU_REG_CONTROL)); @@ -450,10 +524,15 @@ static void
> > > exynos4210_tmu_control(struct platform_device *pdev, bool on) if
> > > (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > >  		interrupt_en =
> > > -			pdata->trigger_enable[3] <<
> > > EXYNOS_TMU_INTEN_RISE3_SHIFT |
> > > -			pdata->trigger_enable[2] <<
> > > EXYNOS_TMU_INTEN_RISE2_SHIFT |
> > > -			pdata->trigger_enable[1] <<
> > > EXYNOS_TMU_INTEN_RISE1_SHIFT |
> > > -			pdata->trigger_enable[0] <<
> > > EXYNOS_TMU_INTEN_RISE0_SHIFT;
> > > +			(of_thermal_is_trip_valid(tz, 3)
> > > +			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
> > > +			(of_thermal_is_trip_valid(tz, 2)
> > > +			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
> > > +			(of_thermal_is_trip_valid(tz, 1)
> > > +			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
> > > +			(of_thermal_is_trip_valid(tz, 0)
> > > +			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
> > > +
> > >  		if (data->soc != SOC_ARCH_EXYNOS4210)
> > >  			interrupt_en |=
> > >  				interrupt_en <<
> > > EXYNOS_TMU_INTEN_FALL0_SHIFT; @@ -468,7 +547,7 @@ static void
> > > exynos4210_tmu_control(struct platform_device *pdev, bool on)
> > > static void exynos5440_tmu_control(struct platform_device *pdev,
> > > bool on) { struct exynos_tmu_data *data =
> > > platform_get_drvdata(pdev);
> > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > +	struct thermal_zone_device *tz = data->tzd;
> > >  	unsigned int con, interrupt_en;
> > >  
> > >  	con = get_con_reg(data, readl(data->base +
> > > EXYNOS5440_TMU_S0_7_CTRL)); @@ -476,11 +555,16 @@ static void
> > > exynos5440_tmu_control(struct platform_device *pdev, bool on) if
> > > (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > >  		interrupt_en =
> > > -			pdata->trigger_enable[3] <<
> > > EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
> > > -			pdata->trigger_enable[2] <<
> > > EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
> > > -			pdata->trigger_enable[1] <<
> > > EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
> > > -			pdata->trigger_enable[0] <<
> > > EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
> > > -		interrupt_en |= interrupt_en <<
> > > EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
> > > +			(of_thermal_is_trip_valid(tz, 3)
> > > +			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
> > > +			(of_thermal_is_trip_valid(tz, 2)
> > > +			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
> > > +			(of_thermal_is_trip_valid(tz, 1)
> > > +			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
> > > +			(of_thermal_is_trip_valid(tz, 0)
> > > +			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
> > > +		interrupt_en |=
> > > +			interrupt_en <<
> > > EXYNOS5440_TMU_INTEN_FALL0_SHIFT; } else {
> > >  		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > >  		interrupt_en = 0; /* Disable all interrupts */
> > > @@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct
> > > platform_device *pdev, bool on) writel(con, data->base +
> > > EXYNOS5440_TMU_S0_7_CTRL); }
> > >  
> > > -static int exynos_tmu_read(struct exynos_tmu_data *data)
> > > +int exynos_get_temp(void *p, long *temp)
> > >  {
> > > -	int ret;
> > > +	struct exynos_tmu_data *data = p;
> > > +
> > > +	if (!data)
> > > +		return -EINVAL;
> > >  
> > >  	mutex_lock(&data->lock);
> > >  	clk_enable(data->clk);
> > > -	ret = data->tmu_read(data);
> > > -	if (ret >= 0)
> > > -		ret = code_to_temp(data, ret);
> > > +
> > > +	*temp = code_to_temp(data, data->tmu_read(data)) *
> > > MCELSIUS; +
> > >  	clk_disable(data->clk);
> > >  	mutex_unlock(&data->lock);
> > >  
> > > -	return ret;
> > > +	return 0;
> > >  }
> > >  
> > >  #ifdef CONFIG_THERMAL_EMULATION
> > > @@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct
> > > *work) if (!IS_ERR(data->clk_sec))
> > >  		clk_disable(data->clk_sec);
> > >  
> > > -	exynos_report_trigger(data->reg_conf);
> > > +	exynos_report_trigger(data);
> > >  	mutex_lock(&data->lock);
> > >  	clk_enable(data->clk);
> > >  
> > > @@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq,
> > > void *id) static const struct of_device_id exynos_tmu_match[] = {
> > >  	{
> > >  		.compatible = "samsung,exynos3250-tmu",
> > > -		.data = &exynos3250_default_tmu_data,
> > >  	},
> > >  	{
> > >  		.compatible = "samsung,exynos4210-tmu",
> > > -		.data = &exynos4210_default_tmu_data,
> > >  	},
> > >  	{
> > >  		.compatible = "samsung,exynos4412-tmu",
> > > -		.data = &exynos4412_default_tmu_data,
> > >  	},
> > >  	{
> > >  		.compatible = "samsung,exynos5250-tmu",
> > > -		.data = &exynos5250_default_tmu_data,
> > >  	},
> > >  	{
> > >  		.compatible = "samsung,exynos5260-tmu",
> > > -		.data = &exynos5260_default_tmu_data,
> > >  	},
> > >  	{
> > >  		.compatible = "samsung,exynos5420-tmu",
> > > -		.data = &exynos5420_default_tmu_data,
> > >  	},
> > >  	{
> > >  		.compatible =
> > > "samsung,exynos5420-tmu-ext-triminfo",
> > > -		.data = &exynos5420_default_tmu_data,
> > >  	},
> > >  	{
> > >  		.compatible = "samsung,exynos5440-tmu",
> > > -		.data = &exynos5440_default_tmu_data,
> > >  	},
> > >  	{},
> > >  };
> > >  MODULE_DEVICE_TABLE(of, exynos_tmu_match);
> > >  
> > > -static inline struct  exynos_tmu_platform_data
> > > *exynos_get_driver_data(
> > > -			struct platform_device *pdev, int id)
> > > +static int exynos_of_get_soc_type(struct device_node *np)
> > >  {
> > > -	struct  exynos_tmu_init_data *data_table;
> > > -	struct exynos_tmu_platform_data *tmu_data;
> > > -	const struct of_device_id *match;
> > > +	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
> > > +		return SOC_ARCH_EXYNOS3250;
> > > +	else if (of_device_is_compatible(np,
> > > "samsung,exynos4210-tmu"))
> > > +		return SOC_ARCH_EXYNOS4210;
> > > +	else if (of_device_is_compatible(np,
> > > "samsung,exynos4412-tmu"))
> > > +		return SOC_ARCH_EXYNOS4412;
> > > +	else if (of_device_is_compatible(np,
> > > "samsung,exynos5250-tmu"))
> > > +		return SOC_ARCH_EXYNOS5250;
> > > +	else if (of_device_is_compatible(np,
> > > "samsung,exynos5260-tmu"))
> > > +		return SOC_ARCH_EXYNOS5260;
> > > +	else if (of_device_is_compatible(np,
> > > "samsung,exynos5420-tmu"))
> > > +		return SOC_ARCH_EXYNOS5420;
> > > +	else if (of_device_is_compatible(np,
> > > +
> > > "samsung,exynos5420-tmu-ext-triminfo"))
> > > +		return SOC_ARCH_EXYNOS5420_TRIMINFO;
> > > +	else if (of_device_is_compatible(np,
> > > "samsung,exynos5440-tmu"))
> > > +		return SOC_ARCH_EXYNOS5440;
> > > +
> > > +	return -EINVAL;
> > > +}
> > >  
> > > -	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
> > > -	if (!match)
> > > -		return NULL;
> > > -	data_table = (struct exynos_tmu_init_data *) match->data;
> > > -	if (!data_table || id >= data_table->tmu_count)
> > > -		return NULL;
> > > -	tmu_data = data_table->tmu_data;
> > > -	return (struct exynos_tmu_platform_data *) (tmu_data + id);
> > > +static int exynos_of_sensor_conf(struct device_node *np,
> > > +				 struct exynos_tmu_platform_data
> > > *pdata) +{
> > > +	u32 value;
> > > +	int ret;
> > > +
> > > +	of_node_get(np);
> > > +
> > > +	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
> > > +	pdata->gain = (u8) value;
> > > +	of_property_read_u32(np, "samsung,tmu_reference_voltage",
> > > &value);
> > > +	pdata->reference_voltage = (u8) value;
> > > +	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode",
> > > &value);
> > > +	pdata->noise_cancel_mode = (u8) value;
> > > +
> > > +	of_property_read_u32(np, "samsung,tmu_efuse_value",
> > > +			     &pdata->efuse_value);
> > > +	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
> > > +			     &pdata->min_efuse_value);
> > > +	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
> > > +			     &pdata->max_efuse_value);
> > > +
> > > +	of_property_read_u32(np, "samsung,tmu_first_point_trim",
> > > &value);
> > > +	pdata->first_point_trim = (u8) value;
> > > +	of_property_read_u32(np, "samsung,tmu_second_point_trim",
> > > &value);
> > > +	pdata->second_point_trim = (u8) value;
> > > +	of_property_read_u32(np,
> > > "samsung,tmu_default_temp_offset", &value);
> > > +	pdata->default_temp_offset = (u8) value;
> > > +
> > > +	of_property_read_u32(np, "samsung,tmu_cal_type",
> > > &pdata->cal_type);
> > > +	of_property_read_u32(np, "samsung,tmu_cal_mode",
> > > &pdata->cal_mode); +
> > > +	of_node_put(np);
> > > +	return 0;
> > >  }
> > >  
> > >  static int exynos_map_dt_data(struct platform_device *pdev)
> > > @@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct
> > > platform_device *pdev) return -EADDRNOTAVAIL;
> > >  	}
> > >  
> > > -	pdata = exynos_get_driver_data(pdev, data->id);
> > > -	if (!pdata) {
> > > -		dev_err(&pdev->dev, "No platform init data
> > > supplied.\n");
> > > -		return -ENODEV;
> > > -	}
> > > +	pdata = devm_kzalloc(&pdev->dev,
> > > +			     sizeof(struct
> > > exynos_tmu_platform_data),
> > > +			     GFP_KERNEL);
> > > +	if (!pdata)
> > > +		return -ENOMEM;
> > >  
> > > +	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
> > >  	data->pdata = pdata;
> > > -	data->soc = pdata->type;
> > > +	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
> > >  
> > >  	switch (data->soc) {
> > >  	case SOC_ARCH_EXYNOS4210:
> > > @@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct
> > > platform_device *pdev) return 0;
> > >  }
> > >  
> > > +static struct thermal_zone_of_device_ops exynos_sensor_ops = {
> > > +	.get_temp = exynos_get_temp,
> > > +	.set_emul_temp = exynos_tmu_set_emulation,
> > > +};
> > > +
> > >  static int exynos_tmu_probe(struct platform_device *pdev)
> > >  {
> > > -	struct exynos_tmu_data *data;
> > >  	struct exynos_tmu_platform_data *pdata;
> > > -	struct thermal_sensor_conf *sensor_conf;
> > > -	int ret, i;
> > > +	struct exynos_tmu_data *data;
> > > +	int ret;
> > >  
> > >  	data = devm_kzalloc(&pdev->dev, sizeof(struct
> > > exynos_tmu_data), GFP_KERNEL);
> > > @@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct
> > > platform_device *pdev) platform_set_drvdata(pdev, data);
> > >  	mutex_init(&data->lock);
> > >  
> > > +	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0,
> > > data,
> > > +
> > > &exynos_sensor_ops);
> > > +	if (IS_ERR(data->tzd)) {
> > > +		pr_err("thermal: tz: %p ERROR\n", data->tzd);
> > > +		return PTR_ERR(data->tzd);
> > > +	}
> > >  	ret = exynos_map_dt_data(pdev);
> > >  	if (ret)
> > > -		return ret;
> > > +		goto err_sensor;
> > >  
> > >  	pdata = data->pdata;
> > >  
> > > @@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct
> > > platform_device *pdev) data->clk = devm_clk_get(&pdev->dev,
> > > "tmu_apbif"); if (IS_ERR(data->clk)) {
> > >  		dev_err(&pdev->dev, "Failed to get clock\n");
> > > -		return  PTR_ERR(data->clk);
> > > +		ret = PTR_ERR(data->clk);
> > > +		goto err_sensor;
> > >  	}
> > >  
> > >  	data->clk_sec = devm_clk_get(&pdev->dev,
> > > "tmu_triminfo_apbif"); if (IS_ERR(data->clk_sec)) {
> > >  		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
> > >  			dev_err(&pdev->dev, "Failed to get
> > > triminfo clock\n");
> > > -			return PTR_ERR(data->clk_sec);
> > > +			ret = PTR_ERR(data->clk_sec);
> > > +			goto err_sensor;
> > >  		}
> > >  	} else {
> > >  		ret = clk_prepare(data->clk_sec);
> > >  		if (ret) {
> > >  			dev_err(&pdev->dev, "Failed to get
> > > clock\n");
> > > -			return ret;
> > > +			goto err_sensor;
> > >  		}
> > >  	}
> > >  
> > > @@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct
> > > platform_device *pdev) goto err_clk;
> > >  	}
> > >  
> > > -	exynos_tmu_control(pdev, true);
> > > -
> > > -	/* Allocate a structure to register with the exynos core
> > > thermal */
> > > -	sensor_conf = devm_kzalloc(&pdev->dev,
> > > -				sizeof(struct
> > > thermal_sensor_conf), GFP_KERNEL);
> > > -	if (!sensor_conf) {
> > > -		ret = -ENOMEM;
> > > -		goto err_clk;
> > > -	}
> > > -	sprintf(sensor_conf->name, "therm_zone%d", data->id);
> > > -	sensor_conf->read_temperature = (int (*)(void
> > > *))exynos_tmu_read;
> > > -	sensor_conf->write_emul_temp =
> > > -		(int (*)(void *, unsigned
> > > long))exynos_tmu_set_emulation;
> > > -	sensor_conf->driver_data = data;
> > > -	sensor_conf->trip_data.trip_count =
> > > pdata->trigger_enable[0] +
> > > -			pdata->trigger_enable[1] +
> > > pdata->trigger_enable[2]+
> > > -			pdata->trigger_enable[3];
> > > -
> > > -	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
> > > -		sensor_conf->trip_data.trip_val[i] =
> > > -			pdata->threshold +
> > > pdata->trigger_levels[i];
> > > -		sensor_conf->trip_data.trip_type[i] =
> > > -					pdata->trigger_type[i];
> > > -	}
> > > -
> > > -	sensor_conf->trip_data.trigger_falling =
> > > pdata->threshold_falling; -
> > > -	sensor_conf->dev = &pdev->dev;
> > > -	/* Register the sensor with thermal management interface */
> > > -	ret = exynos_register_thermal(sensor_conf);
> > > -	if (ret) {
> > > -		if (ret != -EPROBE_DEFER)
> > > -			dev_err(&pdev->dev,
> > > -				"Failed to register thermal
> > > interface: %d\n",
> > > -				ret);
> > > -		goto err_clk;
> > > -	}
> > > -	data->reg_conf = sensor_conf;
> > > -
> > >  	ret = devm_request_irq(&pdev->dev, data->irq,
> > > exynos_tmu_irq, IRQF_TRIGGER_RISING | IRQF_SHARED,
> > > dev_name(&pdev->dev), data); if (ret) {
> > > @@ -935,21 +1030,31 @@ static int exynos_tmu_probe(struct
> > > platform_device *pdev) goto err_clk;
> > >  	}
> > >  
> > > +	ret = exynos_tmu_initialize(pdev);
> > > +	if (ret) {
> > > +		dev_err(&pdev->dev, "Failed to initialize TMU\n");
> > > +		goto err_clk;
> > > +	}
> > > +	exynos_tmu_control(pdev, true);
> > >  	return 0;
> > > +
> > >  err_clk:
> > >  	clk_unprepare(data->clk);
> > >  err_clk_sec:
> > >  	if (!IS_ERR(data->clk_sec))
> > >  		clk_unprepare(data->clk_sec);
> > > +err_sensor:
> > > +	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
> > > +
> > >  	return ret;
> > >  }
> > >  
> > >  static int exynos_tmu_remove(struct platform_device *pdev)
> > >  {
> > >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > > +	struct thermal_zone_device *tzd = data->tzd;
> > >  
> > > -	exynos_unregister_thermal(data->reg_conf);
> > > -
> > > +	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
> > >  	exynos_tmu_control(pdev, false);
> > >  
> > >  	clk_unprepare(data->clk);
> > > diff --git a/drivers/thermal/samsung/exynos_tmu.h
> > > b/drivers/thermal/samsung/exynos_tmu.h index 627dec9..d876d4c 100644
> > > --- a/drivers/thermal/samsung/exynos_tmu.h
> > > +++ b/drivers/thermal/samsung/exynos_tmu.h
> > > @@ -23,8 +23,7 @@
> > >  #ifndef _EXYNOS_TMU_H
> > >  #define _EXYNOS_TMU_H
> > >  #include <linux/cpu_cooling.h>
> > > -
> > > -#include "exynos_thermal_common.h"
> > > +#include <dt-bindings/thermal/thermal_exynos.h>
> > >  
> > >  enum soc_type {
> > >  	SOC_ARCH_EXYNOS3250 = 1,
> > > @@ -36,38 +35,9 @@ enum soc_type {
> > >  	SOC_ARCH_EXYNOS5420_TRIMINFO,
> > >  	SOC_ARCH_EXYNOS5440,
> > >  };
> > > -#include <dt-bindings/thermal/thermal_exynos.h>
> > >  
> > >  /**
> > >   * struct exynos_tmu_platform_data
> > > - * @threshold: basic temperature for generating interrupt
> > > - *	       25 <= threshold <= 125 [unit: degree Celsius]
> > > - * @threshold_falling: differntial value for setting threshold
> > > - *		       of temperature falling interrupt.
> > > - * @trigger_levels: array for each interrupt levels
> > > - *	[unit: degree Celsius]
> > > - *	0: temperature for trigger_level0 interrupt
> > > - *	   condition for trigger_level0 interrupt:
> > > - *		current temperature > threshold +
> > > trigger_levels[0]
> > > - *	1: temperature for trigger_level1 interrupt
> > > - *	   condition for trigger_level1 interrupt:
> > > - *		current temperature > threshold +
> > > trigger_levels[1]
> > > - *	2: temperature for trigger_level2 interrupt
> > > - *	   condition for trigger_level2 interrupt:
> > > - *		current temperature > threshold +
> > > trigger_levels[2]
> > > - *	3: temperature for trigger_level3 interrupt
> > > - *	   condition for trigger_level3 interrupt:
> > > - *		current temperature > threshold +
> > > trigger_levels[3]
> > > - * @trigger_type: defines the type of trigger. Possible values are,
> > > - *	THROTTLE_ACTIVE trigger type
> > > - *	THROTTLE_PASSIVE trigger type
> > > - *	SW_TRIP trigger type
> > > - *	HW_TRIP
> > > - * @trigger_enable[]: array to denote which trigger levels are
> > > enabled.
> > > - *	1 = enable trigger_level[] interrupt,
> > > - *	0 = disable trigger_level[] interrupt
> > > - * @max_trigger_level: max trigger level supported by the TMU
> > > - * @non_hw_trigger_levels: number of defined non-hardware trigger
> > > levels
> > >   * @gain: gain of amplifier in the positive-TC generator block
> > >   *	0 < gain <= 15
> > >   * @reference_voltage: reference voltage of amplifier
> > > @@ -79,21 +49,12 @@ enum soc_type {
> > >   * @efuse_value: platform defined fuse value
> > >   * @min_efuse_value: minimum valid trimming data
> > >   * @max_efuse_value: maximum valid trimming data
> > > - * @first_point_trim: temp value of the first point trimming
> > > - * @second_point_trim: temp value of the second point trimming
> > >   * @default_temp_offset: default temperature offset in case of no
> > > trimming
> > >   * @cal_type: calibration type for temperature
> > >   *
> > >   * This structure is required for configuration of exynos_tmu
> > > driver. */
> > >  struct exynos_tmu_platform_data {
> > > -	u8 threshold;
> > > -	u8 threshold_falling;
> > > -	u8 trigger_levels[MAX_TRIP_COUNT];
> > > -	enum trigger_type trigger_type[MAX_TRIP_COUNT];
> > > -	bool trigger_enable[MAX_TRIP_COUNT];
> > > -	u8 max_trigger_level;
> > > -	u8 non_hw_trigger_levels;
> > >  	u8 gain;
> > >  	u8 reference_voltage;
> > >  	u8 noise_cancel_mode;
> > > @@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
> > >  	u32 cal_mode;
> > >  };
> > >  
> > > -/**
> > > - * struct exynos_tmu_init_data
> > > - * @tmu_count: number of TMU instances.
> > > - * @tmu_data: platform data of all TMU instances.
> > > - * This structure is required to store data for multi-instance
> > > exynos tmu
> > > - * driver.
> > > - */
> > > -struct exynos_tmu_init_data {
> > > -	int tmu_count;
> > > -	struct exynos_tmu_platform_data tmu_data[];
> > > -};
> > > -
> > >  extern struct exynos_tmu_init_data const
> > > exynos3250_default_tmu_data; extern struct exynos_tmu_init_data
> > > const exynos4210_default_tmu_data; extern struct
> > > exynos_tmu_init_data const exynos4412_default_tmu_data; -- 
> > > 2.0.0.rc2
> > > 
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 00/18] thermal: exynos: Thermal code rework to use device tree
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (17 preceding siblings ...)
  2015-01-19 11:21   ` [PATCH v5 18/18] thermal: exynos: Remove not needed exynos_tmu_init_data declarations from exynos_tmu.h Lukasz Majewski
@ 2015-01-21  1:55   ` Eduardo Valentin
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
  2015-01-23 12:14   ` [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered Lukasz Majewski
  20 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-21  1:55 UTC (permalink / raw)
  To: Lukasz Majewski, Arnd Bergmann
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 6204 bytes --]

Hello Arnd,

On Mon, Jan 19, 2015 at 12:20:44PM +0100, Lukasz Majewski wrote:
> 1. Introduction
> 
> Following patches aim to clean up the current implementation of the thermal
> framework on Exynos devices.
> 
> The main goal was to use a generic code for reading thermal configuration
> (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
> were removed.
> 
> Around 400 lines of code (LOC) were removed directly by this patch, which
> is around 20% of the Exynos thermal code base.
> 
> This work should NOT bring any functional changes to Exynos thermal 
> subsystem.
> 
> 2. Patch-set structure
> 
> Then the cpu_cooling functionality has been preserved to allow cooling
> devices by reducing operating frequency. Definition of trip points and
> cpufreq's cooling properties were moved to device tree.
> 
> Then the rework of the way in which configuration data is provided to
> the Exynos thermal subsystem was performed. Now device tree is used for
> configuration.
> 
> 3. Dead code removal
> 
> Thermal support for some SoCs, previously available in the exynos_tmu_data.c 
> file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.
> 
> Moreover, support for cpu_cooling devices was preserved only on those
> SoCs which had available and working cpufreq driver.
> 
> 4. Testing
> 
> Test devices:
> - Exynos4210 - Trats (TMU zone + cpu_cooling)
> - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> - Exynos5420 - Arndale-octa (only TMU zones)
> 
> Unfortunately, I don't posses Exynos5440 for testing. Its functionality
> has been preserved in the code, but not tested on the hardware. I would
> be grateful for help in testing.
> 
> 
> 5. This work apply on the following tree:
> 
> kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
> 
> 

This series contains changes under drivers/thermal that I can pick up,
but it also contains changes under arch/arm/boot/dts that depend on a
header file provided by the driver. The header is introduced in this
series.

How do you prefer to preceed in such sitation? Are you OK if I pick the
complete series, changes under drivers/thermal and the DTS changes?

Cheers,

Eduardo

> Lukasz Majewski (18):
>   thermal: exynos: cosmetic: Correct comment format
>   thermal: exynos: Provide thermal_exynos.h file to be included in
>     device tree files
>   arm: dts: trats: Enable TMU on the Exynos4210 trats device
>   arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid
>   arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
>   arm: dts: Adding CPU cooling binding for Exynos SoCs
>   thermal: exynos: Modify exynos thermal code to use device tree for cpu
>     cooling configuration
>   thermal: exynos: dts: Add default definition of the TMU sensor
>     parameter
>   dts: Documentation: Extending documentation entry for exynos-thermal
>   thermal: dts: Default trip points definition for Exynos5420 SoCs
>   thermal: exynos: dts: Define default thermal-zones for Exynos4
>   thermal: dts: exynos: Trip points and sensor configuration data for
>     Exynos5440
>   dts: Documentation: Update exynos-thermal.txt example for Exynos5440
>   thermal: exynos: dts: Provide device tree bindings identical to the
>     one in exynos_tmu_data.c
>   thermal: samsung: core: Exynos TMU rework to use device tree for
>     configuration
>   thermal: exynos: Remove exynos_thermal_common.[c|h] files
>   thermal: exynos: Remove exynos_tmu_data.c file
>   thermal: exynos: Remove not needed exynos_tmu_init_data declarations
>     from exynos_tmu.h
> 
>  .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
>  arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
>  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
>  arch/arm/boot/dts/exynos4.dtsi                     |   4 +
>  arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
>  arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
>  arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
>  arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
>  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
>  arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
>  arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
>  arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
>  arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
>  arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
>  arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
>  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
>  arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
>  arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
>  drivers/cpufreq/exynos-cpufreq.c                   |  30 +-
>  drivers/thermal/samsung/Makefile                   |   2 -
>  drivers/thermal/samsung/exynos_thermal_common.c    | 427 ---------------------
>  drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
>  drivers/thermal/samsung/exynos_tmu.c               | 348 +++++++++++------
>  drivers/thermal/samsung/exynos_tmu.h               |  76 +---
>  drivers/thermal/samsung/exynos_tmu_data.c          | 264 -------------
>  include/dt-bindings/thermal/thermal_exynos.h       |  28 ++
>  26 files changed, 632 insertions(+), 1009 deletions(-)
>  create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
>  delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
>  create mode 100644 include/dt-bindings/thermal/thermal_exynos.h
> 
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration
  2015-01-19 11:20   ` [PATCH v5 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
@ 2015-01-21  2:18     ` Eduardo Valentin
  2015-01-21  8:21       ` Lukasz Majewski
  2015-01-21  8:33     ` Lukasz Majewski
  1 sibling, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-21  2:18 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 12613 bytes --]

On Mon, Jan 19, 2015 at 12:20:51PM +0100, Lukasz Majewski wrote:
> Up till now exynos_tmu_data.c was used for storing CPU cooling configuration
> data. Now the Exynos thermal core code uses device tree to get this data.
> For this purpose generic thermal code for configuring CPU cooling was
> used.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - None
> Changes for v3:
> - Rewrite code responsible for registering CPU cooling device to not depend
>   on explicit "/cpus/cpu@0" path since now Exynos SoCs use new cpu node
>   names (e.g. cpu@A00). New approach iterates over "cpus" node children.
> - Patch title changed to thermal: exynos
> Changes for v4:
> - None
> Changes for v5:
> - None
> 
> ---
>  drivers/cpufreq/exynos-cpufreq.c                |  30 +++++-
>  drivers/thermal/samsung/exynos_thermal_common.c | 122 ++++++++++++++----------
>  drivers/thermal/samsung/exynos_tmu.c            |   7 --
>  drivers/thermal/samsung/exynos_tmu.h            |   5 -
>  drivers/thermal/samsung/exynos_tmu_data.c       |  42 +-------
>  5 files changed, 101 insertions(+), 105 deletions(-)
> 
> diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
> index f99a0b0..32bc64d 100644
> --- a/drivers/cpufreq/exynos-cpufreq.c
> +++ b/drivers/cpufreq/exynos-cpufreq.c
> @@ -18,10 +18,13 @@
>  #include <linux/cpufreq.h>
>  #include <linux/platform_device.h>
>  #include <linux/of.h>
> +#include <linux/cpu_cooling.h>
> +#include <linux/cpu.h>
>  
>  #include "exynos-cpufreq.h"
>  
>  static struct exynos_dvfs_info *exynos_info;
> +static struct thermal_cooling_device *cdev;
>  static struct regulator *arm_regulator;
>  static unsigned int locking_frequency;
>  
> @@ -156,6 +159,7 @@ static struct cpufreq_driver exynos_driver = {
>  
>  static int exynos_cpufreq_probe(struct platform_device *pdev)
>  {
> +	struct device_node *cpus, *np;
>  	int ret = -EINVAL;
>  
>  	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
> @@ -198,9 +202,31 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
>  	/* Done here as we want to capture boot frequency */
>  	locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;
>  
> -	if (!cpufreq_register_driver(&exynos_driver))
> -		return 0;
> +	if (cpufreq_register_driver(&exynos_driver))
> +		goto err;
>  
> +	cpus = of_find_node_by_path("/cpus");
> +	if (!cpus) {
> +		pr_err("failed to find cpus node\n");
> +		return -ENOENT;
> +	}
> +
> +	for (np = of_get_next_child(cpus, NULL); np;
> +	     of_node_put(np), np = of_get_next_child(cpus, np)) {
> +		if (of_find_property(np, "#cooling-cells", NULL)) {
> +			cdev = of_cpufreq_cooling_register(np,
> +							   cpu_present_mask);
> +			if (IS_ERR(cdev))
> +				pr_err("running cpufreq without cooling device: %ld\n",
> +				       PTR_ERR(cdev));
> +			break;
> +		}
> +	}
> +	of_node_put(np);
> +	of_node_put(cpus);
> +
> +	return 0;
> + err:
>  	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
>  	regulator_put(arm_regulator);
>  err_vdd_arm:

You need at least an ack from a cpufreq maintainer to get this patch in.
I would prefer if you split the cpufreq part from the thermal part. It
avoids merge conflicts in the upstreaming process.

> diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
> index 6dc3815..00aa688 100644
> --- a/drivers/thermal/samsung/exynos_thermal_common.c
> +++ b/drivers/thermal/samsung/exynos_thermal_common.c
> @@ -133,47 +133,62 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
>  static int exynos_bind(struct thermal_zone_device *thermal,
>  			struct thermal_cooling_device *cdev)
>  {
> -	int ret = 0, i, tab_size, level;
> -	struct freq_clip_table *tab_ptr, *clip_data;
>  	struct exynos_thermal_zone *th_zone = thermal->devdata;
>  	struct thermal_sensor_conf *data = th_zone->sensor_conf;
> +	struct device_node *child, *gchild, *np;
> +	struct of_phandle_args cooling_spec;
> +	unsigned long max, state = 0;
> +	int ret = 0, i = 0;
>  
> -	tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data;
> -	tab_size = data->cooling_data.freq_clip_count;
> -
> -	if (tab_ptr == NULL || tab_size == 0)
> +	/*
> +	 * Below code is necessary to skip binding when cpufreq's
> +	 * frequency table is not yet initialized.
> +	 */
> +	cdev->ops->get_max_state(cdev, &state);
> +	if (!state && !th_zone->cool_dev_size) {
> +		th_zone->cool_dev_size = 1;
> +		th_zone->cool_dev[0] = cdev;
> +		th_zone->bind = false;
>  		return 0;
> +	}
>  
> -	/* find the cooling device registered*/
> -	for (i = 0; i < th_zone->cool_dev_size; i++)
> -		if (cdev == th_zone->cool_dev[i])
> -			break;
> +	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
> +	if (!np) {
> +		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
> +		return -ENOENT;
> +	}
>  
> -	/* No matching cooling device */
> -	if (i == th_zone->cool_dev_size)
> -		return 0;
> +	child = of_get_child_by_name(np, "cooling-maps");
>  
> -	/* Bind the thermal zone to the cpufreq cooling device */
> -	for (i = 0; i < tab_size; i++) {
> -		clip_data = (struct freq_clip_table *)&(tab_ptr[i]);
> -		level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max);
> -		if (level == THERMAL_CSTATE_INVALID)
> -			return 0;
> -		switch (GET_ZONE(i)) {
> -		case MONITOR_ZONE:
> -		case WARN_ZONE:
> -			if (thermal_zone_bind_cooling_device(thermal, i, cdev,
> -								level, 0)) {
> -				dev_err(data->dev,
> -					"error unbinding cdev inst=%d\n", i);
> -				ret = -EINVAL;
> -			}
> -			th_zone->bind = true;
> -			break;
> -		default:
> +	for_each_child_of_node(child, gchild) {
> +		ret = of_parse_phandle_with_args(gchild, "cooling-device",
> +						 "#cooling-cells",
> +						 0, &cooling_spec);
> +		if (ret < 0) {
> +			pr_err("missing cooling_device property\n");
> +			goto end;
> +		}
> +
> +		if (cooling_spec.args_count < 2) {
>  			ret = -EINVAL;
> +			goto end;
>  		}
> +
> +		max = cooling_spec.args[0];
> +		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
> +						     max, 0)) {
> +			dev_err(data->dev,
> +				"thermal error unbinding cdev inst=%d\n", i);
> +
> +			ret = -EINVAL;
> +			goto end;
> +		}
> +		i++;
>  	}
> +	th_zone->bind = true;
> +end:
> +	of_node_put(child);
> +	of_node_put(np);
>  
>  	return ret;
>  }
> @@ -182,16 +197,12 @@ static int exynos_bind(struct thermal_zone_device *thermal,
>  static int exynos_unbind(struct thermal_zone_device *thermal,
>  			struct thermal_cooling_device *cdev)
>  {
> -	int ret = 0, i, tab_size;
> +	int ret = 0, i;
>  	struct exynos_thermal_zone *th_zone = thermal->devdata;
>  	struct thermal_sensor_conf *data = th_zone->sensor_conf;
> +	struct device_node *child, *gchild, *np;
>  
> -	if (th_zone->bind == false)
> -		return 0;
> -
> -	tab_size = data->cooling_data.freq_clip_count;
> -
> -	if (tab_size == 0)
> +	if (th_zone->bind == false || !th_zone->cool_dev_size)
>  		return 0;
>  
>  	/* find the cooling device registered*/
> @@ -203,23 +214,30 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
>  	if (i == th_zone->cool_dev_size)
>  		return 0;
>  
> -	/* Bind the thermal zone to the cpufreq cooling device */
> -	for (i = 0; i < tab_size; i++) {
> -		switch (GET_ZONE(i)) {
> -		case MONITOR_ZONE:
> -		case WARN_ZONE:
> -			if (thermal_zone_unbind_cooling_device(thermal, i,
> -								cdev)) {
> -				dev_err(data->dev,
> -					"error unbinding cdev inst=%d\n", i);
> -				ret = -EINVAL;
> -			}
> -			th_zone->bind = false;
> -			break;
> -		default:
> +	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
> +	if (!np) {
> +		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
> +		return -ENOENT;
> +	}
> +
> +	child = of_get_child_by_name(np, "cooling-maps");
> +
> +	i = 0;
> +	for_each_child_of_node(child, gchild) {
> +		if (thermal_zone_unbind_cooling_device(thermal, i,
> +						       cdev)) {
> +			dev_err(data->dev,
> +				"error unbinding cdev inst=%d\n", i);
>  			ret = -EINVAL;
> +			goto end;
>  		}
> +		i++;
>  	}
> +	th_zone->bind = false;
> +end:
> +	of_node_put(child);
> +	of_node_put(np);
> +
>  	return ret;
>  }
>  
> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index 5000727..ae30f6a 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -916,13 +916,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  
>  	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
>  
> -	sensor_conf->cooling_data.freq_clip_count = pdata->freq_tab_count;
> -	for (i = 0; i < pdata->freq_tab_count; i++) {
> -		sensor_conf->cooling_data.freq_data[i].freq_clip_max =
> -					pdata->freq_tab[i].freq_clip_max;
> -		sensor_conf->cooling_data.freq_data[i].temp_level =
> -					pdata->freq_tab[i].temp_level;
> -	}
>  	sensor_conf->dev = &pdev->dev;
>  	/* Register the sensor with thermal management interface */
>  	ret = exynos_register_thermal(sensor_conf);
> diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
> index 7f880d2..627dec9 100644
> --- a/drivers/thermal/samsung/exynos_tmu.h
> +++ b/drivers/thermal/samsung/exynos_tmu.h
> @@ -83,9 +83,6 @@ enum soc_type {
>   * @second_point_trim: temp value of the second point trimming
>   * @default_temp_offset: default temperature offset in case of no trimming
>   * @cal_type: calibration type for temperature
> - * @freq_clip_table: Table representing frequency reduction percentage.
> - * @freq_tab_count: Count of the above table as frequency reduction may
> - *	applicable to only some of the trigger levels.
>   *
>   * This structure is required for configuration of exynos_tmu driver.
>   */
> @@ -111,8 +108,6 @@ struct exynos_tmu_platform_data {
>  	enum soc_type type;
>  	u32 cal_type;
>  	u32 cal_mode;
> -	struct freq_clip_table freq_tab[4];
> -	unsigned int freq_tab_count;
>  };
>  
>  /**
> diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
> index b239100..a993f3d 100644
> --- a/drivers/thermal/samsung/exynos_tmu_data.c
> +++ b/drivers/thermal/samsung/exynos_tmu_data.c
> @@ -47,15 +47,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
>  		.first_point_trim = 25,
>  		.second_point_trim = 85,
>  		.default_temp_offset = 50,
> -		.freq_tab[0] = {
> -			.freq_clip_max = 800 * 1000,
> -			.temp_level = 85,
> -			},
> -		.freq_tab[1] = {
> -			.freq_clip_max = 200 * 1000,
> -			.temp_level = 100,
> -		},
> -		.freq_tab_count = 2,
>  		.type = SOC_ARCH_EXYNOS4210,
>  		},
>  	},
> @@ -87,16 +78,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
>  	.max_efuse_value = 100, \
>  	.first_point_trim = 25, \
>  	.second_point_trim = 85, \
> -	.default_temp_offset = 50, \
> -	.freq_tab[0] = { \
> -		.freq_clip_max = 800 * 1000, \
> -		.temp_level = 70, \
> -	}, \
> -	.freq_tab[1] = { \
> -		.freq_clip_max = 400 * 1000, \
> -		.temp_level = 95, \
> -	}, \
> -	.freq_tab_count = 2
> +	.default_temp_offset = 50
>  
>  struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
>  	.tmu_data = {
> @@ -133,16 +115,7 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
>  	.max_efuse_value = 100, \
>  	.first_point_trim = 25, \
>  	.second_point_trim = 85, \
> -	.default_temp_offset = 50, \
> -	.freq_tab[0] = { \
> -		.freq_clip_max = 1400 * 1000, \
> -		.temp_level = 70, \
> -	}, \
> -	.freq_tab[1] = { \
> -		.freq_clip_max = 400 * 1000, \
> -		.temp_level = 95, \
> -	}, \
> -	.freq_tab_count = 2
> +	.default_temp_offset = 50
>  
>  struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
>  	.tmu_data = {
> @@ -189,16 +162,7 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
>  	.max_efuse_value = 100, \
>  	.first_point_trim = 25, \
>  	.second_point_trim = 85, \
> -	.default_temp_offset = 50, \
> -	.freq_tab[0] = { \
> -		.freq_clip_max = 800 * 1000, \
> -		.temp_level = 85, \
> -	}, \
> -	.freq_tab[1] = { \
> -		.freq_clip_max = 200 * 1000, \
> -		.temp_level = 103, \
> -	}, \
> -	.freq_tab_count = 2, \
> +	.default_temp_offset = 50,
>  
>  #define EXYNOS5260_TMU_DATA \
>  	__EXYNOS5260_TMU_DATA \
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-19 11:20   ` [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
@ 2015-01-21  3:18     ` Eduardo Valentin
  2015-01-21  8:40       ` Lukasz Majewski
  2015-01-21  3:25     ` Eduardo Valentin
  1 sibling, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-21  3:18 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 27458 bytes --]

On Mon, Jan 19, 2015 at 12:20:59PM +0100, Lukasz Majewski wrote:
> This patch brings support for providing configuration via device tree.
> Previously this data has been hardcoded in the exynos_tmu_data.c file.
> Such approach was not scalable and very often required copying the whole
> data.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
> - Usage of of-thermal.c exported trip points table
> Changes for v3:
> - Adding exynos_of_get_soc_type() method to set SOC type from device's
>   compatible string
> - "samsung,tmu_" prefix for TMU specific properties has been added
> Changes for v4:
> - None
> Changes for v5:
> - Remove duplicated exynos_tmu_initialize() - reported by Abhilash Kesavan
>  <a.kesavan@samsung.com>
> 

several checkpatch.pl items to be reviewed in this patch:
CHECK: No space is necessary after a cast
#509: FILE: drivers/thermal/samsung/exynos_tmu.c:821:
+       pdata->gain = (u8) value;

CHECK: No space is necessary after a cast
#511: FILE: drivers/thermal/samsung/exynos_tmu.c:823:
+       pdata->reference_voltage = (u8) value;


Can you please make sure all of your patches pass:
checkpatch.pl --strict

?


> ---
>  drivers/thermal/samsung/Makefile     |   2 -
>  drivers/thermal/samsung/exynos_tmu.c | 339 ++++++++++++++++++++++-------------
>  drivers/thermal/samsung/exynos_tmu.h |  53 +-----
>  3 files changed, 220 insertions(+), 174 deletions(-)
> 
> diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile
> index c09d830..1e47d0d 100644
> --- a/drivers/thermal/samsung/Makefile
> +++ b/drivers/thermal/samsung/Makefile
> @@ -3,5 +3,3 @@
>  #
>  obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_thermal.o
>  exynos_thermal-y				:= exynos_tmu.o
> -exynos_thermal-y				+= exynos_tmu_data.o
> -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+= exynos_thermal_common.o
> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index ae30f6a..9d2d685 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -1,6 +1,10 @@
>  /*
>   * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
>   *
> + *  Copyright (C) 2014 Samsung Electronics
> + *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> + *  Lukasz Majewski <l.majewski@samsung.com>
> + *
>   *  Copyright (C) 2011 Samsung Electronics
>   *  Donggeun Kim <dg77.kim@samsung.com>
>   *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
> @@ -31,8 +35,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/regulator/consumer.h>
>  
> -#include "exynos_thermal_common.h"
>  #include "exynos_tmu.h"
> +#include "../thermal_core.h"
>  
>  /* Exynos generic registers */
>  #define EXYNOS_TMU_REG_TRIMINFO		0x0
> @@ -115,6 +119,7 @@
>  #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
>  #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
>  
> +#define MCELSIUS	1000
>  /**
>   * struct exynos_tmu_data : A structure to hold the private data of the TMU
>  	driver
> @@ -150,7 +155,8 @@ struct exynos_tmu_data {
>  	struct clk *clk, *clk_sec;
>  	u8 temp_error1, temp_error2;
>  	struct regulator *regulator;
> -	struct thermal_sensor_conf *reg_conf;
> +	struct thermal_zone_device *tzd;
> +
>  	int (*tmu_initialize)(struct platform_device *pdev);
>  	void (*tmu_control)(struct platform_device *pdev, bool on);
>  	int (*tmu_read)(struct exynos_tmu_data *data);
> @@ -159,6 +165,33 @@ struct exynos_tmu_data {
>  	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
>  };
>  
> +static void exynos_report_trigger(struct exynos_tmu_data *p)
> +{
> +	char data[10], *envp[] = { data, NULL };
> +	struct thermal_zone_device *tz = p->tzd;
> +	unsigned long temp;
> +	unsigned int i;
> +
> +	if (!p) {
> +		pr_err("Wrong temperature configuration data\n");
> +		return;
> +	}
> +
> +	thermal_zone_device_update(tz);
> +
> +	mutex_lock(&tz->lock);
> +	/* Find the level for which trip happened */
> +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> +		tz->ops->get_trip_temp(tz, i, &temp);
> +		if (tz->last_temperature < temp)
> +			break;
> +	}
> +
> +	snprintf(data, sizeof(data), "%u", i);
> +	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
> +	mutex_unlock(&tz->lock);
> +}
> +
>  /*
>   * TMU treats temperature as a mapped temperature code.
>   * The temperature is converted differently depending on the calibration type.
> @@ -234,14 +267,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
>  
>  static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling)
>  {
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> +	struct thermal_zone_device *tz = data->tzd;
> +	const struct thermal_trip * const trips =
> +		of_thermal_get_trip_points(tz);
> +	unsigned long temp;
>  	int i;
>  
> -	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
> -		u8 temp = pdata->trigger_levels[i];
> +	if (!trips) {
> +		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
> +		       __func__);
> +		return 0;
> +	}
>  
> +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> +		if (trips[i].type == THERMAL_TRIP_CRITICAL)
> +			continue;
> +
> +		temp = trips[i].temperature / MCELSIUS;
>  		if (falling)
> -			temp -= pdata->threshold_falling;
> +			temp -= (trips[i].hysteresis / MCELSIUS);
>  		else
>  			threshold &= ~(0xff << 8 * i);
>  
> @@ -305,9 +349,19 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
>  static int exynos4210_tmu_initialize(struct platform_device *pdev)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> -	unsigned int status;
> +	struct thermal_zone_device *tz = data->tzd;
> +	const struct thermal_trip * const trips =
> +		of_thermal_get_trip_points(tz);
>  	int ret = 0, threshold_code, i;
> +	unsigned long reference, temp;
> +	unsigned int status;
> +
> +	if (!trips) {
> +		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
> +		       __func__);
> +		ret = -ENODEV;
> +		goto out;
> +	}
>  
>  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
>  	if (!status) {
> @@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct platform_device *pdev)
>  	sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));
>  
>  	/* Write temperature code for threshold */
> -	threshold_code = temp_to_code(data, pdata->threshold);
> +	reference = trips[0].temperature / MCELSIUS;
> +	threshold_code = temp_to_code(data, reference);
> +	if (threshold_code < 0) {
> +		ret = threshold_code;
> +		goto out;
> +	}
>  	writeb(threshold_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
>  
> -	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
> -		writeb(pdata->trigger_levels[i], data->base +
> +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> +		temp = trips[i].temperature / MCELSIUS;
> +		writeb(temp - reference, data->base +
>  		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
> +	}
>  
>  	data->tmu_clear_irqs(data);
>  out:
> @@ -333,9 +394,11 @@ out:
>  static int exynos4412_tmu_initialize(struct platform_device *pdev)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> +	const struct thermal_trip * const trips =
> +		of_thermal_get_trip_points(data->tzd);
>  	unsigned int status, trim_info, con, ctrl, rising_threshold;
>  	int ret = 0, threshold_code, i;
> +	unsigned long crit_temp = 0;
>  
>  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
>  	if (!status) {
> @@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
>  	data->tmu_clear_irqs(data);
>  
>  	/* if last threshold limit is also present */
> -	i = pdata->max_trigger_level - 1;
> -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
> -		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
> -		/* 1-4 level to be assigned in th0 reg */
> -		rising_threshold &= ~(0xff << 8 * i);
> -		rising_threshold |= threshold_code << 8 * i;
> -		writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
> -		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> -		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> -		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> +	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
> +		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
> +			crit_temp = trips[i].temperature;
> +			break;
> +		}
> +	}
> +
> +	if (i == of_thermal_get_ntrips(data->tzd)) {
> +		pr_err("%s: No CRITICAL trip point defined at of-thermal.c!\n",
> +		       __func__);
> +		ret = -EINVAL;
> +		goto out;
>  	}
> +
> +	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
> +	/* 1-4 level to be assigned in th0 reg */
> +	rising_threshold &= ~(0xff << 8 * i);
> +	rising_threshold |= threshold_code << 8 * i;
> +	writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
> +	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> +	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> +	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> +
>  out:
>  	return ret;
>  }
> @@ -391,9 +466,9 @@ out:
>  static int exynos5440_tmu_initialize(struct platform_device *pdev)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
>  	unsigned int trim_info = 0, con, rising_threshold;
> -	int ret = 0, threshold_code, i;
> +	int ret = 0, threshold_code;
> +	unsigned long crit_temp = 0;
>  
>  	/*
>  	 * For exynos5440 soc triminfo value is swapped between TMU0 and
> @@ -422,9 +497,8 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
>  	data->tmu_clear_irqs(data);
>  
>  	/* if last threshold limit is also present */
> -	i = pdata->max_trigger_level - 1;
> -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
> -		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
> +	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp)) {
> +		threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
>  		/* 5th level to be assigned in th2 reg */
>  		rising_threshold =
>  			threshold_code << EXYNOS5440_TMU_TH_RISE4_SHIFT;
> @@ -442,7 +516,7 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
>  static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> +	struct thermal_zone_device *tz = data->tzd;
>  	unsigned int con, interrupt_en;
>  
>  	con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
> @@ -450,10 +524,15 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
>  	if (on) {
>  		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
>  		interrupt_en =
> -			pdata->trigger_enable[3] << EXYNOS_TMU_INTEN_RISE3_SHIFT |
> -			pdata->trigger_enable[2] << EXYNOS_TMU_INTEN_RISE2_SHIFT |
> -			pdata->trigger_enable[1] << EXYNOS_TMU_INTEN_RISE1_SHIFT |
> -			pdata->trigger_enable[0] << EXYNOS_TMU_INTEN_RISE0_SHIFT;
> +			(of_thermal_is_trip_valid(tz, 3)
> +			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 2)
> +			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 1)
> +			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 0)
> +			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
> +
>  		if (data->soc != SOC_ARCH_EXYNOS4210)
>  			interrupt_en |=
>  				interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
> @@ -468,7 +547,7 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
>  static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> +	struct thermal_zone_device *tz = data->tzd;
>  	unsigned int con, interrupt_en;
>  
>  	con = get_con_reg(data, readl(data->base + EXYNOS5440_TMU_S0_7_CTRL));
> @@ -476,11 +555,16 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
>  	if (on) {
>  		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
>  		interrupt_en =
> -			pdata->trigger_enable[3] << EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
> -			pdata->trigger_enable[2] << EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
> -			pdata->trigger_enable[1] << EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
> -			pdata->trigger_enable[0] << EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
> -		interrupt_en |= interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
> +			(of_thermal_is_trip_valid(tz, 3)
> +			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 2)
> +			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 1)
> +			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 0)
> +			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
> +		interrupt_en |=
> +			interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
>  	} else {
>  		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
>  		interrupt_en = 0; /* Disable all interrupts */
> @@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
>  	writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL);
>  }
>  
> -static int exynos_tmu_read(struct exynos_tmu_data *data)
> +int exynos_get_temp(void *p, long *temp)
>  {
> -	int ret;
> +	struct exynos_tmu_data *data = p;
> +
> +	if (!data)
> +		return -EINVAL;
>  
>  	mutex_lock(&data->lock);
>  	clk_enable(data->clk);
> -	ret = data->tmu_read(data);
> -	if (ret >= 0)
> -		ret = code_to_temp(data, ret);
> +
> +	*temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS;
> +
>  	clk_disable(data->clk);
>  	mutex_unlock(&data->lock);
>  
> -	return ret;
> +	return 0;
>  }
>  
>  #ifdef CONFIG_THERMAL_EMULATION
> @@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct *work)
>  	if (!IS_ERR(data->clk_sec))
>  		clk_disable(data->clk_sec);
>  
> -	exynos_report_trigger(data->reg_conf);
> +	exynos_report_trigger(data);
>  	mutex_lock(&data->lock);
>  	clk_enable(data->clk);
>  
> @@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
>  static const struct of_device_id exynos_tmu_match[] = {
>  	{
>  		.compatible = "samsung,exynos3250-tmu",
> -		.data = &exynos3250_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos4210-tmu",
> -		.data = &exynos4210_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos4412-tmu",
> -		.data = &exynos4412_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5250-tmu",
> -		.data = &exynos5250_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5260-tmu",
> -		.data = &exynos5260_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5420-tmu",
> -		.data = &exynos5420_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5420-tmu-ext-triminfo",
> -		.data = &exynos5420_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5440-tmu",
> -		.data = &exynos5440_default_tmu_data,
>  	},
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, exynos_tmu_match);
>  
> -static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
> -			struct platform_device *pdev, int id)
> +static int exynos_of_get_soc_type(struct device_node *np)
>  {
> -	struct  exynos_tmu_init_data *data_table;
> -	struct exynos_tmu_platform_data *tmu_data;
> -	const struct of_device_id *match;
> +	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
> +		return SOC_ARCH_EXYNOS3250;
> +	else if (of_device_is_compatible(np, "samsung,exynos4210-tmu"))
> +		return SOC_ARCH_EXYNOS4210;
> +	else if (of_device_is_compatible(np, "samsung,exynos4412-tmu"))
> +		return SOC_ARCH_EXYNOS4412;
> +	else if (of_device_is_compatible(np, "samsung,exynos5250-tmu"))
> +		return SOC_ARCH_EXYNOS5250;
> +	else if (of_device_is_compatible(np, "samsung,exynos5260-tmu"))
> +		return SOC_ARCH_EXYNOS5260;
> +	else if (of_device_is_compatible(np, "samsung,exynos5420-tmu"))
> +		return SOC_ARCH_EXYNOS5420;
> +	else if (of_device_is_compatible(np,
> +					 "samsung,exynos5420-tmu-ext-triminfo"))
> +		return SOC_ARCH_EXYNOS5420_TRIMINFO;
> +	else if (of_device_is_compatible(np, "samsung,exynos5440-tmu"))
> +		return SOC_ARCH_EXYNOS5440;
> +
> +	return -EINVAL;
> +}
>  
> -	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
> -	if (!match)
> -		return NULL;
> -	data_table = (struct exynos_tmu_init_data *) match->data;
> -	if (!data_table || id >= data_table->tmu_count)
> -		return NULL;
> -	tmu_data = data_table->tmu_data;
> -	return (struct exynos_tmu_platform_data *) (tmu_data + id);
> +static int exynos_of_sensor_conf(struct device_node *np,
> +				 struct exynos_tmu_platform_data *pdata)
> +{
> +	u32 value;
> +	int ret;
> +
> +	of_node_get(np);
> +
> +	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
> +	pdata->gain = (u8) value;
> +	of_property_read_u32(np, "samsung,tmu_reference_voltage", &value);
> +	pdata->reference_voltage = (u8) value;
> +	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode", &value);
> +	pdata->noise_cancel_mode = (u8) value;
> +
> +	of_property_read_u32(np, "samsung,tmu_efuse_value",
> +			     &pdata->efuse_value);
> +	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
> +			     &pdata->min_efuse_value);
> +	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
> +			     &pdata->max_efuse_value);
> +
> +	of_property_read_u32(np, "samsung,tmu_first_point_trim", &value);
> +	pdata->first_point_trim = (u8) value;
> +	of_property_read_u32(np, "samsung,tmu_second_point_trim", &value);
> +	pdata->second_point_trim = (u8) value;
> +	of_property_read_u32(np, "samsung,tmu_default_temp_offset", &value);
> +	pdata->default_temp_offset = (u8) value;
> +
> +	of_property_read_u32(np, "samsung,tmu_cal_type", &pdata->cal_type);
> +	of_property_read_u32(np, "samsung,tmu_cal_mode", &pdata->cal_mode);
> +
> +	of_node_put(np);
> +	return 0;
>  }
>  
>  static int exynos_map_dt_data(struct platform_device *pdev)
> @@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct platform_device *pdev)
>  		return -EADDRNOTAVAIL;
>  	}
>  
> -	pdata = exynos_get_driver_data(pdev, data->id);
> -	if (!pdata) {
> -		dev_err(&pdev->dev, "No platform init data supplied.\n");
> -		return -ENODEV;
> -	}
> +	pdata = devm_kzalloc(&pdev->dev,
> +			     sizeof(struct exynos_tmu_platform_data),
> +			     GFP_KERNEL);
> +	if (!pdata)
> +		return -ENOMEM;
>  
> +	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
>  	data->pdata = pdata;
> -	data->soc = pdata->type;
> +	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
>  
>  	switch (data->soc) {
>  	case SOC_ARCH_EXYNOS4210:
> @@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static struct thermal_zone_of_device_ops exynos_sensor_ops = {
> +	.get_temp = exynos_get_temp,
> +	.set_emul_temp = exynos_tmu_set_emulation,
> +};
> +
>  static int exynos_tmu_probe(struct platform_device *pdev)
>  {
> -	struct exynos_tmu_data *data;
>  	struct exynos_tmu_platform_data *pdata;
> -	struct thermal_sensor_conf *sensor_conf;
> -	int ret, i;
> +	struct exynos_tmu_data *data;
> +	int ret;
>  
>  	data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
>  					GFP_KERNEL);
> @@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, data);
>  	mutex_init(&data->lock);
>  
> +	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
> +						    &exynos_sensor_ops);
> +	if (IS_ERR(data->tzd)) {
> +		pr_err("thermal: tz: %p ERROR\n", data->tzd);
> +		return PTR_ERR(data->tzd);
> +	}
>  	ret = exynos_map_dt_data(pdev);
>  	if (ret)
> -		return ret;
> +		goto err_sensor;
>  
>  	pdata = data->pdata;
>  
> @@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  	data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
>  	if (IS_ERR(data->clk)) {
>  		dev_err(&pdev->dev, "Failed to get clock\n");
> -		return  PTR_ERR(data->clk);
> +		ret = PTR_ERR(data->clk);
> +		goto err_sensor;
>  	}
>  
>  	data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
>  	if (IS_ERR(data->clk_sec)) {
>  		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
>  			dev_err(&pdev->dev, "Failed to get triminfo clock\n");
> -			return PTR_ERR(data->clk_sec);
> +			ret = PTR_ERR(data->clk_sec);
> +			goto err_sensor;
>  		}
>  	} else {
>  		ret = clk_prepare(data->clk_sec);
>  		if (ret) {
>  			dev_err(&pdev->dev, "Failed to get clock\n");
> -			return ret;
> +			goto err_sensor;
>  		}
>  	}
>  
> @@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  		goto err_clk;
>  	}
>  
> -	exynos_tmu_control(pdev, true);
> -
> -	/* Allocate a structure to register with the exynos core thermal */
> -	sensor_conf = devm_kzalloc(&pdev->dev,
> -				sizeof(struct thermal_sensor_conf), GFP_KERNEL);
> -	if (!sensor_conf) {
> -		ret = -ENOMEM;
> -		goto err_clk;
> -	}
> -	sprintf(sensor_conf->name, "therm_zone%d", data->id);
> -	sensor_conf->read_temperature = (int (*)(void *))exynos_tmu_read;
> -	sensor_conf->write_emul_temp =
> -		(int (*)(void *, unsigned long))exynos_tmu_set_emulation;
> -	sensor_conf->driver_data = data;
> -	sensor_conf->trip_data.trip_count = pdata->trigger_enable[0] +
> -			pdata->trigger_enable[1] + pdata->trigger_enable[2]+
> -			pdata->trigger_enable[3];
> -
> -	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
> -		sensor_conf->trip_data.trip_val[i] =
> -			pdata->threshold + pdata->trigger_levels[i];
> -		sensor_conf->trip_data.trip_type[i] =
> -					pdata->trigger_type[i];
> -	}
> -
> -	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
> -
> -	sensor_conf->dev = &pdev->dev;
> -	/* Register the sensor with thermal management interface */
> -	ret = exynos_register_thermal(sensor_conf);
> -	if (ret) {
> -		if (ret != -EPROBE_DEFER)
> -			dev_err(&pdev->dev,
> -				"Failed to register thermal interface: %d\n",
> -				ret);
> -		goto err_clk;
> -	}
> -	data->reg_conf = sensor_conf;
> -
>  	ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
>  		IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
>  	if (ret) {
> @@ -935,21 +1030,25 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  		goto err_clk;
>  	}
>  
> +	exynos_tmu_control(pdev, true);
>  	return 0;
>  err_clk:
>  	clk_unprepare(data->clk);
>  err_clk_sec:
>  	if (!IS_ERR(data->clk_sec))
>  		clk_unprepare(data->clk_sec);
> +err_sensor:
> +	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
> +
>  	return ret;
>  }
>  
>  static int exynos_tmu_remove(struct platform_device *pdev)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> +	struct thermal_zone_device *tzd = data->tzd;
>  
> -	exynos_unregister_thermal(data->reg_conf);
> -
> +	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
>  	exynos_tmu_control(pdev, false);
>  
>  	clk_unprepare(data->clk);
> diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
> index 627dec9..d876d4c 100644
> --- a/drivers/thermal/samsung/exynos_tmu.h
> +++ b/drivers/thermal/samsung/exynos_tmu.h
> @@ -23,8 +23,7 @@
>  #ifndef _EXYNOS_TMU_H
>  #define _EXYNOS_TMU_H
>  #include <linux/cpu_cooling.h>
> -
> -#include "exynos_thermal_common.h"
> +#include <dt-bindings/thermal/thermal_exynos.h>
>  
>  enum soc_type {
>  	SOC_ARCH_EXYNOS3250 = 1,
> @@ -36,38 +35,9 @@ enum soc_type {
>  	SOC_ARCH_EXYNOS5420_TRIMINFO,
>  	SOC_ARCH_EXYNOS5440,
>  };
> -#include <dt-bindings/thermal/thermal_exynos.h>
>  
>  /**
>   * struct exynos_tmu_platform_data
> - * @threshold: basic temperature for generating interrupt
> - *	       25 <= threshold <= 125 [unit: degree Celsius]
> - * @threshold_falling: differntial value for setting threshold
> - *		       of temperature falling interrupt.
> - * @trigger_levels: array for each interrupt levels
> - *	[unit: degree Celsius]
> - *	0: temperature for trigger_level0 interrupt
> - *	   condition for trigger_level0 interrupt:
> - *		current temperature > threshold + trigger_levels[0]
> - *	1: temperature for trigger_level1 interrupt
> - *	   condition for trigger_level1 interrupt:
> - *		current temperature > threshold + trigger_levels[1]
> - *	2: temperature for trigger_level2 interrupt
> - *	   condition for trigger_level2 interrupt:
> - *		current temperature > threshold + trigger_levels[2]
> - *	3: temperature for trigger_level3 interrupt
> - *	   condition for trigger_level3 interrupt:
> - *		current temperature > threshold + trigger_levels[3]
> - * @trigger_type: defines the type of trigger. Possible values are,
> - *	THROTTLE_ACTIVE trigger type
> - *	THROTTLE_PASSIVE trigger type
> - *	SW_TRIP trigger type
> - *	HW_TRIP
> - * @trigger_enable[]: array to denote which trigger levels are enabled.
> - *	1 = enable trigger_level[] interrupt,
> - *	0 = disable trigger_level[] interrupt
> - * @max_trigger_level: max trigger level supported by the TMU
> - * @non_hw_trigger_levels: number of defined non-hardware trigger levels
>   * @gain: gain of amplifier in the positive-TC generator block
>   *	0 < gain <= 15
>   * @reference_voltage: reference voltage of amplifier
> @@ -79,21 +49,12 @@ enum soc_type {
>   * @efuse_value: platform defined fuse value
>   * @min_efuse_value: minimum valid trimming data
>   * @max_efuse_value: maximum valid trimming data
> - * @first_point_trim: temp value of the first point trimming
> - * @second_point_trim: temp value of the second point trimming
>   * @default_temp_offset: default temperature offset in case of no trimming
>   * @cal_type: calibration type for temperature
>   *
>   * This structure is required for configuration of exynos_tmu driver.
>   */
>  struct exynos_tmu_platform_data {
> -	u8 threshold;
> -	u8 threshold_falling;
> -	u8 trigger_levels[MAX_TRIP_COUNT];
> -	enum trigger_type trigger_type[MAX_TRIP_COUNT];
> -	bool trigger_enable[MAX_TRIP_COUNT];
> -	u8 max_trigger_level;
> -	u8 non_hw_trigger_levels;
>  	u8 gain;
>  	u8 reference_voltage;
>  	u8 noise_cancel_mode;
> @@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
>  	u32 cal_mode;
>  };
>  
> -/**
> - * struct exynos_tmu_init_data
> - * @tmu_count: number of TMU instances.
> - * @tmu_data: platform data of all TMU instances.
> - * This structure is required to store data for multi-instance exynos tmu
> - * driver.
> - */
> -struct exynos_tmu_init_data {
> -	int tmu_count;
> -	struct exynos_tmu_platform_data tmu_data[];
> -};
> -
>  extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
>  extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
>  extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-19 11:20   ` [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
  2015-01-21  3:18     ` Eduardo Valentin
@ 2015-01-21  3:25     ` Eduardo Valentin
  2015-01-21  8:48       ` Lukasz Majewski
  1 sibling, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-21  3:25 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 27064 bytes --]

On Mon, Jan 19, 2015 at 12:20:59PM +0100, Lukasz Majewski wrote:
> This patch brings support for providing configuration via device tree.
> Previously this data has been hardcoded in the exynos_tmu_data.c file.
> Such approach was not scalable and very often required copying the whole
> data.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
> - Usage of of-thermal.c exported trip points table
> Changes for v3:
> - Adding exynos_of_get_soc_type() method to set SOC type from device's
>   compatible string
> - "samsung,tmu_" prefix for TMU specific properties has been added
> Changes for v4:
> - None
> Changes for v5:
> - Remove duplicated exynos_tmu_initialize() - reported by Abhilash Kesavan
>  <a.kesavan@samsung.com>
> 
> ---
>  drivers/thermal/samsung/Makefile     |   2 -
>  drivers/thermal/samsung/exynos_tmu.c | 339 ++++++++++++++++++++++-------------
>  drivers/thermal/samsung/exynos_tmu.h |  53 +-----
>  3 files changed, 220 insertions(+), 174 deletions(-)
> 
> diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile
> index c09d830..1e47d0d 100644
> --- a/drivers/thermal/samsung/Makefile
> +++ b/drivers/thermal/samsung/Makefile
> @@ -3,5 +3,3 @@
>  #
>  obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_thermal.o
>  exynos_thermal-y				:= exynos_tmu.o
> -exynos_thermal-y				+= exynos_tmu_data.o
> -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+= exynos_thermal_common.o
> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index ae30f6a..9d2d685 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -1,6 +1,10 @@
>  /*
>   * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
>   *
> + *  Copyright (C) 2014 Samsung Electronics
> + *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> + *  Lukasz Majewski <l.majewski@samsung.com>
> + *
>   *  Copyright (C) 2011 Samsung Electronics
>   *  Donggeun Kim <dg77.kim@samsung.com>
>   *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
> @@ -31,8 +35,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/regulator/consumer.h>
>  
> -#include "exynos_thermal_common.h"
>  #include "exynos_tmu.h"
> +#include "../thermal_core.h"
>  
>  /* Exynos generic registers */
>  #define EXYNOS_TMU_REG_TRIMINFO		0x0
> @@ -115,6 +119,7 @@
>  #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
>  #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
>  
> +#define MCELSIUS	1000
>  /**
>   * struct exynos_tmu_data : A structure to hold the private data of the TMU
>  	driver
> @@ -150,7 +155,8 @@ struct exynos_tmu_data {
>  	struct clk *clk, *clk_sec;
>  	u8 temp_error1, temp_error2;
>  	struct regulator *regulator;
> -	struct thermal_sensor_conf *reg_conf;
> +	struct thermal_zone_device *tzd;
> +
>  	int (*tmu_initialize)(struct platform_device *pdev);
>  	void (*tmu_control)(struct platform_device *pdev, bool on);
>  	int (*tmu_read)(struct exynos_tmu_data *data);
> @@ -159,6 +165,33 @@ struct exynos_tmu_data {
>  	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
>  };
>  
> +static void exynos_report_trigger(struct exynos_tmu_data *p)
> +{
> +	char data[10], *envp[] = { data, NULL };
> +	struct thermal_zone_device *tz = p->tzd;
> +	unsigned long temp;
> +	unsigned int i;
> +
> +	if (!p) {
> +		pr_err("Wrong temperature configuration data\n");
> +		return;
> +	}
> +
> +	thermal_zone_device_update(tz);
> +
> +	mutex_lock(&tz->lock);
> +	/* Find the level for which trip happened */
> +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> +		tz->ops->get_trip_temp(tz, i, &temp);
> +		if (tz->last_temperature < temp)
> +			break;
> +	}
> +
> +	snprintf(data, sizeof(data), "%u", i);
> +	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
> +	mutex_unlock(&tz->lock);
> +}
> +
>  /*
>   * TMU treats temperature as a mapped temperature code.
>   * The temperature is converted differently depending on the calibration type.
> @@ -234,14 +267,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
>  
>  static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling)
>  {
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> +	struct thermal_zone_device *tz = data->tzd;
> +	const struct thermal_trip * const trips =
> +		of_thermal_get_trip_points(tz);
> +	unsigned long temp;
>  	int i;
>  
> -	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
> -		u8 temp = pdata->trigger_levels[i];
> +	if (!trips) {
> +		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
> +		       __func__);
> +		return 0;
> +	}
>  
> +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> +		if (trips[i].type == THERMAL_TRIP_CRITICAL)
> +			continue;
> +
> +		temp = trips[i].temperature / MCELSIUS;
>  		if (falling)
> -			temp -= pdata->threshold_falling;
> +			temp -= (trips[i].hysteresis / MCELSIUS);
>  		else
>  			threshold &= ~(0xff << 8 * i);
>  
> @@ -305,9 +349,19 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
>  static int exynos4210_tmu_initialize(struct platform_device *pdev)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> -	unsigned int status;
> +	struct thermal_zone_device *tz = data->tzd;
> +	const struct thermal_trip * const trips =
> +		of_thermal_get_trip_points(tz);
>  	int ret = 0, threshold_code, i;
> +	unsigned long reference, temp;
> +	unsigned int status;
> +
> +	if (!trips) {
> +		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
> +		       __func__);
> +		ret = -ENODEV;
> +		goto out;
> +	}
>  
>  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
>  	if (!status) {
> @@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct platform_device *pdev)
>  	sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));
>  
>  	/* Write temperature code for threshold */
> -	threshold_code = temp_to_code(data, pdata->threshold);
> +	reference = trips[0].temperature / MCELSIUS;
> +	threshold_code = temp_to_code(data, reference);
> +	if (threshold_code < 0) {
> +		ret = threshold_code;
> +		goto out;
> +	}
>  	writeb(threshold_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
>  
> -	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
> -		writeb(pdata->trigger_levels[i], data->base +
> +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> +		temp = trips[i].temperature / MCELSIUS;
> +		writeb(temp - reference, data->base +
>  		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
> +	}
>  
>  	data->tmu_clear_irqs(data);
>  out:
> @@ -333,9 +394,11 @@ out:
>  static int exynos4412_tmu_initialize(struct platform_device *pdev)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> +	const struct thermal_trip * const trips =
> +		of_thermal_get_trip_points(data->tzd);
>  	unsigned int status, trim_info, con, ctrl, rising_threshold;
>  	int ret = 0, threshold_code, i;
> +	unsigned long crit_temp = 0;
>  
>  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
>  	if (!status) {
> @@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
>  	data->tmu_clear_irqs(data);
>  
>  	/* if last threshold limit is also present */
> -	i = pdata->max_trigger_level - 1;
> -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
> -		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
> -		/* 1-4 level to be assigned in th0 reg */
> -		rising_threshold &= ~(0xff << 8 * i);
> -		rising_threshold |= threshold_code << 8 * i;
> -		writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
> -		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> -		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> -		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> +	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
> +		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
> +			crit_temp = trips[i].temperature;
> +			break;
> +		}
> +	}
> +
> +	if (i == of_thermal_get_ntrips(data->tzd)) {
> +		pr_err("%s: No CRITICAL trip point defined at of-thermal.c!\n",
> +		       __func__);
> +		ret = -EINVAL;
> +		goto out;
>  	}
> +
> +	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
> +	/* 1-4 level to be assigned in th0 reg */
> +	rising_threshold &= ~(0xff << 8 * i);
> +	rising_threshold |= threshold_code << 8 * i;
> +	writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
> +	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> +	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> +	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> +
>  out:
>  	return ret;
>  }
> @@ -391,9 +466,9 @@ out:
>  static int exynos5440_tmu_initialize(struct platform_device *pdev)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
>  	unsigned int trim_info = 0, con, rising_threshold;
> -	int ret = 0, threshold_code, i;
> +	int ret = 0, threshold_code;
> +	unsigned long crit_temp = 0;
>  
>  	/*
>  	 * For exynos5440 soc triminfo value is swapped between TMU0 and
> @@ -422,9 +497,8 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
>  	data->tmu_clear_irqs(data);
>  
>  	/* if last threshold limit is also present */
> -	i = pdata->max_trigger_level - 1;
> -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
> -		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
> +	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp)) {
> +		threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
>  		/* 5th level to be assigned in th2 reg */
>  		rising_threshold =
>  			threshold_code << EXYNOS5440_TMU_TH_RISE4_SHIFT;
> @@ -442,7 +516,7 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
>  static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> +	struct thermal_zone_device *tz = data->tzd;
>  	unsigned int con, interrupt_en;
>  
>  	con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
> @@ -450,10 +524,15 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
>  	if (on) {
>  		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
>  		interrupt_en =
> -			pdata->trigger_enable[3] << EXYNOS_TMU_INTEN_RISE3_SHIFT |
> -			pdata->trigger_enable[2] << EXYNOS_TMU_INTEN_RISE2_SHIFT |
> -			pdata->trigger_enable[1] << EXYNOS_TMU_INTEN_RISE1_SHIFT |
> -			pdata->trigger_enable[0] << EXYNOS_TMU_INTEN_RISE0_SHIFT;
> +			(of_thermal_is_trip_valid(tz, 3)
> +			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 2)
> +			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 1)
> +			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 0)
> +			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
> +
>  		if (data->soc != SOC_ARCH_EXYNOS4210)
>  			interrupt_en |=
>  				interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
> @@ -468,7 +547,7 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
>  static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> -	struct exynos_tmu_platform_data *pdata = data->pdata;
> +	struct thermal_zone_device *tz = data->tzd;
>  	unsigned int con, interrupt_en;
>  
>  	con = get_con_reg(data, readl(data->base + EXYNOS5440_TMU_S0_7_CTRL));
> @@ -476,11 +555,16 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
>  	if (on) {
>  		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
>  		interrupt_en =
> -			pdata->trigger_enable[3] << EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
> -			pdata->trigger_enable[2] << EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
> -			pdata->trigger_enable[1] << EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
> -			pdata->trigger_enable[0] << EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
> -		interrupt_en |= interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
> +			(of_thermal_is_trip_valid(tz, 3)
> +			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 2)
> +			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 1)
> +			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
> +			(of_thermal_is_trip_valid(tz, 0)
> +			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
> +		interrupt_en |=
> +			interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
>  	} else {
>  		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
>  		interrupt_en = 0; /* Disable all interrupts */
> @@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
>  	writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL);
>  }
>  
> -static int exynos_tmu_read(struct exynos_tmu_data *data)
> +int exynos_get_temp(void *p, long *temp)

exynos_get_temp must be static.

>  {
> -	int ret;
> +	struct exynos_tmu_data *data = p;
> +
> +	if (!data)
> +		return -EINVAL;
>  
>  	mutex_lock(&data->lock);
>  	clk_enable(data->clk);
> -	ret = data->tmu_read(data);
> -	if (ret >= 0)
> -		ret = code_to_temp(data, ret);
> +
> +	*temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS;
> +
>  	clk_disable(data->clk);
>  	mutex_unlock(&data->lock);
>  
> -	return ret;
> +	return 0;
>  }
>  
>  #ifdef CONFIG_THERMAL_EMULATION
> @@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct *work)
>  	if (!IS_ERR(data->clk_sec))
>  		clk_disable(data->clk_sec);
>  
> -	exynos_report_trigger(data->reg_conf);
> +	exynos_report_trigger(data);
>  	mutex_lock(&data->lock);
>  	clk_enable(data->clk);
>  
> @@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
>  static const struct of_device_id exynos_tmu_match[] = {
>  	{
>  		.compatible = "samsung,exynos3250-tmu",
> -		.data = &exynos3250_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos4210-tmu",
> -		.data = &exynos4210_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos4412-tmu",
> -		.data = &exynos4412_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5250-tmu",
> -		.data = &exynos5250_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5260-tmu",
> -		.data = &exynos5260_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5420-tmu",
> -		.data = &exynos5420_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5420-tmu-ext-triminfo",
> -		.data = &exynos5420_default_tmu_data,
>  	},
>  	{
>  		.compatible = "samsung,exynos5440-tmu",
> -		.data = &exynos5440_default_tmu_data,
>  	},
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, exynos_tmu_match);
>  
> -static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
> -			struct platform_device *pdev, int id)
> +static int exynos_of_get_soc_type(struct device_node *np)
>  {
> -	struct  exynos_tmu_init_data *data_table;
> -	struct exynos_tmu_platform_data *tmu_data;
> -	const struct of_device_id *match;
> +	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
> +		return SOC_ARCH_EXYNOS3250;
> +	else if (of_device_is_compatible(np, "samsung,exynos4210-tmu"))
> +		return SOC_ARCH_EXYNOS4210;
> +	else if (of_device_is_compatible(np, "samsung,exynos4412-tmu"))
> +		return SOC_ARCH_EXYNOS4412;
> +	else if (of_device_is_compatible(np, "samsung,exynos5250-tmu"))
> +		return SOC_ARCH_EXYNOS5250;
> +	else if (of_device_is_compatible(np, "samsung,exynos5260-tmu"))
> +		return SOC_ARCH_EXYNOS5260;
> +	else if (of_device_is_compatible(np, "samsung,exynos5420-tmu"))
> +		return SOC_ARCH_EXYNOS5420;
> +	else if (of_device_is_compatible(np,
> +					 "samsung,exynos5420-tmu-ext-triminfo"))
> +		return SOC_ARCH_EXYNOS5420_TRIMINFO;
> +	else if (of_device_is_compatible(np, "samsung,exynos5440-tmu"))
> +		return SOC_ARCH_EXYNOS5440;
> +
> +	return -EINVAL;
> +}
>  
> -	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
> -	if (!match)
> -		return NULL;
> -	data_table = (struct exynos_tmu_init_data *) match->data;
> -	if (!data_table || id >= data_table->tmu_count)
> -		return NULL;
> -	tmu_data = data_table->tmu_data;
> -	return (struct exynos_tmu_platform_data *) (tmu_data + id);
> +static int exynos_of_sensor_conf(struct device_node *np,
> +				 struct exynos_tmu_platform_data *pdata)
> +{
> +	u32 value;
> +	int ret;
> +
> +	of_node_get(np);
> +
> +	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
> +	pdata->gain = (u8) value;
> +	of_property_read_u32(np, "samsung,tmu_reference_voltage", &value);
> +	pdata->reference_voltage = (u8) value;
> +	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode", &value);
> +	pdata->noise_cancel_mode = (u8) value;
> +
> +	of_property_read_u32(np, "samsung,tmu_efuse_value",
> +			     &pdata->efuse_value);
> +	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
> +			     &pdata->min_efuse_value);
> +	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
> +			     &pdata->max_efuse_value);
> +
> +	of_property_read_u32(np, "samsung,tmu_first_point_trim", &value);
> +	pdata->first_point_trim = (u8) value;
> +	of_property_read_u32(np, "samsung,tmu_second_point_trim", &value);
> +	pdata->second_point_trim = (u8) value;
> +	of_property_read_u32(np, "samsung,tmu_default_temp_offset", &value);
> +	pdata->default_temp_offset = (u8) value;
> +
> +	of_property_read_u32(np, "samsung,tmu_cal_type", &pdata->cal_type);
> +	of_property_read_u32(np, "samsung,tmu_cal_mode", &pdata->cal_mode);
> +
> +	of_node_put(np);
> +	return 0;
>  }
>  
>  static int exynos_map_dt_data(struct platform_device *pdev)
> @@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct platform_device *pdev)
>  		return -EADDRNOTAVAIL;
>  	}
>  
> -	pdata = exynos_get_driver_data(pdev, data->id);
> -	if (!pdata) {
> -		dev_err(&pdev->dev, "No platform init data supplied.\n");
> -		return -ENODEV;
> -	}
> +	pdata = devm_kzalloc(&pdev->dev,
> +			     sizeof(struct exynos_tmu_platform_data),
> +			     GFP_KERNEL);
> +	if (!pdata)
> +		return -ENOMEM;
>  
> +	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
>  	data->pdata = pdata;
> -	data->soc = pdata->type;
> +	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
>  
>  	switch (data->soc) {
>  	case SOC_ARCH_EXYNOS4210:
> @@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static struct thermal_zone_of_device_ops exynos_sensor_ops = {
> +	.get_temp = exynos_get_temp,
> +	.set_emul_temp = exynos_tmu_set_emulation,
> +};
> +
>  static int exynos_tmu_probe(struct platform_device *pdev)
>  {
> -	struct exynos_tmu_data *data;
>  	struct exynos_tmu_platform_data *pdata;
> -	struct thermal_sensor_conf *sensor_conf;
> -	int ret, i;
> +	struct exynos_tmu_data *data;
> +	int ret;
>  
>  	data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
>  					GFP_KERNEL);
> @@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, data);
>  	mutex_init(&data->lock);
>  
> +	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
> +						    &exynos_sensor_ops);
> +	if (IS_ERR(data->tzd)) {
> +		pr_err("thermal: tz: %p ERROR\n", data->tzd);
> +		return PTR_ERR(data->tzd);
> +	}
>  	ret = exynos_map_dt_data(pdev);
>  	if (ret)
> -		return ret;
> +		goto err_sensor;
>  
>  	pdata = data->pdata;
>  
> @@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  	data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
>  	if (IS_ERR(data->clk)) {
>  		dev_err(&pdev->dev, "Failed to get clock\n");
> -		return  PTR_ERR(data->clk);
> +		ret = PTR_ERR(data->clk);
> +		goto err_sensor;
>  	}
>  
>  	data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
>  	if (IS_ERR(data->clk_sec)) {
>  		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
>  			dev_err(&pdev->dev, "Failed to get triminfo clock\n");
> -			return PTR_ERR(data->clk_sec);
> +			ret = PTR_ERR(data->clk_sec);
> +			goto err_sensor;
>  		}
>  	} else {
>  		ret = clk_prepare(data->clk_sec);
>  		if (ret) {
>  			dev_err(&pdev->dev, "Failed to get clock\n");
> -			return ret;
> +			goto err_sensor;
>  		}
>  	}
>  
> @@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  		goto err_clk;
>  	}
>  
> -	exynos_tmu_control(pdev, true);
> -
> -	/* Allocate a structure to register with the exynos core thermal */
> -	sensor_conf = devm_kzalloc(&pdev->dev,
> -				sizeof(struct thermal_sensor_conf), GFP_KERNEL);
> -	if (!sensor_conf) {
> -		ret = -ENOMEM;
> -		goto err_clk;
> -	}
> -	sprintf(sensor_conf->name, "therm_zone%d", data->id);
> -	sensor_conf->read_temperature = (int (*)(void *))exynos_tmu_read;
> -	sensor_conf->write_emul_temp =
> -		(int (*)(void *, unsigned long))exynos_tmu_set_emulation;
> -	sensor_conf->driver_data = data;
> -	sensor_conf->trip_data.trip_count = pdata->trigger_enable[0] +
> -			pdata->trigger_enable[1] + pdata->trigger_enable[2]+
> -			pdata->trigger_enable[3];
> -
> -	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
> -		sensor_conf->trip_data.trip_val[i] =
> -			pdata->threshold + pdata->trigger_levels[i];
> -		sensor_conf->trip_data.trip_type[i] =
> -					pdata->trigger_type[i];
> -	}
> -
> -	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
> -
> -	sensor_conf->dev = &pdev->dev;
> -	/* Register the sensor with thermal management interface */
> -	ret = exynos_register_thermal(sensor_conf);
> -	if (ret) {
> -		if (ret != -EPROBE_DEFER)
> -			dev_err(&pdev->dev,
> -				"Failed to register thermal interface: %d\n",
> -				ret);
> -		goto err_clk;
> -	}
> -	data->reg_conf = sensor_conf;
> -
>  	ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
>  		IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
>  	if (ret) {
> @@ -935,21 +1030,25 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  		goto err_clk;
>  	}
>  
> +	exynos_tmu_control(pdev, true);
>  	return 0;
>  err_clk:
>  	clk_unprepare(data->clk);
>  err_clk_sec:
>  	if (!IS_ERR(data->clk_sec))
>  		clk_unprepare(data->clk_sec);
> +err_sensor:
> +	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
> +
>  	return ret;
>  }
>  
>  static int exynos_tmu_remove(struct platform_device *pdev)
>  {
>  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> +	struct thermal_zone_device *tzd = data->tzd;
>  
> -	exynos_unregister_thermal(data->reg_conf);
> -
> +	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
>  	exynos_tmu_control(pdev, false);
>  
>  	clk_unprepare(data->clk);
> diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
> index 627dec9..d876d4c 100644
> --- a/drivers/thermal/samsung/exynos_tmu.h
> +++ b/drivers/thermal/samsung/exynos_tmu.h
> @@ -23,8 +23,7 @@
>  #ifndef _EXYNOS_TMU_H
>  #define _EXYNOS_TMU_H
>  #include <linux/cpu_cooling.h>
> -
> -#include "exynos_thermal_common.h"
> +#include <dt-bindings/thermal/thermal_exynos.h>
>  
>  enum soc_type {
>  	SOC_ARCH_EXYNOS3250 = 1,
> @@ -36,38 +35,9 @@ enum soc_type {
>  	SOC_ARCH_EXYNOS5420_TRIMINFO,
>  	SOC_ARCH_EXYNOS5440,
>  };
> -#include <dt-bindings/thermal/thermal_exynos.h>
>  
>  /**
>   * struct exynos_tmu_platform_data
> - * @threshold: basic temperature for generating interrupt
> - *	       25 <= threshold <= 125 [unit: degree Celsius]
> - * @threshold_falling: differntial value for setting threshold
> - *		       of temperature falling interrupt.
> - * @trigger_levels: array for each interrupt levels
> - *	[unit: degree Celsius]
> - *	0: temperature for trigger_level0 interrupt
> - *	   condition for trigger_level0 interrupt:
> - *		current temperature > threshold + trigger_levels[0]
> - *	1: temperature for trigger_level1 interrupt
> - *	   condition for trigger_level1 interrupt:
> - *		current temperature > threshold + trigger_levels[1]
> - *	2: temperature for trigger_level2 interrupt
> - *	   condition for trigger_level2 interrupt:
> - *		current temperature > threshold + trigger_levels[2]
> - *	3: temperature for trigger_level3 interrupt
> - *	   condition for trigger_level3 interrupt:
> - *		current temperature > threshold + trigger_levels[3]
> - * @trigger_type: defines the type of trigger. Possible values are,
> - *	THROTTLE_ACTIVE trigger type
> - *	THROTTLE_PASSIVE trigger type
> - *	SW_TRIP trigger type
> - *	HW_TRIP
> - * @trigger_enable[]: array to denote which trigger levels are enabled.
> - *	1 = enable trigger_level[] interrupt,
> - *	0 = disable trigger_level[] interrupt
> - * @max_trigger_level: max trigger level supported by the TMU
> - * @non_hw_trigger_levels: number of defined non-hardware trigger levels
>   * @gain: gain of amplifier in the positive-TC generator block
>   *	0 < gain <= 15
>   * @reference_voltage: reference voltage of amplifier
> @@ -79,21 +49,12 @@ enum soc_type {
>   * @efuse_value: platform defined fuse value
>   * @min_efuse_value: minimum valid trimming data
>   * @max_efuse_value: maximum valid trimming data
> - * @first_point_trim: temp value of the first point trimming
> - * @second_point_trim: temp value of the second point trimming
>   * @default_temp_offset: default temperature offset in case of no trimming
>   * @cal_type: calibration type for temperature
>   *
>   * This structure is required for configuration of exynos_tmu driver.
>   */
>  struct exynos_tmu_platform_data {
> -	u8 threshold;
> -	u8 threshold_falling;
> -	u8 trigger_levels[MAX_TRIP_COUNT];
> -	enum trigger_type trigger_type[MAX_TRIP_COUNT];
> -	bool trigger_enable[MAX_TRIP_COUNT];
> -	u8 max_trigger_level;
> -	u8 non_hw_trigger_levels;
>  	u8 gain;
>  	u8 reference_voltage;
>  	u8 noise_cancel_mode;
> @@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
>  	u32 cal_mode;
>  };
>  
> -/**
> - * struct exynos_tmu_init_data
> - * @tmu_count: number of TMU instances.
> - * @tmu_data: platform data of all TMU instances.
> - * This structure is required to store data for multi-instance exynos tmu
> - * driver.
> - */
> -struct exynos_tmu_init_data {
> -	int tmu_count;
> -	struct exynos_tmu_platform_data tmu_data[];
> -};
> -
>  extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
>  extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
>  extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 18/18] thermal: exynos: Remove not needed exynos_tmu_init_data declarations from exynos_tmu.h
  2015-01-19 11:21   ` [PATCH v5 18/18] thermal: exynos: Remove not needed exynos_tmu_init_data declarations from exynos_tmu.h Lukasz Majewski
@ 2015-01-21  3:30     ` Eduardo Valentin
  2015-01-21  9:00       ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-21  3:30 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 1390 bytes --]

On Mon, Jan 19, 2015 at 12:21:02PM +0100, Lukasz Majewski wrote:
> After switching to device tree based configuration those declarations are
> not needed anymore.
> 
> Reported-by: Abhilash Kesavan <a.kesavan@samsung.com>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v5:
> - New patch
> ---
>  drivers/thermal/samsung/exynos_tmu.h | 8 --------
>  1 file changed, 8 deletions(-)
> 
> diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
> index d876d4c..9f9b1b8 100644
> --- a/drivers/thermal/samsung/exynos_tmu.h
> +++ b/drivers/thermal/samsung/exynos_tmu.h
> @@ -71,12 +71,4 @@ struct exynos_tmu_platform_data {
>  	u32 cal_mode;
>  };
>  
> -extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
> -extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
> -extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
> -extern struct exynos_tmu_init_data const exynos5250_default_tmu_data;
> -extern struct exynos_tmu_init_data const exynos5260_default_tmu_data;
> -extern struct exynos_tmu_init_data const exynos5420_default_tmu_data;
> -extern struct exynos_tmu_init_data const exynos5440_default_tmu_data;

Please merge this patch to the one that removes these symbols from
kernel.

> -
>  #endif /* _EXYNOS_TMU_H */
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-21  1:23         ` Eduardo Valentin
@ 2015-01-21  8:10           ` Lukasz Majewski
  2015-01-21  9:20             ` Eduardo Valentin
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-21  8:10 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Kyungmin Park,
	Chanwoo Choi

Hi Eduardo,

> On Thu, Jan 15, 2015 at 04:17:52PM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > On Wed, Jan 14, 2015 at 02:41:12PM +0100, Lukasz Majewski wrote:
> > > > This patch brings support for providing configuration via device
> > > > tree. Previously this data has been hardcoded in the
> > > > exynos_tmu_data.c file. Such approach was not scalable and very
> > > > often required copying the whole data.
> > > > 
> > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > ---
> > > > Changes for v2:
> > > > - Adjust exynos_tmu.c code to the newest ti-soc-thermal
> > > > repository
> > > > - Usage of of-thermal.c exported trip points table
> > > > Changes for v3:
> > > > - Adding exynos_of_get_soc_type() method to set SOC type from
> > > > device's compatible string
> > > > - "samsung,tmu_" prefix for TMU specific properties has been
> > > > added
> > > > 
> > > > ---
> > > >  drivers/thermal/samsung/Makefile     |   2 -
> > > >  drivers/thermal/samsung/exynos_tmu.c | 345
> > > > +++++++++++++++++++++++------------
> > > > drivers/thermal/samsung/exynos_tmu.h |  53 +----- 3 files
> > > > changed, 226 insertions(+), 174 deletions(-)
> > > > 
> > > > diff --git a/drivers/thermal/samsung/Makefile
> > > > b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644
> > > > --- a/drivers/thermal/samsung/Makefile
> > > > +++ b/drivers/thermal/samsung/Makefile
> > > > @@ -3,5 +3,3 @@
> > > >  #
> > > >  obj-$(CONFIG_EXYNOS_THERMAL)			+=
> > > > exynos_thermal.o
> > > > exynos_thermal-y				:= exynos_tmu.o
> > > > -exynos_thermal-y				+=
> > > > exynos_tmu_data.o
> > > 
> > > Can this makefile change be part of the patch that removes
> > > exynos_tmu_data.c?
> > > 
> > > > -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+=
> > > > exynos_thermal_common.o
> > > 
> > > Can this makefile change be part of the patch that removes
> > > exynos_thermal_common.c?
> > 
> > Unfortunately, this code cannot be moved to the next patch, in
> > which I remove the files, since this causes build break of the
> > series.
> > 
> > The code structure as is, provides working, bisectable thermal
> > solution - thermal and cpu_cooling functionality is preserved across
> > all commits in the series.
> 
> My concern here is simply that this specific commit is leaving unused
> files in the tree.
> 
> One option would be to remove the files altogether in this specific
> commit.

Is is really necessary?

This patch itself changes around 400 LOC. Those changes __are__
important and in my opinion deserve their own commit.

When I squash following patches, which remove old exynos files, we
would have around 1.2K LOC in a single commit.

I think that current approach is far more readable. 

Eduardo, is there a chance for this series (the newest version is v5 -
which include Ablibash comments) to be included to yours -next tree
before v3.19 is out?

> 
> > 
> > > 
> > > > diff --git a/drivers/thermal/samsung/exynos_tmu.c
> > > > b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..633a9e2
> > > > 100644 --- a/drivers/thermal/samsung/exynos_tmu.c
> > > > +++ b/drivers/thermal/samsung/exynos_tmu.c
> > > > @@ -1,6 +1,10 @@
> > > >  /*
> > > >   * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
> > > >   *
> > > > + *  Copyright (C) 2014 Samsung Electronics
> > > > + *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> > > > + *  Lukasz Majewski <l.majewski@samsung.com>
> > > > + *
> > > >   *  Copyright (C) 2011 Samsung Electronics
> > > >   *  Donggeun Kim <dg77.kim@samsung.com>
> > > >   *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
> > > > @@ -31,8 +35,8 @@
> > > >  #include <linux/platform_device.h>
> > > >  #include <linux/regulator/consumer.h>
> > > >  
> > > > -#include "exynos_thermal_common.h"
> > > >  #include "exynos_tmu.h"
> > > > +#include "../thermal_core.h"
> > > >  
> > > >  /* Exynos generic registers */
> > > >  #define EXYNOS_TMU_REG_TRIMINFO		0x0
> > > > @@ -115,6 +119,7 @@
> > > >  #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
> > > >  #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
> > > >  
> > > > +#define MCELSIUS	1000
> > > >  /**
> > > >   * struct exynos_tmu_data : A structure to hold the private
> > > > data of the TMU driver
> > > > @@ -150,7 +155,8 @@ struct exynos_tmu_data {
> > > >  	struct clk *clk, *clk_sec;
> > > >  	u8 temp_error1, temp_error2;
> > > >  	struct regulator *regulator;
> > > > -	struct thermal_sensor_conf *reg_conf;
> > > > +	struct thermal_zone_device *tzd;
> > > > +
> > > >  	int (*tmu_initialize)(struct platform_device *pdev);
> > > >  	void (*tmu_control)(struct platform_device *pdev, bool
> > > > on); int (*tmu_read)(struct exynos_tmu_data *data);
> > > > @@ -159,6 +165,33 @@ struct exynos_tmu_data {
> > > >  	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
> > > >  };
> > > >  
> > > > +static void exynos_report_trigger(struct exynos_tmu_data *p)
> > > > +{
> > > > +	char data[10], *envp[] = { data, NULL };
> > > > +	struct thermal_zone_device *tz = p->tzd;
> > > > +	unsigned long temp;
> > > > +	unsigned int i;
> > > > +
> > > > +	if (!p) {
> > > > +		pr_err("Wrong temperature configuration
> > > > data\n");
> > > > +		return;
> > > > +	}
> > > > +
> > > > +	thermal_zone_device_update(tz);
> > > > +
> > > > +	mutex_lock(&tz->lock);
> > > > +	/* Find the level for which trip happened */
> > > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > > +		tz->ops->get_trip_temp(tz, i, &temp);
> > > > +		if (tz->last_temperature < temp)
> > > > +			break;
> > > > +	}
> > > > +
> > > > +	snprintf(data, sizeof(data), "%u", i);
> > > > +	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE,
> > > > envp);
> > > > +	mutex_unlock(&tz->lock);
> > > > +}
> > > > +
> > > >  /*
> > > >   * TMU treats temperature as a mapped temperature code.
> > > >   * The temperature is converted differently depending on the
> > > > calibration type. @@ -234,14 +267,25 @@ static void
> > > > sanitize_temp_error(struct exynos_tmu_data *data, u32
> > > > trim_info) static u32 get_th_reg(struct exynos_tmu_data *data,
> > > > u32 threshold, bool falling) {
> > > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > > +	struct thermal_zone_device *tz = data->tzd;
> > > > +	const struct thermal_trip * const trips =
> > > > +		of_thermal_get_trip_points(tz);
> > > > +	unsigned long temp;
> > > >  	int i;
> > > >  
> > > > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
> > > > -		u8 temp = pdata->trigger_levels[i];
> > > > +	if (!trips) {
> > > > +		pr_err("%s: Cannot get trip points from
> > > > of-thermal.c!\n",
> > > > +		       __func__);
> > > > +		return 0;
> > > > +	}
> > > > +
> > > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > > +		if (trips[i].type == THERMAL_TRIP_CRITICAL)
> > > > +			continue;
> > > >  
> > > > +		temp = trips[i].temperature / MCELSIUS;
> > > >  		if (falling)
> > > > -			temp -= pdata->threshold_falling;
> > > > +			temp -= (trips[i].hysteresis /
> > > > MCELSIUS); else
> > > >  			threshold &= ~(0xff << 8 * i);
> > > >  
> > > > @@ -305,9 +349,19 @@ static void exynos_tmu_control(struct
> > > > platform_device *pdev, bool on) static int
> > > > exynos4210_tmu_initialize(struct platform_device *pdev) {
> > > >  	struct exynos_tmu_data *data =
> > > > platform_get_drvdata(pdev);
> > > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > > -	unsigned int status;
> > > > +	struct thermal_zone_device *tz = data->tzd;
> > > > +	const struct thermal_trip * const trips =
> > > > +		of_thermal_get_trip_points(tz);
> > > >  	int ret = 0, threshold_code, i;
> > > > +	unsigned long reference, temp;
> > > > +	unsigned int status;
> > > > +
> > > > +	if (!trips) {
> > > > +		pr_err("%s: Cannot get trip points from
> > > > of-thermal.c!\n",
> > > > +		       __func__);
> > > > +		ret = -ENODEV;
> > > > +		goto out;
> > > > +	}
> > > >  
> > > >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> > > >  	if (!status) {
> > > > @@ -318,12 +372,19 @@ static int
> > > > exynos4210_tmu_initialize(struct platform_device *pdev)
> > > > sanitize_temp_error(data, readl(data->base +
> > > > EXYNOS_TMU_REG_TRIMINFO)); /* Write temperature code for
> > > > threshold */
> > > > -	threshold_code = temp_to_code(data, pdata->threshold);
> > > > +	reference = trips[0].temperature / MCELSIUS;
> > > > +	threshold_code = temp_to_code(data, reference);
> > > > +	if (threshold_code < 0) {
> > > > +		ret = threshold_code;
> > > > +		goto out;
> > > > +	}
> > > >  	writeb(threshold_code, data->base +
> > > > EXYNOS4210_TMU_REG_THRESHOLD_TEMP); 
> > > > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
> > > > -		writeb(pdata->trigger_levels[i], data->base +
> > > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > > +		temp = trips[i].temperature / MCELSIUS;
> > > > +		writeb(temp - reference, data->base +
> > > >  		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
> > > > +	}
> > > >  
> > > >  	data->tmu_clear_irqs(data);
> > > >  out:
> > > > @@ -333,9 +394,11 @@ out:
> > > >  static int exynos4412_tmu_initialize(struct platform_device
> > > > *pdev) {
> > > >  	struct exynos_tmu_data *data =
> > > > platform_get_drvdata(pdev);
> > > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > > +	const struct thermal_trip * const trips =
> > > > +		of_thermal_get_trip_points(data->tzd);
> > > >  	unsigned int status, trim_info, con, ctrl,
> > > > rising_threshold; int ret = 0, threshold_code, i;
> > > > +	unsigned long crit_temp = 0;
> > > >  
> > > >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> > > >  	if (!status) {
> > > > @@ -373,17 +436,29 @@ static int
> > > > exynos4412_tmu_initialize(struct platform_device *pdev)
> > > > data->tmu_clear_irqs(data); 
> > > >  	/* if last threshold limit is also present */
> > > > -	i = pdata->max_trigger_level - 1;
> > > > -	if (pdata->trigger_levels[i] && pdata->trigger_type[i]
> > > > == HW_TRIP) {
> > > > -		threshold_code = temp_to_code(data,
> > > > pdata->trigger_levels[i]);
> > > > -		/* 1-4 level to be assigned in th0 reg */
> > > > -		rising_threshold &= ~(0xff << 8 * i);
> > > > -		rising_threshold |= threshold_code << 8 * i;
> > > > -		writel(rising_threshold, data->base +
> > > > EXYNOS_THD_TEMP_RISE);
> > > > -		con = readl(data->base +
> > > > EXYNOS_TMU_REG_CONTROL);
> > > > -		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > > > -		writel(con, data->base +
> > > > EXYNOS_TMU_REG_CONTROL);
> > > > +	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++)
> > > > {
> > > > +		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
> > > > +			crit_temp = trips[i].temperature;
> > > > +			break;
> > > > +		}
> > > >  	}
> > > > +
> > > > +	if (i == of_thermal_get_ntrips(data->tzd)) {
> > > > +		pr_err("%s: No CRITICAL trip point defined at
> > > > of-thermal.c!\n",
> > > > +		       __func__);
> > > > +		ret = -EINVAL;
> > > > +		goto out;
> > > > +	}
> > > > +
> > > > +	threshold_code = temp_to_code(data, crit_temp /
> > > > MCELSIUS);
> > > > +	/* 1-4 level to be assigned in th0 reg */
> > > > +	rising_threshold &= ~(0xff << 8 * i);
> > > > +	rising_threshold |= threshold_code << 8 * i;
> > > > +	writel(rising_threshold, data->base +
> > > > EXYNOS_THD_TEMP_RISE);
> > > > +	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> > > > +	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > > > +	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> > > > +
> > > >  out:
> > > >  	return ret;
> > > >  }
> > > > @@ -391,9 +466,9 @@ out:
> > > >  static int exynos5440_tmu_initialize(struct platform_device
> > > > *pdev) {
> > > >  	struct exynos_tmu_data *data =
> > > > platform_get_drvdata(pdev);
> > > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > >  	unsigned int trim_info = 0, con, rising_threshold;
> > > > -	int ret = 0, threshold_code, i;
> > > > +	int ret = 0, threshold_code;
> > > > +	unsigned long crit_temp = 0;
> > > >  
> > > >  	/*
> > > >  	 * For exynos5440 soc triminfo value is swapped between
> > > > TMU0 and @@ -422,9 +497,8 @@ static int
> > > > exynos5440_tmu_initialize(struct platform_device *pdev)
> > > > data->tmu_clear_irqs(data); 
> > > >  	/* if last threshold limit is also present */
> > > > -	i = pdata->max_trigger_level - 1;
> > > > -	if (pdata->trigger_levels[i] && pdata->trigger_type[i]
> > > > == HW_TRIP) {
> > > > -		threshold_code = temp_to_code(data,
> > > > pdata->trigger_levels[i]);
> > > > +	if (!data->tzd->ops->get_crit_temp(data->tzd,
> > > > &crit_temp)) {
> > > > +		threshold_code = temp_to_code(data, crit_temp /
> > > > MCELSIUS); /* 5th level to be assigned in th2 reg */
> > > >  		rising_threshold =
> > > >  			threshold_code <<
> > > > EXYNOS5440_TMU_TH_RISE4_SHIFT; @@ -442,7 +516,7 @@ static int
> > > > exynos5440_tmu_initialize(struct platform_device *pdev) static
> > > > void exynos4210_tmu_control(struct platform_device *pdev, bool
> > > > on) { struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > > +	struct thermal_zone_device *tz = data->tzd;
> > > >  	unsigned int con, interrupt_en;
> > > >  
> > > >  	con = get_con_reg(data, readl(data->base +
> > > > EXYNOS_TMU_REG_CONTROL)); @@ -450,10 +524,15 @@ static void
> > > > exynos4210_tmu_control(struct platform_device *pdev, bool on) if
> > > > (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > > >  		interrupt_en =
> > > > -			pdata->trigger_enable[3] <<
> > > > EXYNOS_TMU_INTEN_RISE3_SHIFT |
> > > > -			pdata->trigger_enable[2] <<
> > > > EXYNOS_TMU_INTEN_RISE2_SHIFT |
> > > > -			pdata->trigger_enable[1] <<
> > > > EXYNOS_TMU_INTEN_RISE1_SHIFT |
> > > > -			pdata->trigger_enable[0] <<
> > > > EXYNOS_TMU_INTEN_RISE0_SHIFT;
> > > > +			(of_thermal_is_trip_valid(tz, 3)
> > > > +			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
> > > > +			(of_thermal_is_trip_valid(tz, 2)
> > > > +			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
> > > > +			(of_thermal_is_trip_valid(tz, 1)
> > > > +			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
> > > > +			(of_thermal_is_trip_valid(tz, 0)
> > > > +			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
> > > > +
> > > >  		if (data->soc != SOC_ARCH_EXYNOS4210)
> > > >  			interrupt_en |=
> > > >  				interrupt_en <<
> > > > EXYNOS_TMU_INTEN_FALL0_SHIFT; @@ -468,7 +547,7 @@ static void
> > > > exynos4210_tmu_control(struct platform_device *pdev, bool on)
> > > > static void exynos5440_tmu_control(struct platform_device *pdev,
> > > > bool on) { struct exynos_tmu_data *data =
> > > > platform_get_drvdata(pdev);
> > > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > > +	struct thermal_zone_device *tz = data->tzd;
> > > >  	unsigned int con, interrupt_en;
> > > >  
> > > >  	con = get_con_reg(data, readl(data->base +
> > > > EXYNOS5440_TMU_S0_7_CTRL)); @@ -476,11 +555,16 @@ static void
> > > > exynos5440_tmu_control(struct platform_device *pdev, bool on) if
> > > > (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > > >  		interrupt_en =
> > > > -			pdata->trigger_enable[3] <<
> > > > EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
> > > > -			pdata->trigger_enable[2] <<
> > > > EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
> > > > -			pdata->trigger_enable[1] <<
> > > > EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
> > > > -			pdata->trigger_enable[0] <<
> > > > EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
> > > > -		interrupt_en |= interrupt_en <<
> > > > EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
> > > > +			(of_thermal_is_trip_valid(tz, 3)
> > > > +			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
> > > > +			(of_thermal_is_trip_valid(tz, 2)
> > > > +			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
> > > > +			(of_thermal_is_trip_valid(tz, 1)
> > > > +			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
> > > > +			(of_thermal_is_trip_valid(tz, 0)
> > > > +			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
> > > > +		interrupt_en |=
> > > > +			interrupt_en <<
> > > > EXYNOS5440_TMU_INTEN_FALL0_SHIFT; } else {
> > > >  		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > > >  		interrupt_en = 0; /* Disable all interrupts */
> > > > @@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct
> > > > platform_device *pdev, bool on) writel(con, data->base +
> > > > EXYNOS5440_TMU_S0_7_CTRL); }
> > > >  
> > > > -static int exynos_tmu_read(struct exynos_tmu_data *data)
> > > > +int exynos_get_temp(void *p, long *temp)
> > > >  {
> > > > -	int ret;
> > > > +	struct exynos_tmu_data *data = p;
> > > > +
> > > > +	if (!data)
> > > > +		return -EINVAL;
> > > >  
> > > >  	mutex_lock(&data->lock);
> > > >  	clk_enable(data->clk);
> > > > -	ret = data->tmu_read(data);
> > > > -	if (ret >= 0)
> > > > -		ret = code_to_temp(data, ret);
> > > > +
> > > > +	*temp = code_to_temp(data, data->tmu_read(data)) *
> > > > MCELSIUS; +
> > > >  	clk_disable(data->clk);
> > > >  	mutex_unlock(&data->lock);
> > > >  
> > > > -	return ret;
> > > > +	return 0;
> > > >  }
> > > >  
> > > >  #ifdef CONFIG_THERMAL_EMULATION
> > > > @@ -613,7 +700,7 @@ static void exynos_tmu_work(struct
> > > > work_struct *work) if (!IS_ERR(data->clk_sec))
> > > >  		clk_disable(data->clk_sec);
> > > >  
> > > > -	exynos_report_trigger(data->reg_conf);
> > > > +	exynos_report_trigger(data);
> > > >  	mutex_lock(&data->lock);
> > > >  	clk_enable(data->clk);
> > > >  
> > > > @@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq,
> > > > void *id) static const struct of_device_id exynos_tmu_match[] =
> > > > { {
> > > >  		.compatible = "samsung,exynos3250-tmu",
> > > > -		.data = &exynos3250_default_tmu_data,
> > > >  	},
> > > >  	{
> > > >  		.compatible = "samsung,exynos4210-tmu",
> > > > -		.data = &exynos4210_default_tmu_data,
> > > >  	},
> > > >  	{
> > > >  		.compatible = "samsung,exynos4412-tmu",
> > > > -		.data = &exynos4412_default_tmu_data,
> > > >  	},
> > > >  	{
> > > >  		.compatible = "samsung,exynos5250-tmu",
> > > > -		.data = &exynos5250_default_tmu_data,
> > > >  	},
> > > >  	{
> > > >  		.compatible = "samsung,exynos5260-tmu",
> > > > -		.data = &exynos5260_default_tmu_data,
> > > >  	},
> > > >  	{
> > > >  		.compatible = "samsung,exynos5420-tmu",
> > > > -		.data = &exynos5420_default_tmu_data,
> > > >  	},
> > > >  	{
> > > >  		.compatible =
> > > > "samsung,exynos5420-tmu-ext-triminfo",
> > > > -		.data = &exynos5420_default_tmu_data,
> > > >  	},
> > > >  	{
> > > >  		.compatible = "samsung,exynos5440-tmu",
> > > > -		.data = &exynos5440_default_tmu_data,
> > > >  	},
> > > >  	{},
> > > >  };
> > > >  MODULE_DEVICE_TABLE(of, exynos_tmu_match);
> > > >  
> > > > -static inline struct  exynos_tmu_platform_data
> > > > *exynos_get_driver_data(
> > > > -			struct platform_device *pdev, int id)
> > > > +static int exynos_of_get_soc_type(struct device_node *np)
> > > >  {
> > > > -	struct  exynos_tmu_init_data *data_table;
> > > > -	struct exynos_tmu_platform_data *tmu_data;
> > > > -	const struct of_device_id *match;
> > > > +	if (of_device_is_compatible(np,
> > > > "samsung,exynos3250-tmu"))
> > > > +		return SOC_ARCH_EXYNOS3250;
> > > > +	else if (of_device_is_compatible(np,
> > > > "samsung,exynos4210-tmu"))
> > > > +		return SOC_ARCH_EXYNOS4210;
> > > > +	else if (of_device_is_compatible(np,
> > > > "samsung,exynos4412-tmu"))
> > > > +		return SOC_ARCH_EXYNOS4412;
> > > > +	else if (of_device_is_compatible(np,
> > > > "samsung,exynos5250-tmu"))
> > > > +		return SOC_ARCH_EXYNOS5250;
> > > > +	else if (of_device_is_compatible(np,
> > > > "samsung,exynos5260-tmu"))
> > > > +		return SOC_ARCH_EXYNOS5260;
> > > > +	else if (of_device_is_compatible(np,
> > > > "samsung,exynos5420-tmu"))
> > > > +		return SOC_ARCH_EXYNOS5420;
> > > > +	else if (of_device_is_compatible(np,
> > > > +
> > > > "samsung,exynos5420-tmu-ext-triminfo"))
> > > > +		return SOC_ARCH_EXYNOS5420_TRIMINFO;
> > > > +	else if (of_device_is_compatible(np,
> > > > "samsung,exynos5440-tmu"))
> > > > +		return SOC_ARCH_EXYNOS5440;
> > > > +
> > > > +	return -EINVAL;
> > > > +}
> > > >  
> > > > -	match = of_match_node(exynos_tmu_match,
> > > > pdev->dev.of_node);
> > > > -	if (!match)
> > > > -		return NULL;
> > > > -	data_table = (struct exynos_tmu_init_data *)
> > > > match->data;
> > > > -	if (!data_table || id >= data_table->tmu_count)
> > > > -		return NULL;
> > > > -	tmu_data = data_table->tmu_data;
> > > > -	return (struct exynos_tmu_platform_data *) (tmu_data +
> > > > id); +static int exynos_of_sensor_conf(struct device_node *np,
> > > > +				 struct
> > > > exynos_tmu_platform_data *pdata) +{
> > > > +	u32 value;
> > > > +	int ret;
> > > > +
> > > > +	of_node_get(np);
> > > > +
> > > > +	ret = of_property_read_u32(np, "samsung,tmu_gain",
> > > > &value);
> > > > +	pdata->gain = (u8) value;
> > > > +	of_property_read_u32(np,
> > > > "samsung,tmu_reference_voltage", &value);
> > > > +	pdata->reference_voltage = (u8) value;
> > > > +	of_property_read_u32(np,
> > > > "samsung,tmu_noise_cancel_mode", &value);
> > > > +	pdata->noise_cancel_mode = (u8) value;
> > > > +
> > > > +	of_property_read_u32(np, "samsung,tmu_efuse_value",
> > > > +			     &pdata->efuse_value);
> > > > +	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
> > > > +			     &pdata->min_efuse_value);
> > > > +	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
> > > > +			     &pdata->max_efuse_value);
> > > > +
> > > > +	of_property_read_u32(np,
> > > > "samsung,tmu_first_point_trim", &value);
> > > > +	pdata->first_point_trim = (u8) value;
> > > > +	of_property_read_u32(np,
> > > > "samsung,tmu_second_point_trim", &value);
> > > > +	pdata->second_point_trim = (u8) value;
> > > > +	of_property_read_u32(np,
> > > > "samsung,tmu_default_temp_offset", &value);
> > > > +	pdata->default_temp_offset = (u8) value;
> > > > +
> > > > +	of_property_read_u32(np, "samsung,tmu_cal_type",
> > > > &pdata->cal_type);
> > > > +	of_property_read_u32(np, "samsung,tmu_cal_mode",
> > > > &pdata->cal_mode); +
> > > > +	of_node_put(np);
> > > > +	return 0;
> > > >  }
> > > >  
> > > >  static int exynos_map_dt_data(struct platform_device *pdev)
> > > > @@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct
> > > > platform_device *pdev) return -EADDRNOTAVAIL;
> > > >  	}
> > > >  
> > > > -	pdata = exynos_get_driver_data(pdev, data->id);
> > > > -	if (!pdata) {
> > > > -		dev_err(&pdev->dev, "No platform init data
> > > > supplied.\n");
> > > > -		return -ENODEV;
> > > > -	}
> > > > +	pdata = devm_kzalloc(&pdev->dev,
> > > > +			     sizeof(struct
> > > > exynos_tmu_platform_data),
> > > > +			     GFP_KERNEL);
> > > > +	if (!pdata)
> > > > +		return -ENOMEM;
> > > >  
> > > > +	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
> > > >  	data->pdata = pdata;
> > > > -	data->soc = pdata->type;
> > > > +	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
> > > >  
> > > >  	switch (data->soc) {
> > > >  	case SOC_ARCH_EXYNOS4210:
> > > > @@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct
> > > > platform_device *pdev) return 0;
> > > >  }
> > > >  
> > > > +static struct thermal_zone_of_device_ops exynos_sensor_ops = {
> > > > +	.get_temp = exynos_get_temp,
> > > > +	.set_emul_temp = exynos_tmu_set_emulation,
> > > > +};
> > > > +
> > > >  static int exynos_tmu_probe(struct platform_device *pdev)
> > > >  {
> > > > -	struct exynos_tmu_data *data;
> > > >  	struct exynos_tmu_platform_data *pdata;
> > > > -	struct thermal_sensor_conf *sensor_conf;
> > > > -	int ret, i;
> > > > +	struct exynos_tmu_data *data;
> > > > +	int ret;
> > > >  
> > > >  	data = devm_kzalloc(&pdev->dev, sizeof(struct
> > > > exynos_tmu_data), GFP_KERNEL);
> > > > @@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct
> > > > platform_device *pdev) platform_set_drvdata(pdev, data);
> > > >  	mutex_init(&data->lock);
> > > >  
> > > > +	data->tzd =
> > > > thermal_zone_of_sensor_register(&pdev->dev, 0, data,
> > > > +
> > > > &exynos_sensor_ops);
> > > > +	if (IS_ERR(data->tzd)) {
> > > > +		pr_err("thermal: tz: %p ERROR\n", data->tzd);
> > > > +		return PTR_ERR(data->tzd);
> > > > +	}
> > > >  	ret = exynos_map_dt_data(pdev);
> > > >  	if (ret)
> > > > -		return ret;
> > > > +		goto err_sensor;
> > > >  
> > > >  	pdata = data->pdata;
> > > >  
> > > > @@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct
> > > > platform_device *pdev) data->clk = devm_clk_get(&pdev->dev,
> > > > "tmu_apbif"); if (IS_ERR(data->clk)) {
> > > >  		dev_err(&pdev->dev, "Failed to get clock\n");
> > > > -		return  PTR_ERR(data->clk);
> > > > +		ret = PTR_ERR(data->clk);
> > > > +		goto err_sensor;
> > > >  	}
> > > >  
> > > >  	data->clk_sec = devm_clk_get(&pdev->dev,
> > > > "tmu_triminfo_apbif"); if (IS_ERR(data->clk_sec)) {
> > > >  		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO)
> > > > { dev_err(&pdev->dev, "Failed to get
> > > > triminfo clock\n");
> > > > -			return PTR_ERR(data->clk_sec);
> > > > +			ret = PTR_ERR(data->clk_sec);
> > > > +			goto err_sensor;
> > > >  		}
> > > >  	} else {
> > > >  		ret = clk_prepare(data->clk_sec);
> > > >  		if (ret) {
> > > >  			dev_err(&pdev->dev, "Failed to get
> > > > clock\n");
> > > > -			return ret;
> > > > +			goto err_sensor;
> > > >  		}
> > > >  	}
> > > >  
> > > > @@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct
> > > > platform_device *pdev) goto err_clk;
> > > >  	}
> > > >  
> > > > -	exynos_tmu_control(pdev, true);
> > > > -
> > > > -	/* Allocate a structure to register with the exynos
> > > > core thermal */
> > > > -	sensor_conf = devm_kzalloc(&pdev->dev,
> > > > -				sizeof(struct
> > > > thermal_sensor_conf), GFP_KERNEL);
> > > > -	if (!sensor_conf) {
> > > > -		ret = -ENOMEM;
> > > > -		goto err_clk;
> > > > -	}
> > > > -	sprintf(sensor_conf->name, "therm_zone%d", data->id);
> > > > -	sensor_conf->read_temperature = (int (*)(void
> > > > *))exynos_tmu_read;
> > > > -	sensor_conf->write_emul_temp =
> > > > -		(int (*)(void *, unsigned
> > > > long))exynos_tmu_set_emulation;
> > > > -	sensor_conf->driver_data = data;
> > > > -	sensor_conf->trip_data.trip_count =
> > > > pdata->trigger_enable[0] +
> > > > -			pdata->trigger_enable[1] +
> > > > pdata->trigger_enable[2]+
> > > > -			pdata->trigger_enable[3];
> > > > -
> > > > -	for (i = 0; i < sensor_conf->trip_data.trip_count;
> > > > i++) {
> > > > -		sensor_conf->trip_data.trip_val[i] =
> > > > -			pdata->threshold +
> > > > pdata->trigger_levels[i];
> > > > -		sensor_conf->trip_data.trip_type[i] =
> > > > -					pdata->trigger_type[i];
> > > > -	}
> > > > -
> > > > -	sensor_conf->trip_data.trigger_falling =
> > > > pdata->threshold_falling; -
> > > > -	sensor_conf->dev = &pdev->dev;
> > > > -	/* Register the sensor with thermal management
> > > > interface */
> > > > -	ret = exynos_register_thermal(sensor_conf);
> > > > -	if (ret) {
> > > > -		if (ret != -EPROBE_DEFER)
> > > > -			dev_err(&pdev->dev,
> > > > -				"Failed to register thermal
> > > > interface: %d\n",
> > > > -				ret);
> > > > -		goto err_clk;
> > > > -	}
> > > > -	data->reg_conf = sensor_conf;
> > > > -
> > > >  	ret = devm_request_irq(&pdev->dev, data->irq,
> > > > exynos_tmu_irq, IRQF_TRIGGER_RISING | IRQF_SHARED,
> > > > dev_name(&pdev->dev), data); if (ret) {
> > > > @@ -935,21 +1030,31 @@ static int exynos_tmu_probe(struct
> > > > platform_device *pdev) goto err_clk;
> > > >  	}
> > > >  
> > > > +	ret = exynos_tmu_initialize(pdev);
> > > > +	if (ret) {
> > > > +		dev_err(&pdev->dev, "Failed to initialize
> > > > TMU\n");
> > > > +		goto err_clk;
> > > > +	}
> > > > +	exynos_tmu_control(pdev, true);
> > > >  	return 0;
> > > > +
> > > >  err_clk:
> > > >  	clk_unprepare(data->clk);
> > > >  err_clk_sec:
> > > >  	if (!IS_ERR(data->clk_sec))
> > > >  		clk_unprepare(data->clk_sec);
> > > > +err_sensor:
> > > > +	thermal_zone_of_sensor_unregister(&pdev->dev,
> > > > data->tzd); +
> > > >  	return ret;
> > > >  }
> > > >  
> > > >  static int exynos_tmu_remove(struct platform_device *pdev)
> > > >  {
> > > >  	struct exynos_tmu_data *data =
> > > > platform_get_drvdata(pdev);
> > > > +	struct thermal_zone_device *tzd = data->tzd;
> > > >  
> > > > -	exynos_unregister_thermal(data->reg_conf);
> > > > -
> > > > +	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
> > > >  	exynos_tmu_control(pdev, false);
> > > >  
> > > >  	clk_unprepare(data->clk);
> > > > diff --git a/drivers/thermal/samsung/exynos_tmu.h
> > > > b/drivers/thermal/samsung/exynos_tmu.h index 627dec9..d876d4c
> > > > 100644 --- a/drivers/thermal/samsung/exynos_tmu.h
> > > > +++ b/drivers/thermal/samsung/exynos_tmu.h
> > > > @@ -23,8 +23,7 @@
> > > >  #ifndef _EXYNOS_TMU_H
> > > >  #define _EXYNOS_TMU_H
> > > >  #include <linux/cpu_cooling.h>
> > > > -
> > > > -#include "exynos_thermal_common.h"
> > > > +#include <dt-bindings/thermal/thermal_exynos.h>
> > > >  
> > > >  enum soc_type {
> > > >  	SOC_ARCH_EXYNOS3250 = 1,
> > > > @@ -36,38 +35,9 @@ enum soc_type {
> > > >  	SOC_ARCH_EXYNOS5420_TRIMINFO,
> > > >  	SOC_ARCH_EXYNOS5440,
> > > >  };
> > > > -#include <dt-bindings/thermal/thermal_exynos.h>
> > > >  
> > > >  /**
> > > >   * struct exynos_tmu_platform_data
> > > > - * @threshold: basic temperature for generating interrupt
> > > > - *	       25 <= threshold <= 125 [unit: degree Celsius]
> > > > - * @threshold_falling: differntial value for setting threshold
> > > > - *		       of temperature falling interrupt.
> > > > - * @trigger_levels: array for each interrupt levels
> > > > - *	[unit: degree Celsius]
> > > > - *	0: temperature for trigger_level0 interrupt
> > > > - *	   condition for trigger_level0 interrupt:
> > > > - *		current temperature > threshold +
> > > > trigger_levels[0]
> > > > - *	1: temperature for trigger_level1 interrupt
> > > > - *	   condition for trigger_level1 interrupt:
> > > > - *		current temperature > threshold +
> > > > trigger_levels[1]
> > > > - *	2: temperature for trigger_level2 interrupt
> > > > - *	   condition for trigger_level2 interrupt:
> > > > - *		current temperature > threshold +
> > > > trigger_levels[2]
> > > > - *	3: temperature for trigger_level3 interrupt
> > > > - *	   condition for trigger_level3 interrupt:
> > > > - *		current temperature > threshold +
> > > > trigger_levels[3]
> > > > - * @trigger_type: defines the type of trigger. Possible values
> > > > are,
> > > > - *	THROTTLE_ACTIVE trigger type
> > > > - *	THROTTLE_PASSIVE trigger type
> > > > - *	SW_TRIP trigger type
> > > > - *	HW_TRIP
> > > > - * @trigger_enable[]: array to denote which trigger levels are
> > > > enabled.
> > > > - *	1 = enable trigger_level[] interrupt,
> > > > - *	0 = disable trigger_level[] interrupt
> > > > - * @max_trigger_level: max trigger level supported by the TMU
> > > > - * @non_hw_trigger_levels: number of defined non-hardware
> > > > trigger levels
> > > >   * @gain: gain of amplifier in the positive-TC generator block
> > > >   *	0 < gain <= 15
> > > >   * @reference_voltage: reference voltage of amplifier
> > > > @@ -79,21 +49,12 @@ enum soc_type {
> > > >   * @efuse_value: platform defined fuse value
> > > >   * @min_efuse_value: minimum valid trimming data
> > > >   * @max_efuse_value: maximum valid trimming data
> > > > - * @first_point_trim: temp value of the first point trimming
> > > > - * @second_point_trim: temp value of the second point trimming
> > > >   * @default_temp_offset: default temperature offset in case of
> > > > no trimming
> > > >   * @cal_type: calibration type for temperature
> > > >   *
> > > >   * This structure is required for configuration of exynos_tmu
> > > > driver. */
> > > >  struct exynos_tmu_platform_data {
> > > > -	u8 threshold;
> > > > -	u8 threshold_falling;
> > > > -	u8 trigger_levels[MAX_TRIP_COUNT];
> > > > -	enum trigger_type trigger_type[MAX_TRIP_COUNT];
> > > > -	bool trigger_enable[MAX_TRIP_COUNT];
> > > > -	u8 max_trigger_level;
> > > > -	u8 non_hw_trigger_levels;
> > > >  	u8 gain;
> > > >  	u8 reference_voltage;
> > > >  	u8 noise_cancel_mode;
> > > > @@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
> > > >  	u32 cal_mode;
> > > >  };
> > > >  
> > > > -/**
> > > > - * struct exynos_tmu_init_data
> > > > - * @tmu_count: number of TMU instances.
> > > > - * @tmu_data: platform data of all TMU instances.
> > > > - * This structure is required to store data for multi-instance
> > > > exynos tmu
> > > > - * driver.
> > > > - */
> > > > -struct exynos_tmu_init_data {
> > > > -	int tmu_count;
> > > > -	struct exynos_tmu_platform_data tmu_data[];
> > > > -};
> > > > -
> > > >  extern struct exynos_tmu_init_data const
> > > > exynos3250_default_tmu_data; extern struct exynos_tmu_init_data
> > > > const exynos4210_default_tmu_data; extern struct
> > > > exynos_tmu_init_data const exynos4412_default_tmu_data; -- 
> > > > 2.0.0.rc2
> > > > 
> > 
> > 
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration
  2015-01-21  2:18     ` Eduardo Valentin
@ 2015-01-21  8:21       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-21  8:21 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

Hi Eduardo,

> On Mon, Jan 19, 2015 at 12:20:51PM +0100, Lukasz Majewski wrote:
> > Up till now exynos_tmu_data.c was used for storing CPU cooling
> > configuration data. Now the Exynos thermal core code uses device
> > tree to get this data. For this purpose generic thermal code for
> > configuring CPU cooling was used.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - None
> > Changes for v3:
> > - Rewrite code responsible for registering CPU cooling device to
> > not depend on explicit "/cpus/cpu@0" path since now Exynos SoCs use
> > new cpu node names (e.g. cpu@A00). New approach iterates over
> > "cpus" node children.
> > - Patch title changed to thermal: exynos
> > Changes for v4:
> > - None
> > Changes for v5:
> > - None
> > 
> > ---
> >  drivers/cpufreq/exynos-cpufreq.c                |  30 +++++-
> >  drivers/thermal/samsung/exynos_thermal_common.c | 122
> > ++++++++++++++----------
> > drivers/thermal/samsung/exynos_tmu.c            |   7 --
> > drivers/thermal/samsung/exynos_tmu.h            |   5 -
> > drivers/thermal/samsung/exynos_tmu_data.c       |  42 +------- 5
> > files changed, 101 insertions(+), 105 deletions(-)
> > 
> > diff --git a/drivers/cpufreq/exynos-cpufreq.c
> > b/drivers/cpufreq/exynos-cpufreq.c index f99a0b0..32bc64d 100644
> > --- a/drivers/cpufreq/exynos-cpufreq.c
> > +++ b/drivers/cpufreq/exynos-cpufreq.c
> > @@ -18,10 +18,13 @@
> >  #include <linux/cpufreq.h>
> >  #include <linux/platform_device.h>
> >  #include <linux/of.h>
> > +#include <linux/cpu_cooling.h>
> > +#include <linux/cpu.h>
> >  
> >  #include "exynos-cpufreq.h"
> >  
> >  static struct exynos_dvfs_info *exynos_info;
> > +static struct thermal_cooling_device *cdev;
> >  static struct regulator *arm_regulator;
> >  static unsigned int locking_frequency;
> >  
> > @@ -156,6 +159,7 @@ static struct cpufreq_driver exynos_driver = {
> >  
> >  static int exynos_cpufreq_probe(struct platform_device *pdev)
> >  {
> > +	struct device_node *cpus, *np;
> >  	int ret = -EINVAL;
> >  
> >  	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
> > @@ -198,9 +202,31 @@ static int exynos_cpufreq_probe(struct
> > platform_device *pdev) /* Done here as we want to capture boot
> > frequency */ locking_frequency =
> > clk_get_rate(exynos_info->cpu_clk) / 1000; 
> > -	if (!cpufreq_register_driver(&exynos_driver))
> > -		return 0;
> > +	if (cpufreq_register_driver(&exynos_driver))
> > +		goto err;
> >  
> > +	cpus = of_find_node_by_path("/cpus");
> > +	if (!cpus) {
> > +		pr_err("failed to find cpus node\n");
> > +		return -ENOENT;
> > +	}
> > +
> > +	for (np = of_get_next_child(cpus, NULL); np;
> > +	     of_node_put(np), np = of_get_next_child(cpus, np)) {
> > +		if (of_find_property(np, "#cooling-cells", NULL)) {
> > +			cdev = of_cpufreq_cooling_register(np,
> > +
> > cpu_present_mask);
> > +			if (IS_ERR(cdev))
> > +				pr_err("running cpufreq without
> > cooling device: %ld\n",
> > +				       PTR_ERR(cdev));
> > +			break;
> > +		}
> > +	}
> > +	of_node_put(np);
> > +	of_node_put(cpus);
> > +
> > +	return 0;
> > + err:
> >  	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
> >  	regulator_put(arm_regulator);
> >  err_vdd_arm:
> 
> You need at least an ack from a cpufreq maintainer to get this patch
> in. I would prefer if you split the cpufreq part from the thermal
> part. It avoids merge conflicts in the upstreaming process.

Please note that exynos-cpufreq part has around 30 LOC (which only
prevents from a regression). 

When I split it, then if by some mishap this not find its way to
mainline in the same time as thermal, then we would have pretty nasty
regression.

I will ask Viresh to look into this code and NAK/ACK it.

> 
> > diff --git a/drivers/thermal/samsung/exynos_thermal_common.c
> > b/drivers/thermal/samsung/exynos_thermal_common.c index
> > 6dc3815..00aa688 100644 ---
> > a/drivers/thermal/samsung/exynos_thermal_common.c +++
> > b/drivers/thermal/samsung/exynos_thermal_common.c @@ -133,47
> > +133,62 @@ static int exynos_get_crit_temp(struct
> > thermal_zone_device *thermal, static int exynos_bind(struct
> > thermal_zone_device *thermal, struct thermal_cooling_device *cdev) {
> > -	int ret = 0, i, tab_size, level;
> > -	struct freq_clip_table *tab_ptr, *clip_data;
> >  	struct exynos_thermal_zone *th_zone = thermal->devdata;
> >  	struct thermal_sensor_conf *data = th_zone->sensor_conf;
> > +	struct device_node *child, *gchild, *np;
> > +	struct of_phandle_args cooling_spec;
> > +	unsigned long max, state = 0;
> > +	int ret = 0, i = 0;
> >  
> > -	tab_ptr = (struct freq_clip_table
> > *)data->cooling_data.freq_data;
> > -	tab_size = data->cooling_data.freq_clip_count;
> > -
> > -	if (tab_ptr == NULL || tab_size == 0)
> > +	/*
> > +	 * Below code is necessary to skip binding when cpufreq's
> > +	 * frequency table is not yet initialized.
> > +	 */
> > +	cdev->ops->get_max_state(cdev, &state);
> > +	if (!state && !th_zone->cool_dev_size) {
> > +		th_zone->cool_dev_size = 1;
> > +		th_zone->cool_dev[0] = cdev;
> > +		th_zone->bind = false;
> >  		return 0;
> > +	}
> >  
> > -	/* find the cooling device registered*/
> > -	for (i = 0; i < th_zone->cool_dev_size; i++)
> > -		if (cdev == th_zone->cool_dev[i])
> > -			break;
> > +	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
> > +	if (!np) {
> > +		pr_err("failed to find thmerla-zones/cpu-thermal
> > node\n");
> > +		return -ENOENT;
> > +	}
> >  
> > -	/* No matching cooling device */
> > -	if (i == th_zone->cool_dev_size)
> > -		return 0;
> > +	child = of_get_child_by_name(np, "cooling-maps");
> >  
> > -	/* Bind the thermal zone to the cpufreq cooling device */
> > -	for (i = 0; i < tab_size; i++) {
> > -		clip_data = (struct freq_clip_table
> > *)&(tab_ptr[i]);
> > -		level = cpufreq_cooling_get_level(0,
> > clip_data->freq_clip_max);
> > -		if (level == THERMAL_CSTATE_INVALID)
> > -			return 0;
> > -		switch (GET_ZONE(i)) {
> > -		case MONITOR_ZONE:
> > -		case WARN_ZONE:
> > -			if
> > (thermal_zone_bind_cooling_device(thermal, i, cdev,
> > -
> > level, 0)) {
> > -				dev_err(data->dev,
> > -					"error unbinding cdev
> > inst=%d\n", i);
> > -				ret = -EINVAL;
> > -			}
> > -			th_zone->bind = true;
> > -			break;
> > -		default:
> > +	for_each_child_of_node(child, gchild) {
> > +		ret = of_parse_phandle_with_args(gchild,
> > "cooling-device",
> > +						 "#cooling-cells",
> > +						 0, &cooling_spec);
> > +		if (ret < 0) {
> > +			pr_err("missing cooling_device
> > property\n");
> > +			goto end;
> > +		}
> > +
> > +		if (cooling_spec.args_count < 2) {
> >  			ret = -EINVAL;
> > +			goto end;
> >  		}
> > +
> > +		max = cooling_spec.args[0];
> > +		if (thermal_zone_bind_cooling_device(thermal, i,
> > cdev,
> > +						     max, 0)) {
> > +			dev_err(data->dev,
> > +				"thermal error unbinding cdev
> > inst=%d\n", i); +
> > +			ret = -EINVAL;
> > +			goto end;
> > +		}
> > +		i++;
> >  	}
> > +	th_zone->bind = true;
> > +end:
> > +	of_node_put(child);
> > +	of_node_put(np);
> >  
> >  	return ret;
> >  }
> > @@ -182,16 +197,12 @@ static int exynos_bind(struct
> > thermal_zone_device *thermal, static int exynos_unbind(struct
> > thermal_zone_device *thermal, struct thermal_cooling_device *cdev)
> >  {
> > -	int ret = 0, i, tab_size;
> > +	int ret = 0, i;
> >  	struct exynos_thermal_zone *th_zone = thermal->devdata;
> >  	struct thermal_sensor_conf *data = th_zone->sensor_conf;
> > +	struct device_node *child, *gchild, *np;
> >  
> > -	if (th_zone->bind == false)
> > -		return 0;
> > -
> > -	tab_size = data->cooling_data.freq_clip_count;
> > -
> > -	if (tab_size == 0)
> > +	if (th_zone->bind == false || !th_zone->cool_dev_size)
> >  		return 0;
> >  
> >  	/* find the cooling device registered*/
> > @@ -203,23 +214,30 @@ static int exynos_unbind(struct
> > thermal_zone_device *thermal, if (i == th_zone->cool_dev_size)
> >  		return 0;
> >  
> > -	/* Bind the thermal zone to the cpufreq cooling device */
> > -	for (i = 0; i < tab_size; i++) {
> > -		switch (GET_ZONE(i)) {
> > -		case MONITOR_ZONE:
> > -		case WARN_ZONE:
> > -			if
> > (thermal_zone_unbind_cooling_device(thermal, i,
> > -
> > cdev)) {
> > -				dev_err(data->dev,
> > -					"error unbinding cdev
> > inst=%d\n", i);
> > -				ret = -EINVAL;
> > -			}
> > -			th_zone->bind = false;
> > -			break;
> > -		default:
> > +	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
> > +	if (!np) {
> > +		pr_err("failed to find thmerla-zones/cpu-thermal
> > node\n");
> > +		return -ENOENT;
> > +	}
> > +
> > +	child = of_get_child_by_name(np, "cooling-maps");
> > +
> > +	i = 0;
> > +	for_each_child_of_node(child, gchild) {
> > +		if (thermal_zone_unbind_cooling_device(thermal, i,
> > +						       cdev)) {
> > +			dev_err(data->dev,
> > +				"error unbinding cdev inst=%d\n",
> > i); ret = -EINVAL;
> > +			goto end;
> >  		}
> > +		i++;
> >  	}
> > +	th_zone->bind = false;
> > +end:
> > +	of_node_put(child);
> > +	of_node_put(np);
> > +
> >  	return ret;
> >  }
> >  
> > diff --git a/drivers/thermal/samsung/exynos_tmu.c
> > b/drivers/thermal/samsung/exynos_tmu.c index 5000727..ae30f6a 100644
> > --- a/drivers/thermal/samsung/exynos_tmu.c
> > +++ b/drivers/thermal/samsung/exynos_tmu.c
> > @@ -916,13 +916,6 @@ static int exynos_tmu_probe(struct
> > platform_device *pdev) 
> >  	sensor_conf->trip_data.trigger_falling =
> > pdata->threshold_falling; 
> > -	sensor_conf->cooling_data.freq_clip_count =
> > pdata->freq_tab_count;
> > -	for (i = 0; i < pdata->freq_tab_count; i++) {
> > -
> > sensor_conf->cooling_data.freq_data[i].freq_clip_max =
> > -
> > pdata->freq_tab[i].freq_clip_max;
> > -		sensor_conf->cooling_data.freq_data[i].temp_level =
> > -
> > pdata->freq_tab[i].temp_level;
> > -	}
> >  	sensor_conf->dev = &pdev->dev;
> >  	/* Register the sensor with thermal management interface */
> >  	ret = exynos_register_thermal(sensor_conf);
> > diff --git a/drivers/thermal/samsung/exynos_tmu.h
> > b/drivers/thermal/samsung/exynos_tmu.h index 7f880d2..627dec9 100644
> > --- a/drivers/thermal/samsung/exynos_tmu.h
> > +++ b/drivers/thermal/samsung/exynos_tmu.h
> > @@ -83,9 +83,6 @@ enum soc_type {
> >   * @second_point_trim: temp value of the second point trimming
> >   * @default_temp_offset: default temperature offset in case of no
> > trimming
> >   * @cal_type: calibration type for temperature
> > - * @freq_clip_table: Table representing frequency reduction
> > percentage.
> > - * @freq_tab_count: Count of the above table as frequency
> > reduction may
> > - *	applicable to only some of the trigger levels.
> >   *
> >   * This structure is required for configuration of exynos_tmu
> > driver. */
> > @@ -111,8 +108,6 @@ struct exynos_tmu_platform_data {
> >  	enum soc_type type;
> >  	u32 cal_type;
> >  	u32 cal_mode;
> > -	struct freq_clip_table freq_tab[4];
> > -	unsigned int freq_tab_count;
> >  };
> >  
> >  /**
> > diff --git a/drivers/thermal/samsung/exynos_tmu_data.c
> > b/drivers/thermal/samsung/exynos_tmu_data.c index b239100..a993f3d
> > 100644 --- a/drivers/thermal/samsung/exynos_tmu_data.c
> > +++ b/drivers/thermal/samsung/exynos_tmu_data.c
> > @@ -47,15 +47,6 @@ struct exynos_tmu_init_data const
> > exynos4210_default_tmu_data = { .first_point_trim = 25,
> >  		.second_point_trim = 85,
> >  		.default_temp_offset = 50,
> > -		.freq_tab[0] = {
> > -			.freq_clip_max = 800 * 1000,
> > -			.temp_level = 85,
> > -			},
> > -		.freq_tab[1] = {
> > -			.freq_clip_max = 200 * 1000,
> > -			.temp_level = 100,
> > -		},
> > -		.freq_tab_count = 2,
> >  		.type = SOC_ARCH_EXYNOS4210,
> >  		},
> >  	},
> > @@ -87,16 +78,7 @@ struct exynos_tmu_init_data const
> > exynos4210_default_tmu_data = { .max_efuse_value = 100, \
> >  	.first_point_trim = 25, \
> >  	.second_point_trim = 85, \
> > -	.default_temp_offset = 50, \
> > -	.freq_tab[0] = { \
> > -		.freq_clip_max = 800 * 1000, \
> > -		.temp_level = 70, \
> > -	}, \
> > -	.freq_tab[1] = { \
> > -		.freq_clip_max = 400 * 1000, \
> > -		.temp_level = 95, \
> > -	}, \
> > -	.freq_tab_count = 2
> > +	.default_temp_offset = 50
> >  
> >  struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
> >  	.tmu_data = {
> > @@ -133,16 +115,7 @@ struct exynos_tmu_init_data const
> > exynos3250_default_tmu_data = { .max_efuse_value = 100, \
> >  	.first_point_trim = 25, \
> >  	.second_point_trim = 85, \
> > -	.default_temp_offset = 50, \
> > -	.freq_tab[0] = { \
> > -		.freq_clip_max = 1400 * 1000, \
> > -		.temp_level = 70, \
> > -	}, \
> > -	.freq_tab[1] = { \
> > -		.freq_clip_max = 400 * 1000, \
> > -		.temp_level = 95, \
> > -	}, \
> > -	.freq_tab_count = 2
> > +	.default_temp_offset = 50
> >  
> >  struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
> >  	.tmu_data = {
> > @@ -189,16 +162,7 @@ struct exynos_tmu_init_data const
> > exynos5250_default_tmu_data = { .max_efuse_value = 100, \
> >  	.first_point_trim = 25, \
> >  	.second_point_trim = 85, \
> > -	.default_temp_offset = 50, \
> > -	.freq_tab[0] = { \
> > -		.freq_clip_max = 800 * 1000, \
> > -		.temp_level = 85, \
> > -	}, \
> > -	.freq_tab[1] = { \
> > -		.freq_clip_max = 200 * 1000, \
> > -		.temp_level = 103, \
> > -	}, \
> > -	.freq_tab_count = 2, \
> > +	.default_temp_offset = 50,
> >  
> >  #define EXYNOS5260_TMU_DATA \
> >  	__EXYNOS5260_TMU_DATA \
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration
  2015-01-19 11:20   ` [PATCH v5 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
  2015-01-21  2:18     ` Eduardo Valentin
@ 2015-01-21  8:33     ` Lukasz Majewski
  2015-01-21  9:08       ` Viresh Kumar
  1 sibling, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-21  8:33 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Lukasz Majewski, Eduardo Valentin, Zhang Rui, Kukjin Kim,
	Kukjin Kim, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Kyungmin Park, Chanwoo Choi

Hi Viresh,

> Up till now exynos_tmu_data.c was used for storing CPU cooling
> configuration data. Now the Exynos thermal core code uses device tree
> to get this data. For this purpose generic thermal code for
> configuring CPU cooling was used.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - None
> Changes for v3:
> - Rewrite code responsible for registering CPU cooling device to not
> depend on explicit "/cpus/cpu@0" path since now Exynos SoCs use new
> cpu node names (e.g. cpu@A00). New approach iterates over "cpus" node
> children.
> - Patch title changed to thermal: exynos
> Changes for v4:
> - None
> Changes for v5:
> - None
> 
> ---
>  drivers/cpufreq/exynos-cpufreq.c                |  30 +++++-
>  drivers/thermal/samsung/exynos_thermal_common.c | 122
> ++++++++++++++----------
> drivers/thermal/samsung/exynos_tmu.c            |   7 --
> drivers/thermal/samsung/exynos_tmu.h            |   5 -
> drivers/thermal/samsung/exynos_tmu_data.c       |  42 +------- 5
> files changed, 101 insertions(+), 105 deletions(-)
> 
> diff --git a/drivers/cpufreq/exynos-cpufreq.c
> b/drivers/cpufreq/exynos-cpufreq.c index f99a0b0..32bc64d 100644
> --- a/drivers/cpufreq/exynos-cpufreq.c
> +++ b/drivers/cpufreq/exynos-cpufreq.c
> @@ -18,10 +18,13 @@
>  #include <linux/cpufreq.h>
>  #include <linux/platform_device.h>
>  #include <linux/of.h>
> +#include <linux/cpu_cooling.h>
> +#include <linux/cpu.h>
>  
>  #include "exynos-cpufreq.h"
>  
>  static struct exynos_dvfs_info *exynos_info;
> +static struct thermal_cooling_device *cdev;
>  static struct regulator *arm_regulator;
>  static unsigned int locking_frequency;
>  
> @@ -156,6 +159,7 @@ static struct cpufreq_driver exynos_driver = {
>  
>  static int exynos_cpufreq_probe(struct platform_device *pdev)
>  {
> +	struct device_node *cpus, *np;
>  	int ret = -EINVAL;
>  
>  	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
> @@ -198,9 +202,31 @@ static int exynos_cpufreq_probe(struct
> platform_device *pdev) /* Done here as we want to capture boot
> frequency */ locking_frequency = clk_get_rate(exynos_info->cpu_clk) /
> 1000; 
> -	if (!cpufreq_register_driver(&exynos_driver))
> -		return 0;
> +	if (cpufreq_register_driver(&exynos_driver))
> +		goto err;
>  
> +	cpus = of_find_node_by_path("/cpus");
> +	if (!cpus) {
> +		pr_err("failed to find cpus node\n");
> +		return -ENOENT;
> +	}
> +
> +	for (np = of_get_next_child(cpus, NULL); np;
> +	     of_node_put(np), np = of_get_next_child(cpus, np)) {
> +		if (of_find_property(np, "#cooling-cells", NULL)) {
> +			cdev = of_cpufreq_cooling_register(np,
> +
> cpu_present_mask);
> +			if (IS_ERR(cdev))
> +				pr_err("running cpufreq without
> cooling device: %ld\n",
> +				       PTR_ERR(cdev));
> +			break;
> +		}
> +	}
> +	of_node_put(np);
> +	of_node_put(cpus);
> +
> +	return 0;
> + err:
>  	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
>  	regulator_put(arm_regulator);
>  err_vdd_arm:

Viresh, the above is a small part of the cpufreq related code, which is
necessary for Exynos thermal rework to use device tree.

It is NOT adding any new functionality, but preserves possibility to
use cpufreq as a colling device.

Normally I would exclude this part from this commit, but then I cannot
assure that between commits no regression is slipping in.

> diff --git a/drivers/thermal/samsung/exynos_thermal_common.c
> b/drivers/thermal/samsung/exynos_thermal_common.c index
> 6dc3815..00aa688 100644 ---
> a/drivers/thermal/samsung/exynos_thermal_common.c +++
> b/drivers/thermal/samsung/exynos_thermal_common.c @@ -133,47 +133,62
> @@ static int exynos_get_crit_temp(struct thermal_zone_device
> *thermal, static int exynos_bind(struct thermal_zone_device *thermal,
> struct thermal_cooling_device *cdev) {
> -	int ret = 0, i, tab_size, level;
> -	struct freq_clip_table *tab_ptr, *clip_data;
>  	struct exynos_thermal_zone *th_zone = thermal->devdata;
>  	struct thermal_sensor_conf *data = th_zone->sensor_conf;
> +	struct device_node *child, *gchild, *np;
> +	struct of_phandle_args cooling_spec;
> +	unsigned long max, state = 0;
> +	int ret = 0, i = 0;
>  
> -	tab_ptr = (struct freq_clip_table
> *)data->cooling_data.freq_data;
> -	tab_size = data->cooling_data.freq_clip_count;
> -
> -	if (tab_ptr == NULL || tab_size == 0)
> +	/*
> +	 * Below code is necessary to skip binding when cpufreq's
> +	 * frequency table is not yet initialized.
> +	 */
> +	cdev->ops->get_max_state(cdev, &state);
> +	if (!state && !th_zone->cool_dev_size) {
> +		th_zone->cool_dev_size = 1;
> +		th_zone->cool_dev[0] = cdev;
> +		th_zone->bind = false;
>  		return 0;
> +	}
>  
> -	/* find the cooling device registered*/
> -	for (i = 0; i < th_zone->cool_dev_size; i++)
> -		if (cdev == th_zone->cool_dev[i])
> -			break;
> +	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
> +	if (!np) {
> +		pr_err("failed to find thmerla-zones/cpu-thermal
> node\n");
> +		return -ENOENT;
> +	}
>  
> -	/* No matching cooling device */
> -	if (i == th_zone->cool_dev_size)
> -		return 0;
> +	child = of_get_child_by_name(np, "cooling-maps");
>  
> -	/* Bind the thermal zone to the cpufreq cooling device */
> -	for (i = 0; i < tab_size; i++) {
> -		clip_data = (struct freq_clip_table *)&(tab_ptr[i]);
> -		level = cpufreq_cooling_get_level(0,
> clip_data->freq_clip_max);
> -		if (level == THERMAL_CSTATE_INVALID)
> -			return 0;
> -		switch (GET_ZONE(i)) {
> -		case MONITOR_ZONE:
> -		case WARN_ZONE:
> -			if
> (thermal_zone_bind_cooling_device(thermal, i, cdev,
> -
> level, 0)) {
> -				dev_err(data->dev,
> -					"error unbinding cdev
> inst=%d\n", i);
> -				ret = -EINVAL;
> -			}
> -			th_zone->bind = true;
> -			break;
> -		default:
> +	for_each_child_of_node(child, gchild) {
> +		ret = of_parse_phandle_with_args(gchild,
> "cooling-device",
> +						 "#cooling-cells",
> +						 0, &cooling_spec);
> +		if (ret < 0) {
> +			pr_err("missing cooling_device property\n");
> +			goto end;
> +		}
> +
> +		if (cooling_spec.args_count < 2) {
>  			ret = -EINVAL;
> +			goto end;
>  		}
> +
> +		max = cooling_spec.args[0];
> +		if (thermal_zone_bind_cooling_device(thermal, i,
> cdev,
> +						     max, 0)) {
> +			dev_err(data->dev,
> +				"thermal error unbinding cdev
> inst=%d\n", i); +
> +			ret = -EINVAL;
> +			goto end;
> +		}
> +		i++;
>  	}
> +	th_zone->bind = true;
> +end:
> +	of_node_put(child);
> +	of_node_put(np);
>  
>  	return ret;
>  }
> @@ -182,16 +197,12 @@ static int exynos_bind(struct
> thermal_zone_device *thermal, static int exynos_unbind(struct
> thermal_zone_device *thermal, struct thermal_cooling_device *cdev)
>  {
> -	int ret = 0, i, tab_size;
> +	int ret = 0, i;
>  	struct exynos_thermal_zone *th_zone = thermal->devdata;
>  	struct thermal_sensor_conf *data = th_zone->sensor_conf;
> +	struct device_node *child, *gchild, *np;
>  
> -	if (th_zone->bind == false)
> -		return 0;
> -
> -	tab_size = data->cooling_data.freq_clip_count;
> -
> -	if (tab_size == 0)
> +	if (th_zone->bind == false || !th_zone->cool_dev_size)
>  		return 0;
>  
>  	/* find the cooling device registered*/
> @@ -203,23 +214,30 @@ static int exynos_unbind(struct
> thermal_zone_device *thermal, if (i == th_zone->cool_dev_size)
>  		return 0;
>  
> -	/* Bind the thermal zone to the cpufreq cooling device */
> -	for (i = 0; i < tab_size; i++) {
> -		switch (GET_ZONE(i)) {
> -		case MONITOR_ZONE:
> -		case WARN_ZONE:
> -			if
> (thermal_zone_unbind_cooling_device(thermal, i,
> -
> cdev)) {
> -				dev_err(data->dev,
> -					"error unbinding cdev
> inst=%d\n", i);
> -				ret = -EINVAL;
> -			}
> -			th_zone->bind = false;
> -			break;
> -		default:
> +	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
> +	if (!np) {
> +		pr_err("failed to find thmerla-zones/cpu-thermal
> node\n");
> +		return -ENOENT;
> +	}
> +
> +	child = of_get_child_by_name(np, "cooling-maps");
> +
> +	i = 0;
> +	for_each_child_of_node(child, gchild) {
> +		if (thermal_zone_unbind_cooling_device(thermal, i,
> +						       cdev)) {
> +			dev_err(data->dev,
> +				"error unbinding cdev inst=%d\n", i);
>  			ret = -EINVAL;
> +			goto end;
>  		}
> +		i++;
>  	}
> +	th_zone->bind = false;
> +end:
> +	of_node_put(child);
> +	of_node_put(np);
> +
>  	return ret;
>  }
>  
> diff --git a/drivers/thermal/samsung/exynos_tmu.c
> b/drivers/thermal/samsung/exynos_tmu.c index 5000727..ae30f6a 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -916,13 +916,6 @@ static int exynos_tmu_probe(struct
> platform_device *pdev) 
>  	sensor_conf->trip_data.trigger_falling =
> pdata->threshold_falling; 
> -	sensor_conf->cooling_data.freq_clip_count =
> pdata->freq_tab_count;
> -	for (i = 0; i < pdata->freq_tab_count; i++) {
> -		sensor_conf->cooling_data.freq_data[i].freq_clip_max
> =
> -
> pdata->freq_tab[i].freq_clip_max;
> -		sensor_conf->cooling_data.freq_data[i].temp_level =
> -
> pdata->freq_tab[i].temp_level;
> -	}
>  	sensor_conf->dev = &pdev->dev;
>  	/* Register the sensor with thermal management interface */
>  	ret = exynos_register_thermal(sensor_conf);
> diff --git a/drivers/thermal/samsung/exynos_tmu.h
> b/drivers/thermal/samsung/exynos_tmu.h index 7f880d2..627dec9 100644
> --- a/drivers/thermal/samsung/exynos_tmu.h
> +++ b/drivers/thermal/samsung/exynos_tmu.h
> @@ -83,9 +83,6 @@ enum soc_type {
>   * @second_point_trim: temp value of the second point trimming
>   * @default_temp_offset: default temperature offset in case of no
> trimming
>   * @cal_type: calibration type for temperature
> - * @freq_clip_table: Table representing frequency reduction
> percentage.
> - * @freq_tab_count: Count of the above table as frequency reduction
> may
> - *	applicable to only some of the trigger levels.
>   *
>   * This structure is required for configuration of exynos_tmu driver.
>   */
> @@ -111,8 +108,6 @@ struct exynos_tmu_platform_data {
>  	enum soc_type type;
>  	u32 cal_type;
>  	u32 cal_mode;
> -	struct freq_clip_table freq_tab[4];
> -	unsigned int freq_tab_count;
>  };
>  
>  /**
> diff --git a/drivers/thermal/samsung/exynos_tmu_data.c
> b/drivers/thermal/samsung/exynos_tmu_data.c index b239100..a993f3d
> 100644 --- a/drivers/thermal/samsung/exynos_tmu_data.c
> +++ b/drivers/thermal/samsung/exynos_tmu_data.c
> @@ -47,15 +47,6 @@ struct exynos_tmu_init_data const
> exynos4210_default_tmu_data = { .first_point_trim = 25,
>  		.second_point_trim = 85,
>  		.default_temp_offset = 50,
> -		.freq_tab[0] = {
> -			.freq_clip_max = 800 * 1000,
> -			.temp_level = 85,
> -			},
> -		.freq_tab[1] = {
> -			.freq_clip_max = 200 * 1000,
> -			.temp_level = 100,
> -		},
> -		.freq_tab_count = 2,
>  		.type = SOC_ARCH_EXYNOS4210,
>  		},
>  	},
> @@ -87,16 +78,7 @@ struct exynos_tmu_init_data const
> exynos4210_default_tmu_data = { .max_efuse_value = 100, \
>  	.first_point_trim = 25, \
>  	.second_point_trim = 85, \
> -	.default_temp_offset = 50, \
> -	.freq_tab[0] = { \
> -		.freq_clip_max = 800 * 1000, \
> -		.temp_level = 70, \
> -	}, \
> -	.freq_tab[1] = { \
> -		.freq_clip_max = 400 * 1000, \
> -		.temp_level = 95, \
> -	}, \
> -	.freq_tab_count = 2
> +	.default_temp_offset = 50
>  
>  struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
>  	.tmu_data = {
> @@ -133,16 +115,7 @@ struct exynos_tmu_init_data const
> exynos3250_default_tmu_data = { .max_efuse_value = 100, \
>  	.first_point_trim = 25, \
>  	.second_point_trim = 85, \
> -	.default_temp_offset = 50, \
> -	.freq_tab[0] = { \
> -		.freq_clip_max = 1400 * 1000, \
> -		.temp_level = 70, \
> -	}, \
> -	.freq_tab[1] = { \
> -		.freq_clip_max = 400 * 1000, \
> -		.temp_level = 95, \
> -	}, \
> -	.freq_tab_count = 2
> +	.default_temp_offset = 50
>  
>  struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
>  	.tmu_data = {
> @@ -189,16 +162,7 @@ struct exynos_tmu_init_data const
> exynos5250_default_tmu_data = { .max_efuse_value = 100, \
>  	.first_point_trim = 25, \
>  	.second_point_trim = 85, \
> -	.default_temp_offset = 50, \
> -	.freq_tab[0] = { \
> -		.freq_clip_max = 800 * 1000, \
> -		.temp_level = 85, \
> -	}, \
> -	.freq_tab[1] = { \
> -		.freq_clip_max = 200 * 1000, \
> -		.temp_level = 103, \
> -	}, \
> -	.freq_tab_count = 2, \
> +	.default_temp_offset = 50,
>  
>  #define EXYNOS5260_TMU_DATA \
>  	__EXYNOS5260_TMU_DATA \



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-21  3:18     ` Eduardo Valentin
@ 2015-01-21  8:40       ` Lukasz Majewski
  2015-01-21  9:14         ` Eduardo Valentin
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-21  8:40 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

Hi Eduardo,

> On Mon, Jan 19, 2015 at 12:20:59PM +0100, Lukasz Majewski wrote:
> > This patch brings support for providing configuration via device
> > tree. Previously this data has been hardcoded in the
> > exynos_tmu_data.c file. Such approach was not scalable and very
> > often required copying the whole data.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
> > - Usage of of-thermal.c exported trip points table
> > Changes for v3:
> > - Adding exynos_of_get_soc_type() method to set SOC type from
> > device's compatible string
> > - "samsung,tmu_" prefix for TMU specific properties has been added
> > Changes for v4:
> > - None
> > Changes for v5:
> > - Remove duplicated exynos_tmu_initialize() - reported by Abhilash
> > Kesavan <a.kesavan@samsung.com>
> > 
> 
> several checkpatch.pl items to be reviewed in this patch:
> CHECK: No space is necessary after a cast
> #509: FILE: drivers/thermal/samsung/exynos_tmu.c:821:
> +       pdata->gain = (u8) value;
> 
> CHECK: No space is necessary after a cast
> #511: FILE: drivers/thermal/samsung/exynos_tmu.c:823:
> +       pdata->reference_voltage = (u8) value;
> 
> 
> Can you please make sure all of your patches pass:
> checkpatch.pl --strict

`		^^^^^^^^^ Is now checkpatch.pl required to run with
--strict rule? 

I've tested those patches only with checkpatch with no errors.

Has kernel policy changed recently? Are all developers now obliged to
use the --strict rule?


> 
> ?
> 
> 
> > ---
> >  drivers/thermal/samsung/Makefile     |   2 -
> >  drivers/thermal/samsung/exynos_tmu.c | 339
> > ++++++++++++++++++++++-------------
> > drivers/thermal/samsung/exynos_tmu.h |  53 +----- 3 files changed,
> > 220 insertions(+), 174 deletions(-)
> > 
> > diff --git a/drivers/thermal/samsung/Makefile
> > b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644
> > --- a/drivers/thermal/samsung/Makefile
> > +++ b/drivers/thermal/samsung/Makefile
> > @@ -3,5 +3,3 @@
> >  #
> >  obj-$(CONFIG_EXYNOS_THERMAL)			+=
> > exynos_thermal.o exynos_thermal-y				:=
> > exynos_tmu.o -exynos_thermal-y				+=
> > exynos_tmu_data.o
> > -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+=
> > exynos_thermal_common.o diff --git
> > a/drivers/thermal/samsung/exynos_tmu.c
> > b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..9d2d685
> > 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++
> > b/drivers/thermal/samsung/exynos_tmu.c @@ -1,6 +1,10 @@ /*
> >   * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
> >   *
> > + *  Copyright (C) 2014 Samsung Electronics
> > + *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> > + *  Lukasz Majewski <l.majewski@samsung.com>
> > + *
> >   *  Copyright (C) 2011 Samsung Electronics
> >   *  Donggeun Kim <dg77.kim@samsung.com>
> >   *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
> > @@ -31,8 +35,8 @@
> >  #include <linux/platform_device.h>
> >  #include <linux/regulator/consumer.h>
> >  
> > -#include "exynos_thermal_common.h"
> >  #include "exynos_tmu.h"
> > +#include "../thermal_core.h"
> >  
> >  /* Exynos generic registers */
> >  #define EXYNOS_TMU_REG_TRIMINFO		0x0
> > @@ -115,6 +119,7 @@
> >  #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
> >  #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
> >  
> > +#define MCELSIUS	1000
> >  /**
> >   * struct exynos_tmu_data : A structure to hold the private data
> > of the TMU driver
> > @@ -150,7 +155,8 @@ struct exynos_tmu_data {
> >  	struct clk *clk, *clk_sec;
> >  	u8 temp_error1, temp_error2;
> >  	struct regulator *regulator;
> > -	struct thermal_sensor_conf *reg_conf;
> > +	struct thermal_zone_device *tzd;
> > +
> >  	int (*tmu_initialize)(struct platform_device *pdev);
> >  	void (*tmu_control)(struct platform_device *pdev, bool on);
> >  	int (*tmu_read)(struct exynos_tmu_data *data);
> > @@ -159,6 +165,33 @@ struct exynos_tmu_data {
> >  	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
> >  };
> >  
> > +static void exynos_report_trigger(struct exynos_tmu_data *p)
> > +{
> > +	char data[10], *envp[] = { data, NULL };
> > +	struct thermal_zone_device *tz = p->tzd;
> > +	unsigned long temp;
> > +	unsigned int i;
> > +
> > +	if (!p) {
> > +		pr_err("Wrong temperature configuration data\n");
> > +		return;
> > +	}
> > +
> > +	thermal_zone_device_update(tz);
> > +
> > +	mutex_lock(&tz->lock);
> > +	/* Find the level for which trip happened */
> > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > +		tz->ops->get_trip_temp(tz, i, &temp);
> > +		if (tz->last_temperature < temp)
> > +			break;
> > +	}
> > +
> > +	snprintf(data, sizeof(data), "%u", i);
> > +	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
> > +	mutex_unlock(&tz->lock);
> > +}
> > +
> >  /*
> >   * TMU treats temperature as a mapped temperature code.
> >   * The temperature is converted differently depending on the
> > calibration type. @@ -234,14 +267,25 @@ static void
> > sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info) 
> >  static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold,
> > bool falling) {
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > +	struct thermal_zone_device *tz = data->tzd;
> > +	const struct thermal_trip * const trips =
> > +		of_thermal_get_trip_points(tz);
> > +	unsigned long temp;
> >  	int i;
> >  
> > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
> > -		u8 temp = pdata->trigger_levels[i];
> > +	if (!trips) {
> > +		pr_err("%s: Cannot get trip points from
> > of-thermal.c!\n",
> > +		       __func__);
> > +		return 0;
> > +	}
> >  
> > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > +		if (trips[i].type == THERMAL_TRIP_CRITICAL)
> > +			continue;
> > +
> > +		temp = trips[i].temperature / MCELSIUS;
> >  		if (falling)
> > -			temp -= pdata->threshold_falling;
> > +			temp -= (trips[i].hysteresis / MCELSIUS);
> >  		else
> >  			threshold &= ~(0xff << 8 * i);
> >  
> > @@ -305,9 +349,19 @@ static void exynos_tmu_control(struct
> > platform_device *pdev, bool on) static int
> > exynos4210_tmu_initialize(struct platform_device *pdev) {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > -	unsigned int status;
> > +	struct thermal_zone_device *tz = data->tzd;
> > +	const struct thermal_trip * const trips =
> > +		of_thermal_get_trip_points(tz);
> >  	int ret = 0, threshold_code, i;
> > +	unsigned long reference, temp;
> > +	unsigned int status;
> > +
> > +	if (!trips) {
> > +		pr_err("%s: Cannot get trip points from
> > of-thermal.c!\n",
> > +		       __func__);
> > +		ret = -ENODEV;
> > +		goto out;
> > +	}
> >  
> >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> >  	if (!status) {
> > @@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct
> > platform_device *pdev) sanitize_temp_error(data, readl(data->base +
> > EXYNOS_TMU_REG_TRIMINFO)); 
> >  	/* Write temperature code for threshold */
> > -	threshold_code = temp_to_code(data, pdata->threshold);
> > +	reference = trips[0].temperature / MCELSIUS;
> > +	threshold_code = temp_to_code(data, reference);
> > +	if (threshold_code < 0) {
> > +		ret = threshold_code;
> > +		goto out;
> > +	}
> >  	writeb(threshold_code, data->base +
> > EXYNOS4210_TMU_REG_THRESHOLD_TEMP); 
> > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
> > -		writeb(pdata->trigger_levels[i], data->base +
> > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > +		temp = trips[i].temperature / MCELSIUS;
> > +		writeb(temp - reference, data->base +
> >  		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
> > +	}
> >  
> >  	data->tmu_clear_irqs(data);
> >  out:
> > @@ -333,9 +394,11 @@ out:
> >  static int exynos4412_tmu_initialize(struct platform_device *pdev)
> >  {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > +	const struct thermal_trip * const trips =
> > +		of_thermal_get_trip_points(data->tzd);
> >  	unsigned int status, trim_info, con, ctrl,
> > rising_threshold; int ret = 0, threshold_code, i;
> > +	unsigned long crit_temp = 0;
> >  
> >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> >  	if (!status) {
> > @@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct
> > platform_device *pdev) data->tmu_clear_irqs(data);
> >  
> >  	/* if last threshold limit is also present */
> > -	i = pdata->max_trigger_level - 1;
> > -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==
> > HW_TRIP) {
> > -		threshold_code = temp_to_code(data,
> > pdata->trigger_levels[i]);
> > -		/* 1-4 level to be assigned in th0 reg */
> > -		rising_threshold &= ~(0xff << 8 * i);
> > -		rising_threshold |= threshold_code << 8 * i;
> > -		writel(rising_threshold, data->base +
> > EXYNOS_THD_TEMP_RISE);
> > -		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> > -		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > -		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> > +	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
> > +		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
> > +			crit_temp = trips[i].temperature;
> > +			break;
> > +		}
> > +	}
> > +
> > +	if (i == of_thermal_get_ntrips(data->tzd)) {
> > +		pr_err("%s: No CRITICAL trip point defined at
> > of-thermal.c!\n",
> > +		       __func__);
> > +		ret = -EINVAL;
> > +		goto out;
> >  	}
> > +
> > +	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
> > +	/* 1-4 level to be assigned in th0 reg */
> > +	rising_threshold &= ~(0xff << 8 * i);
> > +	rising_threshold |= threshold_code << 8 * i;
> > +	writel(rising_threshold, data->base +
> > EXYNOS_THD_TEMP_RISE);
> > +	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> > +	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > +	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> > +
> >  out:
> >  	return ret;
> >  }
> > @@ -391,9 +466,9 @@ out:
> >  static int exynos5440_tmu_initialize(struct platform_device *pdev)
> >  {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> >  	unsigned int trim_info = 0, con, rising_threshold;
> > -	int ret = 0, threshold_code, i;
> > +	int ret = 0, threshold_code;
> > +	unsigned long crit_temp = 0;
> >  
> >  	/*
> >  	 * For exynos5440 soc triminfo value is swapped between
> > TMU0 and @@ -422,9 +497,8 @@ static int
> > exynos5440_tmu_initialize(struct platform_device *pdev)
> > data->tmu_clear_irqs(data); 
> >  	/* if last threshold limit is also present */
> > -	i = pdata->max_trigger_level - 1;
> > -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==
> > HW_TRIP) {
> > -		threshold_code = temp_to_code(data,
> > pdata->trigger_levels[i]);
> > +	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp))
> > {
> > +		threshold_code = temp_to_code(data, crit_temp /
> > MCELSIUS); /* 5th level to be assigned in th2 reg */
> >  		rising_threshold =
> >  			threshold_code <<
> > EXYNOS5440_TMU_TH_RISE4_SHIFT; @@ -442,7 +516,7 @@ static int
> > exynos5440_tmu_initialize(struct platform_device *pdev) static void
> > exynos4210_tmu_control(struct platform_device *pdev, bool on) {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > +	struct thermal_zone_device *tz = data->tzd;
> >  	unsigned int con, interrupt_en;
> >  
> >  	con = get_con_reg(data, readl(data->base +
> > EXYNOS_TMU_REG_CONTROL)); @@ -450,10 +524,15 @@ static void
> > exynos4210_tmu_control(struct platform_device *pdev, bool on) if
> > (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> >  		interrupt_en =
> > -			pdata->trigger_enable[3] <<
> > EXYNOS_TMU_INTEN_RISE3_SHIFT |
> > -			pdata->trigger_enable[2] <<
> > EXYNOS_TMU_INTEN_RISE2_SHIFT |
> > -			pdata->trigger_enable[1] <<
> > EXYNOS_TMU_INTEN_RISE1_SHIFT |
> > -			pdata->trigger_enable[0] <<
> > EXYNOS_TMU_INTEN_RISE0_SHIFT;
> > +			(of_thermal_is_trip_valid(tz, 3)
> > +			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 2)
> > +			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 1)
> > +			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 0)
> > +			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
> > +
> >  		if (data->soc != SOC_ARCH_EXYNOS4210)
> >  			interrupt_en |=
> >  				interrupt_en <<
> > EXYNOS_TMU_INTEN_FALL0_SHIFT; @@ -468,7 +547,7 @@ static void
> > exynos4210_tmu_control(struct platform_device *pdev, bool on)
> > static void exynos5440_tmu_control(struct platform_device *pdev,
> > bool on) { struct exynos_tmu_data *data =
> > platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > +	struct thermal_zone_device *tz = data->tzd;
> >  	unsigned int con, interrupt_en;
> >  
> >  	con = get_con_reg(data, readl(data->base +
> > EXYNOS5440_TMU_S0_7_CTRL)); @@ -476,11 +555,16 @@ static void
> > exynos5440_tmu_control(struct platform_device *pdev, bool on) if
> > (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> >  		interrupt_en =
> > -			pdata->trigger_enable[3] <<
> > EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
> > -			pdata->trigger_enable[2] <<
> > EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
> > -			pdata->trigger_enable[1] <<
> > EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
> > -			pdata->trigger_enable[0] <<
> > EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
> > -		interrupt_en |= interrupt_en <<
> > EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
> > +			(of_thermal_is_trip_valid(tz, 3)
> > +			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 2)
> > +			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 1)
> > +			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 0)
> > +			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
> > +		interrupt_en |=
> > +			interrupt_en <<
> > EXYNOS5440_TMU_INTEN_FALL0_SHIFT; } else {
> >  		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
> >  		interrupt_en = 0; /* Disable all interrupts */
> > @@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct
> > platform_device *pdev, bool on) writel(con, data->base +
> > EXYNOS5440_TMU_S0_7_CTRL); }
> >  
> > -static int exynos_tmu_read(struct exynos_tmu_data *data)
> > +int exynos_get_temp(void *p, long *temp)
> >  {
> > -	int ret;
> > +	struct exynos_tmu_data *data = p;
> > +
> > +	if (!data)
> > +		return -EINVAL;
> >  
> >  	mutex_lock(&data->lock);
> >  	clk_enable(data->clk);
> > -	ret = data->tmu_read(data);
> > -	if (ret >= 0)
> > -		ret = code_to_temp(data, ret);
> > +
> > +	*temp = code_to_temp(data, data->tmu_read(data)) *
> > MCELSIUS; +
> >  	clk_disable(data->clk);
> >  	mutex_unlock(&data->lock);
> >  
> > -	return ret;
> > +	return 0;
> >  }
> >  
> >  #ifdef CONFIG_THERMAL_EMULATION
> > @@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct
> > *work) if (!IS_ERR(data->clk_sec))
> >  		clk_disable(data->clk_sec);
> >  
> > -	exynos_report_trigger(data->reg_conf);
> > +	exynos_report_trigger(data);
> >  	mutex_lock(&data->lock);
> >  	clk_enable(data->clk);
> >  
> > @@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq,
> > void *id) static const struct of_device_id exynos_tmu_match[] = {
> >  	{
> >  		.compatible = "samsung,exynos3250-tmu",
> > -		.data = &exynos3250_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos4210-tmu",
> > -		.data = &exynos4210_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos4412-tmu",
> > -		.data = &exynos4412_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos5250-tmu",
> > -		.data = &exynos5250_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos5260-tmu",
> > -		.data = &exynos5260_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos5420-tmu",
> > -		.data = &exynos5420_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible =
> > "samsung,exynos5420-tmu-ext-triminfo",
> > -		.data = &exynos5420_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos5440-tmu",
> > -		.data = &exynos5440_default_tmu_data,
> >  	},
> >  	{},
> >  };
> >  MODULE_DEVICE_TABLE(of, exynos_tmu_match);
> >  
> > -static inline struct  exynos_tmu_platform_data
> > *exynos_get_driver_data(
> > -			struct platform_device *pdev, int id)
> > +static int exynos_of_get_soc_type(struct device_node *np)
> >  {
> > -	struct  exynos_tmu_init_data *data_table;
> > -	struct exynos_tmu_platform_data *tmu_data;
> > -	const struct of_device_id *match;
> > +	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
> > +		return SOC_ARCH_EXYNOS3250;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos4210-tmu"))
> > +		return SOC_ARCH_EXYNOS4210;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos4412-tmu"))
> > +		return SOC_ARCH_EXYNOS4412;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos5250-tmu"))
> > +		return SOC_ARCH_EXYNOS5250;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos5260-tmu"))
> > +		return SOC_ARCH_EXYNOS5260;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos5420-tmu"))
> > +		return SOC_ARCH_EXYNOS5420;
> > +	else if (of_device_is_compatible(np,
> > +
> > "samsung,exynos5420-tmu-ext-triminfo"))
> > +		return SOC_ARCH_EXYNOS5420_TRIMINFO;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos5440-tmu"))
> > +		return SOC_ARCH_EXYNOS5440;
> > +
> > +	return -EINVAL;
> > +}
> >  
> > -	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
> > -	if (!match)
> > -		return NULL;
> > -	data_table = (struct exynos_tmu_init_data *) match->data;
> > -	if (!data_table || id >= data_table->tmu_count)
> > -		return NULL;
> > -	tmu_data = data_table->tmu_data;
> > -	return (struct exynos_tmu_platform_data *) (tmu_data + id);
> > +static int exynos_of_sensor_conf(struct device_node *np,
> > +				 struct exynos_tmu_platform_data
> > *pdata) +{
> > +	u32 value;
> > +	int ret;
> > +
> > +	of_node_get(np);
> > +
> > +	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
> > +	pdata->gain = (u8) value;
> > +	of_property_read_u32(np, "samsung,tmu_reference_voltage",
> > &value);
> > +	pdata->reference_voltage = (u8) value;
> > +	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode",
> > &value);
> > +	pdata->noise_cancel_mode = (u8) value;
> > +
> > +	of_property_read_u32(np, "samsung,tmu_efuse_value",
> > +			     &pdata->efuse_value);
> > +	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
> > +			     &pdata->min_efuse_value);
> > +	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
> > +			     &pdata->max_efuse_value);
> > +
> > +	of_property_read_u32(np, "samsung,tmu_first_point_trim",
> > &value);
> > +	pdata->first_point_trim = (u8) value;
> > +	of_property_read_u32(np, "samsung,tmu_second_point_trim",
> > &value);
> > +	pdata->second_point_trim = (u8) value;
> > +	of_property_read_u32(np,
> > "samsung,tmu_default_temp_offset", &value);
> > +	pdata->default_temp_offset = (u8) value;
> > +
> > +	of_property_read_u32(np, "samsung,tmu_cal_type",
> > &pdata->cal_type);
> > +	of_property_read_u32(np, "samsung,tmu_cal_mode",
> > &pdata->cal_mode); +
> > +	of_node_put(np);
> > +	return 0;
> >  }
> >  
> >  static int exynos_map_dt_data(struct platform_device *pdev)
> > @@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct
> > platform_device *pdev) return -EADDRNOTAVAIL;
> >  	}
> >  
> > -	pdata = exynos_get_driver_data(pdev, data->id);
> > -	if (!pdata) {
> > -		dev_err(&pdev->dev, "No platform init data
> > supplied.\n");
> > -		return -ENODEV;
> > -	}
> > +	pdata = devm_kzalloc(&pdev->dev,
> > +			     sizeof(struct
> > exynos_tmu_platform_data),
> > +			     GFP_KERNEL);
> > +	if (!pdata)
> > +		return -ENOMEM;
> >  
> > +	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
> >  	data->pdata = pdata;
> > -	data->soc = pdata->type;
> > +	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
> >  
> >  	switch (data->soc) {
> >  	case SOC_ARCH_EXYNOS4210:
> > @@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct
> > platform_device *pdev) return 0;
> >  }
> >  
> > +static struct thermal_zone_of_device_ops exynos_sensor_ops = {
> > +	.get_temp = exynos_get_temp,
> > +	.set_emul_temp = exynos_tmu_set_emulation,
> > +};
> > +
> >  static int exynos_tmu_probe(struct platform_device *pdev)
> >  {
> > -	struct exynos_tmu_data *data;
> >  	struct exynos_tmu_platform_data *pdata;
> > -	struct thermal_sensor_conf *sensor_conf;
> > -	int ret, i;
> > +	struct exynos_tmu_data *data;
> > +	int ret;
> >  
> >  	data = devm_kzalloc(&pdev->dev, sizeof(struct
> > exynos_tmu_data), GFP_KERNEL);
> > @@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct
> > platform_device *pdev) platform_set_drvdata(pdev, data);
> >  	mutex_init(&data->lock);
> >  
> > +	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0,
> > data,
> > +
> > &exynos_sensor_ops);
> > +	if (IS_ERR(data->tzd)) {
> > +		pr_err("thermal: tz: %p ERROR\n", data->tzd);
> > +		return PTR_ERR(data->tzd);
> > +	}
> >  	ret = exynos_map_dt_data(pdev);
> >  	if (ret)
> > -		return ret;
> > +		goto err_sensor;
> >  
> >  	pdata = data->pdata;
> >  
> > @@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct
> > platform_device *pdev) data->clk = devm_clk_get(&pdev->dev,
> > "tmu_apbif"); if (IS_ERR(data->clk)) {
> >  		dev_err(&pdev->dev, "Failed to get clock\n");
> > -		return  PTR_ERR(data->clk);
> > +		ret = PTR_ERR(data->clk);
> > +		goto err_sensor;
> >  	}
> >  
> >  	data->clk_sec = devm_clk_get(&pdev->dev,
> > "tmu_triminfo_apbif"); if (IS_ERR(data->clk_sec)) {
> >  		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
> >  			dev_err(&pdev->dev, "Failed to get
> > triminfo clock\n");
> > -			return PTR_ERR(data->clk_sec);
> > +			ret = PTR_ERR(data->clk_sec);
> > +			goto err_sensor;
> >  		}
> >  	} else {
> >  		ret = clk_prepare(data->clk_sec);
> >  		if (ret) {
> >  			dev_err(&pdev->dev, "Failed to get
> > clock\n");
> > -			return ret;
> > +			goto err_sensor;
> >  		}
> >  	}
> >  
> > @@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct
> > platform_device *pdev) goto err_clk;
> >  	}
> >  
> > -	exynos_tmu_control(pdev, true);
> > -
> > -	/* Allocate a structure to register with the exynos core
> > thermal */
> > -	sensor_conf = devm_kzalloc(&pdev->dev,
> > -				sizeof(struct
> > thermal_sensor_conf), GFP_KERNEL);
> > -	if (!sensor_conf) {
> > -		ret = -ENOMEM;
> > -		goto err_clk;
> > -	}
> > -	sprintf(sensor_conf->name, "therm_zone%d", data->id);
> > -	sensor_conf->read_temperature = (int (*)(void
> > *))exynos_tmu_read;
> > -	sensor_conf->write_emul_temp =
> > -		(int (*)(void *, unsigned
> > long))exynos_tmu_set_emulation;
> > -	sensor_conf->driver_data = data;
> > -	sensor_conf->trip_data.trip_count =
> > pdata->trigger_enable[0] +
> > -			pdata->trigger_enable[1] +
> > pdata->trigger_enable[2]+
> > -			pdata->trigger_enable[3];
> > -
> > -	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
> > -		sensor_conf->trip_data.trip_val[i] =
> > -			pdata->threshold +
> > pdata->trigger_levels[i];
> > -		sensor_conf->trip_data.trip_type[i] =
> > -					pdata->trigger_type[i];
> > -	}
> > -
> > -	sensor_conf->trip_data.trigger_falling =
> > pdata->threshold_falling; -
> > -	sensor_conf->dev = &pdev->dev;
> > -	/* Register the sensor with thermal management interface */
> > -	ret = exynos_register_thermal(sensor_conf);
> > -	if (ret) {
> > -		if (ret != -EPROBE_DEFER)
> > -			dev_err(&pdev->dev,
> > -				"Failed to register thermal
> > interface: %d\n",
> > -				ret);
> > -		goto err_clk;
> > -	}
> > -	data->reg_conf = sensor_conf;
> > -
> >  	ret = devm_request_irq(&pdev->dev, data->irq,
> > exynos_tmu_irq, IRQF_TRIGGER_RISING | IRQF_SHARED,
> > dev_name(&pdev->dev), data); if (ret) {
> > @@ -935,21 +1030,25 @@ static int exynos_tmu_probe(struct
> > platform_device *pdev) goto err_clk;
> >  	}
> >  
> > +	exynos_tmu_control(pdev, true);
> >  	return 0;
> >  err_clk:
> >  	clk_unprepare(data->clk);
> >  err_clk_sec:
> >  	if (!IS_ERR(data->clk_sec))
> >  		clk_unprepare(data->clk_sec);
> > +err_sensor:
> > +	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
> > +
> >  	return ret;
> >  }
> >  
> >  static int exynos_tmu_remove(struct platform_device *pdev)
> >  {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > +	struct thermal_zone_device *tzd = data->tzd;
> >  
> > -	exynos_unregister_thermal(data->reg_conf);
> > -
> > +	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
> >  	exynos_tmu_control(pdev, false);
> >  
> >  	clk_unprepare(data->clk);
> > diff --git a/drivers/thermal/samsung/exynos_tmu.h
> > b/drivers/thermal/samsung/exynos_tmu.h index 627dec9..d876d4c 100644
> > --- a/drivers/thermal/samsung/exynos_tmu.h
> > +++ b/drivers/thermal/samsung/exynos_tmu.h
> > @@ -23,8 +23,7 @@
> >  #ifndef _EXYNOS_TMU_H
> >  #define _EXYNOS_TMU_H
> >  #include <linux/cpu_cooling.h>
> > -
> > -#include "exynos_thermal_common.h"
> > +#include <dt-bindings/thermal/thermal_exynos.h>
> >  
> >  enum soc_type {
> >  	SOC_ARCH_EXYNOS3250 = 1,
> > @@ -36,38 +35,9 @@ enum soc_type {
> >  	SOC_ARCH_EXYNOS5420_TRIMINFO,
> >  	SOC_ARCH_EXYNOS5440,
> >  };
> > -#include <dt-bindings/thermal/thermal_exynos.h>
> >  
> >  /**
> >   * struct exynos_tmu_platform_data
> > - * @threshold: basic temperature for generating interrupt
> > - *	       25 <= threshold <= 125 [unit: degree Celsius]
> > - * @threshold_falling: differntial value for setting threshold
> > - *		       of temperature falling interrupt.
> > - * @trigger_levels: array for each interrupt levels
> > - *	[unit: degree Celsius]
> > - *	0: temperature for trigger_level0 interrupt
> > - *	   condition for trigger_level0 interrupt:
> > - *		current temperature > threshold +
> > trigger_levels[0]
> > - *	1: temperature for trigger_level1 interrupt
> > - *	   condition for trigger_level1 interrupt:
> > - *		current temperature > threshold +
> > trigger_levels[1]
> > - *	2: temperature for trigger_level2 interrupt
> > - *	   condition for trigger_level2 interrupt:
> > - *		current temperature > threshold +
> > trigger_levels[2]
> > - *	3: temperature for trigger_level3 interrupt
> > - *	   condition for trigger_level3 interrupt:
> > - *		current temperature > threshold +
> > trigger_levels[3]
> > - * @trigger_type: defines the type of trigger. Possible values are,
> > - *	THROTTLE_ACTIVE trigger type
> > - *	THROTTLE_PASSIVE trigger type
> > - *	SW_TRIP trigger type
> > - *	HW_TRIP
> > - * @trigger_enable[]: array to denote which trigger levels are
> > enabled.
> > - *	1 = enable trigger_level[] interrupt,
> > - *	0 = disable trigger_level[] interrupt
> > - * @max_trigger_level: max trigger level supported by the TMU
> > - * @non_hw_trigger_levels: number of defined non-hardware trigger
> > levels
> >   * @gain: gain of amplifier in the positive-TC generator block
> >   *	0 < gain <= 15
> >   * @reference_voltage: reference voltage of amplifier
> > @@ -79,21 +49,12 @@ enum soc_type {
> >   * @efuse_value: platform defined fuse value
> >   * @min_efuse_value: minimum valid trimming data
> >   * @max_efuse_value: maximum valid trimming data
> > - * @first_point_trim: temp value of the first point trimming
> > - * @second_point_trim: temp value of the second point trimming
> >   * @default_temp_offset: default temperature offset in case of no
> > trimming
> >   * @cal_type: calibration type for temperature
> >   *
> >   * This structure is required for configuration of exynos_tmu
> > driver. */
> >  struct exynos_tmu_platform_data {
> > -	u8 threshold;
> > -	u8 threshold_falling;
> > -	u8 trigger_levels[MAX_TRIP_COUNT];
> > -	enum trigger_type trigger_type[MAX_TRIP_COUNT];
> > -	bool trigger_enable[MAX_TRIP_COUNT];
> > -	u8 max_trigger_level;
> > -	u8 non_hw_trigger_levels;
> >  	u8 gain;
> >  	u8 reference_voltage;
> >  	u8 noise_cancel_mode;
> > @@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
> >  	u32 cal_mode;
> >  };
> >  
> > -/**
> > - * struct exynos_tmu_init_data
> > - * @tmu_count: number of TMU instances.
> > - * @tmu_data: platform data of all TMU instances.
> > - * This structure is required to store data for multi-instance
> > exynos tmu
> > - * driver.
> > - */
> > -struct exynos_tmu_init_data {
> > -	int tmu_count;
> > -	struct exynos_tmu_platform_data tmu_data[];
> > -};
> > -
> >  extern struct exynos_tmu_init_data const
> > exynos3250_default_tmu_data; extern struct exynos_tmu_init_data
> > const exynos4210_default_tmu_data; extern struct
> > exynos_tmu_init_data const exynos4412_default_tmu_data; -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-21  3:25     ` Eduardo Valentin
@ 2015-01-21  8:48       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-21  8:48 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

Hi Eduardo,

> On Mon, Jan 19, 2015 at 12:20:59PM +0100, Lukasz Majewski wrote:
> > This patch brings support for providing configuration via device
> > tree. Previously this data has been hardcoded in the
> > exynos_tmu_data.c file. Such approach was not scalable and very
> > often required copying the whole data.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
> > - Usage of of-thermal.c exported trip points table
> > Changes for v3:
> > - Adding exynos_of_get_soc_type() method to set SOC type from
> > device's compatible string
> > - "samsung,tmu_" prefix for TMU specific properties has been added
> > Changes for v4:
> > - None
> > Changes for v5:
> > - Remove duplicated exynos_tmu_initialize() - reported by Abhilash
> > Kesavan <a.kesavan@samsung.com>
> > 
> > ---
> >  drivers/thermal/samsung/Makefile     |   2 -
> >  drivers/thermal/samsung/exynos_tmu.c | 339
> > ++++++++++++++++++++++-------------
> > drivers/thermal/samsung/exynos_tmu.h |  53 +----- 3 files changed,
> > 220 insertions(+), 174 deletions(-)
> > 
> > diff --git a/drivers/thermal/samsung/Makefile
> > b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644
> > --- a/drivers/thermal/samsung/Makefile
> > +++ b/drivers/thermal/samsung/Makefile
> > @@ -3,5 +3,3 @@
> >  #
> >  obj-$(CONFIG_EXYNOS_THERMAL)			+=
> > exynos_thermal.o exynos_thermal-y				:=
> > exynos_tmu.o -exynos_thermal-y				+=
> > exynos_tmu_data.o
> > -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+=
> > exynos_thermal_common.o diff --git
> > a/drivers/thermal/samsung/exynos_tmu.c
> > b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..9d2d685
> > 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++
> > b/drivers/thermal/samsung/exynos_tmu.c @@ -1,6 +1,10 @@ /*
> >   * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
> >   *
> > + *  Copyright (C) 2014 Samsung Electronics
> > + *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> > + *  Lukasz Majewski <l.majewski@samsung.com>
> > + *
> >   *  Copyright (C) 2011 Samsung Electronics
> >   *  Donggeun Kim <dg77.kim@samsung.com>
> >   *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
> > @@ -31,8 +35,8 @@
> >  #include <linux/platform_device.h>
> >  #include <linux/regulator/consumer.h>
> >  
> > -#include "exynos_thermal_common.h"
> >  #include "exynos_tmu.h"
> > +#include "../thermal_core.h"
> >  
> >  /* Exynos generic registers */
> >  #define EXYNOS_TMU_REG_TRIMINFO		0x0
> > @@ -115,6 +119,7 @@
> >  #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
> >  #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
> >  
> > +#define MCELSIUS	1000
> >  /**
> >   * struct exynos_tmu_data : A structure to hold the private data
> > of the TMU driver
> > @@ -150,7 +155,8 @@ struct exynos_tmu_data {
> >  	struct clk *clk, *clk_sec;
> >  	u8 temp_error1, temp_error2;
> >  	struct regulator *regulator;
> > -	struct thermal_sensor_conf *reg_conf;
> > +	struct thermal_zone_device *tzd;
> > +
> >  	int (*tmu_initialize)(struct platform_device *pdev);
> >  	void (*tmu_control)(struct platform_device *pdev, bool on);
> >  	int (*tmu_read)(struct exynos_tmu_data *data);
> > @@ -159,6 +165,33 @@ struct exynos_tmu_data {
> >  	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
> >  };
> >  
> > +static void exynos_report_trigger(struct exynos_tmu_data *p)
> > +{
> > +	char data[10], *envp[] = { data, NULL };
> > +	struct thermal_zone_device *tz = p->tzd;
> > +	unsigned long temp;
> > +	unsigned int i;
> > +
> > +	if (!p) {
> > +		pr_err("Wrong temperature configuration data\n");
> > +		return;
> > +	}
> > +
> > +	thermal_zone_device_update(tz);
> > +
> > +	mutex_lock(&tz->lock);
> > +	/* Find the level for which trip happened */
> > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > +		tz->ops->get_trip_temp(tz, i, &temp);
> > +		if (tz->last_temperature < temp)
> > +			break;
> > +	}
> > +
> > +	snprintf(data, sizeof(data), "%u", i);
> > +	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
> > +	mutex_unlock(&tz->lock);
> > +}
> > +
> >  /*
> >   * TMU treats temperature as a mapped temperature code.
> >   * The temperature is converted differently depending on the
> > calibration type. @@ -234,14 +267,25 @@ static void
> > sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info) 
> >  static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold,
> > bool falling) {
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > +	struct thermal_zone_device *tz = data->tzd;
> > +	const struct thermal_trip * const trips =
> > +		of_thermal_get_trip_points(tz);
> > +	unsigned long temp;
> >  	int i;
> >  
> > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
> > -		u8 temp = pdata->trigger_levels[i];
> > +	if (!trips) {
> > +		pr_err("%s: Cannot get trip points from
> > of-thermal.c!\n",
> > +		       __func__);
> > +		return 0;
> > +	}
> >  
> > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > +		if (trips[i].type == THERMAL_TRIP_CRITICAL)
> > +			continue;
> > +
> > +		temp = trips[i].temperature / MCELSIUS;
> >  		if (falling)
> > -			temp -= pdata->threshold_falling;
> > +			temp -= (trips[i].hysteresis / MCELSIUS);
> >  		else
> >  			threshold &= ~(0xff << 8 * i);
> >  
> > @@ -305,9 +349,19 @@ static void exynos_tmu_control(struct
> > platform_device *pdev, bool on) static int
> > exynos4210_tmu_initialize(struct platform_device *pdev) {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > -	unsigned int status;
> > +	struct thermal_zone_device *tz = data->tzd;
> > +	const struct thermal_trip * const trips =
> > +		of_thermal_get_trip_points(tz);
> >  	int ret = 0, threshold_code, i;
> > +	unsigned long reference, temp;
> > +	unsigned int status;
> > +
> > +	if (!trips) {
> > +		pr_err("%s: Cannot get trip points from
> > of-thermal.c!\n",
> > +		       __func__);
> > +		ret = -ENODEV;
> > +		goto out;
> > +	}
> >  
> >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> >  	if (!status) {
> > @@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct
> > platform_device *pdev) sanitize_temp_error(data, readl(data->base +
> > EXYNOS_TMU_REG_TRIMINFO)); 
> >  	/* Write temperature code for threshold */
> > -	threshold_code = temp_to_code(data, pdata->threshold);
> > +	reference = trips[0].temperature / MCELSIUS;
> > +	threshold_code = temp_to_code(data, reference);
> > +	if (threshold_code < 0) {
> > +		ret = threshold_code;
> > +		goto out;
> > +	}
> >  	writeb(threshold_code, data->base +
> > EXYNOS4210_TMU_REG_THRESHOLD_TEMP); 
> > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
> > -		writeb(pdata->trigger_levels[i], data->base +
> > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > +		temp = trips[i].temperature / MCELSIUS;
> > +		writeb(temp - reference, data->base +
> >  		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
> > +	}
> >  
> >  	data->tmu_clear_irqs(data);
> >  out:
> > @@ -333,9 +394,11 @@ out:
> >  static int exynos4412_tmu_initialize(struct platform_device *pdev)
> >  {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > +	const struct thermal_trip * const trips =
> > +		of_thermal_get_trip_points(data->tzd);
> >  	unsigned int status, trim_info, con, ctrl,
> > rising_threshold; int ret = 0, threshold_code, i;
> > +	unsigned long crit_temp = 0;
> >  
> >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> >  	if (!status) {
> > @@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct
> > platform_device *pdev) data->tmu_clear_irqs(data);
> >  
> >  	/* if last threshold limit is also present */
> > -	i = pdata->max_trigger_level - 1;
> > -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==
> > HW_TRIP) {
> > -		threshold_code = temp_to_code(data,
> > pdata->trigger_levels[i]);
> > -		/* 1-4 level to be assigned in th0 reg */
> > -		rising_threshold &= ~(0xff << 8 * i);
> > -		rising_threshold |= threshold_code << 8 * i;
> > -		writel(rising_threshold, data->base +
> > EXYNOS_THD_TEMP_RISE);
> > -		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> > -		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > -		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> > +	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
> > +		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
> > +			crit_temp = trips[i].temperature;
> > +			break;
> > +		}
> > +	}
> > +
> > +	if (i == of_thermal_get_ntrips(data->tzd)) {
> > +		pr_err("%s: No CRITICAL trip point defined at
> > of-thermal.c!\n",
> > +		       __func__);
> > +		ret = -EINVAL;
> > +		goto out;
> >  	}
> > +
> > +	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
> > +	/* 1-4 level to be assigned in th0 reg */
> > +	rising_threshold &= ~(0xff << 8 * i);
> > +	rising_threshold |= threshold_code << 8 * i;
> > +	writel(rising_threshold, data->base +
> > EXYNOS_THD_TEMP_RISE);
> > +	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> > +	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > +	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> > +
> >  out:
> >  	return ret;
> >  }
> > @@ -391,9 +466,9 @@ out:
> >  static int exynos5440_tmu_initialize(struct platform_device *pdev)
> >  {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> >  	unsigned int trim_info = 0, con, rising_threshold;
> > -	int ret = 0, threshold_code, i;
> > +	int ret = 0, threshold_code;
> > +	unsigned long crit_temp = 0;
> >  
> >  	/*
> >  	 * For exynos5440 soc triminfo value is swapped between
> > TMU0 and @@ -422,9 +497,8 @@ static int
> > exynos5440_tmu_initialize(struct platform_device *pdev)
> > data->tmu_clear_irqs(data); 
> >  	/* if last threshold limit is also present */
> > -	i = pdata->max_trigger_level - 1;
> > -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==
> > HW_TRIP) {
> > -		threshold_code = temp_to_code(data,
> > pdata->trigger_levels[i]);
> > +	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp))
> > {
> > +		threshold_code = temp_to_code(data, crit_temp /
> > MCELSIUS); /* 5th level to be assigned in th2 reg */
> >  		rising_threshold =
> >  			threshold_code <<
> > EXYNOS5440_TMU_TH_RISE4_SHIFT; @@ -442,7 +516,7 @@ static int
> > exynos5440_tmu_initialize(struct platform_device *pdev) static void
> > exynos4210_tmu_control(struct platform_device *pdev, bool on) {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > +	struct thermal_zone_device *tz = data->tzd;
> >  	unsigned int con, interrupt_en;
> >  
> >  	con = get_con_reg(data, readl(data->base +
> > EXYNOS_TMU_REG_CONTROL)); @@ -450,10 +524,15 @@ static void
> > exynos4210_tmu_control(struct platform_device *pdev, bool on) if
> > (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> >  		interrupt_en =
> > -			pdata->trigger_enable[3] <<
> > EXYNOS_TMU_INTEN_RISE3_SHIFT |
> > -			pdata->trigger_enable[2] <<
> > EXYNOS_TMU_INTEN_RISE2_SHIFT |
> > -			pdata->trigger_enable[1] <<
> > EXYNOS_TMU_INTEN_RISE1_SHIFT |
> > -			pdata->trigger_enable[0] <<
> > EXYNOS_TMU_INTEN_RISE0_SHIFT;
> > +			(of_thermal_is_trip_valid(tz, 3)
> > +			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 2)
> > +			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 1)
> > +			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 0)
> > +			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
> > +
> >  		if (data->soc != SOC_ARCH_EXYNOS4210)
> >  			interrupt_en |=
> >  				interrupt_en <<
> > EXYNOS_TMU_INTEN_FALL0_SHIFT; @@ -468,7 +547,7 @@ static void
> > exynos4210_tmu_control(struct platform_device *pdev, bool on)
> > static void exynos5440_tmu_control(struct platform_device *pdev,
> > bool on) { struct exynos_tmu_data *data =
> > platform_get_drvdata(pdev);
> > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > +	struct thermal_zone_device *tz = data->tzd;
> >  	unsigned int con, interrupt_en;
> >  
> >  	con = get_con_reg(data, readl(data->base +
> > EXYNOS5440_TMU_S0_7_CTRL)); @@ -476,11 +555,16 @@ static void
> > exynos5440_tmu_control(struct platform_device *pdev, bool on) if
> > (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> >  		interrupt_en =
> > -			pdata->trigger_enable[3] <<
> > EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
> > -			pdata->trigger_enable[2] <<
> > EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
> > -			pdata->trigger_enable[1] <<
> > EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
> > -			pdata->trigger_enable[0] <<
> > EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
> > -		interrupt_en |= interrupt_en <<
> > EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
> > +			(of_thermal_is_trip_valid(tz, 3)
> > +			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 2)
> > +			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 1)
> > +			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
> > +			(of_thermal_is_trip_valid(tz, 0)
> > +			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
> > +		interrupt_en |=
> > +			interrupt_en <<
> > EXYNOS5440_TMU_INTEN_FALL0_SHIFT; } else {
> >  		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
> >  		interrupt_en = 0; /* Disable all interrupts */
> > @@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct
> > platform_device *pdev, bool on) writel(con, data->base +
> > EXYNOS5440_TMU_S0_7_CTRL); }
> >  
> > -static int exynos_tmu_read(struct exynos_tmu_data *data)
> > +int exynos_get_temp(void *p, long *temp)
> 
> exynos_get_temp must be static.

Yes, this should be static.
Thanks.

> 
> >  {
> > -	int ret;
> > +	struct exynos_tmu_data *data = p;
> > +
> > +	if (!data)
> > +		return -EINVAL;
> >  
> >  	mutex_lock(&data->lock);
> >  	clk_enable(data->clk);
> > -	ret = data->tmu_read(data);
> > -	if (ret >= 0)
> > -		ret = code_to_temp(data, ret);
> > +
> > +	*temp = code_to_temp(data, data->tmu_read(data)) *
> > MCELSIUS; +
> >  	clk_disable(data->clk);
> >  	mutex_unlock(&data->lock);
> >  
> > -	return ret;
> > +	return 0;
> >  }
> >  
> >  #ifdef CONFIG_THERMAL_EMULATION
> > @@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct
> > *work) if (!IS_ERR(data->clk_sec))
> >  		clk_disable(data->clk_sec);
> >  
> > -	exynos_report_trigger(data->reg_conf);
> > +	exynos_report_trigger(data);
> >  	mutex_lock(&data->lock);
> >  	clk_enable(data->clk);
> >  
> > @@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq,
> > void *id) static const struct of_device_id exynos_tmu_match[] = {
> >  	{
> >  		.compatible = "samsung,exynos3250-tmu",
> > -		.data = &exynos3250_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos4210-tmu",
> > -		.data = &exynos4210_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos4412-tmu",
> > -		.data = &exynos4412_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos5250-tmu",
> > -		.data = &exynos5250_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos5260-tmu",
> > -		.data = &exynos5260_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos5420-tmu",
> > -		.data = &exynos5420_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible =
> > "samsung,exynos5420-tmu-ext-triminfo",
> > -		.data = &exynos5420_default_tmu_data,
> >  	},
> >  	{
> >  		.compatible = "samsung,exynos5440-tmu",
> > -		.data = &exynos5440_default_tmu_data,
> >  	},
> >  	{},
> >  };
> >  MODULE_DEVICE_TABLE(of, exynos_tmu_match);
> >  
> > -static inline struct  exynos_tmu_platform_data
> > *exynos_get_driver_data(
> > -			struct platform_device *pdev, int id)
> > +static int exynos_of_get_soc_type(struct device_node *np)
> >  {
> > -	struct  exynos_tmu_init_data *data_table;
> > -	struct exynos_tmu_platform_data *tmu_data;
> > -	const struct of_device_id *match;
> > +	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
> > +		return SOC_ARCH_EXYNOS3250;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos4210-tmu"))
> > +		return SOC_ARCH_EXYNOS4210;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos4412-tmu"))
> > +		return SOC_ARCH_EXYNOS4412;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos5250-tmu"))
> > +		return SOC_ARCH_EXYNOS5250;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos5260-tmu"))
> > +		return SOC_ARCH_EXYNOS5260;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos5420-tmu"))
> > +		return SOC_ARCH_EXYNOS5420;
> > +	else if (of_device_is_compatible(np,
> > +
> > "samsung,exynos5420-tmu-ext-triminfo"))
> > +		return SOC_ARCH_EXYNOS5420_TRIMINFO;
> > +	else if (of_device_is_compatible(np,
> > "samsung,exynos5440-tmu"))
> > +		return SOC_ARCH_EXYNOS5440;
> > +
> > +	return -EINVAL;
> > +}
> >  
> > -	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
> > -	if (!match)
> > -		return NULL;
> > -	data_table = (struct exynos_tmu_init_data *) match->data;
> > -	if (!data_table || id >= data_table->tmu_count)
> > -		return NULL;
> > -	tmu_data = data_table->tmu_data;
> > -	return (struct exynos_tmu_platform_data *) (tmu_data + id);
> > +static int exynos_of_sensor_conf(struct device_node *np,
> > +				 struct exynos_tmu_platform_data
> > *pdata) +{
> > +	u32 value;
> > +	int ret;
> > +
> > +	of_node_get(np);
> > +
> > +	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
> > +	pdata->gain = (u8) value;
> > +	of_property_read_u32(np, "samsung,tmu_reference_voltage",
> > &value);
> > +	pdata->reference_voltage = (u8) value;
> > +	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode",
> > &value);
> > +	pdata->noise_cancel_mode = (u8) value;
> > +
> > +	of_property_read_u32(np, "samsung,tmu_efuse_value",
> > +			     &pdata->efuse_value);
> > +	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
> > +			     &pdata->min_efuse_value);
> > +	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
> > +			     &pdata->max_efuse_value);
> > +
> > +	of_property_read_u32(np, "samsung,tmu_first_point_trim",
> > &value);
> > +	pdata->first_point_trim = (u8) value;
> > +	of_property_read_u32(np, "samsung,tmu_second_point_trim",
> > &value);
> > +	pdata->second_point_trim = (u8) value;
> > +	of_property_read_u32(np,
> > "samsung,tmu_default_temp_offset", &value);
> > +	pdata->default_temp_offset = (u8) value;
> > +
> > +	of_property_read_u32(np, "samsung,tmu_cal_type",
> > &pdata->cal_type);
> > +	of_property_read_u32(np, "samsung,tmu_cal_mode",
> > &pdata->cal_mode); +
> > +	of_node_put(np);
> > +	return 0;
> >  }
> >  
> >  static int exynos_map_dt_data(struct platform_device *pdev)
> > @@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct
> > platform_device *pdev) return -EADDRNOTAVAIL;
> >  	}
> >  
> > -	pdata = exynos_get_driver_data(pdev, data->id);
> > -	if (!pdata) {
> > -		dev_err(&pdev->dev, "No platform init data
> > supplied.\n");
> > -		return -ENODEV;
> > -	}
> > +	pdata = devm_kzalloc(&pdev->dev,
> > +			     sizeof(struct
> > exynos_tmu_platform_data),
> > +			     GFP_KERNEL);
> > +	if (!pdata)
> > +		return -ENOMEM;
> >  
> > +	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
> >  	data->pdata = pdata;
> > -	data->soc = pdata->type;
> > +	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
> >  
> >  	switch (data->soc) {
> >  	case SOC_ARCH_EXYNOS4210:
> > @@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct
> > platform_device *pdev) return 0;
> >  }
> >  
> > +static struct thermal_zone_of_device_ops exynos_sensor_ops = {
> > +	.get_temp = exynos_get_temp,
> > +	.set_emul_temp = exynos_tmu_set_emulation,
> > +};
> > +
> >  static int exynos_tmu_probe(struct platform_device *pdev)
> >  {
> > -	struct exynos_tmu_data *data;
> >  	struct exynos_tmu_platform_data *pdata;
> > -	struct thermal_sensor_conf *sensor_conf;
> > -	int ret, i;
> > +	struct exynos_tmu_data *data;
> > +	int ret;
> >  
> >  	data = devm_kzalloc(&pdev->dev, sizeof(struct
> > exynos_tmu_data), GFP_KERNEL);
> > @@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct
> > platform_device *pdev) platform_set_drvdata(pdev, data);
> >  	mutex_init(&data->lock);
> >  
> > +	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0,
> > data,
> > +
> > &exynos_sensor_ops);
> > +	if (IS_ERR(data->tzd)) {
> > +		pr_err("thermal: tz: %p ERROR\n", data->tzd);
> > +		return PTR_ERR(data->tzd);
> > +	}
> >  	ret = exynos_map_dt_data(pdev);
> >  	if (ret)
> > -		return ret;
> > +		goto err_sensor;
> >  
> >  	pdata = data->pdata;
> >  
> > @@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct
> > platform_device *pdev) data->clk = devm_clk_get(&pdev->dev,
> > "tmu_apbif"); if (IS_ERR(data->clk)) {
> >  		dev_err(&pdev->dev, "Failed to get clock\n");
> > -		return  PTR_ERR(data->clk);
> > +		ret = PTR_ERR(data->clk);
> > +		goto err_sensor;
> >  	}
> >  
> >  	data->clk_sec = devm_clk_get(&pdev->dev,
> > "tmu_triminfo_apbif"); if (IS_ERR(data->clk_sec)) {
> >  		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
> >  			dev_err(&pdev->dev, "Failed to get
> > triminfo clock\n");
> > -			return PTR_ERR(data->clk_sec);
> > +			ret = PTR_ERR(data->clk_sec);
> > +			goto err_sensor;
> >  		}
> >  	} else {
> >  		ret = clk_prepare(data->clk_sec);
> >  		if (ret) {
> >  			dev_err(&pdev->dev, "Failed to get
> > clock\n");
> > -			return ret;
> > +			goto err_sensor;
> >  		}
> >  	}
> >  
> > @@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct
> > platform_device *pdev) goto err_clk;
> >  	}
> >  
> > -	exynos_tmu_control(pdev, true);
> > -
> > -	/* Allocate a structure to register with the exynos core
> > thermal */
> > -	sensor_conf = devm_kzalloc(&pdev->dev,
> > -				sizeof(struct
> > thermal_sensor_conf), GFP_KERNEL);
> > -	if (!sensor_conf) {
> > -		ret = -ENOMEM;
> > -		goto err_clk;
> > -	}
> > -	sprintf(sensor_conf->name, "therm_zone%d", data->id);
> > -	sensor_conf->read_temperature = (int (*)(void
> > *))exynos_tmu_read;
> > -	sensor_conf->write_emul_temp =
> > -		(int (*)(void *, unsigned
> > long))exynos_tmu_set_emulation;
> > -	sensor_conf->driver_data = data;
> > -	sensor_conf->trip_data.trip_count =
> > pdata->trigger_enable[0] +
> > -			pdata->trigger_enable[1] +
> > pdata->trigger_enable[2]+
> > -			pdata->trigger_enable[3];
> > -
> > -	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
> > -		sensor_conf->trip_data.trip_val[i] =
> > -			pdata->threshold +
> > pdata->trigger_levels[i];
> > -		sensor_conf->trip_data.trip_type[i] =
> > -					pdata->trigger_type[i];
> > -	}
> > -
> > -	sensor_conf->trip_data.trigger_falling =
> > pdata->threshold_falling; -
> > -	sensor_conf->dev = &pdev->dev;
> > -	/* Register the sensor with thermal management interface */
> > -	ret = exynos_register_thermal(sensor_conf);
> > -	if (ret) {
> > -		if (ret != -EPROBE_DEFER)
> > -			dev_err(&pdev->dev,
> > -				"Failed to register thermal
> > interface: %d\n",
> > -				ret);
> > -		goto err_clk;
> > -	}
> > -	data->reg_conf = sensor_conf;
> > -
> >  	ret = devm_request_irq(&pdev->dev, data->irq,
> > exynos_tmu_irq, IRQF_TRIGGER_RISING | IRQF_SHARED,
> > dev_name(&pdev->dev), data); if (ret) {
> > @@ -935,21 +1030,25 @@ static int exynos_tmu_probe(struct
> > platform_device *pdev) goto err_clk;
> >  	}
> >  
> > +	exynos_tmu_control(pdev, true);
> >  	return 0;
> >  err_clk:
> >  	clk_unprepare(data->clk);
> >  err_clk_sec:
> >  	if (!IS_ERR(data->clk_sec))
> >  		clk_unprepare(data->clk_sec);
> > +err_sensor:
> > +	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
> > +
> >  	return ret;
> >  }
> >  
> >  static int exynos_tmu_remove(struct platform_device *pdev)
> >  {
> >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > +	struct thermal_zone_device *tzd = data->tzd;
> >  
> > -	exynos_unregister_thermal(data->reg_conf);
> > -
> > +	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
> >  	exynos_tmu_control(pdev, false);
> >  
> >  	clk_unprepare(data->clk);
> > diff --git a/drivers/thermal/samsung/exynos_tmu.h
> > b/drivers/thermal/samsung/exynos_tmu.h index 627dec9..d876d4c 100644
> > --- a/drivers/thermal/samsung/exynos_tmu.h
> > +++ b/drivers/thermal/samsung/exynos_tmu.h
> > @@ -23,8 +23,7 @@
> >  #ifndef _EXYNOS_TMU_H
> >  #define _EXYNOS_TMU_H
> >  #include <linux/cpu_cooling.h>
> > -
> > -#include "exynos_thermal_common.h"
> > +#include <dt-bindings/thermal/thermal_exynos.h>
> >  
> >  enum soc_type {
> >  	SOC_ARCH_EXYNOS3250 = 1,
> > @@ -36,38 +35,9 @@ enum soc_type {
> >  	SOC_ARCH_EXYNOS5420_TRIMINFO,
> >  	SOC_ARCH_EXYNOS5440,
> >  };
> > -#include <dt-bindings/thermal/thermal_exynos.h>
> >  
> >  /**
> >   * struct exynos_tmu_platform_data
> > - * @threshold: basic temperature for generating interrupt
> > - *	       25 <= threshold <= 125 [unit: degree Celsius]
> > - * @threshold_falling: differntial value for setting threshold
> > - *		       of temperature falling interrupt.
> > - * @trigger_levels: array for each interrupt levels
> > - *	[unit: degree Celsius]
> > - *	0: temperature for trigger_level0 interrupt
> > - *	   condition for trigger_level0 interrupt:
> > - *		current temperature > threshold +
> > trigger_levels[0]
> > - *	1: temperature for trigger_level1 interrupt
> > - *	   condition for trigger_level1 interrupt:
> > - *		current temperature > threshold +
> > trigger_levels[1]
> > - *	2: temperature for trigger_level2 interrupt
> > - *	   condition for trigger_level2 interrupt:
> > - *		current temperature > threshold +
> > trigger_levels[2]
> > - *	3: temperature for trigger_level3 interrupt
> > - *	   condition for trigger_level3 interrupt:
> > - *		current temperature > threshold +
> > trigger_levels[3]
> > - * @trigger_type: defines the type of trigger. Possible values are,
> > - *	THROTTLE_ACTIVE trigger type
> > - *	THROTTLE_PASSIVE trigger type
> > - *	SW_TRIP trigger type
> > - *	HW_TRIP
> > - * @trigger_enable[]: array to denote which trigger levels are
> > enabled.
> > - *	1 = enable trigger_level[] interrupt,
> > - *	0 = disable trigger_level[] interrupt
> > - * @max_trigger_level: max trigger level supported by the TMU
> > - * @non_hw_trigger_levels: number of defined non-hardware trigger
> > levels
> >   * @gain: gain of amplifier in the positive-TC generator block
> >   *	0 < gain <= 15
> >   * @reference_voltage: reference voltage of amplifier
> > @@ -79,21 +49,12 @@ enum soc_type {
> >   * @efuse_value: platform defined fuse value
> >   * @min_efuse_value: minimum valid trimming data
> >   * @max_efuse_value: maximum valid trimming data
> > - * @first_point_trim: temp value of the first point trimming
> > - * @second_point_trim: temp value of the second point trimming
> >   * @default_temp_offset: default temperature offset in case of no
> > trimming
> >   * @cal_type: calibration type for temperature
> >   *
> >   * This structure is required for configuration of exynos_tmu
> > driver. */
> >  struct exynos_tmu_platform_data {
> > -	u8 threshold;
> > -	u8 threshold_falling;
> > -	u8 trigger_levels[MAX_TRIP_COUNT];
> > -	enum trigger_type trigger_type[MAX_TRIP_COUNT];
> > -	bool trigger_enable[MAX_TRIP_COUNT];
> > -	u8 max_trigger_level;
> > -	u8 non_hw_trigger_levels;
> >  	u8 gain;
> >  	u8 reference_voltage;
> >  	u8 noise_cancel_mode;
> > @@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
> >  	u32 cal_mode;
> >  };
> >  
> > -/**
> > - * struct exynos_tmu_init_data
> > - * @tmu_count: number of TMU instances.
> > - * @tmu_data: platform data of all TMU instances.
> > - * This structure is required to store data for multi-instance
> > exynos tmu
> > - * driver.
> > - */
> > -struct exynos_tmu_init_data {
> > -	int tmu_count;
> > -	struct exynos_tmu_platform_data tmu_data[];
> > -};
> > -
> >  extern struct exynos_tmu_init_data const
> > exynos3250_default_tmu_data; extern struct exynos_tmu_init_data
> > const exynos4210_default_tmu_data; extern struct
> > exynos_tmu_init_data const exynos4412_default_tmu_data; -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 18/18] thermal: exynos: Remove not needed exynos_tmu_init_data declarations from exynos_tmu.h
  2015-01-21  3:30     ` Eduardo Valentin
@ 2015-01-21  9:00       ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-21  9:00 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

Hi Eduardo,

> On Mon, Jan 19, 2015 at 12:21:02PM +0100, Lukasz Majewski wrote:
> > After switching to device tree based configuration those
> > declarations are not needed anymore.
> > 
> > Reported-by: Abhilash Kesavan <a.kesavan@samsung.com>
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v5:
> > - New patch
> > ---
> >   | 8 --------
> >  1 file changed, 8 deletions(-)
> > 
> > diff --git a/drivers/thermal/samsung/exynos_tmu.h
> > b/drivers/thermal/samsung/exynos_tmu.h index d876d4c..9f9b1b8 100644
> > --- a/drivers/thermal/samsung/exynos_tmu.h
> > +++ b/drivers/thermal/samsung/exynos_tmu.h
> > @@ -71,12 +71,4 @@ struct exynos_tmu_platform_data {
> >  	u32 cal_mode;
> >  };
> >  
> > -extern struct exynos_tmu_init_data const
> > exynos3250_default_tmu_data; -extern struct exynos_tmu_init_data
> > const exynos4210_default_tmu_data; -extern struct
> > exynos_tmu_init_data const exynos4412_default_tmu_data; -extern
> > struct exynos_tmu_init_data const exynos5250_default_tmu_data;
> > -extern struct exynos_tmu_init_data const
> > exynos5260_default_tmu_data; -extern struct exynos_tmu_init_data
> > const exynos5420_default_tmu_data; -extern struct
> > exynos_tmu_init_data const exynos5440_default_tmu_data;
> 
> Please merge this patch to the one that removes these symbols from
> kernel.

Will be done for v6 version.

> 
> > -
> >  #endif /* _EXYNOS_TMU_H */
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 00/16] thermal: exynos: Thermal code rework to use device tree
  2015-01-22  1:06           ` Tobias Jakobi
@ 2015-01-21  9:08             ` Eduardo Valentin
  2015-01-24  1:00               ` Tobias Jakobi
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-21  9:08 UTC (permalink / raw)
  To: Tobias Jakobi
  Cc: Lukasz Majewski, Zhang Rui, Kukjin Kim, Kukjin Kim,
	Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Thomas Abraham, tomasz.figa

[-- Attachment #1: Type: text/plain, Size: 2035 bytes --]

On Thu, Jan 22, 2015 at 02:06:10AM +0100, Tobias Jakobi wrote:
> Hello!
> 
> 
> Lukasz Majewski wrote:
> >> The point is that I'm still working with a rather old version of the
> >> cpufreq series, a version which still had the Exynos4x12 code in it
> >> (this was removed later, if I remember correctly because of problems
> >> with how to properly describe boost configuration in DT).
> > 
> > Is your board Odroid-U3/Trats2 ?
> It's an Odroid-X2, so pretty similar to the U3, except that it doesn't
> have any active cooling device.
> 
> 
> >> Anyway, to not get completly off-topic here, I noticed some small
> >> issue with v3 of the thermal series. I've enabled
> >> CONFIG_THERMAL_HWMON so that I can use lm_sensors to query
> >> temperature of the board. However while the thermal_zone is created,
> >> there is no hwmon node to be found. 
> > 
> > I'm not surprised, that some use cases (about which I wasn't even
> > aware) show up. 
> > I've already fixed issues reported by Abhilash (with v5 and a following
> > patch) and look closer into the THERMAL_HWMON.
> The problem seems to be that of_parse_thermal_zones always sets
> 'no_hwmon' to true, so that thermal_zone_device_register never registers
> a hwmon device when the underlaying thermal zone is setup through DT. I
> don't understand the rationale behind this, even with the comment ('No
> hwmon because there might be hwmon drivers registering').
> 

The reason is that hwmon sensor device drivers also register via of-thermal.
So, adding hwmon interface by default will create a cyclic problem.

Cheers,

> 
> > I've also done some work regarding FAN controlled by hwmon for Odroid
> > U3.
> > Could you look on following series:
> > http://www.spinics.net/lists/linux-samsung-soc/msg40471.html
> > 
> > I can only guess that your board might need similar entries for your
> > DTS file(s).
> 
> Like I said, the X2 only has a passive heatsink, so no fan controlling here.
> 
> 
> With best wishes,
> Tobias
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration
  2015-01-21  8:33     ` Lukasz Majewski
@ 2015-01-21  9:08       ` Viresh Kumar
  2015-01-21  9:47         ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Viresh Kumar @ 2015-01-21  9:08 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim,
	Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi

On 21 January 2015 at 14:03, Lukasz Majewski <l.majewski@samsung.com> wrote:
>> diff --git a/drivers/cpufreq/exynos-cpufreq.c

>>  static int exynos_cpufreq_probe(struct platform_device *pdev)
>>  {
>> +     struct device_node *cpus, *np;
>>       int ret = -EINVAL;
>>
>>       exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
>> @@ -198,9 +202,31 @@ static int exynos_cpufreq_probe(struct
>> platform_device *pdev) /* Done here as we want to capture boot
>> frequency */ locking_frequency = clk_get_rate(exynos_info->cpu_clk) /
>> 1000;
>> -     if (!cpufreq_register_driver(&exynos_driver))
>> -             return 0;
>> +     if (cpufreq_register_driver(&exynos_driver))

You should return the error returned by cpufreq_register_driver().

>> +             goto err;
>>
>> +     cpus = of_find_node_by_path("/cpus");
>> +     if (!cpus) {
>> +             pr_err("failed to find cpus node\n");
>> +             return -ENOENT;
>> +     }
>> +
>> +     for (np = of_get_next_child(cpus, NULL); np;
>> +          of_node_put(np), np = of_get_next_child(cpus, np)) {
>> +             if (of_find_property(np, "#cooling-cells", NULL)) {

Shouldn't you be checking this just for cpu 0 ?

>> +                     cdev = of_cpufreq_cooling_register(np,
>> +
>> cpu_present_mask);
>> +                     if (IS_ERR(cdev))
>> +                             pr_err("running cpufreq without
>> cooling device: %ld\n",
>> +                                    PTR_ERR(cdev));
>> +                     break;
>> +             }
>> +     }
>> +     of_node_put(np);
>> +     of_node_put(cpus);
>> +
>> +     return 0;
>> + err:
>>       dev_err(&pdev->dev, "failed to register cpufreq driver\n");
>>       regulator_put(arm_regulator);
>>  err_vdd_arm:
>
> Viresh, the above is a small part of the cpufreq related code, which is
> necessary for Exynos thermal rework to use device tree.
>
> It is NOT adding any new functionality, but preserves possibility to
> use cpufreq as a colling device.
>
> Normally I would exclude this part from this commit, but then I cannot
> assure that between commits no regression is slipping in.

Mostly looks fine. Just few nits.

But another important thing is to split this patch, so that there is a separate
patch for cpufreq driver.

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-21  8:40       ` Lukasz Majewski
@ 2015-01-21  9:14         ` Eduardo Valentin
  0 siblings, 0 replies; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-21  9:14 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 31431 bytes --]

On Wed, Jan 21, 2015 at 09:40:55AM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > On Mon, Jan 19, 2015 at 12:20:59PM +0100, Lukasz Majewski wrote:
> > > This patch brings support for providing configuration via device
> > > tree. Previously this data has been hardcoded in the
> > > exynos_tmu_data.c file. Such approach was not scalable and very
> > > often required copying the whole data.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > > Changes for v2:
> > > - Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
> > > - Usage of of-thermal.c exported trip points table
> > > Changes for v3:
> > > - Adding exynos_of_get_soc_type() method to set SOC type from
> > > device's compatible string
> > > - "samsung,tmu_" prefix for TMU specific properties has been added
> > > Changes for v4:
> > > - None
> > > Changes for v5:
> > > - Remove duplicated exynos_tmu_initialize() - reported by Abhilash
> > > Kesavan <a.kesavan@samsung.com>
> > > 
> > 
> > several checkpatch.pl items to be reviewed in this patch:
> > CHECK: No space is necessary after a cast
> > #509: FILE: drivers/thermal/samsung/exynos_tmu.c:821:
> > +       pdata->gain = (u8) value;
> > 
> > CHECK: No space is necessary after a cast
> > #511: FILE: drivers/thermal/samsung/exynos_tmu.c:823:
> > +       pdata->reference_voltage = (u8) value;
> > 
> > 
> > Can you please make sure all of your patches pass:
> > checkpatch.pl --strict
> 
> `		^^^^^^^^^ Is now checkpatch.pl required to run with
> --strict rule? 
> 
> I've tested those patches only with checkpatch with no errors.
> 
> Has kernel policy changed recently? Are all developers now obliged to
> use the --strict rule?

no change in policy. the --strict is just appreciated. it depends on
maintainer to maintainer. --strict catches more checks and warnings
though. that is probably why I see people asking for it.

> 
> 
> > 
> > ?
> > 
> > 
> > > ---
> > >  drivers/thermal/samsung/Makefile     |   2 -
> > >  drivers/thermal/samsung/exynos_tmu.c | 339
> > > ++++++++++++++++++++++-------------
> > > drivers/thermal/samsung/exynos_tmu.h |  53 +----- 3 files changed,
> > > 220 insertions(+), 174 deletions(-)
> > > 
> > > diff --git a/drivers/thermal/samsung/Makefile
> > > b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644
> > > --- a/drivers/thermal/samsung/Makefile
> > > +++ b/drivers/thermal/samsung/Makefile
> > > @@ -3,5 +3,3 @@
> > >  #
> > >  obj-$(CONFIG_EXYNOS_THERMAL)			+=
> > > exynos_thermal.o exynos_thermal-y				:=
> > > exynos_tmu.o -exynos_thermal-y				+=
> > > exynos_tmu_data.o
> > > -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+=
> > > exynos_thermal_common.o diff --git
> > > a/drivers/thermal/samsung/exynos_tmu.c
> > > b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..9d2d685
> > > 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++
> > > b/drivers/thermal/samsung/exynos_tmu.c @@ -1,6 +1,10 @@ /*
> > >   * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
> > >   *
> > > + *  Copyright (C) 2014 Samsung Electronics
> > > + *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> > > + *  Lukasz Majewski <l.majewski@samsung.com>
> > > + *
> > >   *  Copyright (C) 2011 Samsung Electronics
> > >   *  Donggeun Kim <dg77.kim@samsung.com>
> > >   *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
> > > @@ -31,8 +35,8 @@
> > >  #include <linux/platform_device.h>
> > >  #include <linux/regulator/consumer.h>
> > >  
> > > -#include "exynos_thermal_common.h"
> > >  #include "exynos_tmu.h"
> > > +#include "../thermal_core.h"
> > >  
> > >  /* Exynos generic registers */
> > >  #define EXYNOS_TMU_REG_TRIMINFO		0x0
> > > @@ -115,6 +119,7 @@
> > >  #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
> > >  #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
> > >  
> > > +#define MCELSIUS	1000
> > >  /**
> > >   * struct exynos_tmu_data : A structure to hold the private data
> > > of the TMU driver
> > > @@ -150,7 +155,8 @@ struct exynos_tmu_data {
> > >  	struct clk *clk, *clk_sec;
> > >  	u8 temp_error1, temp_error2;
> > >  	struct regulator *regulator;
> > > -	struct thermal_sensor_conf *reg_conf;
> > > +	struct thermal_zone_device *tzd;
> > > +
> > >  	int (*tmu_initialize)(struct platform_device *pdev);
> > >  	void (*tmu_control)(struct platform_device *pdev, bool on);
> > >  	int (*tmu_read)(struct exynos_tmu_data *data);
> > > @@ -159,6 +165,33 @@ struct exynos_tmu_data {
> > >  	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
> > >  };
> > >  
> > > +static void exynos_report_trigger(struct exynos_tmu_data *p)
> > > +{
> > > +	char data[10], *envp[] = { data, NULL };
> > > +	struct thermal_zone_device *tz = p->tzd;
> > > +	unsigned long temp;
> > > +	unsigned int i;
> > > +
> > > +	if (!p) {
> > > +		pr_err("Wrong temperature configuration data\n");
> > > +		return;
> > > +	}
> > > +
> > > +	thermal_zone_device_update(tz);
> > > +
> > > +	mutex_lock(&tz->lock);
> > > +	/* Find the level for which trip happened */
> > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > +		tz->ops->get_trip_temp(tz, i, &temp);
> > > +		if (tz->last_temperature < temp)
> > > +			break;
> > > +	}
> > > +
> > > +	snprintf(data, sizeof(data), "%u", i);
> > > +	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
> > > +	mutex_unlock(&tz->lock);
> > > +}
> > > +
> > >  /*
> > >   * TMU treats temperature as a mapped temperature code.
> > >   * The temperature is converted differently depending on the
> > > calibration type. @@ -234,14 +267,25 @@ static void
> > > sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info) 
> > >  static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold,
> > > bool falling) {
> > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > +	struct thermal_zone_device *tz = data->tzd;
> > > +	const struct thermal_trip * const trips =
> > > +		of_thermal_get_trip_points(tz);
> > > +	unsigned long temp;
> > >  	int i;
> > >  
> > > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
> > > -		u8 temp = pdata->trigger_levels[i];
> > > +	if (!trips) {
> > > +		pr_err("%s: Cannot get trip points from
> > > of-thermal.c!\n",
> > > +		       __func__);
> > > +		return 0;
> > > +	}
> > >  
> > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > +		if (trips[i].type == THERMAL_TRIP_CRITICAL)
> > > +			continue;
> > > +
> > > +		temp = trips[i].temperature / MCELSIUS;
> > >  		if (falling)
> > > -			temp -= pdata->threshold_falling;
> > > +			temp -= (trips[i].hysteresis / MCELSIUS);
> > >  		else
> > >  			threshold &= ~(0xff << 8 * i);
> > >  
> > > @@ -305,9 +349,19 @@ static void exynos_tmu_control(struct
> > > platform_device *pdev, bool on) static int
> > > exynos4210_tmu_initialize(struct platform_device *pdev) {
> > >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > -	unsigned int status;
> > > +	struct thermal_zone_device *tz = data->tzd;
> > > +	const struct thermal_trip * const trips =
> > > +		of_thermal_get_trip_points(tz);
> > >  	int ret = 0, threshold_code, i;
> > > +	unsigned long reference, temp;
> > > +	unsigned int status;
> > > +
> > > +	if (!trips) {
> > > +		pr_err("%s: Cannot get trip points from
> > > of-thermal.c!\n",
> > > +		       __func__);
> > > +		ret = -ENODEV;
> > > +		goto out;
> > > +	}
> > >  
> > >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> > >  	if (!status) {
> > > @@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct
> > > platform_device *pdev) sanitize_temp_error(data, readl(data->base +
> > > EXYNOS_TMU_REG_TRIMINFO)); 
> > >  	/* Write temperature code for threshold */
> > > -	threshold_code = temp_to_code(data, pdata->threshold);
> > > +	reference = trips[0].temperature / MCELSIUS;
> > > +	threshold_code = temp_to_code(data, reference);
> > > +	if (threshold_code < 0) {
> > > +		ret = threshold_code;
> > > +		goto out;
> > > +	}
> > >  	writeb(threshold_code, data->base +
> > > EXYNOS4210_TMU_REG_THRESHOLD_TEMP); 
> > > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
> > > -		writeb(pdata->trigger_levels[i], data->base +
> > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > +		temp = trips[i].temperature / MCELSIUS;
> > > +		writeb(temp - reference, data->base +
> > >  		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
> > > +	}
> > >  
> > >  	data->tmu_clear_irqs(data);
> > >  out:
> > > @@ -333,9 +394,11 @@ out:
> > >  static int exynos4412_tmu_initialize(struct platform_device *pdev)
> > >  {
> > >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > +	const struct thermal_trip * const trips =
> > > +		of_thermal_get_trip_points(data->tzd);
> > >  	unsigned int status, trim_info, con, ctrl,
> > > rising_threshold; int ret = 0, threshold_code, i;
> > > +	unsigned long crit_temp = 0;
> > >  
> > >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> > >  	if (!status) {
> > > @@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct
> > > platform_device *pdev) data->tmu_clear_irqs(data);
> > >  
> > >  	/* if last threshold limit is also present */
> > > -	i = pdata->max_trigger_level - 1;
> > > -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==
> > > HW_TRIP) {
> > > -		threshold_code = temp_to_code(data,
> > > pdata->trigger_levels[i]);
> > > -		/* 1-4 level to be assigned in th0 reg */
> > > -		rising_threshold &= ~(0xff << 8 * i);
> > > -		rising_threshold |= threshold_code << 8 * i;
> > > -		writel(rising_threshold, data->base +
> > > EXYNOS_THD_TEMP_RISE);
> > > -		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> > > -		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > > -		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> > > +	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
> > > +		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
> > > +			crit_temp = trips[i].temperature;
> > > +			break;
> > > +		}
> > > +	}
> > > +
> > > +	if (i == of_thermal_get_ntrips(data->tzd)) {
> > > +		pr_err("%s: No CRITICAL trip point defined at
> > > of-thermal.c!\n",
> > > +		       __func__);
> > > +		ret = -EINVAL;
> > > +		goto out;
> > >  	}
> > > +
> > > +	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
> > > +	/* 1-4 level to be assigned in th0 reg */
> > > +	rising_threshold &= ~(0xff << 8 * i);
> > > +	rising_threshold |= threshold_code << 8 * i;
> > > +	writel(rising_threshold, data->base +
> > > EXYNOS_THD_TEMP_RISE);
> > > +	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> > > +	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > > +	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> > > +
> > >  out:
> > >  	return ret;
> > >  }
> > > @@ -391,9 +466,9 @@ out:
> > >  static int exynos5440_tmu_initialize(struct platform_device *pdev)
> > >  {
> > >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > >  	unsigned int trim_info = 0, con, rising_threshold;
> > > -	int ret = 0, threshold_code, i;
> > > +	int ret = 0, threshold_code;
> > > +	unsigned long crit_temp = 0;
> > >  
> > >  	/*
> > >  	 * For exynos5440 soc triminfo value is swapped between
> > > TMU0 and @@ -422,9 +497,8 @@ static int
> > > exynos5440_tmu_initialize(struct platform_device *pdev)
> > > data->tmu_clear_irqs(data); 
> > >  	/* if last threshold limit is also present */
> > > -	i = pdata->max_trigger_level - 1;
> > > -	if (pdata->trigger_levels[i] && pdata->trigger_type[i] ==
> > > HW_TRIP) {
> > > -		threshold_code = temp_to_code(data,
> > > pdata->trigger_levels[i]);
> > > +	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp))
> > > {
> > > +		threshold_code = temp_to_code(data, crit_temp /
> > > MCELSIUS); /* 5th level to be assigned in th2 reg */
> > >  		rising_threshold =
> > >  			threshold_code <<
> > > EXYNOS5440_TMU_TH_RISE4_SHIFT; @@ -442,7 +516,7 @@ static int
> > > exynos5440_tmu_initialize(struct platform_device *pdev) static void
> > > exynos4210_tmu_control(struct platform_device *pdev, bool on) {
> > >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > +	struct thermal_zone_device *tz = data->tzd;
> > >  	unsigned int con, interrupt_en;
> > >  
> > >  	con = get_con_reg(data, readl(data->base +
> > > EXYNOS_TMU_REG_CONTROL)); @@ -450,10 +524,15 @@ static void
> > > exynos4210_tmu_control(struct platform_device *pdev, bool on) if
> > > (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > >  		interrupt_en =
> > > -			pdata->trigger_enable[3] <<
> > > EXYNOS_TMU_INTEN_RISE3_SHIFT |
> > > -			pdata->trigger_enable[2] <<
> > > EXYNOS_TMU_INTEN_RISE2_SHIFT |
> > > -			pdata->trigger_enable[1] <<
> > > EXYNOS_TMU_INTEN_RISE1_SHIFT |
> > > -			pdata->trigger_enable[0] <<
> > > EXYNOS_TMU_INTEN_RISE0_SHIFT;
> > > +			(of_thermal_is_trip_valid(tz, 3)
> > > +			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
> > > +			(of_thermal_is_trip_valid(tz, 2)
> > > +			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
> > > +			(of_thermal_is_trip_valid(tz, 1)
> > > +			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
> > > +			(of_thermal_is_trip_valid(tz, 0)
> > > +			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
> > > +
> > >  		if (data->soc != SOC_ARCH_EXYNOS4210)
> > >  			interrupt_en |=
> > >  				interrupt_en <<
> > > EXYNOS_TMU_INTEN_FALL0_SHIFT; @@ -468,7 +547,7 @@ static void
> > > exynos4210_tmu_control(struct platform_device *pdev, bool on)
> > > static void exynos5440_tmu_control(struct platform_device *pdev,
> > > bool on) { struct exynos_tmu_data *data =
> > > platform_get_drvdata(pdev);
> > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > +	struct thermal_zone_device *tz = data->tzd;
> > >  	unsigned int con, interrupt_en;
> > >  
> > >  	con = get_con_reg(data, readl(data->base +
> > > EXYNOS5440_TMU_S0_7_CTRL)); @@ -476,11 +555,16 @@ static void
> > > exynos5440_tmu_control(struct platform_device *pdev, bool on) if
> > > (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > >  		interrupt_en =
> > > -			pdata->trigger_enable[3] <<
> > > EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
> > > -			pdata->trigger_enable[2] <<
> > > EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
> > > -			pdata->trigger_enable[1] <<
> > > EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
> > > -			pdata->trigger_enable[0] <<
> > > EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
> > > -		interrupt_en |= interrupt_en <<
> > > EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
> > > +			(of_thermal_is_trip_valid(tz, 3)
> > > +			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
> > > +			(of_thermal_is_trip_valid(tz, 2)
> > > +			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
> > > +			(of_thermal_is_trip_valid(tz, 1)
> > > +			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
> > > +			(of_thermal_is_trip_valid(tz, 0)
> > > +			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
> > > +		interrupt_en |=
> > > +			interrupt_en <<
> > > EXYNOS5440_TMU_INTEN_FALL0_SHIFT; } else {
> > >  		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > >  		interrupt_en = 0; /* Disable all interrupts */
> > > @@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct
> > > platform_device *pdev, bool on) writel(con, data->base +
> > > EXYNOS5440_TMU_S0_7_CTRL); }
> > >  
> > > -static int exynos_tmu_read(struct exynos_tmu_data *data)
> > > +int exynos_get_temp(void *p, long *temp)
> > >  {
> > > -	int ret;
> > > +	struct exynos_tmu_data *data = p;
> > > +
> > > +	if (!data)
> > > +		return -EINVAL;
> > >  
> > >  	mutex_lock(&data->lock);
> > >  	clk_enable(data->clk);
> > > -	ret = data->tmu_read(data);
> > > -	if (ret >= 0)
> > > -		ret = code_to_temp(data, ret);
> > > +
> > > +	*temp = code_to_temp(data, data->tmu_read(data)) *
> > > MCELSIUS; +
> > >  	clk_disable(data->clk);
> > >  	mutex_unlock(&data->lock);
> > >  
> > > -	return ret;
> > > +	return 0;
> > >  }
> > >  
> > >  #ifdef CONFIG_THERMAL_EMULATION
> > > @@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct
> > > *work) if (!IS_ERR(data->clk_sec))
> > >  		clk_disable(data->clk_sec);
> > >  
> > > -	exynos_report_trigger(data->reg_conf);
> > > +	exynos_report_trigger(data);
> > >  	mutex_lock(&data->lock);
> > >  	clk_enable(data->clk);
> > >  
> > > @@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq,
> > > void *id) static const struct of_device_id exynos_tmu_match[] = {
> > >  	{
> > >  		.compatible = "samsung,exynos3250-tmu",
> > > -		.data = &exynos3250_default_tmu_data,
> > >  	},
> > >  	{
> > >  		.compatible = "samsung,exynos4210-tmu",
> > > -		.data = &exynos4210_default_tmu_data,
> > >  	},
> > >  	{
> > >  		.compatible = "samsung,exynos4412-tmu",
> > > -		.data = &exynos4412_default_tmu_data,
> > >  	},
> > >  	{
> > >  		.compatible = "samsung,exynos5250-tmu",
> > > -		.data = &exynos5250_default_tmu_data,
> > >  	},
> > >  	{
> > >  		.compatible = "samsung,exynos5260-tmu",
> > > -		.data = &exynos5260_default_tmu_data,
> > >  	},
> > >  	{
> > >  		.compatible = "samsung,exynos5420-tmu",
> > > -		.data = &exynos5420_default_tmu_data,
> > >  	},
> > >  	{
> > >  		.compatible =
> > > "samsung,exynos5420-tmu-ext-triminfo",
> > > -		.data = &exynos5420_default_tmu_data,
> > >  	},
> > >  	{
> > >  		.compatible = "samsung,exynos5440-tmu",
> > > -		.data = &exynos5440_default_tmu_data,
> > >  	},
> > >  	{},
> > >  };
> > >  MODULE_DEVICE_TABLE(of, exynos_tmu_match);
> > >  
> > > -static inline struct  exynos_tmu_platform_data
> > > *exynos_get_driver_data(
> > > -			struct platform_device *pdev, int id)
> > > +static int exynos_of_get_soc_type(struct device_node *np)
> > >  {
> > > -	struct  exynos_tmu_init_data *data_table;
> > > -	struct exynos_tmu_platform_data *tmu_data;
> > > -	const struct of_device_id *match;
> > > +	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
> > > +		return SOC_ARCH_EXYNOS3250;
> > > +	else if (of_device_is_compatible(np,
> > > "samsung,exynos4210-tmu"))
> > > +		return SOC_ARCH_EXYNOS4210;
> > > +	else if (of_device_is_compatible(np,
> > > "samsung,exynos4412-tmu"))
> > > +		return SOC_ARCH_EXYNOS4412;
> > > +	else if (of_device_is_compatible(np,
> > > "samsung,exynos5250-tmu"))
> > > +		return SOC_ARCH_EXYNOS5250;
> > > +	else if (of_device_is_compatible(np,
> > > "samsung,exynos5260-tmu"))
> > > +		return SOC_ARCH_EXYNOS5260;
> > > +	else if (of_device_is_compatible(np,
> > > "samsung,exynos5420-tmu"))
> > > +		return SOC_ARCH_EXYNOS5420;
> > > +	else if (of_device_is_compatible(np,
> > > +
> > > "samsung,exynos5420-tmu-ext-triminfo"))
> > > +		return SOC_ARCH_EXYNOS5420_TRIMINFO;
> > > +	else if (of_device_is_compatible(np,
> > > "samsung,exynos5440-tmu"))
> > > +		return SOC_ARCH_EXYNOS5440;
> > > +
> > > +	return -EINVAL;
> > > +}
> > >  
> > > -	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
> > > -	if (!match)
> > > -		return NULL;
> > > -	data_table = (struct exynos_tmu_init_data *) match->data;
> > > -	if (!data_table || id >= data_table->tmu_count)
> > > -		return NULL;
> > > -	tmu_data = data_table->tmu_data;
> > > -	return (struct exynos_tmu_platform_data *) (tmu_data + id);
> > > +static int exynos_of_sensor_conf(struct device_node *np,
> > > +				 struct exynos_tmu_platform_data
> > > *pdata) +{
> > > +	u32 value;
> > > +	int ret;
> > > +
> > > +	of_node_get(np);
> > > +
> > > +	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
> > > +	pdata->gain = (u8) value;
> > > +	of_property_read_u32(np, "samsung,tmu_reference_voltage",
> > > &value);
> > > +	pdata->reference_voltage = (u8) value;
> > > +	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode",
> > > &value);
> > > +	pdata->noise_cancel_mode = (u8) value;
> > > +
> > > +	of_property_read_u32(np, "samsung,tmu_efuse_value",
> > > +			     &pdata->efuse_value);
> > > +	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
> > > +			     &pdata->min_efuse_value);
> > > +	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
> > > +			     &pdata->max_efuse_value);
> > > +
> > > +	of_property_read_u32(np, "samsung,tmu_first_point_trim",
> > > &value);
> > > +	pdata->first_point_trim = (u8) value;
> > > +	of_property_read_u32(np, "samsung,tmu_second_point_trim",
> > > &value);
> > > +	pdata->second_point_trim = (u8) value;
> > > +	of_property_read_u32(np,
> > > "samsung,tmu_default_temp_offset", &value);
> > > +	pdata->default_temp_offset = (u8) value;
> > > +
> > > +	of_property_read_u32(np, "samsung,tmu_cal_type",
> > > &pdata->cal_type);
> > > +	of_property_read_u32(np, "samsung,tmu_cal_mode",
> > > &pdata->cal_mode); +
> > > +	of_node_put(np);
> > > +	return 0;
> > >  }
> > >  
> > >  static int exynos_map_dt_data(struct platform_device *pdev)
> > > @@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct
> > > platform_device *pdev) return -EADDRNOTAVAIL;
> > >  	}
> > >  
> > > -	pdata = exynos_get_driver_data(pdev, data->id);
> > > -	if (!pdata) {
> > > -		dev_err(&pdev->dev, "No platform init data
> > > supplied.\n");
> > > -		return -ENODEV;
> > > -	}
> > > +	pdata = devm_kzalloc(&pdev->dev,
> > > +			     sizeof(struct
> > > exynos_tmu_platform_data),
> > > +			     GFP_KERNEL);
> > > +	if (!pdata)
> > > +		return -ENOMEM;
> > >  
> > > +	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
> > >  	data->pdata = pdata;
> > > -	data->soc = pdata->type;
> > > +	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
> > >  
> > >  	switch (data->soc) {
> > >  	case SOC_ARCH_EXYNOS4210:
> > > @@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct
> > > platform_device *pdev) return 0;
> > >  }
> > >  
> > > +static struct thermal_zone_of_device_ops exynos_sensor_ops = {
> > > +	.get_temp = exynos_get_temp,
> > > +	.set_emul_temp = exynos_tmu_set_emulation,
> > > +};
> > > +
> > >  static int exynos_tmu_probe(struct platform_device *pdev)
> > >  {
> > > -	struct exynos_tmu_data *data;
> > >  	struct exynos_tmu_platform_data *pdata;
> > > -	struct thermal_sensor_conf *sensor_conf;
> > > -	int ret, i;
> > > +	struct exynos_tmu_data *data;
> > > +	int ret;
> > >  
> > >  	data = devm_kzalloc(&pdev->dev, sizeof(struct
> > > exynos_tmu_data), GFP_KERNEL);
> > > @@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct
> > > platform_device *pdev) platform_set_drvdata(pdev, data);
> > >  	mutex_init(&data->lock);
> > >  
> > > +	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0,
> > > data,
> > > +
> > > &exynos_sensor_ops);
> > > +	if (IS_ERR(data->tzd)) {
> > > +		pr_err("thermal: tz: %p ERROR\n", data->tzd);
> > > +		return PTR_ERR(data->tzd);
> > > +	}
> > >  	ret = exynos_map_dt_data(pdev);
> > >  	if (ret)
> > > -		return ret;
> > > +		goto err_sensor;
> > >  
> > >  	pdata = data->pdata;
> > >  
> > > @@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct
> > > platform_device *pdev) data->clk = devm_clk_get(&pdev->dev,
> > > "tmu_apbif"); if (IS_ERR(data->clk)) {
> > >  		dev_err(&pdev->dev, "Failed to get clock\n");
> > > -		return  PTR_ERR(data->clk);
> > > +		ret = PTR_ERR(data->clk);
> > > +		goto err_sensor;
> > >  	}
> > >  
> > >  	data->clk_sec = devm_clk_get(&pdev->dev,
> > > "tmu_triminfo_apbif"); if (IS_ERR(data->clk_sec)) {
> > >  		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
> > >  			dev_err(&pdev->dev, "Failed to get
> > > triminfo clock\n");
> > > -			return PTR_ERR(data->clk_sec);
> > > +			ret = PTR_ERR(data->clk_sec);
> > > +			goto err_sensor;
> > >  		}
> > >  	} else {
> > >  		ret = clk_prepare(data->clk_sec);
> > >  		if (ret) {
> > >  			dev_err(&pdev->dev, "Failed to get
> > > clock\n");
> > > -			return ret;
> > > +			goto err_sensor;
> > >  		}
> > >  	}
> > >  
> > > @@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct
> > > platform_device *pdev) goto err_clk;
> > >  	}
> > >  
> > > -	exynos_tmu_control(pdev, true);
> > > -
> > > -	/* Allocate a structure to register with the exynos core
> > > thermal */
> > > -	sensor_conf = devm_kzalloc(&pdev->dev,
> > > -				sizeof(struct
> > > thermal_sensor_conf), GFP_KERNEL);
> > > -	if (!sensor_conf) {
> > > -		ret = -ENOMEM;
> > > -		goto err_clk;
> > > -	}
> > > -	sprintf(sensor_conf->name, "therm_zone%d", data->id);
> > > -	sensor_conf->read_temperature = (int (*)(void
> > > *))exynos_tmu_read;
> > > -	sensor_conf->write_emul_temp =
> > > -		(int (*)(void *, unsigned
> > > long))exynos_tmu_set_emulation;
> > > -	sensor_conf->driver_data = data;
> > > -	sensor_conf->trip_data.trip_count =
> > > pdata->trigger_enable[0] +
> > > -			pdata->trigger_enable[1] +
> > > pdata->trigger_enable[2]+
> > > -			pdata->trigger_enable[3];
> > > -
> > > -	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
> > > -		sensor_conf->trip_data.trip_val[i] =
> > > -			pdata->threshold +
> > > pdata->trigger_levels[i];
> > > -		sensor_conf->trip_data.trip_type[i] =
> > > -					pdata->trigger_type[i];
> > > -	}
> > > -
> > > -	sensor_conf->trip_data.trigger_falling =
> > > pdata->threshold_falling; -
> > > -	sensor_conf->dev = &pdev->dev;
> > > -	/* Register the sensor with thermal management interface */
> > > -	ret = exynos_register_thermal(sensor_conf);
> > > -	if (ret) {
> > > -		if (ret != -EPROBE_DEFER)
> > > -			dev_err(&pdev->dev,
> > > -				"Failed to register thermal
> > > interface: %d\n",
> > > -				ret);
> > > -		goto err_clk;
> > > -	}
> > > -	data->reg_conf = sensor_conf;
> > > -
> > >  	ret = devm_request_irq(&pdev->dev, data->irq,
> > > exynos_tmu_irq, IRQF_TRIGGER_RISING | IRQF_SHARED,
> > > dev_name(&pdev->dev), data); if (ret) {
> > > @@ -935,21 +1030,25 @@ static int exynos_tmu_probe(struct
> > > platform_device *pdev) goto err_clk;
> > >  	}
> > >  
> > > +	exynos_tmu_control(pdev, true);
> > >  	return 0;
> > >  err_clk:
> > >  	clk_unprepare(data->clk);
> > >  err_clk_sec:
> > >  	if (!IS_ERR(data->clk_sec))
> > >  		clk_unprepare(data->clk_sec);
> > > +err_sensor:
> > > +	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
> > > +
> > >  	return ret;
> > >  }
> > >  
> > >  static int exynos_tmu_remove(struct platform_device *pdev)
> > >  {
> > >  	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > > +	struct thermal_zone_device *tzd = data->tzd;
> > >  
> > > -	exynos_unregister_thermal(data->reg_conf);
> > > -
> > > +	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
> > >  	exynos_tmu_control(pdev, false);
> > >  
> > >  	clk_unprepare(data->clk);
> > > diff --git a/drivers/thermal/samsung/exynos_tmu.h
> > > b/drivers/thermal/samsung/exynos_tmu.h index 627dec9..d876d4c 100644
> > > --- a/drivers/thermal/samsung/exynos_tmu.h
> > > +++ b/drivers/thermal/samsung/exynos_tmu.h
> > > @@ -23,8 +23,7 @@
> > >  #ifndef _EXYNOS_TMU_H
> > >  #define _EXYNOS_TMU_H
> > >  #include <linux/cpu_cooling.h>
> > > -
> > > -#include "exynos_thermal_common.h"
> > > +#include <dt-bindings/thermal/thermal_exynos.h>
> > >  
> > >  enum soc_type {
> > >  	SOC_ARCH_EXYNOS3250 = 1,
> > > @@ -36,38 +35,9 @@ enum soc_type {
> > >  	SOC_ARCH_EXYNOS5420_TRIMINFO,
> > >  	SOC_ARCH_EXYNOS5440,
> > >  };
> > > -#include <dt-bindings/thermal/thermal_exynos.h>
> > >  
> > >  /**
> > >   * struct exynos_tmu_platform_data
> > > - * @threshold: basic temperature for generating interrupt
> > > - *	       25 <= threshold <= 125 [unit: degree Celsius]
> > > - * @threshold_falling: differntial value for setting threshold
> > > - *		       of temperature falling interrupt.
> > > - * @trigger_levels: array for each interrupt levels
> > > - *	[unit: degree Celsius]
> > > - *	0: temperature for trigger_level0 interrupt
> > > - *	   condition for trigger_level0 interrupt:
> > > - *		current temperature > threshold +
> > > trigger_levels[0]
> > > - *	1: temperature for trigger_level1 interrupt
> > > - *	   condition for trigger_level1 interrupt:
> > > - *		current temperature > threshold +
> > > trigger_levels[1]
> > > - *	2: temperature for trigger_level2 interrupt
> > > - *	   condition for trigger_level2 interrupt:
> > > - *		current temperature > threshold +
> > > trigger_levels[2]
> > > - *	3: temperature for trigger_level3 interrupt
> > > - *	   condition for trigger_level3 interrupt:
> > > - *		current temperature > threshold +
> > > trigger_levels[3]
> > > - * @trigger_type: defines the type of trigger. Possible values are,
> > > - *	THROTTLE_ACTIVE trigger type
> > > - *	THROTTLE_PASSIVE trigger type
> > > - *	SW_TRIP trigger type
> > > - *	HW_TRIP
> > > - * @trigger_enable[]: array to denote which trigger levels are
> > > enabled.
> > > - *	1 = enable trigger_level[] interrupt,
> > > - *	0 = disable trigger_level[] interrupt
> > > - * @max_trigger_level: max trigger level supported by the TMU
> > > - * @non_hw_trigger_levels: number of defined non-hardware trigger
> > > levels
> > >   * @gain: gain of amplifier in the positive-TC generator block
> > >   *	0 < gain <= 15
> > >   * @reference_voltage: reference voltage of amplifier
> > > @@ -79,21 +49,12 @@ enum soc_type {
> > >   * @efuse_value: platform defined fuse value
> > >   * @min_efuse_value: minimum valid trimming data
> > >   * @max_efuse_value: maximum valid trimming data
> > > - * @first_point_trim: temp value of the first point trimming
> > > - * @second_point_trim: temp value of the second point trimming
> > >   * @default_temp_offset: default temperature offset in case of no
> > > trimming
> > >   * @cal_type: calibration type for temperature
> > >   *
> > >   * This structure is required for configuration of exynos_tmu
> > > driver. */
> > >  struct exynos_tmu_platform_data {
> > > -	u8 threshold;
> > > -	u8 threshold_falling;
> > > -	u8 trigger_levels[MAX_TRIP_COUNT];
> > > -	enum trigger_type trigger_type[MAX_TRIP_COUNT];
> > > -	bool trigger_enable[MAX_TRIP_COUNT];
> > > -	u8 max_trigger_level;
> > > -	u8 non_hw_trigger_levels;
> > >  	u8 gain;
> > >  	u8 reference_voltage;
> > >  	u8 noise_cancel_mode;
> > > @@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
> > >  	u32 cal_mode;
> > >  };
> > >  
> > > -/**
> > > - * struct exynos_tmu_init_data
> > > - * @tmu_count: number of TMU instances.
> > > - * @tmu_data: platform data of all TMU instances.
> > > - * This structure is required to store data for multi-instance
> > > exynos tmu
> > > - * driver.
> > > - */
> > > -struct exynos_tmu_init_data {
> > > -	int tmu_count;
> > > -	struct exynos_tmu_platform_data tmu_data[];
> > > -};
> > > -
> > >  extern struct exynos_tmu_init_data const
> > > exynos3250_default_tmu_data; extern struct exynos_tmu_init_data
> > > const exynos4210_default_tmu_data; extern struct
> > > exynos_tmu_init_data const exynos4412_default_tmu_data; -- 
> > > 2.0.0.rc2
> > > 
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-21  8:10           ` Lukasz Majewski
@ 2015-01-21  9:20             ` Eduardo Valentin
  2015-01-22 14:17               ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-21  9:20 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Kyungmin Park,
	Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 36122 bytes --]

On Wed, Jan 21, 2015 at 09:10:15AM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > On Thu, Jan 15, 2015 at 04:17:52PM +0100, Lukasz Majewski wrote:
> > > Hi Eduardo,
> > > 
> > > > On Wed, Jan 14, 2015 at 02:41:12PM +0100, Lukasz Majewski wrote:
> > > > > This patch brings support for providing configuration via device
> > > > > tree. Previously this data has been hardcoded in the
> > > > > exynos_tmu_data.c file. Such approach was not scalable and very
> > > > > often required copying the whole data.
> > > > > 
> > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > > ---
> > > > > Changes for v2:
> > > > > - Adjust exynos_tmu.c code to the newest ti-soc-thermal
> > > > > repository
> > > > > - Usage of of-thermal.c exported trip points table
> > > > > Changes for v3:
> > > > > - Adding exynos_of_get_soc_type() method to set SOC type from
> > > > > device's compatible string
> > > > > - "samsung,tmu_" prefix for TMU specific properties has been
> > > > > added
> > > > > 
> > > > > ---
> > > > >  drivers/thermal/samsung/Makefile     |   2 -
> > > > >  drivers/thermal/samsung/exynos_tmu.c | 345
> > > > > +++++++++++++++++++++++------------
> > > > > drivers/thermal/samsung/exynos_tmu.h |  53 +----- 3 files
> > > > > changed, 226 insertions(+), 174 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/thermal/samsung/Makefile
> > > > > b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d 100644
> > > > > --- a/drivers/thermal/samsung/Makefile
> > > > > +++ b/drivers/thermal/samsung/Makefile
> > > > > @@ -3,5 +3,3 @@
> > > > >  #
> > > > >  obj-$(CONFIG_EXYNOS_THERMAL)			+=
> > > > > exynos_thermal.o
> > > > > exynos_thermal-y				:= exynos_tmu.o
> > > > > -exynos_thermal-y				+=
> > > > > exynos_tmu_data.o
> > > > 
> > > > Can this makefile change be part of the patch that removes
> > > > exynos_tmu_data.c?
> > > > 
> > > > > -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+=
> > > > > exynos_thermal_common.o
> > > > 
> > > > Can this makefile change be part of the patch that removes
> > > > exynos_thermal_common.c?
> > > 
> > > Unfortunately, this code cannot be moved to the next patch, in
> > > which I remove the files, since this causes build break of the
> > > series.
> > > 
> > > The code structure as is, provides working, bisectable thermal
> > > solution - thermal and cpu_cooling functionality is preserved across
> > > all commits in the series.
> > 
> > My concern here is simply that this specific commit is leaving unused
> > files in the tree.
> > 
> > One option would be to remove the files altogether in this specific
> > commit.
> 
> Is is really necessary?
> 
> This patch itself changes around 400 LOC. Those changes __are__
> important and in my opinion deserve their own commit.
> 
> When I squash following patches, which remove old exynos files, we
> would have around 1.2K LOC in a single commit.
> 
> I think that current approach is far more readable. 

I agree that separating is far more readable. However, the commit leaves
zombie files.

> 
> Eduardo, is there a chance for this series (the newest version is v5 -
> which include Ablibash comments) to be included to yours -next tree
> before v3.19 is out?

Yes, we can target this. I have sent couple of minor comments on v5.
Despite them, there are also some parts of this series that are supposed
to be merged via other trees. The cpufreq part seams to be too little
and Viresh has already flagged that I can merge it as long it is in a
separated patch. However, most part of this series touches arch/arm
directory and those should go via your platform tree. Is there a change
you could either as your Exynos maintainer to queue the patches touching
arch/arm or ask him if he is fine if I merge them via my tree?

Cheers,

> 
> > 
> > > 
> > > > 
> > > > > diff --git a/drivers/thermal/samsung/exynos_tmu.c
> > > > > b/drivers/thermal/samsung/exynos_tmu.c index ae30f6a..633a9e2
> > > > > 100644 --- a/drivers/thermal/samsung/exynos_tmu.c
> > > > > +++ b/drivers/thermal/samsung/exynos_tmu.c
> > > > > @@ -1,6 +1,10 @@
> > > > >  /*
> > > > >   * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
> > > > >   *
> > > > > + *  Copyright (C) 2014 Samsung Electronics
> > > > > + *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> > > > > + *  Lukasz Majewski <l.majewski@samsung.com>
> > > > > + *
> > > > >   *  Copyright (C) 2011 Samsung Electronics
> > > > >   *  Donggeun Kim <dg77.kim@samsung.com>
> > > > >   *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
> > > > > @@ -31,8 +35,8 @@
> > > > >  #include <linux/platform_device.h>
> > > > >  #include <linux/regulator/consumer.h>
> > > > >  
> > > > > -#include "exynos_thermal_common.h"
> > > > >  #include "exynos_tmu.h"
> > > > > +#include "../thermal_core.h"
> > > > >  
> > > > >  /* Exynos generic registers */
> > > > >  #define EXYNOS_TMU_REG_TRIMINFO		0x0
> > > > > @@ -115,6 +119,7 @@
> > > > >  #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
> > > > >  #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
> > > > >  
> > > > > +#define MCELSIUS	1000
> > > > >  /**
> > > > >   * struct exynos_tmu_data : A structure to hold the private
> > > > > data of the TMU driver
> > > > > @@ -150,7 +155,8 @@ struct exynos_tmu_data {
> > > > >  	struct clk *clk, *clk_sec;
> > > > >  	u8 temp_error1, temp_error2;
> > > > >  	struct regulator *regulator;
> > > > > -	struct thermal_sensor_conf *reg_conf;
> > > > > +	struct thermal_zone_device *tzd;
> > > > > +
> > > > >  	int (*tmu_initialize)(struct platform_device *pdev);
> > > > >  	void (*tmu_control)(struct platform_device *pdev, bool
> > > > > on); int (*tmu_read)(struct exynos_tmu_data *data);
> > > > > @@ -159,6 +165,33 @@ struct exynos_tmu_data {
> > > > >  	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
> > > > >  };
> > > > >  
> > > > > +static void exynos_report_trigger(struct exynos_tmu_data *p)
> > > > > +{
> > > > > +	char data[10], *envp[] = { data, NULL };
> > > > > +	struct thermal_zone_device *tz = p->tzd;
> > > > > +	unsigned long temp;
> > > > > +	unsigned int i;
> > > > > +
> > > > > +	if (!p) {
> > > > > +		pr_err("Wrong temperature configuration
> > > > > data\n");
> > > > > +		return;
> > > > > +	}
> > > > > +
> > > > > +	thermal_zone_device_update(tz);
> > > > > +
> > > > > +	mutex_lock(&tz->lock);
> > > > > +	/* Find the level for which trip happened */
> > > > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > > > +		tz->ops->get_trip_temp(tz, i, &temp);
> > > > > +		if (tz->last_temperature < temp)
> > > > > +			break;
> > > > > +	}
> > > > > +
> > > > > +	snprintf(data, sizeof(data), "%u", i);
> > > > > +	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE,
> > > > > envp);
> > > > > +	mutex_unlock(&tz->lock);
> > > > > +}
> > > > > +
> > > > >  /*
> > > > >   * TMU treats temperature as a mapped temperature code.
> > > > >   * The temperature is converted differently depending on the
> > > > > calibration type. @@ -234,14 +267,25 @@ static void
> > > > > sanitize_temp_error(struct exynos_tmu_data *data, u32
> > > > > trim_info) static u32 get_th_reg(struct exynos_tmu_data *data,
> > > > > u32 threshold, bool falling) {
> > > > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > > > +	struct thermal_zone_device *tz = data->tzd;
> > > > > +	const struct thermal_trip * const trips =
> > > > > +		of_thermal_get_trip_points(tz);
> > > > > +	unsigned long temp;
> > > > >  	int i;
> > > > >  
> > > > > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
> > > > > -		u8 temp = pdata->trigger_levels[i];
> > > > > +	if (!trips) {
> > > > > +		pr_err("%s: Cannot get trip points from
> > > > > of-thermal.c!\n",
> > > > > +		       __func__);
> > > > > +		return 0;
> > > > > +	}
> > > > > +
> > > > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > > > +		if (trips[i].type == THERMAL_TRIP_CRITICAL)
> > > > > +			continue;
> > > > >  
> > > > > +		temp = trips[i].temperature / MCELSIUS;
> > > > >  		if (falling)
> > > > > -			temp -= pdata->threshold_falling;
> > > > > +			temp -= (trips[i].hysteresis /
> > > > > MCELSIUS); else
> > > > >  			threshold &= ~(0xff << 8 * i);
> > > > >  
> > > > > @@ -305,9 +349,19 @@ static void exynos_tmu_control(struct
> > > > > platform_device *pdev, bool on) static int
> > > > > exynos4210_tmu_initialize(struct platform_device *pdev) {
> > > > >  	struct exynos_tmu_data *data =
> > > > > platform_get_drvdata(pdev);
> > > > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > > > -	unsigned int status;
> > > > > +	struct thermal_zone_device *tz = data->tzd;
> > > > > +	const struct thermal_trip * const trips =
> > > > > +		of_thermal_get_trip_points(tz);
> > > > >  	int ret = 0, threshold_code, i;
> > > > > +	unsigned long reference, temp;
> > > > > +	unsigned int status;
> > > > > +
> > > > > +	if (!trips) {
> > > > > +		pr_err("%s: Cannot get trip points from
> > > > > of-thermal.c!\n",
> > > > > +		       __func__);
> > > > > +		ret = -ENODEV;
> > > > > +		goto out;
> > > > > +	}
> > > > >  
> > > > >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> > > > >  	if (!status) {
> > > > > @@ -318,12 +372,19 @@ static int
> > > > > exynos4210_tmu_initialize(struct platform_device *pdev)
> > > > > sanitize_temp_error(data, readl(data->base +
> > > > > EXYNOS_TMU_REG_TRIMINFO)); /* Write temperature code for
> > > > > threshold */
> > > > > -	threshold_code = temp_to_code(data, pdata->threshold);
> > > > > +	reference = trips[0].temperature / MCELSIUS;
> > > > > +	threshold_code = temp_to_code(data, reference);
> > > > > +	if (threshold_code < 0) {
> > > > > +		ret = threshold_code;
> > > > > +		goto out;
> > > > > +	}
> > > > >  	writeb(threshold_code, data->base +
> > > > > EXYNOS4210_TMU_REG_THRESHOLD_TEMP); 
> > > > > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
> > > > > -		writeb(pdata->trigger_levels[i], data->base +
> > > > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > > > +		temp = trips[i].temperature / MCELSIUS;
> > > > > +		writeb(temp - reference, data->base +
> > > > >  		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
> > > > > +	}
> > > > >  
> > > > >  	data->tmu_clear_irqs(data);
> > > > >  out:
> > > > > @@ -333,9 +394,11 @@ out:
> > > > >  static int exynos4412_tmu_initialize(struct platform_device
> > > > > *pdev) {
> > > > >  	struct exynos_tmu_data *data =
> > > > > platform_get_drvdata(pdev);
> > > > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > > > +	const struct thermal_trip * const trips =
> > > > > +		of_thermal_get_trip_points(data->tzd);
> > > > >  	unsigned int status, trim_info, con, ctrl,
> > > > > rising_threshold; int ret = 0, threshold_code, i;
> > > > > +	unsigned long crit_temp = 0;
> > > > >  
> > > > >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> > > > >  	if (!status) {
> > > > > @@ -373,17 +436,29 @@ static int
> > > > > exynos4412_tmu_initialize(struct platform_device *pdev)
> > > > > data->tmu_clear_irqs(data); 
> > > > >  	/* if last threshold limit is also present */
> > > > > -	i = pdata->max_trigger_level - 1;
> > > > > -	if (pdata->trigger_levels[i] && pdata->trigger_type[i]
> > > > > == HW_TRIP) {
> > > > > -		threshold_code = temp_to_code(data,
> > > > > pdata->trigger_levels[i]);
> > > > > -		/* 1-4 level to be assigned in th0 reg */
> > > > > -		rising_threshold &= ~(0xff << 8 * i);
> > > > > -		rising_threshold |= threshold_code << 8 * i;
> > > > > -		writel(rising_threshold, data->base +
> > > > > EXYNOS_THD_TEMP_RISE);
> > > > > -		con = readl(data->base +
> > > > > EXYNOS_TMU_REG_CONTROL);
> > > > > -		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > > > > -		writel(con, data->base +
> > > > > EXYNOS_TMU_REG_CONTROL);
> > > > > +	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++)
> > > > > {
> > > > > +		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
> > > > > +			crit_temp = trips[i].temperature;
> > > > > +			break;
> > > > > +		}
> > > > >  	}
> > > > > +
> > > > > +	if (i == of_thermal_get_ntrips(data->tzd)) {
> > > > > +		pr_err("%s: No CRITICAL trip point defined at
> > > > > of-thermal.c!\n",
> > > > > +		       __func__);
> > > > > +		ret = -EINVAL;
> > > > > +		goto out;
> > > > > +	}
> > > > > +
> > > > > +	threshold_code = temp_to_code(data, crit_temp /
> > > > > MCELSIUS);
> > > > > +	/* 1-4 level to be assigned in th0 reg */
> > > > > +	rising_threshold &= ~(0xff << 8 * i);
> > > > > +	rising_threshold |= threshold_code << 8 * i;
> > > > > +	writel(rising_threshold, data->base +
> > > > > EXYNOS_THD_TEMP_RISE);
> > > > > +	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> > > > > +	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > > > > +	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> > > > > +
> > > > >  out:
> > > > >  	return ret;
> > > > >  }
> > > > > @@ -391,9 +466,9 @@ out:
> > > > >  static int exynos5440_tmu_initialize(struct platform_device
> > > > > *pdev) {
> > > > >  	struct exynos_tmu_data *data =
> > > > > platform_get_drvdata(pdev);
> > > > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > > >  	unsigned int trim_info = 0, con, rising_threshold;
> > > > > -	int ret = 0, threshold_code, i;
> > > > > +	int ret = 0, threshold_code;
> > > > > +	unsigned long crit_temp = 0;
> > > > >  
> > > > >  	/*
> > > > >  	 * For exynos5440 soc triminfo value is swapped between
> > > > > TMU0 and @@ -422,9 +497,8 @@ static int
> > > > > exynos5440_tmu_initialize(struct platform_device *pdev)
> > > > > data->tmu_clear_irqs(data); 
> > > > >  	/* if last threshold limit is also present */
> > > > > -	i = pdata->max_trigger_level - 1;
> > > > > -	if (pdata->trigger_levels[i] && pdata->trigger_type[i]
> > > > > == HW_TRIP) {
> > > > > -		threshold_code = temp_to_code(data,
> > > > > pdata->trigger_levels[i]);
> > > > > +	if (!data->tzd->ops->get_crit_temp(data->tzd,
> > > > > &crit_temp)) {
> > > > > +		threshold_code = temp_to_code(data, crit_temp /
> > > > > MCELSIUS); /* 5th level to be assigned in th2 reg */
> > > > >  		rising_threshold =
> > > > >  			threshold_code <<
> > > > > EXYNOS5440_TMU_TH_RISE4_SHIFT; @@ -442,7 +516,7 @@ static int
> > > > > exynos5440_tmu_initialize(struct platform_device *pdev) static
> > > > > void exynos4210_tmu_control(struct platform_device *pdev, bool
> > > > > on) { struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > > > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > > > +	struct thermal_zone_device *tz = data->tzd;
> > > > >  	unsigned int con, interrupt_en;
> > > > >  
> > > > >  	con = get_con_reg(data, readl(data->base +
> > > > > EXYNOS_TMU_REG_CONTROL)); @@ -450,10 +524,15 @@ static void
> > > > > exynos4210_tmu_control(struct platform_device *pdev, bool on) if
> > > > > (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > > > >  		interrupt_en =
> > > > > -			pdata->trigger_enable[3] <<
> > > > > EXYNOS_TMU_INTEN_RISE3_SHIFT |
> > > > > -			pdata->trigger_enable[2] <<
> > > > > EXYNOS_TMU_INTEN_RISE2_SHIFT |
> > > > > -			pdata->trigger_enable[1] <<
> > > > > EXYNOS_TMU_INTEN_RISE1_SHIFT |
> > > > > -			pdata->trigger_enable[0] <<
> > > > > EXYNOS_TMU_INTEN_RISE0_SHIFT;
> > > > > +			(of_thermal_is_trip_valid(tz, 3)
> > > > > +			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
> > > > > +			(of_thermal_is_trip_valid(tz, 2)
> > > > > +			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
> > > > > +			(of_thermal_is_trip_valid(tz, 1)
> > > > > +			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
> > > > > +			(of_thermal_is_trip_valid(tz, 0)
> > > > > +			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
> > > > > +
> > > > >  		if (data->soc != SOC_ARCH_EXYNOS4210)
> > > > >  			interrupt_en |=
> > > > >  				interrupt_en <<
> > > > > EXYNOS_TMU_INTEN_FALL0_SHIFT; @@ -468,7 +547,7 @@ static void
> > > > > exynos4210_tmu_control(struct platform_device *pdev, bool on)
> > > > > static void exynos5440_tmu_control(struct platform_device *pdev,
> > > > > bool on) { struct exynos_tmu_data *data =
> > > > > platform_get_drvdata(pdev);
> > > > > -	struct exynos_tmu_platform_data *pdata = data->pdata;
> > > > > +	struct thermal_zone_device *tz = data->tzd;
> > > > >  	unsigned int con, interrupt_en;
> > > > >  
> > > > >  	con = get_con_reg(data, readl(data->base +
> > > > > EXYNOS5440_TMU_S0_7_CTRL)); @@ -476,11 +555,16 @@ static void
> > > > > exynos5440_tmu_control(struct platform_device *pdev, bool on) if
> > > > > (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > > > >  		interrupt_en =
> > > > > -			pdata->trigger_enable[3] <<
> > > > > EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
> > > > > -			pdata->trigger_enable[2] <<
> > > > > EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
> > > > > -			pdata->trigger_enable[1] <<
> > > > > EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
> > > > > -			pdata->trigger_enable[0] <<
> > > > > EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
> > > > > -		interrupt_en |= interrupt_en <<
> > > > > EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
> > > > > +			(of_thermal_is_trip_valid(tz, 3)
> > > > > +			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
> > > > > +			(of_thermal_is_trip_valid(tz, 2)
> > > > > +			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
> > > > > +			(of_thermal_is_trip_valid(tz, 1)
> > > > > +			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
> > > > > +			(of_thermal_is_trip_valid(tz, 0)
> > > > > +			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
> > > > > +		interrupt_en |=
> > > > > +			interrupt_en <<
> > > > > EXYNOS5440_TMU_INTEN_FALL0_SHIFT; } else {
> > > > >  		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > > > >  		interrupt_en = 0; /* Disable all interrupts */
> > > > > @@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct
> > > > > platform_device *pdev, bool on) writel(con, data->base +
> > > > > EXYNOS5440_TMU_S0_7_CTRL); }
> > > > >  
> > > > > -static int exynos_tmu_read(struct exynos_tmu_data *data)
> > > > > +int exynos_get_temp(void *p, long *temp)
> > > > >  {
> > > > > -	int ret;
> > > > > +	struct exynos_tmu_data *data = p;
> > > > > +
> > > > > +	if (!data)
> > > > > +		return -EINVAL;
> > > > >  
> > > > >  	mutex_lock(&data->lock);
> > > > >  	clk_enable(data->clk);
> > > > > -	ret = data->tmu_read(data);
> > > > > -	if (ret >= 0)
> > > > > -		ret = code_to_temp(data, ret);
> > > > > +
> > > > > +	*temp = code_to_temp(data, data->tmu_read(data)) *
> > > > > MCELSIUS; +
> > > > >  	clk_disable(data->clk);
> > > > >  	mutex_unlock(&data->lock);
> > > > >  
> > > > > -	return ret;
> > > > > +	return 0;
> > > > >  }
> > > > >  
> > > > >  #ifdef CONFIG_THERMAL_EMULATION
> > > > > @@ -613,7 +700,7 @@ static void exynos_tmu_work(struct
> > > > > work_struct *work) if (!IS_ERR(data->clk_sec))
> > > > >  		clk_disable(data->clk_sec);
> > > > >  
> > > > > -	exynos_report_trigger(data->reg_conf);
> > > > > +	exynos_report_trigger(data);
> > > > >  	mutex_lock(&data->lock);
> > > > >  	clk_enable(data->clk);
> > > > >  
> > > > > @@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq,
> > > > > void *id) static const struct of_device_id exynos_tmu_match[] =
> > > > > { {
> > > > >  		.compatible = "samsung,exynos3250-tmu",
> > > > > -		.data = &exynos3250_default_tmu_data,
> > > > >  	},
> > > > >  	{
> > > > >  		.compatible = "samsung,exynos4210-tmu",
> > > > > -		.data = &exynos4210_default_tmu_data,
> > > > >  	},
> > > > >  	{
> > > > >  		.compatible = "samsung,exynos4412-tmu",
> > > > > -		.data = &exynos4412_default_tmu_data,
> > > > >  	},
> > > > >  	{
> > > > >  		.compatible = "samsung,exynos5250-tmu",
> > > > > -		.data = &exynos5250_default_tmu_data,
> > > > >  	},
> > > > >  	{
> > > > >  		.compatible = "samsung,exynos5260-tmu",
> > > > > -		.data = &exynos5260_default_tmu_data,
> > > > >  	},
> > > > >  	{
> > > > >  		.compatible = "samsung,exynos5420-tmu",
> > > > > -		.data = &exynos5420_default_tmu_data,
> > > > >  	},
> > > > >  	{
> > > > >  		.compatible =
> > > > > "samsung,exynos5420-tmu-ext-triminfo",
> > > > > -		.data = &exynos5420_default_tmu_data,
> > > > >  	},
> > > > >  	{
> > > > >  		.compatible = "samsung,exynos5440-tmu",
> > > > > -		.data = &exynos5440_default_tmu_data,
> > > > >  	},
> > > > >  	{},
> > > > >  };
> > > > >  MODULE_DEVICE_TABLE(of, exynos_tmu_match);
> > > > >  
> > > > > -static inline struct  exynos_tmu_platform_data
> > > > > *exynos_get_driver_data(
> > > > > -			struct platform_device *pdev, int id)
> > > > > +static int exynos_of_get_soc_type(struct device_node *np)
> > > > >  {
> > > > > -	struct  exynos_tmu_init_data *data_table;
> > > > > -	struct exynos_tmu_platform_data *tmu_data;
> > > > > -	const struct of_device_id *match;
> > > > > +	if (of_device_is_compatible(np,
> > > > > "samsung,exynos3250-tmu"))
> > > > > +		return SOC_ARCH_EXYNOS3250;
> > > > > +	else if (of_device_is_compatible(np,
> > > > > "samsung,exynos4210-tmu"))
> > > > > +		return SOC_ARCH_EXYNOS4210;
> > > > > +	else if (of_device_is_compatible(np,
> > > > > "samsung,exynos4412-tmu"))
> > > > > +		return SOC_ARCH_EXYNOS4412;
> > > > > +	else if (of_device_is_compatible(np,
> > > > > "samsung,exynos5250-tmu"))
> > > > > +		return SOC_ARCH_EXYNOS5250;
> > > > > +	else if (of_device_is_compatible(np,
> > > > > "samsung,exynos5260-tmu"))
> > > > > +		return SOC_ARCH_EXYNOS5260;
> > > > > +	else if (of_device_is_compatible(np,
> > > > > "samsung,exynos5420-tmu"))
> > > > > +		return SOC_ARCH_EXYNOS5420;
> > > > > +	else if (of_device_is_compatible(np,
> > > > > +
> > > > > "samsung,exynos5420-tmu-ext-triminfo"))
> > > > > +		return SOC_ARCH_EXYNOS5420_TRIMINFO;
> > > > > +	else if (of_device_is_compatible(np,
> > > > > "samsung,exynos5440-tmu"))
> > > > > +		return SOC_ARCH_EXYNOS5440;
> > > > > +
> > > > > +	return -EINVAL;
> > > > > +}
> > > > >  
> > > > > -	match = of_match_node(exynos_tmu_match,
> > > > > pdev->dev.of_node);
> > > > > -	if (!match)
> > > > > -		return NULL;
> > > > > -	data_table = (struct exynos_tmu_init_data *)
> > > > > match->data;
> > > > > -	if (!data_table || id >= data_table->tmu_count)
> > > > > -		return NULL;
> > > > > -	tmu_data = data_table->tmu_data;
> > > > > -	return (struct exynos_tmu_platform_data *) (tmu_data +
> > > > > id); +static int exynos_of_sensor_conf(struct device_node *np,
> > > > > +				 struct
> > > > > exynos_tmu_platform_data *pdata) +{
> > > > > +	u32 value;
> > > > > +	int ret;
> > > > > +
> > > > > +	of_node_get(np);
> > > > > +
> > > > > +	ret = of_property_read_u32(np, "samsung,tmu_gain",
> > > > > &value);
> > > > > +	pdata->gain = (u8) value;
> > > > > +	of_property_read_u32(np,
> > > > > "samsung,tmu_reference_voltage", &value);
> > > > > +	pdata->reference_voltage = (u8) value;
> > > > > +	of_property_read_u32(np,
> > > > > "samsung,tmu_noise_cancel_mode", &value);
> > > > > +	pdata->noise_cancel_mode = (u8) value;
> > > > > +
> > > > > +	of_property_read_u32(np, "samsung,tmu_efuse_value",
> > > > > +			     &pdata->efuse_value);
> > > > > +	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
> > > > > +			     &pdata->min_efuse_value);
> > > > > +	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
> > > > > +			     &pdata->max_efuse_value);
> > > > > +
> > > > > +	of_property_read_u32(np,
> > > > > "samsung,tmu_first_point_trim", &value);
> > > > > +	pdata->first_point_trim = (u8) value;
> > > > > +	of_property_read_u32(np,
> > > > > "samsung,tmu_second_point_trim", &value);
> > > > > +	pdata->second_point_trim = (u8) value;
> > > > > +	of_property_read_u32(np,
> > > > > "samsung,tmu_default_temp_offset", &value);
> > > > > +	pdata->default_temp_offset = (u8) value;
> > > > > +
> > > > > +	of_property_read_u32(np, "samsung,tmu_cal_type",
> > > > > &pdata->cal_type);
> > > > > +	of_property_read_u32(np, "samsung,tmu_cal_mode",
> > > > > &pdata->cal_mode); +
> > > > > +	of_node_put(np);
> > > > > +	return 0;
> > > > >  }
> > > > >  
> > > > >  static int exynos_map_dt_data(struct platform_device *pdev)
> > > > > @@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct
> > > > > platform_device *pdev) return -EADDRNOTAVAIL;
> > > > >  	}
> > > > >  
> > > > > -	pdata = exynos_get_driver_data(pdev, data->id);
> > > > > -	if (!pdata) {
> > > > > -		dev_err(&pdev->dev, "No platform init data
> > > > > supplied.\n");
> > > > > -		return -ENODEV;
> > > > > -	}
> > > > > +	pdata = devm_kzalloc(&pdev->dev,
> > > > > +			     sizeof(struct
> > > > > exynos_tmu_platform_data),
> > > > > +			     GFP_KERNEL);
> > > > > +	if (!pdata)
> > > > > +		return -ENOMEM;
> > > > >  
> > > > > +	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
> > > > >  	data->pdata = pdata;
> > > > > -	data->soc = pdata->type;
> > > > > +	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
> > > > >  
> > > > >  	switch (data->soc) {
> > > > >  	case SOC_ARCH_EXYNOS4210:
> > > > > @@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct
> > > > > platform_device *pdev) return 0;
> > > > >  }
> > > > >  
> > > > > +static struct thermal_zone_of_device_ops exynos_sensor_ops = {
> > > > > +	.get_temp = exynos_get_temp,
> > > > > +	.set_emul_temp = exynos_tmu_set_emulation,
> > > > > +};
> > > > > +
> > > > >  static int exynos_tmu_probe(struct platform_device *pdev)
> > > > >  {
> > > > > -	struct exynos_tmu_data *data;
> > > > >  	struct exynos_tmu_platform_data *pdata;
> > > > > -	struct thermal_sensor_conf *sensor_conf;
> > > > > -	int ret, i;
> > > > > +	struct exynos_tmu_data *data;
> > > > > +	int ret;
> > > > >  
> > > > >  	data = devm_kzalloc(&pdev->dev, sizeof(struct
> > > > > exynos_tmu_data), GFP_KERNEL);
> > > > > @@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct
> > > > > platform_device *pdev) platform_set_drvdata(pdev, data);
> > > > >  	mutex_init(&data->lock);
> > > > >  
> > > > > +	data->tzd =
> > > > > thermal_zone_of_sensor_register(&pdev->dev, 0, data,
> > > > > +
> > > > > &exynos_sensor_ops);
> > > > > +	if (IS_ERR(data->tzd)) {
> > > > > +		pr_err("thermal: tz: %p ERROR\n", data->tzd);
> > > > > +		return PTR_ERR(data->tzd);
> > > > > +	}
> > > > >  	ret = exynos_map_dt_data(pdev);
> > > > >  	if (ret)
> > > > > -		return ret;
> > > > > +		goto err_sensor;
> > > > >  
> > > > >  	pdata = data->pdata;
> > > > >  
> > > > > @@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct
> > > > > platform_device *pdev) data->clk = devm_clk_get(&pdev->dev,
> > > > > "tmu_apbif"); if (IS_ERR(data->clk)) {
> > > > >  		dev_err(&pdev->dev, "Failed to get clock\n");
> > > > > -		return  PTR_ERR(data->clk);
> > > > > +		ret = PTR_ERR(data->clk);
> > > > > +		goto err_sensor;
> > > > >  	}
> > > > >  
> > > > >  	data->clk_sec = devm_clk_get(&pdev->dev,
> > > > > "tmu_triminfo_apbif"); if (IS_ERR(data->clk_sec)) {
> > > > >  		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO)
> > > > > { dev_err(&pdev->dev, "Failed to get
> > > > > triminfo clock\n");
> > > > > -			return PTR_ERR(data->clk_sec);
> > > > > +			ret = PTR_ERR(data->clk_sec);
> > > > > +			goto err_sensor;
> > > > >  		}
> > > > >  	} else {
> > > > >  		ret = clk_prepare(data->clk_sec);
> > > > >  		if (ret) {
> > > > >  			dev_err(&pdev->dev, "Failed to get
> > > > > clock\n");
> > > > > -			return ret;
> > > > > +			goto err_sensor;
> > > > >  		}
> > > > >  	}
> > > > >  
> > > > > @@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct
> > > > > platform_device *pdev) goto err_clk;
> > > > >  	}
> > > > >  
> > > > > -	exynos_tmu_control(pdev, true);
> > > > > -
> > > > > -	/* Allocate a structure to register with the exynos
> > > > > core thermal */
> > > > > -	sensor_conf = devm_kzalloc(&pdev->dev,
> > > > > -				sizeof(struct
> > > > > thermal_sensor_conf), GFP_KERNEL);
> > > > > -	if (!sensor_conf) {
> > > > > -		ret = -ENOMEM;
> > > > > -		goto err_clk;
> > > > > -	}
> > > > > -	sprintf(sensor_conf->name, "therm_zone%d", data->id);
> > > > > -	sensor_conf->read_temperature = (int (*)(void
> > > > > *))exynos_tmu_read;
> > > > > -	sensor_conf->write_emul_temp =
> > > > > -		(int (*)(void *, unsigned
> > > > > long))exynos_tmu_set_emulation;
> > > > > -	sensor_conf->driver_data = data;
> > > > > -	sensor_conf->trip_data.trip_count =
> > > > > pdata->trigger_enable[0] +
> > > > > -			pdata->trigger_enable[1] +
> > > > > pdata->trigger_enable[2]+
> > > > > -			pdata->trigger_enable[3];
> > > > > -
> > > > > -	for (i = 0; i < sensor_conf->trip_data.trip_count;
> > > > > i++) {
> > > > > -		sensor_conf->trip_data.trip_val[i] =
> > > > > -			pdata->threshold +
> > > > > pdata->trigger_levels[i];
> > > > > -		sensor_conf->trip_data.trip_type[i] =
> > > > > -					pdata->trigger_type[i];
> > > > > -	}
> > > > > -
> > > > > -	sensor_conf->trip_data.trigger_falling =
> > > > > pdata->threshold_falling; -
> > > > > -	sensor_conf->dev = &pdev->dev;
> > > > > -	/* Register the sensor with thermal management
> > > > > interface */
> > > > > -	ret = exynos_register_thermal(sensor_conf);
> > > > > -	if (ret) {
> > > > > -		if (ret != -EPROBE_DEFER)
> > > > > -			dev_err(&pdev->dev,
> > > > > -				"Failed to register thermal
> > > > > interface: %d\n",
> > > > > -				ret);
> > > > > -		goto err_clk;
> > > > > -	}
> > > > > -	data->reg_conf = sensor_conf;
> > > > > -
> > > > >  	ret = devm_request_irq(&pdev->dev, data->irq,
> > > > > exynos_tmu_irq, IRQF_TRIGGER_RISING | IRQF_SHARED,
> > > > > dev_name(&pdev->dev), data); if (ret) {
> > > > > @@ -935,21 +1030,31 @@ static int exynos_tmu_probe(struct
> > > > > platform_device *pdev) goto err_clk;
> > > > >  	}
> > > > >  
> > > > > +	ret = exynos_tmu_initialize(pdev);
> > > > > +	if (ret) {
> > > > > +		dev_err(&pdev->dev, "Failed to initialize
> > > > > TMU\n");
> > > > > +		goto err_clk;
> > > > > +	}
> > > > > +	exynos_tmu_control(pdev, true);
> > > > >  	return 0;
> > > > > +
> > > > >  err_clk:
> > > > >  	clk_unprepare(data->clk);
> > > > >  err_clk_sec:
> > > > >  	if (!IS_ERR(data->clk_sec))
> > > > >  		clk_unprepare(data->clk_sec);
> > > > > +err_sensor:
> > > > > +	thermal_zone_of_sensor_unregister(&pdev->dev,
> > > > > data->tzd); +
> > > > >  	return ret;
> > > > >  }
> > > > >  
> > > > >  static int exynos_tmu_remove(struct platform_device *pdev)
> > > > >  {
> > > > >  	struct exynos_tmu_data *data =
> > > > > platform_get_drvdata(pdev);
> > > > > +	struct thermal_zone_device *tzd = data->tzd;
> > > > >  
> > > > > -	exynos_unregister_thermal(data->reg_conf);
> > > > > -
> > > > > +	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
> > > > >  	exynos_tmu_control(pdev, false);
> > > > >  
> > > > >  	clk_unprepare(data->clk);
> > > > > diff --git a/drivers/thermal/samsung/exynos_tmu.h
> > > > > b/drivers/thermal/samsung/exynos_tmu.h index 627dec9..d876d4c
> > > > > 100644 --- a/drivers/thermal/samsung/exynos_tmu.h
> > > > > +++ b/drivers/thermal/samsung/exynos_tmu.h
> > > > > @@ -23,8 +23,7 @@
> > > > >  #ifndef _EXYNOS_TMU_H
> > > > >  #define _EXYNOS_TMU_H
> > > > >  #include <linux/cpu_cooling.h>
> > > > > -
> > > > > -#include "exynos_thermal_common.h"
> > > > > +#include <dt-bindings/thermal/thermal_exynos.h>
> > > > >  
> > > > >  enum soc_type {
> > > > >  	SOC_ARCH_EXYNOS3250 = 1,
> > > > > @@ -36,38 +35,9 @@ enum soc_type {
> > > > >  	SOC_ARCH_EXYNOS5420_TRIMINFO,
> > > > >  	SOC_ARCH_EXYNOS5440,
> > > > >  };
> > > > > -#include <dt-bindings/thermal/thermal_exynos.h>
> > > > >  
> > > > >  /**
> > > > >   * struct exynos_tmu_platform_data
> > > > > - * @threshold: basic temperature for generating interrupt
> > > > > - *	       25 <= threshold <= 125 [unit: degree Celsius]
> > > > > - * @threshold_falling: differntial value for setting threshold
> > > > > - *		       of temperature falling interrupt.
> > > > > - * @trigger_levels: array for each interrupt levels
> > > > > - *	[unit: degree Celsius]
> > > > > - *	0: temperature for trigger_level0 interrupt
> > > > > - *	   condition for trigger_level0 interrupt:
> > > > > - *		current temperature > threshold +
> > > > > trigger_levels[0]
> > > > > - *	1: temperature for trigger_level1 interrupt
> > > > > - *	   condition for trigger_level1 interrupt:
> > > > > - *		current temperature > threshold +
> > > > > trigger_levels[1]
> > > > > - *	2: temperature for trigger_level2 interrupt
> > > > > - *	   condition for trigger_level2 interrupt:
> > > > > - *		current temperature > threshold +
> > > > > trigger_levels[2]
> > > > > - *	3: temperature for trigger_level3 interrupt
> > > > > - *	   condition for trigger_level3 interrupt:
> > > > > - *		current temperature > threshold +
> > > > > trigger_levels[3]
> > > > > - * @trigger_type: defines the type of trigger. Possible values
> > > > > are,
> > > > > - *	THROTTLE_ACTIVE trigger type
> > > > > - *	THROTTLE_PASSIVE trigger type
> > > > > - *	SW_TRIP trigger type
> > > > > - *	HW_TRIP
> > > > > - * @trigger_enable[]: array to denote which trigger levels are
> > > > > enabled.
> > > > > - *	1 = enable trigger_level[] interrupt,
> > > > > - *	0 = disable trigger_level[] interrupt
> > > > > - * @max_trigger_level: max trigger level supported by the TMU
> > > > > - * @non_hw_trigger_levels: number of defined non-hardware
> > > > > trigger levels
> > > > >   * @gain: gain of amplifier in the positive-TC generator block
> > > > >   *	0 < gain <= 15
> > > > >   * @reference_voltage: reference voltage of amplifier
> > > > > @@ -79,21 +49,12 @@ enum soc_type {
> > > > >   * @efuse_value: platform defined fuse value
> > > > >   * @min_efuse_value: minimum valid trimming data
> > > > >   * @max_efuse_value: maximum valid trimming data
> > > > > - * @first_point_trim: temp value of the first point trimming
> > > > > - * @second_point_trim: temp value of the second point trimming
> > > > >   * @default_temp_offset: default temperature offset in case of
> > > > > no trimming
> > > > >   * @cal_type: calibration type for temperature
> > > > >   *
> > > > >   * This structure is required for configuration of exynos_tmu
> > > > > driver. */
> > > > >  struct exynos_tmu_platform_data {
> > > > > -	u8 threshold;
> > > > > -	u8 threshold_falling;
> > > > > -	u8 trigger_levels[MAX_TRIP_COUNT];
> > > > > -	enum trigger_type trigger_type[MAX_TRIP_COUNT];
> > > > > -	bool trigger_enable[MAX_TRIP_COUNT];
> > > > > -	u8 max_trigger_level;
> > > > > -	u8 non_hw_trigger_levels;
> > > > >  	u8 gain;
> > > > >  	u8 reference_voltage;
> > > > >  	u8 noise_cancel_mode;
> > > > > @@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
> > > > >  	u32 cal_mode;
> > > > >  };
> > > > >  
> > > > > -/**
> > > > > - * struct exynos_tmu_init_data
> > > > > - * @tmu_count: number of TMU instances.
> > > > > - * @tmu_data: platform data of all TMU instances.
> > > > > - * This structure is required to store data for multi-instance
> > > > > exynos tmu
> > > > > - * driver.
> > > > > - */
> > > > > -struct exynos_tmu_init_data {
> > > > > -	int tmu_count;
> > > > > -	struct exynos_tmu_platform_data tmu_data[];
> > > > > -};
> > > > > -
> > > > >  extern struct exynos_tmu_init_data const
> > > > > exynos3250_default_tmu_data; extern struct exynos_tmu_init_data
> > > > > const exynos4210_default_tmu_data; extern struct
> > > > > exynos_tmu_init_data const exynos4412_default_tmu_data; -- 
> > > > > 2.0.0.rc2
> > > > > 
> > > 
> > > 
> > > 
> > > -- 
> > > Best regards,
> > > 
> > > Lukasz Majewski
> > > 
> > > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration
  2015-01-21  9:08       ` Viresh Kumar
@ 2015-01-21  9:47         ` Lukasz Majewski
  2015-01-21  9:55           ` Viresh Kumar
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-21  9:47 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim,
	Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi

Hi Viresh,

> On 21 January 2015 at 14:03, Lukasz Majewski <l.majewski@samsung.com>
> wrote:
> >> diff --git a/drivers/cpufreq/exynos-cpufreq.c
> 
> >>  static int exynos_cpufreq_probe(struct platform_device *pdev)
> >>  {
> >> +     struct device_node *cpus, *np;
> >>       int ret = -EINVAL;
> >>
> >>       exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
> >> @@ -198,9 +202,31 @@ static int exynos_cpufreq_probe(struct
> >> platform_device *pdev) /* Done here as we want to capture boot
> >> frequency */ locking_frequency =
> >> clk_get_rate(exynos_info->cpu_clk) / 1000;
> >> -     if (!cpufreq_register_driver(&exynos_driver))
> >> -             return 0;
> >> +     if (cpufreq_register_driver(&exynos_driver))
> 
> You should return the error returned by cpufreq_register_driver().

OK.

> 
> >> +             goto err;
> >>
> >> +     cpus = of_find_node_by_path("/cpus");
> >> +     if (!cpus) {
> >> +             pr_err("failed to find cpus node\n");
> >> +             return -ENOENT;
> >> +     }
> >> +
> >> +     for (np = of_get_next_child(cpus, NULL); np;
> >> +          of_node_put(np), np = of_get_next_child(cpus, np)) {
> >> +             if (of_find_property(np, "#cooling-cells", NULL)) {
> 
> Shouldn't you be checking this just for cpu 0 ?

In previous versions I've only checked for cpu 0.

If you think that it is enough to explicitly check only for cpu 0 and
forget about above "fail safe" code (when. e.g. CPU3 has defined
cooling-cells), then I'm fine with it.

> 
> >> +                     cdev = of_cpufreq_cooling_register(np,
> >> +
> >> cpu_present_mask);
> >> +                     if (IS_ERR(cdev))
> >> +                             pr_err("running cpufreq without
> >> cooling device: %ld\n",
> >> +                                    PTR_ERR(cdev));
> >> +                     break;
> >> +             }
> >> +     }
> >> +     of_node_put(np);
> >> +     of_node_put(cpus);
> >> +
> >> +     return 0;
> >> + err:
> >>       dev_err(&pdev->dev, "failed to register cpufreq driver\n");
> >>       regulator_put(arm_regulator);
> >>  err_vdd_arm:
> >
> > Viresh, the above is a small part of the cpufreq related code,
> > which is necessary for Exynos thermal rework to use device tree.
> >
> > It is NOT adding any new functionality, but preserves possibility to
> > use cpufreq as a colling device.
> >
> > Normally I would exclude this part from this commit, but then I
> > cannot assure that between commits no regression is slipping in.
> 
> Mostly looks fine. Just few nits.
> 
> But another important thing is to split this patch, so that there is
> a separate patch for cpufreq driver.

As I've mention - it would be maintainer's call if one trades potential
regression for patch separation.

Thanks for a prompt reply.

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration
  2015-01-21  9:47         ` Lukasz Majewski
@ 2015-01-21  9:55           ` Viresh Kumar
  2015-01-21 10:09             ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Viresh Kumar @ 2015-01-21  9:55 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim,
	Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi

On 21 January 2015 at 15:17, Lukasz Majewski <l.majewski@samsung.com> wrote:
> In previous versions I've only checked for cpu 0.
>
> If you think that it is enough to explicitly check only for cpu 0 and
> forget about above "fail safe" code (when. e.g. CPU3 has defined
> cooling-cells), then I'm fine with it.

I don't know what bindings are you following, but cpufreq-dt's bindings
say that it has to be present in cpu0. Anyway, this driver isn't for a
multi-cluster system and so cpu0 should be fine.

> As I've mention - it would be maintainer's call if one trades potential
> regression for patch separation.

I am just asking it to split into a separate patch, not that I will
get it through
cpufreq. Eduardo can take it, but it should be a separate patch.

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v5 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration
  2015-01-21  9:55           ` Viresh Kumar
@ 2015-01-21 10:09             ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-21 10:09 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim,
	Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi

Hi Viresh,

> On 21 January 2015 at 15:17, Lukasz Majewski <l.majewski@samsung.com>
> wrote:
> > In previous versions I've only checked for cpu 0.
> >
> > If you think that it is enough to explicitly check only for cpu 0
> > and forget about above "fail safe" code (when. e.g. CPU3 has defined
> > cooling-cells), then I'm fine with it.
> 
> I don't know what bindings are you following, but cpufreq-dt's
> bindings say that it has to be present in cpu0. Anyway, this driver
> isn't for a multi-cluster system and so cpu0 should be fine.

Ok.

> 
> > As I've mention - it would be maintainer's call if one trades
> > potential regression for patch separation.
> 
> I am just asking it to split into a separate patch, not that I will
> get it through
> cpufreq. Eduardo can take it, but it should be a separate patch.

Lets do it in this way :-).

Thanks.

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 00/16] thermal: exynos: Thermal code rework to use device tree
  2015-01-20  8:17         ` Lukasz Majewski
@ 2015-01-22  1:06           ` Tobias Jakobi
  2015-01-21  9:08             ` Eduardo Valentin
  0 siblings, 1 reply; 288+ messages in thread
From: Tobias Jakobi @ 2015-01-22  1:06 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim,
	Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Thomas Abraham, tomasz.figa

Hello!


Lukasz Majewski wrote:
>> The point is that I'm still working with a rather old version of the
>> cpufreq series, a version which still had the Exynos4x12 code in it
>> (this was removed later, if I remember correctly because of problems
>> with how to properly describe boost configuration in DT).
> 
> Is your board Odroid-U3/Trats2 ?
It's an Odroid-X2, so pretty similar to the U3, except that it doesn't
have any active cooling device.


>> Anyway, to not get completly off-topic here, I noticed some small
>> issue with v3 of the thermal series. I've enabled
>> CONFIG_THERMAL_HWMON so that I can use lm_sensors to query
>> temperature of the board. However while the thermal_zone is created,
>> there is no hwmon node to be found. 
> 
> I'm not surprised, that some use cases (about which I wasn't even
> aware) show up. 
> I've already fixed issues reported by Abhilash (with v5 and a following
> patch) and look closer into the THERMAL_HWMON.
The problem seems to be that of_parse_thermal_zones always sets
'no_hwmon' to true, so that thermal_zone_device_register never registers
a hwmon device when the underlaying thermal zone is setup through DT. I
don't understand the rationale behind this, even with the comment ('No
hwmon because there might be hwmon drivers registering').


> I've also done some work regarding FAN controlled by hwmon for Odroid
> U3.
> Could you look on following series:
> http://www.spinics.net/lists/linux-samsung-soc/msg40471.html
> 
> I can only guess that your board might need similar entries for your
> DTS file(s).

Like I said, the X2 only has a passive heatsink, so no fan controlling here.


With best wishes,
Tobias

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-21  9:20             ` Eduardo Valentin
@ 2015-01-22 14:17               ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-22 14:17 UTC (permalink / raw)
  To: Eduardo Valentin, Kukjin Kim, Kukjin Kim
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Abhilash Kesavan, Kyungmin Park, Chanwoo Choi

Hi Eduardo,

> On Wed, Jan 21, 2015 at 09:10:15AM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > On Thu, Jan 15, 2015 at 04:17:52PM +0100, Lukasz Majewski wrote:
> > > > Hi Eduardo,
> > > > 
> > > > > On Wed, Jan 14, 2015 at 02:41:12PM +0100, Lukasz Majewski
> > > > > wrote:
> > > > > > This patch brings support for providing configuration via
> > > > > > device tree. Previously this data has been hardcoded in the
> > > > > > exynos_tmu_data.c file. Such approach was not scalable and
> > > > > > very often required copying the whole data.
> > > > > > 
> > > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > > > ---
> > > > > > Changes for v2:
> > > > > > - Adjust exynos_tmu.c code to the newest ti-soc-thermal
> > > > > > repository
> > > > > > - Usage of of-thermal.c exported trip points table
> > > > > > Changes for v3:
> > > > > > - Adding exynos_of_get_soc_type() method to set SOC type
> > > > > > from device's compatible string
> > > > > > - "samsung,tmu_" prefix for TMU specific properties has been
> > > > > > added
> > > > > > 
> > > > > > ---
> > > > > >  drivers/thermal/samsung/Makefile     |   2 -
> > > > > >  drivers/thermal/samsung/exynos_tmu.c | 345
> > > > > > +++++++++++++++++++++++------------
> > > > > > drivers/thermal/samsung/exynos_tmu.h |  53 +----- 3 files
> > > > > > changed, 226 insertions(+), 174 deletions(-)
> > > > > > 
> > > > > > diff --git a/drivers/thermal/samsung/Makefile
> > > > > > b/drivers/thermal/samsung/Makefile index c09d830..1e47d0d
> > > > > > 100644 --- a/drivers/thermal/samsung/Makefile
> > > > > > +++ b/drivers/thermal/samsung/Makefile
> > > > > > @@ -3,5 +3,3 @@
> > > > > >  #
> > > > > >  obj-$(CONFIG_EXYNOS_THERMAL)			+=
> > > > > > exynos_thermal.o
> > > > > > exynos_thermal-y				:=
> > > > > > exynos_tmu.o
> > > > > > -exynos_thermal-y				+=
> > > > > > exynos_tmu_data.o
> > > > > 
> > > > > Can this makefile change be part of the patch that removes
> > > > > exynos_tmu_data.c?
> > > > > 
> > > > > > -exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+=
> > > > > > exynos_thermal_common.o
> > > > > 
> > > > > Can this makefile change be part of the patch that removes
> > > > > exynos_thermal_common.c?
> > > > 
> > > > Unfortunately, this code cannot be moved to the next patch, in
> > > > which I remove the files, since this causes build break of the
> > > > series.
> > > > 
> > > > The code structure as is, provides working, bisectable thermal
> > > > solution - thermal and cpu_cooling functionality is preserved
> > > > across all commits in the series.
> > > 
> > > My concern here is simply that this specific commit is leaving
> > > unused files in the tree.
> > > 
> > > One option would be to remove the files altogether in this
> > > specific commit.
> > 
> > Is is really necessary?
> > 
> > This patch itself changes around 400 LOC. Those changes __are__
> > important and in my opinion deserve their own commit.
> > 
> > When I squash following patches, which remove old exynos files, we
> > would have around 1.2K LOC in a single commit.
> > 
> > I think that current approach is far more readable. 
> 
> I agree that separating is far more readable. However, the commit
> leaves zombie files.

For a sake of simplicity, lets leave those files as zombie for one (or
at most two) commit.

> 
> > 
> > Eduardo, is there a chance for this series (the newest version is
> > v5 - which include Ablibash comments) to be included to yours -next
> > tree before v3.19 is out?
> 
> Yes, we can target this. I have sent couple of minor comments on v5.
> Despite them, there are also some parts of this series that are
> supposed to be merged via other trees. The cpufreq part seams to be
> too little and Viresh has already flagged that I can merge it as long
> it is in a separated patch. 

Indeed, this was already agreed with Viresh.

>However, most part of this series touches
> arch/arm directory and those should go via your platform tree. Is
> there a change you could either as your Exynos maintainer to queue
> the patches touching arch/arm or ask him if he is fine if I merge
> them via my tree?

I've asked Kukjin to ACK those patches, so it would be possible for you
to grab them all and push them to your tree.

Such approach allows us to keep this rework in one piece (and hence
assure no regression).

> 
> Cheers,
> 
> > 
> > > 
> > > > 
> > > > > 
> > > > > > diff --git a/drivers/thermal/samsung/exynos_tmu.c
> > > > > > b/drivers/thermal/samsung/exynos_tmu.c index
> > > > > > ae30f6a..633a9e2 100644 ---
> > > > > > a/drivers/thermal/samsung/exynos_tmu.c +++
> > > > > > b/drivers/thermal/samsung/exynos_tmu.c @@ -1,6 +1,10 @@
> > > > > >  /*
> > > > > >   * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management
> > > > > > Unit) *
> > > > > > + *  Copyright (C) 2014 Samsung Electronics
> > > > > > + *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> > > > > > + *  Lukasz Majewski <l.majewski@samsung.com>
> > > > > > + *
> > > > > >   *  Copyright (C) 2011 Samsung Electronics
> > > > > >   *  Donggeun Kim <dg77.kim@samsung.com>
> > > > > >   *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
> > > > > > @@ -31,8 +35,8 @@
> > > > > >  #include <linux/platform_device.h>
> > > > > >  #include <linux/regulator/consumer.h>
> > > > > >  
> > > > > > -#include "exynos_thermal_common.h"
> > > > > >  #include "exynos_tmu.h"
> > > > > > +#include "../thermal_core.h"
> > > > > >  
> > > > > >  /* Exynos generic registers */
> > > > > >  #define EXYNOS_TMU_REG_TRIMINFO		0x0
> > > > > > @@ -115,6 +119,7 @@
> > > > > >  #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
> > > > > >  #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
> > > > > >  
> > > > > > +#define MCELSIUS	1000
> > > > > >  /**
> > > > > >   * struct exynos_tmu_data : A structure to hold the private
> > > > > > data of the TMU driver
> > > > > > @@ -150,7 +155,8 @@ struct exynos_tmu_data {
> > > > > >  	struct clk *clk, *clk_sec;
> > > > > >  	u8 temp_error1, temp_error2;
> > > > > >  	struct regulator *regulator;
> > > > > > -	struct thermal_sensor_conf *reg_conf;
> > > > > > +	struct thermal_zone_device *tzd;
> > > > > > +
> > > > > >  	int (*tmu_initialize)(struct platform_device
> > > > > > *pdev); void (*tmu_control)(struct platform_device *pdev,
> > > > > > bool on); int (*tmu_read)(struct exynos_tmu_data *data);
> > > > > > @@ -159,6 +165,33 @@ struct exynos_tmu_data {
> > > > > >  	void (*tmu_clear_irqs)(struct exynos_tmu_data
> > > > > > *data); };
> > > > > >  
> > > > > > +static void exynos_report_trigger(struct exynos_tmu_data
> > > > > > *p) +{
> > > > > > +	char data[10], *envp[] = { data, NULL };
> > > > > > +	struct thermal_zone_device *tz = p->tzd;
> > > > > > +	unsigned long temp;
> > > > > > +	unsigned int i;
> > > > > > +
> > > > > > +	if (!p) {
> > > > > > +		pr_err("Wrong temperature configuration
> > > > > > data\n");
> > > > > > +		return;
> > > > > > +	}
> > > > > > +
> > > > > > +	thermal_zone_device_update(tz);
> > > > > > +
> > > > > > +	mutex_lock(&tz->lock);
> > > > > > +	/* Find the level for which trip happened */
> > > > > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > > > > +		tz->ops->get_trip_temp(tz, i, &temp);
> > > > > > +		if (tz->last_temperature < temp)
> > > > > > +			break;
> > > > > > +	}
> > > > > > +
> > > > > > +	snprintf(data, sizeof(data), "%u", i);
> > > > > > +	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE,
> > > > > > envp);
> > > > > > +	mutex_unlock(&tz->lock);
> > > > > > +}
> > > > > > +
> > > > > >  /*
> > > > > >   * TMU treats temperature as a mapped temperature code.
> > > > > >   * The temperature is converted differently depending on
> > > > > > the calibration type. @@ -234,14 +267,25 @@ static void
> > > > > > sanitize_temp_error(struct exynos_tmu_data *data, u32
> > > > > > trim_info) static u32 get_th_reg(struct exynos_tmu_data
> > > > > > *data, u32 threshold, bool falling) {
> > > > > > -	struct exynos_tmu_platform_data *pdata =
> > > > > > data->pdata;
> > > > > > +	struct thermal_zone_device *tz = data->tzd;
> > > > > > +	const struct thermal_trip * const trips =
> > > > > > +		of_thermal_get_trip_points(tz);
> > > > > > +	unsigned long temp;
> > > > > >  	int i;
> > > > > >  
> > > > > > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
> > > > > > {
> > > > > > -		u8 temp = pdata->trigger_levels[i];
> > > > > > +	if (!trips) {
> > > > > > +		pr_err("%s: Cannot get trip points from
> > > > > > of-thermal.c!\n",
> > > > > > +		       __func__);
> > > > > > +		return 0;
> > > > > > +	}
> > > > > > +
> > > > > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > > > > +		if (trips[i].type == THERMAL_TRIP_CRITICAL)
> > > > > > +			continue;
> > > > > >  
> > > > > > +		temp = trips[i].temperature / MCELSIUS;
> > > > > >  		if (falling)
> > > > > > -			temp -= pdata->threshold_falling;
> > > > > > +			temp -= (trips[i].hysteresis /
> > > > > > MCELSIUS); else
> > > > > >  			threshold &= ~(0xff << 8 * i);
> > > > > >  
> > > > > > @@ -305,9 +349,19 @@ static void exynos_tmu_control(struct
> > > > > > platform_device *pdev, bool on) static int
> > > > > > exynos4210_tmu_initialize(struct platform_device *pdev) {
> > > > > >  	struct exynos_tmu_data *data =
> > > > > > platform_get_drvdata(pdev);
> > > > > > -	struct exynos_tmu_platform_data *pdata =
> > > > > > data->pdata;
> > > > > > -	unsigned int status;
> > > > > > +	struct thermal_zone_device *tz = data->tzd;
> > > > > > +	const struct thermal_trip * const trips =
> > > > > > +		of_thermal_get_trip_points(tz);
> > > > > >  	int ret = 0, threshold_code, i;
> > > > > > +	unsigned long reference, temp;
> > > > > > +	unsigned int status;
> > > > > > +
> > > > > > +	if (!trips) {
> > > > > > +		pr_err("%s: Cannot get trip points from
> > > > > > of-thermal.c!\n",
> > > > > > +		       __func__);
> > > > > > +		ret = -ENODEV;
> > > > > > +		goto out;
> > > > > > +	}
> > > > > >  
> > > > > >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> > > > > >  	if (!status) {
> > > > > > @@ -318,12 +372,19 @@ static int
> > > > > > exynos4210_tmu_initialize(struct platform_device *pdev)
> > > > > > sanitize_temp_error(data, readl(data->base +
> > > > > > EXYNOS_TMU_REG_TRIMINFO)); /* Write temperature code for
> > > > > > threshold */
> > > > > > -	threshold_code = temp_to_code(data,
> > > > > > pdata->threshold);
> > > > > > +	reference = trips[0].temperature / MCELSIUS;
> > > > > > +	threshold_code = temp_to_code(data, reference);
> > > > > > +	if (threshold_code < 0) {
> > > > > > +		ret = threshold_code;
> > > > > > +		goto out;
> > > > > > +	}
> > > > > >  	writeb(threshold_code, data->base +
> > > > > > EXYNOS4210_TMU_REG_THRESHOLD_TEMP); 
> > > > > > -	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
> > > > > > -		writeb(pdata->trigger_levels[i],
> > > > > > data->base +
> > > > > > +	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
> > > > > > +		temp = trips[i].temperature / MCELSIUS;
> > > > > > +		writeb(temp - reference, data->base +
> > > > > >  		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i
> > > > > > * 4);
> > > > > > +	}
> > > > > >  
> > > > > >  	data->tmu_clear_irqs(data);
> > > > > >  out:
> > > > > > @@ -333,9 +394,11 @@ out:
> > > > > >  static int exynos4412_tmu_initialize(struct platform_device
> > > > > > *pdev) {
> > > > > >  	struct exynos_tmu_data *data =
> > > > > > platform_get_drvdata(pdev);
> > > > > > -	struct exynos_tmu_platform_data *pdata =
> > > > > > data->pdata;
> > > > > > +	const struct thermal_trip * const trips =
> > > > > > +		of_thermal_get_trip_points(data->tzd);
> > > > > >  	unsigned int status, trim_info, con, ctrl,
> > > > > > rising_threshold; int ret = 0, threshold_code, i;
> > > > > > +	unsigned long crit_temp = 0;
> > > > > >  
> > > > > >  	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
> > > > > >  	if (!status) {
> > > > > > @@ -373,17 +436,29 @@ static int
> > > > > > exynos4412_tmu_initialize(struct platform_device *pdev)
> > > > > > data->tmu_clear_irqs(data); 
> > > > > >  	/* if last threshold limit is also present */
> > > > > > -	i = pdata->max_trigger_level - 1;
> > > > > > -	if (pdata->trigger_levels[i] &&
> > > > > > pdata->trigger_type[i] == HW_TRIP) {
> > > > > > -		threshold_code = temp_to_code(data,
> > > > > > pdata->trigger_levels[i]);
> > > > > > -		/* 1-4 level to be assigned in th0 reg */
> > > > > > -		rising_threshold &= ~(0xff << 8 * i);
> > > > > > -		rising_threshold |= threshold_code << 8 *
> > > > > > i;
> > > > > > -		writel(rising_threshold, data->base +
> > > > > > EXYNOS_THD_TEMP_RISE);
> > > > > > -		con = readl(data->base +
> > > > > > EXYNOS_TMU_REG_CONTROL);
> > > > > > -		con |= (1 <<
> > > > > > EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > > > > > -		writel(con, data->base +
> > > > > > EXYNOS_TMU_REG_CONTROL);
> > > > > > +	for (i = 0; i < of_thermal_get_ntrips(data->tzd);
> > > > > > i++) {
> > > > > > +		if (trips[i].type ==
> > > > > > THERMAL_TRIP_CRITICAL) {
> > > > > > +			crit_temp = trips[i].temperature;
> > > > > > +			break;
> > > > > > +		}
> > > > > >  	}
> > > > > > +
> > > > > > +	if (i == of_thermal_get_ntrips(data->tzd)) {
> > > > > > +		pr_err("%s: No CRITICAL trip point defined
> > > > > > at of-thermal.c!\n",
> > > > > > +		       __func__);
> > > > > > +		ret = -EINVAL;
> > > > > > +		goto out;
> > > > > > +	}
> > > > > > +
> > > > > > +	threshold_code = temp_to_code(data, crit_temp /
> > > > > > MCELSIUS);
> > > > > > +	/* 1-4 level to be assigned in th0 reg */
> > > > > > +	rising_threshold &= ~(0xff << 8 * i);
> > > > > > +	rising_threshold |= threshold_code << 8 * i;
> > > > > > +	writel(rising_threshold, data->base +
> > > > > > EXYNOS_THD_TEMP_RISE);
> > > > > > +	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
> > > > > > +	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
> > > > > > +	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
> > > > > > +
> > > > > >  out:
> > > > > >  	return ret;
> > > > > >  }
> > > > > > @@ -391,9 +466,9 @@ out:
> > > > > >  static int exynos5440_tmu_initialize(struct platform_device
> > > > > > *pdev) {
> > > > > >  	struct exynos_tmu_data *data =
> > > > > > platform_get_drvdata(pdev);
> > > > > > -	struct exynos_tmu_platform_data *pdata =
> > > > > > data->pdata; unsigned int trim_info = 0, con,
> > > > > > rising_threshold;
> > > > > > -	int ret = 0, threshold_code, i;
> > > > > > +	int ret = 0, threshold_code;
> > > > > > +	unsigned long crit_temp = 0;
> > > > > >  
> > > > > >  	/*
> > > > > >  	 * For exynos5440 soc triminfo value is swapped
> > > > > > between TMU0 and @@ -422,9 +497,8 @@ static int
> > > > > > exynos5440_tmu_initialize(struct platform_device *pdev)
> > > > > > data->tmu_clear_irqs(data); 
> > > > > >  	/* if last threshold limit is also present */
> > > > > > -	i = pdata->max_trigger_level - 1;
> > > > > > -	if (pdata->trigger_levels[i] &&
> > > > > > pdata->trigger_type[i] == HW_TRIP) {
> > > > > > -		threshold_code = temp_to_code(data,
> > > > > > pdata->trigger_levels[i]);
> > > > > > +	if (!data->tzd->ops->get_crit_temp(data->tzd,
> > > > > > &crit_temp)) {
> > > > > > +		threshold_code = temp_to_code(data,
> > > > > > crit_temp / MCELSIUS); /* 5th level to be assigned in th2
> > > > > > reg */ rising_threshold =
> > > > > >  			threshold_code <<
> > > > > > EXYNOS5440_TMU_TH_RISE4_SHIFT; @@ -442,7 +516,7 @@ static
> > > > > > int exynos5440_tmu_initialize(struct platform_device *pdev)
> > > > > > static void exynos4210_tmu_control(struct platform_device
> > > > > > *pdev, bool on) { struct exynos_tmu_data *data =
> > > > > > platform_get_drvdata(pdev);
> > > > > > -	struct exynos_tmu_platform_data *pdata =
> > > > > > data->pdata;
> > > > > > +	struct thermal_zone_device *tz = data->tzd;
> > > > > >  	unsigned int con, interrupt_en;
> > > > > >  
> > > > > >  	con = get_con_reg(data, readl(data->base +
> > > > > > EXYNOS_TMU_REG_CONTROL)); @@ -450,10 +524,15 @@ static void
> > > > > > exynos4210_tmu_control(struct platform_device *pdev, bool
> > > > > > on) if (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > > > > >  		interrupt_en =
> > > > > > -			pdata->trigger_enable[3] <<
> > > > > > EXYNOS_TMU_INTEN_RISE3_SHIFT |
> > > > > > -			pdata->trigger_enable[2] <<
> > > > > > EXYNOS_TMU_INTEN_RISE2_SHIFT |
> > > > > > -			pdata->trigger_enable[1] <<
> > > > > > EXYNOS_TMU_INTEN_RISE1_SHIFT |
> > > > > > -			pdata->trigger_enable[0] <<
> > > > > > EXYNOS_TMU_INTEN_RISE0_SHIFT;
> > > > > > +			(of_thermal_is_trip_valid(tz, 3)
> > > > > > +			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
> > > > > > +			(of_thermal_is_trip_valid(tz, 2)
> > > > > > +			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
> > > > > > +			(of_thermal_is_trip_valid(tz, 1)
> > > > > > +			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
> > > > > > +			(of_thermal_is_trip_valid(tz, 0)
> > > > > > +			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
> > > > > > +
> > > > > >  		if (data->soc != SOC_ARCH_EXYNOS4210)
> > > > > >  			interrupt_en |=
> > > > > >  				interrupt_en <<
> > > > > > EXYNOS_TMU_INTEN_FALL0_SHIFT; @@ -468,7 +547,7 @@ static
> > > > > > void exynos4210_tmu_control(struct platform_device *pdev,
> > > > > > bool on) static void exynos5440_tmu_control(struct
> > > > > > platform_device *pdev, bool on) { struct exynos_tmu_data
> > > > > > *data = platform_get_drvdata(pdev);
> > > > > > -	struct exynos_tmu_platform_data *pdata =
> > > > > > data->pdata;
> > > > > > +	struct thermal_zone_device *tz = data->tzd;
> > > > > >  	unsigned int con, interrupt_en;
> > > > > >  
> > > > > >  	con = get_con_reg(data, readl(data->base +
> > > > > > EXYNOS5440_TMU_S0_7_CTRL)); @@ -476,11 +555,16 @@ static
> > > > > > void exynos5440_tmu_control(struct platform_device *pdev,
> > > > > > bool on) if (on) { con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > > > > >  		interrupt_en =
> > > > > > -			pdata->trigger_enable[3] <<
> > > > > > EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
> > > > > > -			pdata->trigger_enable[2] <<
> > > > > > EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
> > > > > > -			pdata->trigger_enable[1] <<
> > > > > > EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
> > > > > > -			pdata->trigger_enable[0] <<
> > > > > > EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
> > > > > > -		interrupt_en |= interrupt_en <<
> > > > > > EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
> > > > > > +			(of_thermal_is_trip_valid(tz, 3)
> > > > > > +			 <<
> > > > > > EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
> > > > > > +			(of_thermal_is_trip_valid(tz, 2)
> > > > > > +			 <<
> > > > > > EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
> > > > > > +			(of_thermal_is_trip_valid(tz, 1)
> > > > > > +			 <<
> > > > > > EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
> > > > > > +			(of_thermal_is_trip_valid(tz, 0)
> > > > > > +			 <<
> > > > > > EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
> > > > > > +		interrupt_en |=
> > > > > > +			interrupt_en <<
> > > > > > EXYNOS5440_TMU_INTEN_FALL0_SHIFT; } else {
> > > > > >  		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > > > > >  		interrupt_en = 0; /* Disable all
> > > > > > interrupts */ @@ -489,19 +573,22 @@ static void
> > > > > > exynos5440_tmu_control(struct platform_device *pdev, bool
> > > > > > on) writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL); }
> > > > > >  
> > > > > > -static int exynos_tmu_read(struct exynos_tmu_data *data)
> > > > > > +int exynos_get_temp(void *p, long *temp)
> > > > > >  {
> > > > > > -	int ret;
> > > > > > +	struct exynos_tmu_data *data = p;
> > > > > > +
> > > > > > +	if (!data)
> > > > > > +		return -EINVAL;
> > > > > >  
> > > > > >  	mutex_lock(&data->lock);
> > > > > >  	clk_enable(data->clk);
> > > > > > -	ret = data->tmu_read(data);
> > > > > > -	if (ret >= 0)
> > > > > > -		ret = code_to_temp(data, ret);
> > > > > > +
> > > > > > +	*temp = code_to_temp(data, data->tmu_read(data)) *
> > > > > > MCELSIUS; +
> > > > > >  	clk_disable(data->clk);
> > > > > >  	mutex_unlock(&data->lock);
> > > > > >  
> > > > > > -	return ret;
> > > > > > +	return 0;
> > > > > >  }
> > > > > >  
> > > > > >  #ifdef CONFIG_THERMAL_EMULATION
> > > > > > @@ -613,7 +700,7 @@ static void exynos_tmu_work(struct
> > > > > > work_struct *work) if (!IS_ERR(data->clk_sec))
> > > > > >  		clk_disable(data->clk_sec);
> > > > > >  
> > > > > > -	exynos_report_trigger(data->reg_conf);
> > > > > > +	exynos_report_trigger(data);
> > > > > >  	mutex_lock(&data->lock);
> > > > > >  	clk_enable(data->clk);
> > > > > >  
> > > > > > @@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int
> > > > > > irq, void *id) static const struct of_device_id
> > > > > > exynos_tmu_match[] = { {
> > > > > >  		.compatible = "samsung,exynos3250-tmu",
> > > > > > -		.data = &exynos3250_default_tmu_data,
> > > > > >  	},
> > > > > >  	{
> > > > > >  		.compatible = "samsung,exynos4210-tmu",
> > > > > > -		.data = &exynos4210_default_tmu_data,
> > > > > >  	},
> > > > > >  	{
> > > > > >  		.compatible = "samsung,exynos4412-tmu",
> > > > > > -		.data = &exynos4412_default_tmu_data,
> > > > > >  	},
> > > > > >  	{
> > > > > >  		.compatible = "samsung,exynos5250-tmu",
> > > > > > -		.data = &exynos5250_default_tmu_data,
> > > > > >  	},
> > > > > >  	{
> > > > > >  		.compatible = "samsung,exynos5260-tmu",
> > > > > > -		.data = &exynos5260_default_tmu_data,
> > > > > >  	},
> > > > > >  	{
> > > > > >  		.compatible = "samsung,exynos5420-tmu",
> > > > > > -		.data = &exynos5420_default_tmu_data,
> > > > > >  	},
> > > > > >  	{
> > > > > >  		.compatible =
> > > > > > "samsung,exynos5420-tmu-ext-triminfo",
> > > > > > -		.data = &exynos5420_default_tmu_data,
> > > > > >  	},
> > > > > >  	{
> > > > > >  		.compatible = "samsung,exynos5440-tmu",
> > > > > > -		.data = &exynos5440_default_tmu_data,
> > > > > >  	},
> > > > > >  	{},
> > > > > >  };
> > > > > >  MODULE_DEVICE_TABLE(of, exynos_tmu_match);
> > > > > >  
> > > > > > -static inline struct  exynos_tmu_platform_data
> > > > > > *exynos_get_driver_data(
> > > > > > -			struct platform_device *pdev, int
> > > > > > id) +static int exynos_of_get_soc_type(struct device_node
> > > > > > *np) {
> > > > > > -	struct  exynos_tmu_init_data *data_table;
> > > > > > -	struct exynos_tmu_platform_data *tmu_data;
> > > > > > -	const struct of_device_id *match;
> > > > > > +	if (of_device_is_compatible(np,
> > > > > > "samsung,exynos3250-tmu"))
> > > > > > +		return SOC_ARCH_EXYNOS3250;
> > > > > > +	else if (of_device_is_compatible(np,
> > > > > > "samsung,exynos4210-tmu"))
> > > > > > +		return SOC_ARCH_EXYNOS4210;
> > > > > > +	else if (of_device_is_compatible(np,
> > > > > > "samsung,exynos4412-tmu"))
> > > > > > +		return SOC_ARCH_EXYNOS4412;
> > > > > > +	else if (of_device_is_compatible(np,
> > > > > > "samsung,exynos5250-tmu"))
> > > > > > +		return SOC_ARCH_EXYNOS5250;
> > > > > > +	else if (of_device_is_compatible(np,
> > > > > > "samsung,exynos5260-tmu"))
> > > > > > +		return SOC_ARCH_EXYNOS5260;
> > > > > > +	else if (of_device_is_compatible(np,
> > > > > > "samsung,exynos5420-tmu"))
> > > > > > +		return SOC_ARCH_EXYNOS5420;
> > > > > > +	else if (of_device_is_compatible(np,
> > > > > > +
> > > > > > "samsung,exynos5420-tmu-ext-triminfo"))
> > > > > > +		return SOC_ARCH_EXYNOS5420_TRIMINFO;
> > > > > > +	else if (of_device_is_compatible(np,
> > > > > > "samsung,exynos5440-tmu"))
> > > > > > +		return SOC_ARCH_EXYNOS5440;
> > > > > > +
> > > > > > +	return -EINVAL;
> > > > > > +}
> > > > > >  
> > > > > > -	match = of_match_node(exynos_tmu_match,
> > > > > > pdev->dev.of_node);
> > > > > > -	if (!match)
> > > > > > -		return NULL;
> > > > > > -	data_table = (struct exynos_tmu_init_data *)
> > > > > > match->data;
> > > > > > -	if (!data_table || id >= data_table->tmu_count)
> > > > > > -		return NULL;
> > > > > > -	tmu_data = data_table->tmu_data;
> > > > > > -	return (struct exynos_tmu_platform_data *)
> > > > > > (tmu_data + id); +static int exynos_of_sensor_conf(struct
> > > > > > device_node *np,
> > > > > > +				 struct
> > > > > > exynos_tmu_platform_data *pdata) +{
> > > > > > +	u32 value;
> > > > > > +	int ret;
> > > > > > +
> > > > > > +	of_node_get(np);
> > > > > > +
> > > > > > +	ret = of_property_read_u32(np, "samsung,tmu_gain",
> > > > > > &value);
> > > > > > +	pdata->gain = (u8) value;
> > > > > > +	of_property_read_u32(np,
> > > > > > "samsung,tmu_reference_voltage", &value);
> > > > > > +	pdata->reference_voltage = (u8) value;
> > > > > > +	of_property_read_u32(np,
> > > > > > "samsung,tmu_noise_cancel_mode", &value);
> > > > > > +	pdata->noise_cancel_mode = (u8) value;
> > > > > > +
> > > > > > +	of_property_read_u32(np, "samsung,tmu_efuse_value",
> > > > > > +			     &pdata->efuse_value);
> > > > > > +	of_property_read_u32(np,
> > > > > > "samsung,tmu_min_efuse_value",
> > > > > > +			     &pdata->min_efuse_value);
> > > > > > +	of_property_read_u32(np,
> > > > > > "samsung,tmu_max_efuse_value",
> > > > > > +			     &pdata->max_efuse_value);
> > > > > > +
> > > > > > +	of_property_read_u32(np,
> > > > > > "samsung,tmu_first_point_trim", &value);
> > > > > > +	pdata->first_point_trim = (u8) value;
> > > > > > +	of_property_read_u32(np,
> > > > > > "samsung,tmu_second_point_trim", &value);
> > > > > > +	pdata->second_point_trim = (u8) value;
> > > > > > +	of_property_read_u32(np,
> > > > > > "samsung,tmu_default_temp_offset", &value);
> > > > > > +	pdata->default_temp_offset = (u8) value;
> > > > > > +
> > > > > > +	of_property_read_u32(np, "samsung,tmu_cal_type",
> > > > > > &pdata->cal_type);
> > > > > > +	of_property_read_u32(np, "samsung,tmu_cal_mode",
> > > > > > &pdata->cal_mode); +
> > > > > > +	of_node_put(np);
> > > > > > +	return 0;
> > > > > >  }
> > > > > >  
> > > > > >  static int exynos_map_dt_data(struct platform_device *pdev)
> > > > > > @@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct
> > > > > > platform_device *pdev) return -EADDRNOTAVAIL;
> > > > > >  	}
> > > > > >  
> > > > > > -	pdata = exynos_get_driver_data(pdev, data->id);
> > > > > > -	if (!pdata) {
> > > > > > -		dev_err(&pdev->dev, "No platform init data
> > > > > > supplied.\n");
> > > > > > -		return -ENODEV;
> > > > > > -	}
> > > > > > +	pdata = devm_kzalloc(&pdev->dev,
> > > > > > +			     sizeof(struct
> > > > > > exynos_tmu_platform_data),
> > > > > > +			     GFP_KERNEL);
> > > > > > +	if (!pdata)
> > > > > > +		return -ENOMEM;
> > > > > >  
> > > > > > +	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
> > > > > >  	data->pdata = pdata;
> > > > > > -	data->soc = pdata->type;
> > > > > > +	data->soc =
> > > > > > exynos_of_get_soc_type(pdev->dev.of_node); 
> > > > > >  	switch (data->soc) {
> > > > > >  	case SOC_ARCH_EXYNOS4210:
> > > > > > @@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct
> > > > > > platform_device *pdev) return 0;
> > > > > >  }
> > > > > >  
> > > > > > +static struct thermal_zone_of_device_ops exynos_sensor_ops
> > > > > > = {
> > > > > > +	.get_temp = exynos_get_temp,
> > > > > > +	.set_emul_temp = exynos_tmu_set_emulation,
> > > > > > +};
> > > > > > +
> > > > > >  static int exynos_tmu_probe(struct platform_device *pdev)
> > > > > >  {
> > > > > > -	struct exynos_tmu_data *data;
> > > > > >  	struct exynos_tmu_platform_data *pdata;
> > > > > > -	struct thermal_sensor_conf *sensor_conf;
> > > > > > -	int ret, i;
> > > > > > +	struct exynos_tmu_data *data;
> > > > > > +	int ret;
> > > > > >  
> > > > > >  	data = devm_kzalloc(&pdev->dev, sizeof(struct
> > > > > > exynos_tmu_data), GFP_KERNEL);
> > > > > > @@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct
> > > > > > platform_device *pdev) platform_set_drvdata(pdev, data);
> > > > > >  	mutex_init(&data->lock);
> > > > > >  
> > > > > > +	data->tzd =
> > > > > > thermal_zone_of_sensor_register(&pdev->dev, 0, data,
> > > > > > +
> > > > > > &exynos_sensor_ops);
> > > > > > +	if (IS_ERR(data->tzd)) {
> > > > > > +		pr_err("thermal: tz: %p ERROR\n",
> > > > > > data->tzd);
> > > > > > +		return PTR_ERR(data->tzd);
> > > > > > +	}
> > > > > >  	ret = exynos_map_dt_data(pdev);
> > > > > >  	if (ret)
> > > > > > -		return ret;
> > > > > > +		goto err_sensor;
> > > > > >  
> > > > > >  	pdata = data->pdata;
> > > > > >  
> > > > > > @@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct
> > > > > > platform_device *pdev) data->clk = devm_clk_get(&pdev->dev,
> > > > > > "tmu_apbif"); if (IS_ERR(data->clk)) {
> > > > > >  		dev_err(&pdev->dev, "Failed to get
> > > > > > clock\n");
> > > > > > -		return  PTR_ERR(data->clk);
> > > > > > +		ret = PTR_ERR(data->clk);
> > > > > > +		goto err_sensor;
> > > > > >  	}
> > > > > >  
> > > > > >  	data->clk_sec = devm_clk_get(&pdev->dev,
> > > > > > "tmu_triminfo_apbif"); if (IS_ERR(data->clk_sec)) {
> > > > > >  		if (data->soc ==
> > > > > > SOC_ARCH_EXYNOS5420_TRIMINFO) { dev_err(&pdev->dev, "Failed
> > > > > > to get triminfo clock\n");
> > > > > > -			return PTR_ERR(data->clk_sec);
> > > > > > +			ret = PTR_ERR(data->clk_sec);
> > > > > > +			goto err_sensor;
> > > > > >  		}
> > > > > >  	} else {
> > > > > >  		ret = clk_prepare(data->clk_sec);
> > > > > >  		if (ret) {
> > > > > >  			dev_err(&pdev->dev, "Failed to get
> > > > > > clock\n");
> > > > > > -			return ret;
> > > > > > +			goto err_sensor;
> > > > > >  		}
> > > > > >  	}
> > > > > >  
> > > > > > @@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct
> > > > > > platform_device *pdev) goto err_clk;
> > > > > >  	}
> > > > > >  
> > > > > > -	exynos_tmu_control(pdev, true);
> > > > > > -
> > > > > > -	/* Allocate a structure to register with the exynos
> > > > > > core thermal */
> > > > > > -	sensor_conf = devm_kzalloc(&pdev->dev,
> > > > > > -				sizeof(struct
> > > > > > thermal_sensor_conf), GFP_KERNEL);
> > > > > > -	if (!sensor_conf) {
> > > > > > -		ret = -ENOMEM;
> > > > > > -		goto err_clk;
> > > > > > -	}
> > > > > > -	sprintf(sensor_conf->name, "therm_zone%d",
> > > > > > data->id);
> > > > > > -	sensor_conf->read_temperature = (int (*)(void
> > > > > > *))exynos_tmu_read;
> > > > > > -	sensor_conf->write_emul_temp =
> > > > > > -		(int (*)(void *, unsigned
> > > > > > long))exynos_tmu_set_emulation;
> > > > > > -	sensor_conf->driver_data = data;
> > > > > > -	sensor_conf->trip_data.trip_count =
> > > > > > pdata->trigger_enable[0] +
> > > > > > -			pdata->trigger_enable[1] +
> > > > > > pdata->trigger_enable[2]+
> > > > > > -			pdata->trigger_enable[3];
> > > > > > -
> > > > > > -	for (i = 0; i < sensor_conf->trip_data.trip_count;
> > > > > > i++) {
> > > > > > -		sensor_conf->trip_data.trip_val[i] =
> > > > > > -			pdata->threshold +
> > > > > > pdata->trigger_levels[i];
> > > > > > -		sensor_conf->trip_data.trip_type[i] =
> > > > > > -
> > > > > > pdata->trigger_type[i];
> > > > > > -	}
> > > > > > -
> > > > > > -	sensor_conf->trip_data.trigger_falling =
> > > > > > pdata->threshold_falling; -
> > > > > > -	sensor_conf->dev = &pdev->dev;
> > > > > > -	/* Register the sensor with thermal management
> > > > > > interface */
> > > > > > -	ret = exynos_register_thermal(sensor_conf);
> > > > > > -	if (ret) {
> > > > > > -		if (ret != -EPROBE_DEFER)
> > > > > > -			dev_err(&pdev->dev,
> > > > > > -				"Failed to register thermal
> > > > > > interface: %d\n",
> > > > > > -				ret);
> > > > > > -		goto err_clk;
> > > > > > -	}
> > > > > > -	data->reg_conf = sensor_conf;
> > > > > > -
> > > > > >  	ret = devm_request_irq(&pdev->dev, data->irq,
> > > > > > exynos_tmu_irq, IRQF_TRIGGER_RISING | IRQF_SHARED,
> > > > > > dev_name(&pdev->dev), data); if (ret) {
> > > > > > @@ -935,21 +1030,31 @@ static int exynos_tmu_probe(struct
> > > > > > platform_device *pdev) goto err_clk;
> > > > > >  	}
> > > > > >  
> > > > > > +	ret = exynos_tmu_initialize(pdev);
> > > > > > +	if (ret) {
> > > > > > +		dev_err(&pdev->dev, "Failed to initialize
> > > > > > TMU\n");
> > > > > > +		goto err_clk;
> > > > > > +	}
> > > > > > +	exynos_tmu_control(pdev, true);
> > > > > >  	return 0;
> > > > > > +
> > > > > >  err_clk:
> > > > > >  	clk_unprepare(data->clk);
> > > > > >  err_clk_sec:
> > > > > >  	if (!IS_ERR(data->clk_sec))
> > > > > >  		clk_unprepare(data->clk_sec);
> > > > > > +err_sensor:
> > > > > > +	thermal_zone_of_sensor_unregister(&pdev->dev,
> > > > > > data->tzd); +
> > > > > >  	return ret;
> > > > > >  }
> > > > > >  
> > > > > >  static int exynos_tmu_remove(struct platform_device *pdev)
> > > > > >  {
> > > > > >  	struct exynos_tmu_data *data =
> > > > > > platform_get_drvdata(pdev);
> > > > > > +	struct thermal_zone_device *tzd = data->tzd;
> > > > > >  
> > > > > > -	exynos_unregister_thermal(data->reg_conf);
> > > > > > -
> > > > > > +	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
> > > > > >  	exynos_tmu_control(pdev, false);
> > > > > >  
> > > > > >  	clk_unprepare(data->clk);
> > > > > > diff --git a/drivers/thermal/samsung/exynos_tmu.h
> > > > > > b/drivers/thermal/samsung/exynos_tmu.h index
> > > > > > 627dec9..d876d4c 100644 ---
> > > > > > a/drivers/thermal/samsung/exynos_tmu.h +++
> > > > > > b/drivers/thermal/samsung/exynos_tmu.h @@ -23,8 +23,7 @@
> > > > > >  #ifndef _EXYNOS_TMU_H
> > > > > >  #define _EXYNOS_TMU_H
> > > > > >  #include <linux/cpu_cooling.h>
> > > > > > -
> > > > > > -#include "exynos_thermal_common.h"
> > > > > > +#include <dt-bindings/thermal/thermal_exynos.h>
> > > > > >  
> > > > > >  enum soc_type {
> > > > > >  	SOC_ARCH_EXYNOS3250 = 1,
> > > > > > @@ -36,38 +35,9 @@ enum soc_type {
> > > > > >  	SOC_ARCH_EXYNOS5420_TRIMINFO,
> > > > > >  	SOC_ARCH_EXYNOS5440,
> > > > > >  };
> > > > > > -#include <dt-bindings/thermal/thermal_exynos.h>
> > > > > >  
> > > > > >  /**
> > > > > >   * struct exynos_tmu_platform_data
> > > > > > - * @threshold: basic temperature for generating interrupt
> > > > > > - *	       25 <= threshold <= 125 [unit: degree
> > > > > > Celsius]
> > > > > > - * @threshold_falling: differntial value for setting
> > > > > > threshold
> > > > > > - *		       of temperature falling interrupt.
> > > > > > - * @trigger_levels: array for each interrupt levels
> > > > > > - *	[unit: degree Celsius]
> > > > > > - *	0: temperature for trigger_level0 interrupt
> > > > > > - *	   condition for trigger_level0 interrupt:
> > > > > > - *		current temperature > threshold +
> > > > > > trigger_levels[0]
> > > > > > - *	1: temperature for trigger_level1 interrupt
> > > > > > - *	   condition for trigger_level1 interrupt:
> > > > > > - *		current temperature > threshold +
> > > > > > trigger_levels[1]
> > > > > > - *	2: temperature for trigger_level2 interrupt
> > > > > > - *	   condition for trigger_level2 interrupt:
> > > > > > - *		current temperature > threshold +
> > > > > > trigger_levels[2]
> > > > > > - *	3: temperature for trigger_level3 interrupt
> > > > > > - *	   condition for trigger_level3 interrupt:
> > > > > > - *		current temperature > threshold +
> > > > > > trigger_levels[3]
> > > > > > - * @trigger_type: defines the type of trigger. Possible
> > > > > > values are,
> > > > > > - *	THROTTLE_ACTIVE trigger type
> > > > > > - *	THROTTLE_PASSIVE trigger type
> > > > > > - *	SW_TRIP trigger type
> > > > > > - *	HW_TRIP
> > > > > > - * @trigger_enable[]: array to denote which trigger levels
> > > > > > are enabled.
> > > > > > - *	1 = enable trigger_level[] interrupt,
> > > > > > - *	0 = disable trigger_level[] interrupt
> > > > > > - * @max_trigger_level: max trigger level supported by the
> > > > > > TMU
> > > > > > - * @non_hw_trigger_levels: number of defined non-hardware
> > > > > > trigger levels
> > > > > >   * @gain: gain of amplifier in the positive-TC generator
> > > > > > block
> > > > > >   *	0 < gain <= 15
> > > > > >   * @reference_voltage: reference voltage of amplifier
> > > > > > @@ -79,21 +49,12 @@ enum soc_type {
> > > > > >   * @efuse_value: platform defined fuse value
> > > > > >   * @min_efuse_value: minimum valid trimming data
> > > > > >   * @max_efuse_value: maximum valid trimming data
> > > > > > - * @first_point_trim: temp value of the first point
> > > > > > trimming
> > > > > > - * @second_point_trim: temp value of the second point
> > > > > > trimming
> > > > > >   * @default_temp_offset: default temperature offset in
> > > > > > case of no trimming
> > > > > >   * @cal_type: calibration type for temperature
> > > > > >   *
> > > > > >   * This structure is required for configuration of
> > > > > > exynos_tmu driver. */
> > > > > >  struct exynos_tmu_platform_data {
> > > > > > -	u8 threshold;
> > > > > > -	u8 threshold_falling;
> > > > > > -	u8 trigger_levels[MAX_TRIP_COUNT];
> > > > > > -	enum trigger_type trigger_type[MAX_TRIP_COUNT];
> > > > > > -	bool trigger_enable[MAX_TRIP_COUNT];
> > > > > > -	u8 max_trigger_level;
> > > > > > -	u8 non_hw_trigger_levels;
> > > > > >  	u8 gain;
> > > > > >  	u8 reference_voltage;
> > > > > >  	u8 noise_cancel_mode;
> > > > > > @@ -110,18 +71,6 @@ struct exynos_tmu_platform_data {
> > > > > >  	u32 cal_mode;
> > > > > >  };
> > > > > >  
> > > > > > -/**
> > > > > > - * struct exynos_tmu_init_data
> > > > > > - * @tmu_count: number of TMU instances.
> > > > > > - * @tmu_data: platform data of all TMU instances.
> > > > > > - * This structure is required to store data for
> > > > > > multi-instance exynos tmu
> > > > > > - * driver.
> > > > > > - */
> > > > > > -struct exynos_tmu_init_data {
> > > > > > -	int tmu_count;
> > > > > > -	struct exynos_tmu_platform_data tmu_data[];
> > > > > > -};
> > > > > > -
> > > > > >  extern struct exynos_tmu_init_data const
> > > > > > exynos3250_default_tmu_data; extern struct
> > > > > > exynos_tmu_init_data const exynos4210_default_tmu_data;
> > > > > > extern struct exynos_tmu_init_data const
> > > > > > exynos4412_default_tmu_data; -- 2.0.0.rc2
> > > > > > 
> > > > 
> > > > 
> > > > 
> > > > -- 
> > > > Best regards,
> > > > 
> > > > Lukasz Majewski
> > > > 
> > > > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
> > 
> > 
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* RE: [PATCH v4 00/17] thermal: exynos: Thermal code rework to use device tree
  2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
                     ` (17 preceding siblings ...)
  2015-01-17  7:17   ` [PATCH v4 00/17] thermal: exynos: Thermal code rework to use device tree Abhilash Kesavan
@ 2015-01-23  7:42   ` Kukjin Kim
  2015-01-23  9:59     ` Lukasz Majewski
  18 siblings, 1 reply; 288+ messages in thread
From: Kukjin Kim @ 2015-01-23  7:42 UTC (permalink / raw)
  To: 'Lukasz Majewski', 'Eduardo Valentin',
	'Zhang Rui', 'Kukjin Kim'
  Cc: 'Linux PM list',
	linux-samsung-soc, 'Bartlomiej Zolnierkiewicz',
	'Lukasz Majewski', 'Amit Daniel Kachhap',
	'Abhilash Kesavan', 'Kyungmin Park',
	'Chanwoo Choi', 'Abhilash Kesavan'

Lukasz Majewski wrote:
> 
Hi,

> 1. Introduction
> 
> Following patches aim to clean up the current implementation of the thermal
> framework on Exynos devices.
> 
> The main goal was to use a generic code for reading thermal configuration
> (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
> were removed.
> 
> Around 400 lines of code (LOC) were removed directly by this patch, which
> is around 20% of the Exynos thermal code base.
> 
> This work should NOT bring any functional changes to Exynos thermal
> subsystem.
> 
Sounds great to use generic some framework in kernel.

> 2. Patch-set structure
> 
> Then the cpu_cooling functionality has been preserved to allow cooling
> devices by reducing operating frequency. Definition of trip points and
> cpufreq's cooling properties were moved to device tree.
> 
> Then the rework of the way in which configuration data is provided to
> the Exynos thermal subsystem was performed. Now device tree is used for
> configuration.
> 
> 3. Dead code removal
> 
> Thermal support for some SoCs, previously available in the exynos_tmu_data.c
> file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.
> 
> Moreover, support for cpu_cooling devices was preserved only on those
> SoCs which had available and working cpufreq driver.
> 
> 4. Testing
> 
> Test devices:
> - Exynos4210 - Trats (TMU zone + cpu_cooling)
> - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> - Exynos5420 - Arndale-octa (only TMU zones)
> 
Thanks for your check on the boards...

> Unfortunately, I don't posses Exynos5440 for testing. Its functionality
> has been preserved in the code, but not tested on the hardware. I would
> be grateful for help in testing.
> 
I think, Amit can do it on exynos5440 ;)

> 
> 5. This work apply on the following tree:
> 
> kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
> 
> 
> Lukasz Majewski (17):
>   thermal: exynos: cosmetic: Correct comment format
>   thermal: exynos: Provide thermal_exynos.h file to be included in
>     device tree files
>   arm: dts: trats: Enable TMU on the Exynos4210 trats device
>   arm: dts: odroid: Add LD010 regulator node necessary for TMU on Odroid
>   arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
>   arm: dts: Adding CPU cooling binding for Exynos SoCs
>   thermal: exynos: Modify exynos thermal code to use device tree for cpu
>     cooling configuration
>   thermal: exynos: dts: Add default definition of the TMU sensor
>     parameter
>   dts: Documentation: Extending documentation entry for exynos-thermal
>   thermal: dts: Default trip points definition for Exynos5420 SoCs
>   thermal: exynos: dts: Define default thermal-zones for Exynos4
>   thermal: dts: exynos: Trip points and sensor configuration data for
>     Exynos5440
>   dts: Documentation: Update exynos-thermal.txt example for Exynos5440
>   thermal: exynos: dts: Provide device tree bindings identical to the
>     one in exynos_tmu_data.c
>   thermal: samsung: core: Exynos TMU rework to use device tree for
>     configuration
>   thermal: exynos: Remove exynos_thermal_common.[c|h] files
>   thermal: exynos: Remove exynos_tmu_data.c file
> 
>  .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
>  arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
>  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
>  arch/arm/boot/dts/exynos4.dtsi                     |   4 +
>  arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
>  arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
>  arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
>  arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
>  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
>  arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
>  arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
>  arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
>  arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
>  arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
>  arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
>  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
>  arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
>  arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
>  drivers/cpufreq/exynos-cpufreq.c                   |  30 +-
>  drivers/thermal/samsung/Makefile                   |   2 -
>  drivers/thermal/samsung/exynos_thermal_common.c    | 427 ---------------------
>  drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
>  drivers/thermal/samsung/exynos_tmu.c               | 354 +++++++++++------
>  drivers/thermal/samsung/exynos_tmu.h               |  68 +---
>  drivers/thermal/samsung/exynos_tmu_data.c          | 264 -------------
>  include/dt-bindings/thermal/thermal_exynos.h       |  28 ++
>  26 files changed, 638 insertions(+), 1001 deletions(-)
>  create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
>  delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
>  create mode 100644 include/dt-bindings/thermal/thermal_exynos.h
> 
> --

I hope will apply DT changes in Samsung tree. Is it OK to thermal tree?

Thanks,
Kukjin

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v4 00/17] thermal: exynos: Thermal code rework to use device tree
  2015-01-23  7:42   ` Kukjin Kim
@ 2015-01-23  9:59     ` Lukasz Majewski
  2015-01-23 11:00       ` Kukjin Kim
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23  9:59 UTC (permalink / raw)
  To: Kukjin Kim
  Cc: 'Eduardo Valentin', 'Zhang Rui',
	'Linux PM list',
	linux-samsung-soc, 'Bartlomiej Zolnierkiewicz',
	'Lukasz Majewski', 'Amit Daniel Kachhap',
	'Abhilash Kesavan', 'Kyungmin Park',
	'Chanwoo Choi', 'Abhilash Kesavan'

Hi Kukjin,

> Lukasz Majewski wrote:
> > 
> Hi,
> 
> > 1. Introduction
> > 
> > Following patches aim to clean up the current implementation of the
> > thermal framework on Exynos devices.
> > 
> > The main goal was to use a generic code for reading thermal
> > configuration (of-thermal.c). Due to that redundant
> > exynos_thermal_common.[h|c] files were removed.
> > 
> > Around 400 lines of code (LOC) were removed directly by this patch,
> > which is around 20% of the Exynos thermal code base.
> > 
> > This work should NOT bring any functional changes to Exynos thermal
> > subsystem.
> > 
> Sounds great to use generic some framework in kernel.
> 
> > 2. Patch-set structure
> > 
> > Then the cpu_cooling functionality has been preserved to allow
> > cooling devices by reducing operating frequency. Definition of trip
> > points and cpufreq's cooling properties were moved to device tree.
> > 
> > Then the rework of the way in which configuration data is provided
> > to the Exynos thermal subsystem was performed. Now device tree is
> > used for configuration.
> > 
> > 3. Dead code removal
> > 
> > Thermal support for some SoCs, previously available in the
> > exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3,
> > they didn't have TMU bindings.
> > 
> > Moreover, support for cpu_cooling devices was preserved only on
> > those SoCs which had available and working cpufreq driver.
> > 
> > 4. Testing
> > 
> > Test devices:
> > - Exynos4210 - Trats (TMU zone + cpu_cooling)
> > - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> > - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> > - Exynos5420 - Arndale-octa (only TMU zones)
> > 
> Thanks for your check on the boards...
> 
> > Unfortunately, I don't posses Exynos5440 for testing. Its
> > functionality has been preserved in the code, but not tested on the
> > hardware. I would be grateful for help in testing.
> > 
> I think, Amit can do it on exynos5440 ;)
> 
> > 
> > 5. This work apply on the following tree:
> > 
> > kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> > SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
> > 
> > 
> > Lukasz Majewski (17):
> >   thermal: exynos: cosmetic: Correct comment format
> >   thermal: exynos: Provide thermal_exynos.h file to be included in
> >     device tree files
> >   arm: dts: trats: Enable TMU on the Exynos4210 trats device
> >   arm: dts: odroid: Add LD010 regulator node necessary for TMU on
> > Odroid arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3
> > device arm: dts: Adding CPU cooling binding for Exynos SoCs
> >   thermal: exynos: Modify exynos thermal code to use device tree
> > for cpu cooling configuration
> >   thermal: exynos: dts: Add default definition of the TMU sensor
> >     parameter
> >   dts: Documentation: Extending documentation entry for
> > exynos-thermal thermal: dts: Default trip points definition for
> > Exynos5420 SoCs thermal: exynos: dts: Define default thermal-zones
> > for Exynos4 thermal: dts: exynos: Trip points and sensor
> > configuration data for Exynos5440
> >   dts: Documentation: Update exynos-thermal.txt example for
> > Exynos5440 thermal: exynos: dts: Provide device tree bindings
> > identical to the one in exynos_tmu_data.c
> >   thermal: samsung: core: Exynos TMU rework to use device tree for
> >     configuration
> >   thermal: exynos: Remove exynos_thermal_common.[c|h] files
> >   thermal: exynos: Remove exynos_tmu_data.c file
> > 
> >  .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
> >  arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
> >  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
> >  arch/arm/boot/dts/exynos4.dtsi                     |   4 +
> >  arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
> >  arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
> >  arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
> >  arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
> >  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
> >  arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
> >  arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
> >  arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
> >  arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
> >  arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
> >  arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
> >  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
> >  arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
> >  arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
> >  drivers/cpufreq/exynos-cpufreq.c                   |  30 +-
> >  drivers/thermal/samsung/Makefile                   |   2 -
> >  drivers/thermal/samsung/exynos_thermal_common.c    | 427
> > ---------------------
> > drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
> > drivers/thermal/samsung/exynos_tmu.c               | 354
> > +++++++++++------
> > drivers/thermal/samsung/exynos_tmu.h               |  68 +---
> > drivers/thermal/samsung/exynos_tmu_data.c          | 264
> > ------------- include/dt-bindings/thermal/thermal_exynos.h       |
> > 28 ++ 26 files changed, 638 insertions(+), 1001 deletions(-) create
> > mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi create mode
> > 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi create
> > mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi create
> > mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
> > create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
> > delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
> > delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
> > delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c create
> > mode 100644 include/dt-bindings/thermal/thermal_exynos.h
> > 
> > --
> 
> I hope will apply DT changes in Samsung tree. Is it OK to thermal
> tree?

I think that it is up to you and Eduardo to decide :-). 

I'd personally prefer to add this patch set at once to Eduardo's tree
(of course with your ACKs).

> 
> Thanks,
> Kukjin
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* RE: [PATCH v4 00/17] thermal: exynos: Thermal code rework to use device tree
  2015-01-23  9:59     ` Lukasz Majewski
@ 2015-01-23 11:00       ` Kukjin Kim
  2015-01-23 14:45         ` Eduardo Valentin
  0 siblings, 1 reply; 288+ messages in thread
From: Kukjin Kim @ 2015-01-23 11:00 UTC (permalink / raw)
  To: 'Lukasz Majewski', 'Kukjin Kim'
  Cc: 'Eduardo Valentin', 'Zhang Rui',
	'Linux PM list',
	linux-samsung-soc, 'Bartlomiej Zolnierkiewicz',
	'Lukasz Majewski', 'Amit Daniel Kachhap',
	'Abhilash Kesavan', 'Kyungmin Park',
	'Chanwoo Choi', 'Abhilash Kesavan'

Lukasz Majewski wrote:
> 
> Hi Kukjin,
> 
Hi,

> > Lukasz Majewski wrote:
> > >
> > Hi,
> >
> > > 1. Introduction
> > >
> > > Following patches aim to clean up the current implementation of the
> > > thermal framework on Exynos devices.
> > >
> > > The main goal was to use a generic code for reading thermal
> > > configuration (of-thermal.c). Due to that redundant
> > > exynos_thermal_common.[h|c] files were removed.
> > >
> > > Around 400 lines of code (LOC) were removed directly by this patch,
> > > which is around 20% of the Exynos thermal code base.
> > >
> > > This work should NOT bring any functional changes to Exynos thermal
> > > subsystem.
> > >
> > Sounds great to use generic some framework in kernel.
> >
> > > 2. Patch-set structure
> > >
> > > Then the cpu_cooling functionality has been preserved to allow
> > > cooling devices by reducing operating frequency. Definition of trip
> > > points and cpufreq's cooling properties were moved to device tree.
> > >
> > > Then the rework of the way in which configuration data is provided
> > > to the Exynos thermal subsystem was performed. Now device tree is
> > > used for configuration.
> > >
> > > 3. Dead code removal
> > >
> > > Thermal support for some SoCs, previously available in the
> > > exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3,
> > > they didn't have TMU bindings.
> > >
> > > Moreover, support for cpu_cooling devices was preserved only on
> > > those SoCs which had available and working cpufreq driver.
> > >
> > > 4. Testing
> > >
> > > Test devices:
> > > - Exynos4210 - Trats (TMU zone + cpu_cooling)
> > > - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> > > - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> > > - Exynos5420 - Arndale-octa (only TMU zones)
> > >
> > Thanks for your check on the boards...
> >
> > > Unfortunately, I don't posses Exynos5440 for testing. Its
> > > functionality has been preserved in the code, but not tested on the
> > > hardware. I would be grateful for help in testing.
> > >
> > I think, Amit can do it on exynos5440 ;)
> >
> > >
> > > 5. This work apply on the following tree:
> > >
> > > kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> > > SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
> > >
> > >
> > > Lukasz Majewski (17):
> > >   thermal: exynos: cosmetic: Correct comment format
> > >   thermal: exynos: Provide thermal_exynos.h file to be included in
> > >     device tree files
> > >   arm: dts: trats: Enable TMU on the Exynos4210 trats device
> > >   arm: dts: odroid: Add LD010 regulator node necessary for TMU on
> > > Odroid arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3
> > > device arm: dts: Adding CPU cooling binding for Exynos SoCs
> > >   thermal: exynos: Modify exynos thermal code to use device tree
> > > for cpu cooling configuration
> > >   thermal: exynos: dts: Add default definition of the TMU sensor
> > >     parameter
> > >   dts: Documentation: Extending documentation entry for
> > > exynos-thermal thermal: dts: Default trip points definition for
> > > Exynos5420 SoCs thermal: exynos: dts: Define default thermal-zones
> > > for Exynos4 thermal: dts: exynos: Trip points and sensor
> > > configuration data for Exynos5440
> > >   dts: Documentation: Update exynos-thermal.txt example for
> > > Exynos5440 thermal: exynos: dts: Provide device tree bindings
> > > identical to the one in exynos_tmu_data.c
> > >   thermal: samsung: core: Exynos TMU rework to use device tree for
> > >     configuration
> > >   thermal: exynos: Remove exynos_thermal_common.[c|h] files
> > >   thermal: exynos: Remove exynos_tmu_data.c file
> > >
> > >  .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
> > >  arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
> > >  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
> > >  arch/arm/boot/dts/exynos4.dtsi                     |   4 +
> > >  arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
> > >  arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
> > >  arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
> > >  arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
> > >  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
> > >  arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
> > >  arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
> > >  arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
> > >  arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
> > >  arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
> > >  arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
> > >  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
> > >  arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
> > >  arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
> > >  drivers/cpufreq/exynos-cpufreq.c                   |  30 +-
> > >  drivers/thermal/samsung/Makefile                   |   2 -
> > >  drivers/thermal/samsung/exynos_thermal_common.c    | 427
> > > ---------------------
> > > drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
> > > drivers/thermal/samsung/exynos_tmu.c               | 354
> > > +++++++++++------
> > > drivers/thermal/samsung/exynos_tmu.h               |  68 +---
> > > drivers/thermal/samsung/exynos_tmu_data.c          | 264
> > > ------------- include/dt-bindings/thermal/thermal_exynos.h       |
> > > 28 ++ 26 files changed, 638 insertions(+), 1001 deletions(-) create
> > > mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi create mode
> > > 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi create
> > > mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi create
> > > mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
> > > create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
> > > delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
> > > delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
> > > delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c create
> > > mode 100644 include/dt-bindings/thermal/thermal_exynos.h
> > >
> > > --
> >
> > I hope will apply DT changes in Samsung tree. Is it OK to thermal
> > tree?
> 
> I think that it is up to you and Eduardo to decide :-).
> 
> I'd personally prefer to add this patch set at once to Eduardo's tree
> (of course with your ACKs).
> 
If so, we could see too many useless merge conflicts. Because your patches
touch most of exynos DT stuff and that's why DT changes should be handled in
Samsung tree if there is no problem ;) Let's wait for thermal guys.

- Kukjin


^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v6 00/18] thermal: exynos: Thermal code rework to use device tree
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (18 preceding siblings ...)
  2015-01-21  1:55   ` [PATCH v5 00/18] thermal: exynos: Thermal code rework to use device tree Eduardo Valentin
@ 2015-01-23 12:09   ` Lukasz Majewski
  2015-01-23 12:09     ` [PATCH v6 01/18] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
                       ` (17 more replies)
  2015-01-23 12:14   ` [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered Lukasz Majewski
  20 siblings, 18 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

1. Introduction

Following patches aim to clean up the current implementation of the thermal
framework on Exynos devices.

The main goal was to use a generic code for reading thermal configuration
(of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
were removed.

Around 400 lines of code (LOC) were removed directly by this patch, which
is around 20% of the Exynos thermal code base.

This work should NOT bring any functional changes to Exynos thermal 
subsystem.

2. Patch-set structure

Then the cpu_cooling functionality has been preserved to allow cooling
devices by reducing operating frequency. Definition of trip points and
cpufreq's cooling properties were moved to device tree.

Then the rework of the way in which configuration data is provided to
the Exynos thermal subsystem was performed. Now device tree is used for
configuration.

3. Dead code removal

Thermal support for some SoCs, previously available in the exynos_tmu_data.c 
file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.

Moreover, support for cpu_cooling devices was preserved only on those
SoCs which had available and working cpufreq driver.

4. Testing

Test devices:
- Exynos4210 - Trats (TMU zone + cpu_cooling)
- Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
- Exynos5250 - Arndale (TMU zone + cpu_cooling)
- Exynos5420 - Arndale-octa (only TMU zones)

Unfortunately, I don't posses Exynos5440 for testing. Its functionality
has been preserved in the code, but not tested on the hardware. I would
be grateful for help in testing.


5. This work apply on the following tree:

kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
SHA1: 1813d80874699145f04af6b05ebab0a6419001fb


Lukasz Majewski (18):
  thermal: exynos: cosmetic: Correct comment format
  thermal: exynos: Provide thermal_exynos.h file to be included in
    device tree files
  arm: dts: trats: Enable TMU on the Exynos4210 trats device
  arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid
  arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
  arm: dts: Adding CPU cooling binding for Exynos SoCs
  thermal: exynos: Modify exynos thermal code to use device tree for cpu
    cooling configuration
  cpufreq: exynos: Use device tree to determine if cpufreq cooling
    should be registered
  thermal: exynos: dts: Add default definition of the TMU sensor
    parameter
  dts: Documentation: Extending documentation entry for exynos-thermal
  thermal: dts: Default trip points definition for Exynos5420 SoCs
  thermal: exynos: dts: Define default thermal-zones for Exynos4
  thermal: dts: exynos: Trip points and sensor configuration data for
    Exynos5440
  dts: Documentation: Update exynos-thermal.txt example for Exynos5440
  thermal: exynos: dts: Provide device tree bindings identical to the
    one in exynos_tmu_data.c
  thermal: samsung: core: Exynos TMU rework to use device tree for
    configuration
  thermal: exynos: Remove exynos_thermal_common.[c|h] files
  thermal: exynos: Remove exynos_tmu_data.c file

 .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
 arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   4 +
 arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
 arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
 arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
 arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
 arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
 arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
 arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
 arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
 arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
 drivers/cpufreq/exynos-cpufreq.c                   |  33 +-
 drivers/thermal/samsung/Makefile                   |   2 -
 drivers/thermal/samsung/exynos_thermal_common.c    | 427 ---------------------
 drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
 drivers/thermal/samsung/exynos_tmu.c               | 348 +++++++++++------
 drivers/thermal/samsung/exynos_tmu.h               |  76 +---
 drivers/thermal/samsung/exynos_tmu_data.c          | 264 -------------
 include/dt-bindings/thermal/thermal_exynos.h       |  28 ++
 26 files changed, 636 insertions(+), 1008 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

-- 
2.0.0.rc2

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v6 01/18] thermal: exynos: cosmetic: Correct comment format
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
@ 2015-01-23 12:09     ` Lukasz Majewski
  2015-01-23 12:09     ` [PATCH v6 02/18] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
                       ` (16 subsequent siblings)
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 drivers/thermal/samsung/exynos_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index d2f1e62..5000727 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -576,7 +576,7 @@ out:
 #define exynos5440_tmu_set_emulation NULL
 static int exynos_tmu_set_emulation(void *drv_data,	unsigned long temp)
 	{ return -EINVAL; }
-#endif/*CONFIG_THERMAL_EMULATION*/
+#endif /* CONFIG_THERMAL_EMULATION */
 
 static int exynos4210_tmu_read(struct exynos_tmu_data *data)
 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 02/18] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
  2015-01-23 12:09     ` [PATCH v6 01/18] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
@ 2015-01-23 12:09     ` Lukasz Majewski
  2015-01-23 12:09     ` [PATCH v6 03/18] arm: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
                       ` (15 subsequent siblings)
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

This patch is a preparatory patch to be able to read Exynos thermal
configuration from the device tree.

It turned out that DTC is not able to interpret enums properly and hence
it is necessary to #define those values explicitly.

For this reason the ./include/dt-bindings/thermal/thermal_exynos.h file
has been introduced.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Restore 'enum soc_type type' since TMU sensor type will be extracted from
  device tree compatible
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 drivers/thermal/samsung/exynos_tmu.h         | 12 +++---------
 include/dt-bindings/thermal/thermal_exynos.h | 28 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 9 deletions(-)
 create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index da3009b..7f880d2 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -26,14 +26,6 @@
 
 #include "exynos_thermal_common.h"
 
-enum calibration_type {
-	TYPE_ONE_POINT_TRIMMING,
-	TYPE_ONE_POINT_TRIMMING_25,
-	TYPE_ONE_POINT_TRIMMING_85,
-	TYPE_TWO_POINT_TRIMMING,
-	TYPE_NONE,
-};
-
 enum soc_type {
 	SOC_ARCH_EXYNOS3250 = 1,
 	SOC_ARCH_EXYNOS4210,
@@ -44,6 +36,7 @@ enum soc_type {
 	SOC_ARCH_EXYNOS5420_TRIMINFO,
 	SOC_ARCH_EXYNOS5440,
 };
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
@@ -115,8 +108,9 @@ struct exynos_tmu_platform_data {
 	u8 second_point_trim;
 	u8 default_temp_offset;
 
-	enum calibration_type cal_type;
 	enum soc_type type;
+	u32 cal_type;
+	u32 cal_mode;
 	struct freq_clip_table freq_tab[4];
 	unsigned int freq_tab_count;
 };
diff --git a/include/dt-bindings/thermal/thermal_exynos.h b/include/dt-bindings/thermal/thermal_exynos.h
new file mode 100644
index 0000000..0646500
--- /dev/null
+++ b/include/dt-bindings/thermal/thermal_exynos.h
@@ -0,0 +1,28 @@
+/*
+ * thermal_exynos.h - Samsung EXYNOS TMU device tree definitions
+ *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef _EXYNOS_THERMAL_TMU_DT_H
+#define _EXYNOS_THERMAL_TMU_DT_H
+
+#define TYPE_ONE_POINT_TRIMMING 0
+#define TYPE_ONE_POINT_TRIMMING_25 1
+#define TYPE_ONE_POINT_TRIMMING_85 2
+#define TYPE_TWO_POINT_TRIMMING 3
+#define TYPE_NONE 4
+
+#endif /* _EXYNOS_THERMAL_TMU_DT_H */
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 03/18] arm: dts: trats: Enable TMU on the Exynos4210 trats device
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
  2015-01-23 12:09     ` [PATCH v6 01/18] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
  2015-01-23 12:09     ` [PATCH v6 02/18] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
@ 2015-01-23 12:09     ` Lukasz Majewski
  2015-01-23 12:09     ` [PATCH v6 04/18] arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid Lukasz Majewski
                       ` (14 subsequent siblings)
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

The thermal IP block (Thermal Management Unit) called TMU has been enabled
in this device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Patch title has been changed from thermal: dts: arm to arm: dts: trats
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 arch/arm/boot/dts/exynos4210-trats.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index 7208362..61009f4 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -424,6 +424,10 @@
 		status = "okay";
 	};
 
+	tmu@100C0000 {
+		status = "okay";
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 04/18] arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (2 preceding siblings ...)
  2015-01-23 12:09     ` [PATCH v6 03/18] arm: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
@ 2015-01-23 12:09     ` Lukasz Majewski
  2015-01-23 12:09     ` [PATCH v6 05/18] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
                       ` (13 subsequent siblings)
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Patch title has been changed from thermal: dts: exynos to arm: dts: Odroid
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 3fbf588..0adb57c 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -231,6 +231,13 @@
 					regulator-always-on;
 				};
 
+				ldo10_reg: LDO10 {
+					regulator-name = "VDD18_MIPIHSI_1.8V";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <1800000>;
+					regulator-always-on;
+				};
+
 				ldo11_reg: LDO11 {
 					regulator-name = "VDD18_ABB1_1.8V";
 					regulator-min-microvolt = <1800000>;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 05/18] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (3 preceding siblings ...)
  2015-01-23 12:09     ` [PATCH v6 04/18] arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid Lukasz Majewski
@ 2015-01-23 12:09     ` Lukasz Majewski
  2015-01-23 12:23       ` Aw: " Tobias Jakobi
  2015-01-23 12:09     ` [PATCH v6 06/18] arm: dts: Adding CPU cooling binding for Exynos SoCs Lukasz Majewski
                       ` (12 subsequent siblings)
  17 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

This commit enables TMU IP block on the Exynos4412 Odroid U3
device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- Rename patch title from "thermal: dts:" to "arm: dts: odroid"
Changes for v5:
- None
Changes for v6:
- None
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 0adb57c..c7517fc 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -396,6 +396,11 @@
 	ehci: ehci@12580000 {
 		status = "okay";
 	};
+
+	tmu@100C0000 {
+		vtmu-supply = <&ldo10_reg>;
+		status = "okay";
+	};
 };
 
 &pinctrl_1 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 06/18] arm: dts: Adding CPU cooling binding for Exynos SoCs
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (4 preceding siblings ...)
  2015-01-23 12:09     ` [PATCH v6 05/18] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
@ 2015-01-23 12:09     ` Lukasz Majewski
  2015-01-23 12:10     ` [PATCH v6 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
                       ` (11 subsequent siblings)
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:09 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

Presented patch aims to move data necessary for correct CPU cooling device
configuration from exynos_tmu_data.c to device tree.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Adjust CPU's DT nodes to work with newest ti-soc-thermal/next branch
- Patch title has been changed from "thermal: cpu_cooling: dts: ..."
Changes for v4:
- Spaces and tabs cleanup
Changes for v5:
- None
Changes for v6:
- None
---
 arch/arm/boot/dts/exynos4210-trats.dts          | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4210.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos4212.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4412-trats2.dts         | 15 +++++++++++++++
 arch/arm/boot/dts/exynos4412.dtsi               |  5 ++++-
 arch/arm/boot/dts/exynos5250.dtsi               | 20 +++++++++++++++++++-
 7 files changed, 76 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index 61009f4..e3879c0 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -428,6 +428,21 @@
 		status = "okay";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 2 2>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 4 4>;
+			       };
+		       };
+		};
+	};
+
 	camera {
 		pinctrl-names = "default";
 		pinctrl-0 = <>;
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index bcc9e63..2e66df8 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -35,10 +35,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@900 {
+		cpu0: cpu@900 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0x900>;
+			cooling-min-level = <4>;
+			cooling-max-level = <2>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@901 {
diff --git a/arch/arm/boot/dts/exynos4212.dtsi b/arch/arm/boot/dts/exynos4212.dtsi
index dd0a43e..5be03288 100644
--- a/arch/arm/boot/dts/exynos4212.dtsi
+++ b/arch/arm/boot/dts/exynos4212.dtsi
@@ -26,10 +26,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@A00 {
+		cpu0: cpu@A00 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@A01 {
diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index c7517fc..25b4f7d 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -401,6 +401,21 @@
 		vtmu-supply = <&ldo10_reg>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 13 13>;
+			       };
+		       };
+		};
+	};
 };
 
 &pinctrl_1 {
diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts b/arch/arm/boot/dts/exynos4412-trats2.dts
index 29231b4..52a7771 100644
--- a/arch/arm/boot/dts/exynos4412-trats2.dts
+++ b/arch/arm/boot/dts/exynos4412-trats2.dts
@@ -863,6 +863,21 @@
 		pulldown-ohm = <100000>; /* 100K */
 		io-channels = <&adc 2>;  /* Battery temperature */
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 13 13>;
+			       };
+		       };
+		};
+	};
 };
 
 &pinctrl_0 {
diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
index 0f6ec93..68ad43b 100644
--- a/arch/arm/boot/dts/exynos4412.dtsi
+++ b/arch/arm/boot/dts/exynos4412.dtsi
@@ -26,10 +26,13 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@A00 {
+		cpu0: cpu@A00 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0xA00>;
+			cooling-min-level = <13>;
+			cooling-max-level = <7>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu@A01 {
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index 0a229fc..4641d3c 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -58,11 +58,14 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@0 {
+		cpu0: cpu@0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a15";
 			reg = <0>;
 			clock-frequency = <1700000000>;
+			cooling-min-level = <15>;
+			cooling-max-level = <9>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 		cpu@1 {
 			device_type = "cpu";
@@ -241,6 +244,21 @@
 		clock-names = "tmu_apbif";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     /* Corresponds to 800MHz at freq_table */
+				     cooling-device = <&cpu0 9 9>;
+				};
+				map1 {
+				     /* Corresponds to 200MHz at freq_table */
+				     cooling-device = <&cpu0 15 15>;
+			       };
+		       };
+		};
+	};
+
 	serial@12C00000 {
 		clocks = <&clock CLK_UART0>, <&clock CLK_SCLK_UART0>;
 		clock-names = "uart", "clk_uart_baud0";
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (5 preceding siblings ...)
  2015-01-23 12:09     ` [PATCH v6 06/18] arm: dts: Adding CPU cooling binding for Exynos SoCs Lukasz Majewski
@ 2015-01-23 12:10     ` Lukasz Majewski
  2015-01-23 12:10     ` [PATCH v6 09/18] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
                       ` (10 subsequent siblings)
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:10 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

Up till now exynos_tmu_data.c was used for storing CPU cooling configuration
data. Now the Exynos thermal core code uses device tree to get this data.
For this purpose generic thermal code for configuring CPU cooling was
used.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Rewrite code responsible for registering CPU cooling device to not depend
  on explicit "/cpus/cpu@0" path since now Exynos SoCs use new cpu node
  names (e.g. cpu@A00). New approach iterates over "cpus" node children.
- Patch title changed to thermal: exynos
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- Remove exynos cpufreq related code (exynos-cpufreq.c) from this commit

---
 drivers/thermal/samsung/exynos_thermal_common.c | 122 ++++++++++++++----------
 drivers/thermal/samsung/exynos_tmu.c            |   7 --
 drivers/thermal/samsung/exynos_tmu.h            |   5 -
 drivers/thermal/samsung/exynos_tmu_data.c       |  42 +-------
 4 files changed, 73 insertions(+), 103 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 6dc3815..00aa688 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -133,47 +133,62 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
 static int exynos_bind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size, level;
-	struct freq_clip_table *tab_ptr, *clip_data;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
+	struct of_phandle_args cooling_spec;
+	unsigned long max, state = 0;
+	int ret = 0, i = 0;
 
-	tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data;
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_ptr == NULL || tab_size == 0)
+	/*
+	 * Below code is necessary to skip binding when cpufreq's
+	 * frequency table is not yet initialized.
+	 */
+	cdev->ops->get_max_state(cdev, &state);
+	if (!state && !th_zone->cool_dev_size) {
+		th_zone->cool_dev_size = 1;
+		th_zone->cool_dev[0] = cdev;
+		th_zone->bind = false;
 		return 0;
+	}
 
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
 
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
+	child = of_get_child_by_name(np, "cooling-maps");
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		clip_data = (struct freq_clip_table *)&(tab_ptr[i]);
-		level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max);
-		if (level == THERMAL_CSTATE_INVALID)
-			return 0;
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-								level, 0)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = true;
-			break;
-		default:
+	for_each_child_of_node(child, gchild) {
+		ret = of_parse_phandle_with_args(gchild, "cooling-device",
+						 "#cooling-cells",
+						 0, &cooling_spec);
+		if (ret < 0) {
+			pr_err("missing cooling_device property\n");
+			goto end;
+		}
+
+		if (cooling_spec.args_count < 2) {
 			ret = -EINVAL;
+			goto end;
 		}
+
+		max = cooling_spec.args[0];
+		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
+						     max, 0)) {
+			dev_err(data->dev,
+				"thermal error unbinding cdev inst=%d\n", i);
+
+			ret = -EINVAL;
+			goto end;
+		}
+		i++;
 	}
+	th_zone->bind = true;
+end:
+	of_node_put(child);
+	of_node_put(np);
 
 	return ret;
 }
@@ -182,16 +197,12 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 static int exynos_unbind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
-	int ret = 0, i, tab_size;
+	int ret = 0, i;
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
+	struct device_node *child, *gchild, *np;
 
-	if (th_zone->bind == false)
-		return 0;
-
-	tab_size = data->cooling_data.freq_clip_count;
-
-	if (tab_size == 0)
+	if (th_zone->bind == false || !th_zone->cool_dev_size)
 		return 0;
 
 	/* find the cooling device registered*/
@@ -203,23 +214,30 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
 	if (i == th_zone->cool_dev_size)
 		return 0;
 
-	/* Bind the thermal zone to the cpufreq cooling device */
-	for (i = 0; i < tab_size; i++) {
-		switch (GET_ZONE(i)) {
-		case MONITOR_ZONE:
-		case WARN_ZONE:
-			if (thermal_zone_unbind_cooling_device(thermal, i,
-								cdev)) {
-				dev_err(data->dev,
-					"error unbinding cdev inst=%d\n", i);
-				ret = -EINVAL;
-			}
-			th_zone->bind = false;
-			break;
-		default:
+	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
+	if (!np) {
+		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
+		return -ENOENT;
+	}
+
+	child = of_get_child_by_name(np, "cooling-maps");
+
+	i = 0;
+	for_each_child_of_node(child, gchild) {
+		if (thermal_zone_unbind_cooling_device(thermal, i,
+						       cdev)) {
+			dev_err(data->dev,
+				"error unbinding cdev inst=%d\n", i);
 			ret = -EINVAL;
+			goto end;
 		}
+		i++;
 	}
+	th_zone->bind = false;
+end:
+	of_node_put(child);
+	of_node_put(np);
+
 	return ret;
 }
 
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 5000727..ae30f6a 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -916,13 +916,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 
 	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
 
-	sensor_conf->cooling_data.freq_clip_count = pdata->freq_tab_count;
-	for (i = 0; i < pdata->freq_tab_count; i++) {
-		sensor_conf->cooling_data.freq_data[i].freq_clip_max =
-					pdata->freq_tab[i].freq_clip_max;
-		sensor_conf->cooling_data.freq_data[i].temp_level =
-					pdata->freq_tab[i].temp_level;
-	}
 	sensor_conf->dev = &pdev->dev;
 	/* Register the sensor with thermal management interface */
 	ret = exynos_register_thermal(sensor_conf);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 7f880d2..627dec9 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -83,9 +83,6 @@ enum soc_type {
  * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
- * @freq_clip_table: Table representing frequency reduction percentage.
- * @freq_tab_count: Count of the above table as frequency reduction may
- *	applicable to only some of the trigger levels.
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
@@ -111,8 +108,6 @@ struct exynos_tmu_platform_data {
 	enum soc_type type;
 	u32 cal_type;
 	u32 cal_mode;
-	struct freq_clip_table freq_tab[4];
-	unsigned int freq_tab_count;
 };
 
 /**
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
index b239100..a993f3d 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -47,15 +47,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 		.first_point_trim = 25,
 		.second_point_trim = 85,
 		.default_temp_offset = 50,
-		.freq_tab[0] = {
-			.freq_clip_max = 800 * 1000,
-			.temp_level = 85,
-			},
-		.freq_tab[1] = {
-			.freq_clip_max = 200 * 1000,
-			.temp_level = 100,
-		},
-		.freq_tab_count = 2,
 		.type = SOC_ARCH_EXYNOS4210,
 		},
 	},
@@ -87,16 +78,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 800 * 1000, \
-		.temp_level = 70, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 400 * 1000, \
-		.temp_level = 95, \
-	}, \
-	.freq_tab_count = 2
+	.default_temp_offset = 50
 
 struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 	.tmu_data = {
@@ -133,16 +115,7 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 1400 * 1000, \
-		.temp_level = 70, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 400 * 1000, \
-		.temp_level = 95, \
-	}, \
-	.freq_tab_count = 2
+	.default_temp_offset = 50
 
 struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
 	.tmu_data = {
@@ -189,16 +162,7 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
 	.max_efuse_value = 100, \
 	.first_point_trim = 25, \
 	.second_point_trim = 85, \
-	.default_temp_offset = 50, \
-	.freq_tab[0] = { \
-		.freq_clip_max = 800 * 1000, \
-		.temp_level = 85, \
-	}, \
-	.freq_tab[1] = { \
-		.freq_clip_max = 200 * 1000, \
-		.temp_level = 103, \
-	}, \
-	.freq_tab_count = 2, \
+	.default_temp_offset = 50,
 
 #define EXYNOS5260_TMU_DATA \
 	__EXYNOS5260_TMU_DATA \
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 09/18] thermal: exynos: dts: Add default definition of the TMU sensor parameter
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (6 preceding siblings ...)
  2015-01-23 12:10     ` [PATCH v6 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
@ 2015-01-23 12:10     ` Lukasz Majewski
  2015-01-23 12:10     ` [PATCH v6 10/18] dts: Documentation: Extending documentation entry for exynos-thermal Lukasz Majewski
                       ` (9 subsequent siblings)
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:10 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

Exynos 4 and 5 family of SoCs uses almost identical TMU sensor to measure the
on chip temperature. For this reason it is possible to group TMU configuration
parameters in one dts file.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- "samsung,tmu_" prefix for TMU specific properties has been added
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi | 24 +++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi

diff --git a/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
new file mode 100644
index 0000000..e3f7934
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
@@ -0,0 +1,24 @@
+/*
+ * Device tree sources for Exynos4412 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+samsung,tmu_gain = <8>;
+samsung,tmu_reference_voltage = <16>;
+samsung,tmu_noise_cancel_mode = <4>;
+samsung,tmu_efuse_value = <55>;
+samsung,tmu_min_efuse_value = <40>;
+samsung,tmu_max_efuse_value = <100>;
+samsung,tmu_first_point_trim = <25>;
+samsung,tmu_second_point_trim = <85>;
+samsung,tmu_default_temp_offset = <50>;
+samsung,tmu_cal_type = <TYPE_ONE_POINT_TRIMMING>;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 10/18] dts: Documentation: Extending documentation entry for exynos-thermal
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (7 preceding siblings ...)
  2015-01-23 12:10     ` [PATCH v6 09/18] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
@ 2015-01-23 12:10     ` Lukasz Majewski
  2015-01-23 12:10     ` [PATCH v6 11/18] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
                       ` (8 subsequent siblings)
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:10 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

Properties necessary for providing Exynos thermal configuration via device
tree.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v3:
- New patch
Changes for v4:
- Remove entry regarding Exynos5440
Changes for v5:
- None
Changes for v6:
- None

---
 .../devicetree/bindings/thermal/exynos-thermal.txt       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
index ae738f5..8497794 100644
--- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
@@ -39,6 +39,18 @@
 - vtmu-supply: This entry is optional and provides the regulator node supplying
 		voltage to TMU. If needed this entry can be placed inside
 		board/platform specific dts file.
+Following properties are mandatory (depending on SoC):
+- samsung,tmu_gain: Gain value for internal TMU operation.
+- samsung,tmu_reference_voltage: Value of TMU IP block's reference voltage
+- samsung,tmu_noise_cancel_mode: Mode for noise cancellation
+- samsung,tmu_efuse_value: Default level of temperature - it is needed when
+			   in factory fusing produced wrong value
+- samsung,tmu_min_efuse_value: Minimum temperature fused value
+- samsung,tmu_max_efuse_value: Maximum temperature fused value
+- samsung,tmu_first_point_trim: First point trimming value
+- samsung,tmu_second_point_trim: Second point trimming value
+- samsung,tmu_default_temp_offset: Default temperature offset
+- samsung,tmu_cal_type: Callibration type
 
 Example 1):
 
@@ -51,6 +63,7 @@ Example 1):
 		clock-names = "tmu_apbif";
 		status = "disabled";
 		vtmu-supply = <&tmu_regulator_node>;
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 Example 2):
@@ -70,6 +83,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 184 0>;
 		clocks = <&clock 318>, <&clock 318>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu3: tmu@1006c000 {
@@ -78,6 +92,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 185 0>;
 		clocks = <&clock 318>, <&clock 319>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_gpu: tmu@100a0000 {
@@ -86,6 +101,7 @@ Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
 		interrupts = <0 215 0>;
 		clocks = <&clock 319>, <&clock 318>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 Note: For multi-instance tmu each instance should have an alias correctly
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 11/18] thermal: dts: Default trip points definition for Exynos5420 SoCs
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (8 preceding siblings ...)
  2015-01-23 12:10     ` [PATCH v6 10/18] dts: Documentation: Extending documentation entry for exynos-thermal Lukasz Majewski
@ 2015-01-23 12:10     ` Lukasz Majewski
  2015-01-23 12:10     ` [PATCH v6 12/18] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
                       ` (7 subsequent siblings)
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:10 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

This code groups in one place default settings of trip points. It is used
in SoCs with multiple instances of TMU sensor.

Separate device tree file prevents from multiple copying of the same data.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 arch/arm/boot/dts/exynos5420-trip-points.dtsi | 35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi

diff --git a/arch/arm/boot/dts/exynos5420-trip-points.dtsi b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
new file mode 100644
index 0000000..09d6c56
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5420-trip-points.dtsi
@@ -0,0 +1,35 @@
+/*
+ * Device tree sources for default Exynos 5420 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <85000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-1 {
+		temperature = <103000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-alert-2 {
+		temperature = <110000>; /* millicelsius */
+		hysteresis = <10000>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1200000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 12/18] thermal: exynos: dts: Define default thermal-zones for Exynos4
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (9 preceding siblings ...)
  2015-01-23 12:10     ` [PATCH v6 11/18] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
@ 2015-01-23 12:10     ` Lukasz Majewski
  2015-01-23 12:10     ` [PATCH v6 13/18] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
                       ` (6 subsequent siblings)
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:10 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

Trip points corresponding to the one defined in the exynos_tmu_data.c
for Exynos4 have been included.
This thermal-zones attribute is afterwards reused for Exynos4210, Exynos4412
and Exynos5250.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi | 52 ++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi

diff --git a/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
new file mode 100644
index 0000000..506600a
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
@@ -0,0 +1,52 @@
+/*
+ * Device tree sources for Exynos4 thermal zone
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal.h>
+
+/ {
+  thermal-zones {
+	cpu_thermal: cpu-thermal {
+		thermal-sensors = <&tmu 0>;
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		trips {
+			cpu_alert0: cpu-alert-0 {
+				temperature = <70000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert1: cpu-alert-1 {
+				temperature = <95000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_alert2: cpu-alert-2 {
+				temperature = <110000>; /* millicelsius */
+				hysteresis = <10000>; /* millicelsius */
+				type = "active";
+			};
+			cpu_crit0: cpu-crit-0 {
+				temperature = <120000>; /* millicelsius */
+				hysteresis = <0>; /* millicelsius */
+				type = "critical";
+			};
+		};
+		cooling-maps {
+			map0 {
+			    trip = <&cpu_alert0>;
+			};
+			map1 {
+			    trip = <&cpu_alert1>;
+			};
+		};
+	};
+  };
+};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 13/18] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (10 preceding siblings ...)
  2015-01-23 12:10     ` [PATCH v6 12/18] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
@ 2015-01-23 12:10     ` Lukasz Majewski
  2015-01-23 12:10     ` [PATCH v6 14/18] dts: Documentation: Update exynos-thermal.txt example " Lukasz Majewski
                       ` (5 subsequent siblings)
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:10 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

This commit provides information about Exynos5440 device configuration.
Previously this information was available in exynos_tmu_data.c file.
Now it is available in the device tree.
Such approach allows reusing some common code for thermal.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- "type" property removed
- "samsung,tmu_" prefix for TMU specific properties has been added
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi | 24 ++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440-trip-points.dtsi     | 25 +++++++++++++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
 create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi

diff --git a/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
new file mode 100644
index 0000000..7b2fba0
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
@@ -0,0 +1,24 @@
+/*
+ * Device tree sources for Exynos5440 TMU sensor configuration
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <dt-bindings/thermal/thermal_exynos.h>
+
+#thermal-sensor-cells = <0>;
+samsung,tmu_gain = <5>;
+samsung,tmu_reference_voltage = <16>;
+samsung,tmu_noise_cancel_mode = <4>;
+samsung,tmu_efuse_value = <0x5d2d>;
+samsung,tmu_min_efuse_value = <16>;
+samsung,tmu_max_efuse_value = <76>;
+samsung,tmu_first_point_trim = <25>;
+samsung,tmu_second_point_trim = <70>;
+samsung,tmu_default_temp_offset = <25>;
+samsung,tmu_cal_type = <TYPE_ONE_POINT_TRIMMING>;
diff --git a/arch/arm/boot/dts/exynos5440-trip-points.dtsi b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
new file mode 100644
index 0000000..48adfa8
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
@@ -0,0 +1,25 @@
+/*
+ * Device tree sources for default Exynos5440 thermal zone definition
+ *
+ * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+polling-delay-passive = <0>;
+polling-delay = <0>;
+trips {
+	cpu-alert-0 {
+		temperature = <100000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "active";
+	};
+	cpu-crit-0 {
+		temperature = <1050000>; /* millicelsius */
+		hysteresis = <0>; /* millicelsius */
+		type = "critical";
+	};
+};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 14/18] dts: Documentation: Update exynos-thermal.txt example for Exynos5440
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (11 preceding siblings ...)
  2015-01-23 12:10     ` [PATCH v6 13/18] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
@ 2015-01-23 12:10     ` Lukasz Majewski
  2015-01-23 12:10     ` [PATCH v6 15/18] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c Lukasz Majewski
                       ` (4 subsequent siblings)
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:10 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

Updating exynos-thermal.txt documentation entry for Exynos5440

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v4:
- New patch
Changes for v5:
- None
Changes for v6:
- None
---
 Documentation/devicetree/bindings/thermal/exynos-thermal.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
index 8497794..0f44932 100644
--- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
@@ -74,6 +74,7 @@ Example 2):
 		interrupts = <0 58 0>;
 		clocks = <&clock 21>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 15/18] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (12 preceding siblings ...)
  2015-01-23 12:10     ` [PATCH v6 14/18] dts: Documentation: Update exynos-thermal.txt example " Lukasz Majewski
@ 2015-01-23 12:10     ` Lukasz Majewski
  2015-01-23 12:10     ` [PATCH v6 16/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
                       ` (3 subsequent siblings)
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:10 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

Presented device tree bindings provide data already hardcoded in the
exynos_tmu_data.c file.
After this commit, it should be possible to reuse common thermal core
framework in Exynos SoCs.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Add proper TMU entries for exynos3250.dtsi
Changes for v3:
- Remove "type" DT properties, which will be extracted from compatible
- "samsung,tmu_" prefix for TMU specific properties has been added
Changes for v4:
- Providing mandatory properties for thermal-zones (Exynos4210 and Exynos5250)
Changes for v5:
- None
Changes for v6:
- None
---
 arch/arm/boot/dts/exynos3250.dtsi |  2 ++
 arch/arm/boot/dts/exynos4.dtsi    |  4 ++++
 arch/arm/boot/dts/exynos4210.dtsi | 25 ++++++++++++++++++++++++-
 arch/arm/boot/dts/exynos4x12.dtsi |  1 +
 arch/arm/boot/dts/exynos5250.dtsi |  9 +++++++--
 arch/arm/boot/dts/exynos5420.dtsi | 28 ++++++++++++++++++++++++++++
 arch/arm/boot/dts/exynos5440.dtsi | 18 ++++++++++++++++++
 7 files changed, 84 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/exynos3250.dtsi b/arch/arm/boot/dts/exynos3250.dtsi
index 2246549..8cc078c 100644
--- a/arch/arm/boot/dts/exynos3250.dtsi
+++ b/arch/arm/boot/dts/exynos3250.dtsi
@@ -18,6 +18,7 @@
  */
 
 #include "skeleton.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 #include <dt-bindings/clock/exynos3250.h>
 
 / {
@@ -188,6 +189,7 @@
 			interrupts = <0 216 0>;
 			clocks = <&cmu CLK_TMU_APBIF>;
 			clock-names = "tmu_apbif";
+			#include "exynos4412-tmu-sensor-conf.dtsi"
 			status = "disabled";
 		};
 
diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index b8168f1..f18d746 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -645,4 +645,8 @@
 		samsung,sysreg = <&sys_reg>;
 		status = "disabled";
 	};
+
+	tmu: tmu@100C0000 {
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+	};
 };
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index 2e66df8..78a43b0 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -21,6 +21,7 @@
 
 #include "exynos4.dtsi"
 #include "exynos4210-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 
 / {
 	compatible = "samsung,exynos4210", "samsung,exynos4";
@@ -146,16 +147,38 @@
 		reg = <0x03860000 0x1000>;
 	};
 
-	tmu@100C0000 {
+	tmu: tmu@100C0000 {
 		compatible = "samsung,exynos4210-tmu";
 		interrupt-parent = <&combiner>;
 		reg = <0x100C0000 0x100>;
 		interrupts = <2 4>;
 		clocks = <&clock CLK_TMU_APBIF>;
 		clock-names = "tmu_apbif";
+		samsung,tmu_gain = <15>;
+		samsung,tmu_reference_voltage = <7>;
 		status = "disabled";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&tmu 0>;
+
+			trips {
+			      cpu_alert0: cpu-alert-0 {
+				      temperature = <85000>; /* millicelsius */
+			      };
+			      cpu_alert1: cpu-alert-1 {
+				      temperature = <100000>; /* millicelsius */
+			      };
+			      cpu_alert2: cpu-alert-2 {
+				      temperature = <110000>; /* millicelsius */
+			      };
+			};
+		};
+	};
+
 	g2d@12800000 {
 		compatible = "samsung,s5pv210-g2d";
 		reg = <0x12800000 0x1000>;
diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi
index 93b7040..3ee2031 100644
--- a/arch/arm/boot/dts/exynos4x12.dtsi
+++ b/arch/arm/boot/dts/exynos4x12.dtsi
@@ -19,6 +19,7 @@
 
 #include "exynos4.dtsi"
 #include "exynos4x12-pinctrl.dtsi"
+#include "exynos4-cpu-thermal.dtsi"
 
 / {
 	aliases {
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index 4641d3c..90211c0 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -20,7 +20,7 @@
 #include <dt-bindings/clock/exynos5250.h>
 #include "exynos5.dtsi"
 #include "exynos5250-pinctrl.dtsi"
-
+#include "exynos4-cpu-thermal.dtsi"
 #include <dt-bindings/clock/exynos-audss-clk.h>
 
 / {
@@ -236,16 +236,21 @@
 		status = "disabled";
 	};
 
-	tmu@10060000 {
+	tmu: tmu@10060000 {
 		compatible = "samsung,exynos5250-tmu";
 		reg = <0x10060000 0x100>;
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	thermal-zones {
 		cpu_thermal: cpu-thermal {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&tmu 0>;
+
 			cooling-maps {
 				map0 {
 				     /* Corresponds to 800MHz at freq_table */
diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
index 517e50f..f5771e5 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -761,6 +761,7 @@
 		interrupts = <0 65 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu1: tmu@10064000 {
@@ -769,6 +770,7 @@
 		interrupts = <0 183 0>;
 		clocks = <&clock CLK_TMU>;
 		clock-names = "tmu_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu2: tmu@10068000 {
@@ -777,6 +779,7 @@
 		interrupts = <0 184 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_cpu3: tmu@1006c000 {
@@ -785,6 +788,7 @@
 		interrupts = <0 185 0>;
 		clocks = <&clock CLK_TMU>, <&clock CLK_TMU_GPU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
 	};
 
 	tmu_gpu: tmu@100a0000 {
@@ -793,6 +797,30 @@
 		interrupts = <0 215 0>;
 		clocks = <&clock CLK_TMU_GPU>, <&clock CLK_TMU>;
 		clock-names = "tmu_apbif", "tmu_triminfo_apbif";
+		#include "exynos4412-tmu-sensor-conf.dtsi"
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmu_cpu0>;
+			#include "exynos5420-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmu_cpu1>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmu_cpu2>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		cpu3_thermal: cpu3-thermal {
+		       thermal-sensors = <&tmu_cpu3>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
+		gpu_thermal: gpu-thermal {
+		       thermal-sensors = <&tmu_gpu>;
+		       #include "exynos5420-trip-points.dtsi"
+		};
 	};
 
         watchdog: watchdog@101D0000 {
diff --git a/arch/arm/boot/dts/exynos5440.dtsi b/arch/arm/boot/dts/exynos5440.dtsi
index 8f3373c..59d9416 100644
--- a/arch/arm/boot/dts/exynos5440.dtsi
+++ b/arch/arm/boot/dts/exynos5440.dtsi
@@ -219,6 +219,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_1: tmuctrl@16011C {
@@ -227,6 +228,7 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
 	};
 
 	tmuctrl_2: tmuctrl@160120 {
@@ -235,6 +237,22 @@
 		interrupts = <0 58 0>;
 		clocks = <&clock CLK_B_125>;
 		clock-names = "tmu_apbif";
+		#include "exynos5440-tmu-sensor-conf.dtsi"
+	};
+
+	thermal-zones {
+		cpu0_thermal: cpu0-thermal {
+			thermal-sensors = <&tmuctrl_0>;
+			#include "exynos5440-trip-points.dtsi"
+		};
+		cpu1_thermal: cpu1-thermal {
+		       thermal-sensors = <&tmuctrl_1>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
+		cpu2_thermal: cpu2-thermal {
+		       thermal-sensors = <&tmuctrl_2>;
+		       #include "exynos5440-trip-points.dtsi"
+		};
 	};
 
 	sata@210000 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 16/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (13 preceding siblings ...)
  2015-01-23 12:10     ` [PATCH v6 15/18] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c Lukasz Majewski
@ 2015-01-23 12:10     ` Lukasz Majewski
  2015-01-23 12:10     ` [PATCH v6 17/18] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
                       ` (2 subsequent siblings)
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:10 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

This patch brings support for providing configuration via device tree.
Previously this data has been hardcoded in the exynos_tmu_data.c file.
Such approach was not scalable and very often required copying the whole
data.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Adjust exynos_tmu.c code to the newest ti-soc-thermal repository
- Usage of of-thermal.c exported trip points table
Changes for v3:
- Adding exynos_of_get_soc_type() method to set SOC type from device's
  compatible string
- "samsung,tmu_" prefix for TMU specific properties has been added
Changes for v4:
- None
Changes for v5:
- Remove duplicated exynos_tmu_initialize() - reported by Abhilash Kesavan
 <a.kesavan@samsung.com>
Changes for v6:
- change exynos_get_temp() definition to be static
- squash with v5's patch:
  "thermal: exynos: Remove not needed exynos_tmu_init_data declarations from exynos_tmu.h"
- Remove space after cast to squash checkpatch.pl --strict
---
 drivers/thermal/samsung/Makefile     |   2 -
 drivers/thermal/samsung/exynos_tmu.c | 339 ++++++++++++++++++++++-------------
 drivers/thermal/samsung/exynos_tmu.h |  61 +------
 3 files changed, 220 insertions(+), 182 deletions(-)

diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile
index c09d830..1e47d0d 100644
--- a/drivers/thermal/samsung/Makefile
+++ b/drivers/thermal/samsung/Makefile
@@ -3,5 +3,3 @@
 #
 obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_thermal.o
 exynos_thermal-y				:= exynos_tmu.o
-exynos_thermal-y				+= exynos_tmu_data.o
-exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+= exynos_thermal_common.o
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index ae30f6a..864eec8 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -1,6 +1,10 @@
 /*
  * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
  *
+ *  Copyright (C) 2014 Samsung Electronics
+ *  Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
  *  Copyright (C) 2011 Samsung Electronics
  *  Donggeun Kim <dg77.kim@samsung.com>
  *  Amit Daniel Kachhap <amit.kachhap@linaro.org>
@@ -31,8 +35,8 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 
-#include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
+#include "../thermal_core.h"
 
 /* Exynos generic registers */
 #define EXYNOS_TMU_REG_TRIMINFO		0x0
@@ -115,6 +119,7 @@
 #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
 #define EXYNOS5440_EFUSE_SWAP_OFFSET		8
 
+#define MCELSIUS	1000
 /**
  * struct exynos_tmu_data : A structure to hold the private data of the TMU
 	driver
@@ -150,7 +155,8 @@ struct exynos_tmu_data {
 	struct clk *clk, *clk_sec;
 	u8 temp_error1, temp_error2;
 	struct regulator *regulator;
-	struct thermal_sensor_conf *reg_conf;
+	struct thermal_zone_device *tzd;
+
 	int (*tmu_initialize)(struct platform_device *pdev);
 	void (*tmu_control)(struct platform_device *pdev, bool on);
 	int (*tmu_read)(struct exynos_tmu_data *data);
@@ -159,6 +165,33 @@ struct exynos_tmu_data {
 	void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
 };
 
+static void exynos_report_trigger(struct exynos_tmu_data *p)
+{
+	char data[10], *envp[] = { data, NULL };
+	struct thermal_zone_device *tz = p->tzd;
+	unsigned long temp;
+	unsigned int i;
+
+	if (!p) {
+		pr_err("Wrong temperature configuration data\n");
+		return;
+	}
+
+	thermal_zone_device_update(tz);
+
+	mutex_lock(&tz->lock);
+	/* Find the level for which trip happened */
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		tz->ops->get_trip_temp(tz, i, &temp);
+		if (tz->last_temperature < temp)
+			break;
+	}
+
+	snprintf(data, sizeof(data), "%u", i);
+	kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
+	mutex_unlock(&tz->lock);
+}
+
 /*
  * TMU treats temperature as a mapped temperature code.
  * The temperature is converted differently depending on the calibration type.
@@ -234,14 +267,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
 
 static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling)
 {
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
+	unsigned long temp;
 	int i;
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
-		u8 temp = pdata->trigger_levels[i];
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
+		       __func__);
+		return 0;
+	}
 
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL)
+			continue;
+
+		temp = trips[i].temperature / MCELSIUS;
 		if (falling)
-			temp -= pdata->threshold_falling;
+			temp -= (trips[i].hysteresis / MCELSIUS);
 		else
 			threshold &= ~(0xff << 8 * i);
 
@@ -305,9 +349,19 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 static int exynos4210_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
-	unsigned int status;
+	struct thermal_zone_device *tz = data->tzd;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(tz);
 	int ret = 0, threshold_code, i;
+	unsigned long reference, temp;
+	unsigned int status;
+
+	if (!trips) {
+		pr_err("%s: Cannot get trip points from of-thermal.c!\n",
+		       __func__);
+		ret = -ENODEV;
+		goto out;
+	}
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -318,12 +372,19 @@ static int exynos4210_tmu_initialize(struct platform_device *pdev)
 	sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));
 
 	/* Write temperature code for threshold */
-	threshold_code = temp_to_code(data, pdata->threshold);
+	reference = trips[0].temperature / MCELSIUS;
+	threshold_code = temp_to_code(data, reference);
+	if (threshold_code < 0) {
+		ret = threshold_code;
+		goto out;
+	}
 	writeb(threshold_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
 
-	for (i = 0; i < pdata->non_hw_trigger_levels; i++)
-		writeb(pdata->trigger_levels[i], data->base +
+	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+		temp = trips[i].temperature / MCELSIUS;
+		writeb(temp - reference, data->base +
 		       EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
+	}
 
 	data->tmu_clear_irqs(data);
 out:
@@ -333,9 +394,11 @@ out:
 static int exynos4412_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	const struct thermal_trip * const trips =
+		of_thermal_get_trip_points(data->tzd);
 	unsigned int status, trim_info, con, ctrl, rising_threshold;
 	int ret = 0, threshold_code, i;
+	unsigned long crit_temp = 0;
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
 	if (!status) {
@@ -373,17 +436,29 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
 	data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
-		/* 1-4 level to be assigned in th0 reg */
-		rising_threshold &= ~(0xff << 8 * i);
-		rising_threshold |= threshold_code << 8 * i;
-		writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
-		con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
-		con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
-		writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+	for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
+		if (trips[i].type == THERMAL_TRIP_CRITICAL) {
+			crit_temp = trips[i].temperature;
+			break;
+		}
+	}
+
+	if (i == of_thermal_get_ntrips(data->tzd)) {
+		pr_err("%s: No CRITICAL trip point defined at of-thermal.c!\n",
+		       __func__);
+		ret = -EINVAL;
+		goto out;
 	}
+
+	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
+	/* 1-4 level to be assigned in th0 reg */
+	rising_threshold &= ~(0xff << 8 * i);
+	rising_threshold |= threshold_code << 8 * i;
+	writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
+	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
+	con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
+	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+
 out:
 	return ret;
 }
@@ -391,9 +466,9 @@ out:
 static int exynos5440_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
 	unsigned int trim_info = 0, con, rising_threshold;
-	int ret = 0, threshold_code, i;
+	int ret = 0, threshold_code;
+	unsigned long crit_temp = 0;
 
 	/*
 	 * For exynos5440 soc triminfo value is swapped between TMU0 and
@@ -422,9 +497,8 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 	data->tmu_clear_irqs(data);
 
 	/* if last threshold limit is also present */
-	i = pdata->max_trigger_level - 1;
-	if (pdata->trigger_levels[i] && pdata->trigger_type[i] == HW_TRIP) {
-		threshold_code = temp_to_code(data, pdata->trigger_levels[i]);
+	if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp)) {
+		threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
 		/* 5th level to be assigned in th2 reg */
 		rising_threshold =
 			threshold_code << EXYNOS5440_TMU_TH_RISE4_SHIFT;
@@ -442,7 +516,7 @@ static int exynos5440_tmu_initialize(struct platform_device *pdev)
 static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
@@ -450,10 +524,15 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS_TMU_INTEN_RISE0_SHIFT;
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS_TMU_INTEN_RISE0_SHIFT);
+
 		if (data->soc != SOC_ARCH_EXYNOS4210)
 			interrupt_en |=
 				interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
@@ -468,7 +547,7 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct exynos_tmu_platform_data *pdata = data->pdata;
+	struct thermal_zone_device *tz = data->tzd;
 	unsigned int con, interrupt_en;
 
 	con = get_con_reg(data, readl(data->base + EXYNOS5440_TMU_S0_7_CTRL));
@@ -476,11 +555,16 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-			pdata->trigger_enable[3] << EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
-			pdata->trigger_enable[2] << EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
-			pdata->trigger_enable[1] << EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
-			pdata->trigger_enable[0] << EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
-		interrupt_en |= interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
+			(of_thermal_is_trip_valid(tz, 3)
+			 << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 2)
+			 << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 1)
+			 << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
+			(of_thermal_is_trip_valid(tz, 0)
+			 << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
+		interrupt_en |=
+			interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
 	} else {
 		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en = 0; /* Disable all interrupts */
@@ -489,19 +573,22 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 	writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL);
 }
 
-static int exynos_tmu_read(struct exynos_tmu_data *data)
+static int exynos_get_temp(void *p, long *temp)
 {
-	int ret;
+	struct exynos_tmu_data *data = p;
+
+	if (!data)
+		return -EINVAL;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
-	ret = data->tmu_read(data);
-	if (ret >= 0)
-		ret = code_to_temp(data, ret);
+
+	*temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS;
+
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
 
-	return ret;
+	return 0;
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
@@ -613,7 +700,7 @@ static void exynos_tmu_work(struct work_struct *work)
 	if (!IS_ERR(data->clk_sec))
 		clk_disable(data->clk_sec);
 
-	exynos_report_trigger(data->reg_conf);
+	exynos_report_trigger(data);
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
@@ -673,55 +760,89 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 static const struct of_device_id exynos_tmu_match[] = {
 	{
 		.compatible = "samsung,exynos3250-tmu",
-		.data = &exynos3250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4210-tmu",
-		.data = &exynos4210_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos4412-tmu",
-		.data = &exynos4412_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5250-tmu",
-		.data = &exynos5250_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5260-tmu",
-		.data = &exynos5260_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5420-tmu-ext-triminfo",
-		.data = &exynos5420_default_tmu_data,
 	},
 	{
 		.compatible = "samsung,exynos5440-tmu",
-		.data = &exynos5440_default_tmu_data,
 	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 
-static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
-			struct platform_device *pdev, int id)
+static int exynos_of_get_soc_type(struct device_node *np)
 {
-	struct  exynos_tmu_init_data *data_table;
-	struct exynos_tmu_platform_data *tmu_data;
-	const struct of_device_id *match;
+	if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
+		return SOC_ARCH_EXYNOS3250;
+	else if (of_device_is_compatible(np, "samsung,exynos4210-tmu"))
+		return SOC_ARCH_EXYNOS4210;
+	else if (of_device_is_compatible(np, "samsung,exynos4412-tmu"))
+		return SOC_ARCH_EXYNOS4412;
+	else if (of_device_is_compatible(np, "samsung,exynos5250-tmu"))
+		return SOC_ARCH_EXYNOS5250;
+	else if (of_device_is_compatible(np, "samsung,exynos5260-tmu"))
+		return SOC_ARCH_EXYNOS5260;
+	else if (of_device_is_compatible(np, "samsung,exynos5420-tmu"))
+		return SOC_ARCH_EXYNOS5420;
+	else if (of_device_is_compatible(np,
+					 "samsung,exynos5420-tmu-ext-triminfo"))
+		return SOC_ARCH_EXYNOS5420_TRIMINFO;
+	else if (of_device_is_compatible(np, "samsung,exynos5440-tmu"))
+		return SOC_ARCH_EXYNOS5440;
+
+	return -EINVAL;
+}
 
-	match = of_match_node(exynos_tmu_match, pdev->dev.of_node);
-	if (!match)
-		return NULL;
-	data_table = (struct exynos_tmu_init_data *) match->data;
-	if (!data_table || id >= data_table->tmu_count)
-		return NULL;
-	tmu_data = data_table->tmu_data;
-	return (struct exynos_tmu_platform_data *) (tmu_data + id);
+static int exynos_of_sensor_conf(struct device_node *np,
+				 struct exynos_tmu_platform_data *pdata)
+{
+	u32 value;
+	int ret;
+
+	of_node_get(np);
+
+	ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
+	pdata->gain = (u8)value;
+	of_property_read_u32(np, "samsung,tmu_reference_voltage", &value);
+	pdata->reference_voltage = (u8)value;
+	of_property_read_u32(np, "samsung,tmu_noise_cancel_mode", &value);
+	pdata->noise_cancel_mode = (u8)value;
+
+	of_property_read_u32(np, "samsung,tmu_efuse_value",
+			     &pdata->efuse_value);
+	of_property_read_u32(np, "samsung,tmu_min_efuse_value",
+			     &pdata->min_efuse_value);
+	of_property_read_u32(np, "samsung,tmu_max_efuse_value",
+			     &pdata->max_efuse_value);
+
+	of_property_read_u32(np, "samsung,tmu_first_point_trim", &value);
+	pdata->first_point_trim = (u8)value;
+	of_property_read_u32(np, "samsung,tmu_second_point_trim", &value);
+	pdata->second_point_trim = (u8)value;
+	of_property_read_u32(np, "samsung,tmu_default_temp_offset", &value);
+	pdata->default_temp_offset = (u8)value;
+
+	of_property_read_u32(np, "samsung,tmu_cal_type", &pdata->cal_type);
+	of_property_read_u32(np, "samsung,tmu_cal_mode", &pdata->cal_mode);
+
+	of_node_put(np);
+	return 0;
 }
 
 static int exynos_map_dt_data(struct platform_device *pdev)
@@ -771,14 +892,15 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 		return -EADDRNOTAVAIL;
 	}
 
-	pdata = exynos_get_driver_data(pdev, data->id);
-	if (!pdata) {
-		dev_err(&pdev->dev, "No platform init data supplied.\n");
-		return -ENODEV;
-	}
+	pdata = devm_kzalloc(&pdev->dev,
+			     sizeof(struct exynos_tmu_platform_data),
+			     GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
 
+	exynos_of_sensor_conf(pdev->dev.of_node, pdata);
 	data->pdata = pdata;
-	data->soc = pdata->type;
+	data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
 
 	switch (data->soc) {
 	case SOC_ARCH_EXYNOS4210:
@@ -834,12 +956,16 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 	return 0;
 }
 
+static struct thermal_zone_of_device_ops exynos_sensor_ops = {
+	.get_temp = exynos_get_temp,
+	.set_emul_temp = exynos_tmu_set_emulation,
+};
+
 static int exynos_tmu_probe(struct platform_device *pdev)
 {
-	struct exynos_tmu_data *data;
 	struct exynos_tmu_platform_data *pdata;
-	struct thermal_sensor_conf *sensor_conf;
-	int ret, i;
+	struct exynos_tmu_data *data;
+	int ret;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
 					GFP_KERNEL);
@@ -849,9 +975,15 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, data);
 	mutex_init(&data->lock);
 
+	data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
+						    &exynos_sensor_ops);
+	if (IS_ERR(data->tzd)) {
+		pr_err("thermal: tz: %p ERROR\n", data->tzd);
+		return PTR_ERR(data->tzd);
+	}
 	ret = exynos_map_dt_data(pdev);
 	if (ret)
-		return ret;
+		goto err_sensor;
 
 	pdata = data->pdata;
 
@@ -860,20 +992,22 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
 	if (IS_ERR(data->clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
-		return  PTR_ERR(data->clk);
+		ret = PTR_ERR(data->clk);
+		goto err_sensor;
 	}
 
 	data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
 	if (IS_ERR(data->clk_sec)) {
 		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
 			dev_err(&pdev->dev, "Failed to get triminfo clock\n");
-			return PTR_ERR(data->clk_sec);
+			ret = PTR_ERR(data->clk_sec);
+			goto err_sensor;
 		}
 	} else {
 		ret = clk_prepare(data->clk_sec);
 		if (ret) {
 			dev_err(&pdev->dev, "Failed to get clock\n");
-			return ret;
+			goto err_sensor;
 		}
 	}
 
@@ -889,45 +1023,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	exynos_tmu_control(pdev, true);
-
-	/* Allocate a structure to register with the exynos core thermal */
-	sensor_conf = devm_kzalloc(&pdev->dev,
-				sizeof(struct thermal_sensor_conf), GFP_KERNEL);
-	if (!sensor_conf) {
-		ret = -ENOMEM;
-		goto err_clk;
-	}
-	sprintf(sensor_conf->name, "therm_zone%d", data->id);
-	sensor_conf->read_temperature = (int (*)(void *))exynos_tmu_read;
-	sensor_conf->write_emul_temp =
-		(int (*)(void *, unsigned long))exynos_tmu_set_emulation;
-	sensor_conf->driver_data = data;
-	sensor_conf->trip_data.trip_count = pdata->trigger_enable[0] +
-			pdata->trigger_enable[1] + pdata->trigger_enable[2]+
-			pdata->trigger_enable[3];
-
-	for (i = 0; i < sensor_conf->trip_data.trip_count; i++) {
-		sensor_conf->trip_data.trip_val[i] =
-			pdata->threshold + pdata->trigger_levels[i];
-		sensor_conf->trip_data.trip_type[i] =
-					pdata->trigger_type[i];
-	}
-
-	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
-
-	sensor_conf->dev = &pdev->dev;
-	/* Register the sensor with thermal management interface */
-	ret = exynos_register_thermal(sensor_conf);
-	if (ret) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"Failed to register thermal interface: %d\n",
-				ret);
-		goto err_clk;
-	}
-	data->reg_conf = sensor_conf;
-
 	ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
 		IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
 	if (ret) {
@@ -935,21 +1030,25 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
+	exynos_tmu_control(pdev, true);
 	return 0;
 err_clk:
 	clk_unprepare(data->clk);
 err_clk_sec:
 	if (!IS_ERR(data->clk_sec))
 		clk_unprepare(data->clk_sec);
+err_sensor:
+	thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
+
 	return ret;
 }
 
 static int exynos_tmu_remove(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	struct thermal_zone_device *tzd = data->tzd;
 
-	exynos_unregister_thermal(data->reg_conf);
-
+	thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
 	exynos_tmu_control(pdev, false);
 
 	clk_unprepare(data->clk);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 627dec9..9f9b1b8 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -23,8 +23,7 @@
 #ifndef _EXYNOS_TMU_H
 #define _EXYNOS_TMU_H
 #include <linux/cpu_cooling.h>
-
-#include "exynos_thermal_common.h"
+#include <dt-bindings/thermal/thermal_exynos.h>
 
 enum soc_type {
 	SOC_ARCH_EXYNOS3250 = 1,
@@ -36,38 +35,9 @@ enum soc_type {
 	SOC_ARCH_EXYNOS5420_TRIMINFO,
 	SOC_ARCH_EXYNOS5440,
 };
-#include <dt-bindings/thermal/thermal_exynos.h>
 
 /**
  * struct exynos_tmu_platform_data
- * @threshold: basic temperature for generating interrupt
- *	       25 <= threshold <= 125 [unit: degree Celsius]
- * @threshold_falling: differntial value for setting threshold
- *		       of temperature falling interrupt.
- * @trigger_levels: array for each interrupt levels
- *	[unit: degree Celsius]
- *	0: temperature for trigger_level0 interrupt
- *	   condition for trigger_level0 interrupt:
- *		current temperature > threshold + trigger_levels[0]
- *	1: temperature for trigger_level1 interrupt
- *	   condition for trigger_level1 interrupt:
- *		current temperature > threshold + trigger_levels[1]
- *	2: temperature for trigger_level2 interrupt
- *	   condition for trigger_level2 interrupt:
- *		current temperature > threshold + trigger_levels[2]
- *	3: temperature for trigger_level3 interrupt
- *	   condition for trigger_level3 interrupt:
- *		current temperature > threshold + trigger_levels[3]
- * @trigger_type: defines the type of trigger. Possible values are,
- *	THROTTLE_ACTIVE trigger type
- *	THROTTLE_PASSIVE trigger type
- *	SW_TRIP trigger type
- *	HW_TRIP
- * @trigger_enable[]: array to denote which trigger levels are enabled.
- *	1 = enable trigger_level[] interrupt,
- *	0 = disable trigger_level[] interrupt
- * @max_trigger_level: max trigger level supported by the TMU
- * @non_hw_trigger_levels: number of defined non-hardware trigger levels
  * @gain: gain of amplifier in the positive-TC generator block
  *	0 < gain <= 15
  * @reference_voltage: reference voltage of amplifier
@@ -79,21 +49,12 @@ enum soc_type {
  * @efuse_value: platform defined fuse value
  * @min_efuse_value: minimum valid trimming data
  * @max_efuse_value: maximum valid trimming data
- * @first_point_trim: temp value of the first point trimming
- * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @cal_type: calibration type for temperature
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
 struct exynos_tmu_platform_data {
-	u8 threshold;
-	u8 threshold_falling;
-	u8 trigger_levels[MAX_TRIP_COUNT];
-	enum trigger_type trigger_type[MAX_TRIP_COUNT];
-	bool trigger_enable[MAX_TRIP_COUNT];
-	u8 max_trigger_level;
-	u8 non_hw_trigger_levels;
 	u8 gain;
 	u8 reference_voltage;
 	u8 noise_cancel_mode;
@@ -110,24 +71,4 @@ struct exynos_tmu_platform_data {
 	u32 cal_mode;
 };
 
-/**
- * struct exynos_tmu_init_data
- * @tmu_count: number of TMU instances.
- * @tmu_data: platform data of all TMU instances.
- * This structure is required to store data for multi-instance exynos tmu
- * driver.
- */
-struct exynos_tmu_init_data {
-	int tmu_count;
-	struct exynos_tmu_platform_data tmu_data[];
-};
-
-extern struct exynos_tmu_init_data const exynos3250_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5250_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5260_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5420_default_tmu_data;
-extern struct exynos_tmu_init_data const exynos5440_default_tmu_data;
-
 #endif /* _EXYNOS_TMU_H */
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 17/18] thermal: exynos: Remove exynos_thermal_common.[c|h] files
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (14 preceding siblings ...)
  2015-01-23 12:10     ` [PATCH v6 16/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
@ 2015-01-23 12:10     ` Lukasz Majewski
  2015-01-23 12:10     ` [PATCH v6 18/18] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
  2015-01-24 21:49     ` [PATCH v6 00/18] thermal: exynos: Thermal code rework to use device tree Eduardo Valentin
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:10 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

After defining all necessary Exynos data in the device tree and heavy
reusage of the of-thermal.c those files can be removed.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 drivers/thermal/samsung/exynos_thermal_common.c | 445 ------------------------
 drivers/thermal/samsung/exynos_thermal_common.h | 106 ------
 2 files changed, 551 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
deleted file mode 100644
index 00aa688..0000000
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ /dev/null
@@ -1,445 +0,0 @@
-/*
- * exynos_thermal_common.c - Samsung EXYNOS common thermal file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include <linux/cpu_cooling.h>
-#include <linux/err.h>
-#include <linux/slab.h>
-#include <linux/thermal.h>
-
-#include "exynos_thermal_common.h"
-
-struct exynos_thermal_zone {
-	enum thermal_device_mode mode;
-	struct thermal_zone_device *therm_dev;
-	struct thermal_cooling_device *cool_dev[MAX_COOLING_DEVICE];
-	unsigned int cool_dev_size;
-	struct platform_device *exynos4_dev;
-	struct thermal_sensor_conf *sensor_conf;
-	bool bind;
-};
-
-/* Get mode callback functions for thermal zone */
-static int exynos_get_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode *mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (th_zone)
-		*mode = th_zone->mode;
-	return 0;
-}
-
-/* Set mode callback functions for thermal zone */
-static int exynos_set_mode(struct thermal_zone_device *thermal,
-			enum thermal_device_mode mode)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	if (!th_zone) {
-		dev_err(&thermal->device,
-			"thermal zone not registered\n");
-		return 0;
-	}
-
-	mutex_lock(&thermal->lock);
-
-	if (mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling)
-		thermal->polling_delay = IDLE_INTERVAL;
-	else
-		thermal->polling_delay = 0;
-
-	mutex_unlock(&thermal->lock);
-
-	th_zone->mode = mode;
-	thermal_zone_device_update(thermal);
-	dev_dbg(th_zone->sensor_conf->dev,
-		"thermal polling set for duration=%d msec\n",
-		thermal->polling_delay);
-	return 0;
-}
-
-
-/* Get trip type callback functions for thermal zone */
-static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
-				 enum thermal_trip_type *type)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	int trip_type;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	trip_type = th_zone->sensor_conf->trip_data.trip_type[trip];
-
-	if (trip_type == SW_TRIP)
-		*type = THERMAL_TRIP_CRITICAL;
-	else if (trip_type == THROTTLE_ACTIVE)
-		*type = THERMAL_TRIP_ACTIVE;
-	else if (trip_type == THROTTLE_PASSIVE)
-		*type = THERMAL_TRIP_PASSIVE;
-	else
-		return -EINVAL;
-
-	return 0;
-}
-
-/* Get trip temperature callback functions for thermal zone */
-static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-
-	if (trip < 0 || trip >= max_trip)
-		return -EINVAL;
-
-	*temp = th_zone->sensor_conf->trip_data.trip_val[trip];
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-
-	return 0;
-}
-
-/* Get critical temperature callback functions for thermal zone */
-static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
-				unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
-	/* Get the temp of highest trip*/
-	return exynos_get_trip_temp(thermal, max_trip - 1, temp);
-}
-
-/* Bind callback functions for thermal zone */
-static int exynos_bind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-	struct of_phandle_args cooling_spec;
-	unsigned long max, state = 0;
-	int ret = 0, i = 0;
-
-	/*
-	 * Below code is necessary to skip binding when cpufreq's
-	 * frequency table is not yet initialized.
-	 */
-	cdev->ops->get_max_state(cdev, &state);
-	if (!state && !th_zone->cool_dev_size) {
-		th_zone->cool_dev_size = 1;
-		th_zone->cool_dev[0] = cdev;
-		th_zone->bind = false;
-		return 0;
-	}
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	for_each_child_of_node(child, gchild) {
-		ret = of_parse_phandle_with_args(gchild, "cooling-device",
-						 "#cooling-cells",
-						 0, &cooling_spec);
-		if (ret < 0) {
-			pr_err("missing cooling_device property\n");
-			goto end;
-		}
-
-		if (cooling_spec.args_count < 2) {
-			ret = -EINVAL;
-			goto end;
-		}
-
-		max = cooling_spec.args[0];
-		if (thermal_zone_bind_cooling_device(thermal, i, cdev,
-						     max, 0)) {
-			dev_err(data->dev,
-				"thermal error unbinding cdev inst=%d\n", i);
-
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = true;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Unbind callback functions for thermal zone */
-static int exynos_unbind(struct thermal_zone_device *thermal,
-			struct thermal_cooling_device *cdev)
-{
-	int ret = 0, i;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	struct thermal_sensor_conf *data = th_zone->sensor_conf;
-	struct device_node *child, *gchild, *np;
-
-	if (th_zone->bind == false || !th_zone->cool_dev_size)
-		return 0;
-
-	/* find the cooling device registered*/
-	for (i = 0; i < th_zone->cool_dev_size; i++)
-		if (cdev == th_zone->cool_dev[i])
-			break;
-
-	/* No matching cooling device */
-	if (i == th_zone->cool_dev_size)
-		return 0;
-
-	np = of_find_node_by_path("/thermal-zones/cpu-thermal");
-	if (!np) {
-		pr_err("failed to find thmerla-zones/cpu-thermal node\n");
-		return -ENOENT;
-	}
-
-	child = of_get_child_by_name(np, "cooling-maps");
-
-	i = 0;
-	for_each_child_of_node(child, gchild) {
-		if (thermal_zone_unbind_cooling_device(thermal, i,
-						       cdev)) {
-			dev_err(data->dev,
-				"error unbinding cdev inst=%d\n", i);
-			ret = -EINVAL;
-			goto end;
-		}
-		i++;
-	}
-	th_zone->bind = false;
-end:
-	of_node_put(child);
-	of_node_put(np);
-
-	return ret;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_get_temp(struct thermal_zone_device *thermal,
-			unsigned long *temp)
-{
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-	void *data;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	*temp = th_zone->sensor_conf->read_temperature(data);
-	/* convert the temperature into millicelsius */
-	*temp = *temp * MCELSIUS;
-	return 0;
-}
-
-/* Get temperature callback functions for thermal zone */
-static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
-						unsigned long temp)
-{
-	void *data;
-	int ret = -EINVAL;
-	struct exynos_thermal_zone *th_zone = thermal->devdata;
-
-	if (!th_zone->sensor_conf) {
-		dev_err(&thermal->device,
-			"Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-	data = th_zone->sensor_conf->driver_data;
-	if (th_zone->sensor_conf->write_emul_temp)
-		ret = th_zone->sensor_conf->write_emul_temp(data, temp);
-	return ret;
-}
-
-/* Get the temperature trend */
-static int exynos_get_trend(struct thermal_zone_device *thermal,
-			int trip, enum thermal_trend *trend)
-{
-	int ret;
-	unsigned long trip_temp;
-
-	ret = exynos_get_trip_temp(thermal, trip, &trip_temp);
-	if (ret < 0)
-		return ret;
-
-	if (thermal->temperature >= trip_temp)
-		*trend = THERMAL_TREND_RAISE_FULL;
-	else
-		*trend = THERMAL_TREND_DROP_FULL;
-
-	return 0;
-}
-/* Operation callback functions for thermal zone */
-static struct thermal_zone_device_ops exynos_dev_ops = {
-	.bind = exynos_bind,
-	.unbind = exynos_unbind,
-	.get_temp = exynos_get_temp,
-	.set_emul_temp = exynos_set_emul_temp,
-	.get_trend = exynos_get_trend,
-	.get_mode = exynos_get_mode,
-	.set_mode = exynos_set_mode,
-	.get_trip_type = exynos_get_trip_type,
-	.get_trip_temp = exynos_get_trip_temp,
-	.get_crit_temp = exynos_get_crit_temp,
-};
-
-/*
- * This function may be called from interrupt based temperature sensor
- * when threshold is changed.
- */
-void exynos_report_trigger(struct thermal_sensor_conf *conf)
-{
-	unsigned int i;
-	char data[10];
-	char *envp[] = { data, NULL };
-	struct exynos_thermal_zone *th_zone;
-
-	if (!conf || !conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = conf->pzone_data;
-
-	if (th_zone->bind == false) {
-		for (i = 0; i < th_zone->cool_dev_size; i++) {
-			if (!th_zone->cool_dev[i])
-				continue;
-			exynos_bind(th_zone->therm_dev,
-					th_zone->cool_dev[i]);
-		}
-	}
-
-	thermal_zone_device_update(th_zone->therm_dev);
-
-	mutex_lock(&th_zone->therm_dev->lock);
-	/* Find the level for which trip happened */
-	for (i = 0; i < th_zone->sensor_conf->trip_data.trip_count; i++) {
-		if (th_zone->therm_dev->last_temperature <
-			th_zone->sensor_conf->trip_data.trip_val[i] * MCELSIUS)
-			break;
-	}
-
-	if (th_zone->mode == THERMAL_DEVICE_ENABLED &&
-		!th_zone->sensor_conf->trip_data.trigger_falling) {
-		if (i > 0)
-			th_zone->therm_dev->polling_delay = ACTIVE_INTERVAL;
-		else
-			th_zone->therm_dev->polling_delay = IDLE_INTERVAL;
-	}
-
-	snprintf(data, sizeof(data), "%u", i);
-	kobject_uevent_env(&th_zone->therm_dev->device.kobj, KOBJ_CHANGE, envp);
-	mutex_unlock(&th_zone->therm_dev->lock);
-}
-
-/* Register with the in-kernel thermal management */
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int ret;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->read_temperature) {
-		pr_err("Temperature sensor not initialised\n");
-		return -EINVAL;
-	}
-
-	th_zone = devm_kzalloc(sensor_conf->dev,
-				sizeof(struct exynos_thermal_zone), GFP_KERNEL);
-	if (!th_zone)
-		return -ENOMEM;
-
-	th_zone->sensor_conf = sensor_conf;
-	/*
-	 * TODO: 1) Handle multiple cooling devices in a thermal zone
-	 *	 2) Add a flag/name in cooling info to map to specific
-	 *	 sensor
-	 */
-	if (sensor_conf->cooling_data.freq_clip_count > 0) {
-		th_zone->cool_dev[th_zone->cool_dev_size] =
-				cpufreq_cooling_register(cpu_present_mask);
-		if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
-			ret = PTR_ERR(th_zone->cool_dev[th_zone->cool_dev_size]);
-			if (ret != -EPROBE_DEFER)
-				dev_err(sensor_conf->dev,
-					"Failed to register cpufreq cooling device: %d\n",
-					ret);
-			goto err_unregister;
-		}
-		th_zone->cool_dev_size++;
-	}
-
-	th_zone->therm_dev = thermal_zone_device_register(
-			sensor_conf->name, sensor_conf->trip_data.trip_count,
-			0, th_zone, &exynos_dev_ops, NULL, 0,
-			sensor_conf->trip_data.trigger_falling ? 0 :
-			IDLE_INTERVAL);
-
-	if (IS_ERR(th_zone->therm_dev)) {
-		dev_err(sensor_conf->dev,
-			"Failed to register thermal zone device\n");
-		ret = PTR_ERR(th_zone->therm_dev);
-		goto err_unregister;
-	}
-	th_zone->mode = THERMAL_DEVICE_ENABLED;
-	sensor_conf->pzone_data = th_zone;
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Thermal zone(%s) registered\n", sensor_conf->name);
-
-	return 0;
-
-err_unregister:
-	exynos_unregister_thermal(sensor_conf);
-	return ret;
-}
-
-/* Un-Register with the in-kernel thermal management */
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
-{
-	int i;
-	struct exynos_thermal_zone *th_zone;
-
-	if (!sensor_conf || !sensor_conf->pzone_data) {
-		pr_err("Invalid temperature sensor configuration data\n");
-		return;
-	}
-
-	th_zone = sensor_conf->pzone_data;
-
-	thermal_zone_device_unregister(th_zone->therm_dev);
-
-	for (i = 0; i < th_zone->cool_dev_size; ++i)
-		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-
-	dev_info(sensor_conf->dev,
-		"Exynos: Kernel Thermal management unregistered\n");
-}
diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h
deleted file mode 100644
index cd44719..0000000
--- a/drivers/thermal/samsung/exynos_thermal_common.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * exynos_thermal_common.h - Samsung EXYNOS common header file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#ifndef _EXYNOS_THERMAL_COMMON_H
-#define _EXYNOS_THERMAL_COMMON_H
-
-/* In-kernel thermal framework related macros & definations */
-#define SENSOR_NAME_LEN	16
-#define MAX_TRIP_COUNT	8
-#define MAX_COOLING_DEVICE 4
-
-#define ACTIVE_INTERVAL 500
-#define IDLE_INTERVAL 10000
-#define MCELSIUS	1000
-
-/* CPU Zone information */
-#define PANIC_ZONE      4
-#define WARN_ZONE       3
-#define MONITOR_ZONE    2
-#define SAFE_ZONE       1
-
-#define GET_ZONE(trip) (trip + 2)
-#define GET_TRIP(zone) (zone - 2)
-
-enum trigger_type {
-	THROTTLE_ACTIVE = 1,
-	THROTTLE_PASSIVE,
-	SW_TRIP,
-	HW_TRIP,
-};
-
-/**
- * struct freq_clip_table
- * @freq_clip_max: maximum frequency allowed for this cooling state.
- * @temp_level: Temperature level at which the temperature clipping will
- *	happen.
- * @mask_val: cpumask of the allowed cpu's where the clipping will take place.
- *
- * This structure is required to be filled and passed to the
- * cpufreq_cooling_unregister function.
- */
-struct freq_clip_table {
-	unsigned int freq_clip_max;
-	unsigned int temp_level;
-	const struct cpumask *mask_val;
-};
-
-struct	thermal_trip_point_conf {
-	int trip_val[MAX_TRIP_COUNT];
-	int trip_type[MAX_TRIP_COUNT];
-	int trip_count;
-	unsigned char trigger_falling;
-};
-
-struct	thermal_cooling_conf {
-	struct freq_clip_table freq_data[MAX_TRIP_COUNT];
-	int freq_clip_count;
-};
-
-struct thermal_sensor_conf {
-	char name[SENSOR_NAME_LEN];
-	int (*read_temperature)(void *data);
-	int (*write_emul_temp)(void *drv_data, unsigned long temp);
-	struct thermal_trip_point_conf trip_data;
-	struct thermal_cooling_conf cooling_data;
-	void *driver_data;
-	void *pzone_data;
-	struct device *dev;
-};
-
-/*Functions used exynos based thermal sensor driver*/
-#ifdef CONFIG_EXYNOS_THERMAL_CORE
-void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf);
-int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf);
-void exynos_report_trigger(struct thermal_sensor_conf *sensor_conf);
-#else
-static inline void
-exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf) { return; }
-
-static inline int
-exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) { return 0; }
-
-static inline void
-exynos_report_trigger(struct thermal_sensor_conf *sensor_conf) { return; }
-
-#endif /* CONFIG_EXYNOS_THERMAL_CORE */
-#endif /* _EXYNOS_THERMAL_COMMON_H */
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 18/18] thermal: exynos: Remove exynos_tmu_data.c file
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (15 preceding siblings ...)
  2015-01-23 12:10     ` [PATCH v6 17/18] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
@ 2015-01-23 12:10     ` Lukasz Majewski
  2015-01-24 21:49     ` [PATCH v6 00/18] thermal: exynos: Thermal code rework to use device tree Eduardo Valentin
  17 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:10 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

Data already present in the exynos_tmu_data.c file has been moved to the
appropriate device tree files.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 drivers/thermal/samsung/exynos_tmu_data.c | 228 ------------------------------
 1 file changed, 228 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c

diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
deleted file mode 100644
index a993f3d..0000000
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * exynos_tmu_data.c - Samsung EXYNOS tmu data file
- *
- *  Copyright (C) 2013 Samsung Electronics
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include "exynos_thermal_common.h"
-#include "exynos_tmu.h"
-
-struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
-	.tmu_data = {
-		{
-		.threshold = 80,
-		.trigger_levels[0] = 5,
-		.trigger_levels[1] = 20,
-		.trigger_levels[2] = 30,
-		.trigger_enable[0] = true,
-		.trigger_enable[1] = true,
-		.trigger_enable[2] = true,
-		.trigger_enable[3] = false,
-		.trigger_type[0] = THROTTLE_ACTIVE,
-		.trigger_type[1] = THROTTLE_ACTIVE,
-		.trigger_type[2] = SW_TRIP,
-		.max_trigger_level = 4,
-		.non_hw_trigger_levels = 3,
-		.gain = 15,
-		.reference_voltage = 7,
-		.cal_type = TYPE_ONE_POINT_TRIMMING,
-		.min_efuse_value = 40,
-		.max_efuse_value = 100,
-		.first_point_trim = 25,
-		.second_point_trim = 85,
-		.default_temp_offset = 50,
-		.type = SOC_ARCH_EXYNOS4210,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS3250_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_TWO_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS3250_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS3250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define EXYNOS4412_TMU_DATA \
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 70, \
-	.trigger_levels[1] = 95, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50
-
-struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS4412,
-		},
-	},
-	.tmu_count = 1,
-};
-
-struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
-	.tmu_data = {
-		{
-			EXYNOS4412_TMU_DATA,
-			.type = SOC_ARCH_EXYNOS5250,
-		},
-	},
-	.tmu_count = 1,
-};
-
-#define __EXYNOS5260_TMU_DATA	\
-	.threshold_falling = 10, \
-	.trigger_levels[0] = 85, \
-	.trigger_levels[1] = 103, \
-	.trigger_levels[2] = 110, \
-	.trigger_levels[3] = 120, \
-	.trigger_enable[0] = true, \
-	.trigger_enable[1] = true, \
-	.trigger_enable[2] = true, \
-	.trigger_enable[3] = false, \
-	.trigger_type[0] = THROTTLE_ACTIVE, \
-	.trigger_type[1] = THROTTLE_ACTIVE, \
-	.trigger_type[2] = SW_TRIP, \
-	.trigger_type[3] = HW_TRIP, \
-	.max_trigger_level = 4, \
-	.non_hw_trigger_levels = 3, \
-	.gain = 8, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 55, \
-	.min_efuse_value = 40, \
-	.max_efuse_value = 100, \
-	.first_point_trim = 25, \
-	.second_point_trim = 85, \
-	.default_temp_offset = 50,
-
-#define EXYNOS5260_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5260
-
-struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-		{ EXYNOS5260_TMU_DATA },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5420_TMU_DATA \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420
-
-#define EXYNOS5420_TMU_DATA_SHARED \
-	__EXYNOS5260_TMU_DATA \
-	.type = SOC_ARCH_EXYNOS5420_TRIMINFO
-
-struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-		{ EXYNOS5420_TMU_DATA_SHARED },
-	},
-	.tmu_count = 5,
-};
-
-#define EXYNOS5440_TMU_DATA \
-	.trigger_levels[0] = 100, \
-	.trigger_levels[4] = 105, \
-	.trigger_enable[0] = 1, \
-	.trigger_type[0] = SW_TRIP, \
-	.trigger_type[4] = HW_TRIP, \
-	.max_trigger_level = 5, \
-	.non_hw_trigger_levels = 1, \
-	.gain = 5, \
-	.reference_voltage = 16, \
-	.noise_cancel_mode = 4, \
-	.cal_type = TYPE_ONE_POINT_TRIMMING, \
-	.efuse_value = 0x5b2d, \
-	.min_efuse_value = 16, \
-	.max_efuse_value = 76, \
-	.first_point_trim = 25, \
-	.second_point_trim = 70, \
-	.default_temp_offset = 25, \
-	.type = SOC_ARCH_EXYNOS5440
-
-struct exynos_tmu_init_data const exynos5440_default_tmu_data = {
-	.tmu_data = {
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-		{ EXYNOS5440_TMU_DATA } ,
-	},
-	.tmu_count = 3,
-};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered
  2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
                     ` (19 preceding siblings ...)
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
@ 2015-01-23 12:14   ` Lukasz Majewski
  2015-01-23 12:59     ` Viresh Kumar
  2015-01-26  9:25     ` [PATCH] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used Lukasz Majewski
  20 siblings, 2 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 12:14 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Eduardo Valentin, Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kukjin Kim, Chanwoo Choi, Lukasz Majewski

With thermal subsystem rework it is necessary to tune current cpufreq code
to use cpu frequency change as a potential cooling device.

Now the cpu cooling device is registered only when proper nodes and properties
are available in device tree. Lack of them, however, will not prevent
cpufreq for normal operation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v6:
- New patch

---
 drivers/cpufreq/exynos-cpufreq.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index f99a0b0..5e98c6b 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -18,10 +18,13 @@
 #include <linux/cpufreq.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/cpu_cooling.h>
+#include <linux/cpu.h>
 
 #include "exynos-cpufreq.h"
 
 static struct exynos_dvfs_info *exynos_info;
+static struct thermal_cooling_device *cdev;
 static struct regulator *arm_regulator;
 static unsigned int locking_frequency;
 
@@ -156,6 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
+	struct device_node *cpus, *np;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -198,9 +202,36 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	/* Done here as we want to capture boot frequency */
 	locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;
 
-	if (!cpufreq_register_driver(&exynos_driver))
+	ret = cpufreq_register_driver(&exynos_driver);
+	if (ret)
+		goto err_cpufreq_reg;
+
+	cpus = of_find_node_by_path("/cpus");
+	if (!cpus) {
+		pr_err("failed to find cpus node\n");
+		return 0;
+	}
+
+	np = of_get_next_child(cpus, NULL);
+	if (!np) {
+		pr_err("failed to find cpus child node\n");
+		of_node_put(cpus);
 		return 0;
+	}
+
+	if (of_find_property(np, "#cooling-cells", NULL)) {
+		cdev = of_cpufreq_cooling_register(np,
+						   cpu_present_mask);
+		if (IS_ERR(cdev))
+			pr_err("running cpufreq without cooling device: %ld\n",
+			       PTR_ERR(cdev));
+	}
+	of_node_put(np);
+	of_node_put(cpus);
+
+	return 0;
 
+err_cpufreq_reg:
 	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
 	regulator_put(arm_regulator);
 err_vdd_arm:
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* Aw: [PATCH v6 05/18] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
  2015-01-23 12:09     ` [PATCH v6 05/18] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
@ 2015-01-23 12:23       ` Tobias Jakobi
  0 siblings, 0 replies; 288+ messages in thread
From: Tobias Jakobi @ 2015-01-23 12:23 UTC (permalink / raw)
  Cc: Eduardo Valentin, Zhang Rui, Kukjin Kim, Kukjin Kim,
	Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

Hello,

just a small nit concerning the patch subject. Shouldn't it be "Enable TMU on Exynos4412 based Odroid devices" (since it's not just for the U3)?

With best wishes,
Tobias
 

Gesendet: Freitag, 23. Januar 2015 um 13:09 Uhr
Von: "Lukasz Majewski" <l.majewski@samsung.com>
An: "Eduardo Valentin" <edubezval@gmail.com>, "Zhang Rui" <rui.zhang@intel.com>, "Kukjin Kim" <kgene.kim@samsung.com>, "Kukjin Kim" <kgene@kernel.org>
Cc: "Linux PM list" <linux-pm@vger.kernel.org>, "linux-samsung-soc@vger.kernel.org" <linux-samsung-soc@vger.kernel.org>, "Bartlomiej Zolnierkiewicz" <b.zolnierkie@samsung.com>, "Lukasz Majewski" <l.majewski@majess.pl>, "Amit Daniel Kachhap" <amit.daniel@samsung.com>, "Abhilash Kesavan" <kesavan.abhilash@gmail.com>, "Abhilash Kesavan" <a.kesavan@samsung.com>, "Chanwoo Choi" <cw00.choi@samsung.com>, "Viresh Kumar" <viresh.kumar@linaro.org>, "Lukasz Majewski" <l.majewski@samsung.com>
Betreff: [PATCH v6 05/18] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
This commit enables TMU IP block on the Exynos4412 Odroid U3
device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- Rename patch title from "thermal: dts:" to "arm: dts: odroid"
Changes for v5:
- None
Changes for v6:
- None
---
arch/arm/boot/dts/exynos4412-odroid-common.dtsi | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 0adb57c..c7517fc 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -396,6 +396,11 @@
ehci: ehci@12580000 {
status = "okay";
};
+
+ tmu@100C0000 {
+ vtmu-supply = <&ldo10_reg>;
+ status = "okay";
+ };
};

&pinctrl_1 {
--
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 288+ messages in thread

* Re: [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered
  2015-01-23 12:14   ` [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered Lukasz Majewski
@ 2015-01-23 12:59     ` Viresh Kumar
  2015-01-23 13:57       ` Lukasz Majewski
  2015-01-26  9:25     ` [PATCH] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used Lukasz Majewski
  1 sibling, 1 reply; 288+ messages in thread
From: Viresh Kumar @ 2015-01-23 12:59 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kukjin Kim, Chanwoo Choi

On 23 January 2015 at 17:44, Lukasz Majewski <l.majewski@samsung.com> wrote:
> +       cpus = of_find_node_by_path("/cpus");
> +       if (!cpus) {
> +               pr_err("failed to find cpus node\n");
> +               return 0;
> +       }
> +
> +       np = of_get_next_child(cpus, NULL);
> +       if (!np) {
> +               pr_err("failed to find cpus child node\n");
> +               of_node_put(cpus);
>                 return 0;
> +       }

Why making it complex? Just get device node for cpu 0 and
do cpu_dev->np.

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered
  2015-01-23 12:59     ` Viresh Kumar
@ 2015-01-23 13:57       ` Lukasz Majewski
  2015-01-25 14:01         ` Viresh Kumar
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-23 13:57 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Eduardo Valentin, Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kukjin Kim, Chanwoo Choi

Hi Viresh,

> On 23 January 2015 at 17:44, Lukasz Majewski <l.majewski@samsung.com>
> wrote:
> > +       cpus = of_find_node_by_path("/cpus");
> > +       if (!cpus) {
> > +               pr_err("failed to find cpus node\n");
> > +               return 0;
> > +       }
> > +
> > +       np = of_get_next_child(cpus, NULL);
> > +       if (!np) {
> > +               pr_err("failed to find cpus child node\n");
> > +               of_node_put(cpus);
> >                 return 0;
> > +       }
> 
> Why making it complex? Just get device node for cpu 0 and
> do cpu_dev->np.

Please pay a note about following problem:

Previously we got: cpu0: cpu@0 for all Exynos devices.

Now, however, cpu numbering has changed (due to GIC rework).
For example:

Exynos4412:
	cpus {
		cpu0: cpu@A00 {
			...
			#cooling-cells = <2>; /* min followed by max */
		};

		cpu@A01 {
		};

		cpu@A02 {
		};

		cpu@A03 {
		};
	}

Exynos 4210:
	cpus {
		cpu0: cpu@900 {
			#cooling-cells = <2>; /* min followed by max */
		};

		cpu@901 {
		};
	};

Exynos 5250:
	cpus {
		cpu0: cpu@0 {
			#cooling-cells = <2>; /* min followed by max */
		};

		cpu@1 {
		};
	};
	

As you can see different cpu@XXY nodes we have and simply calling cpu@0
won't work.


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v4 00/17] thermal: exynos: Thermal code rework to use device tree
  2015-01-23 11:00       ` Kukjin Kim
@ 2015-01-23 14:45         ` Eduardo Valentin
  2015-01-24  4:04           ` Kukjin Kim
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-23 14:45 UTC (permalink / raw)
  To: Kukjin Kim
  Cc: 'Lukasz Majewski', 'Zhang Rui',
	'Linux PM list',
	linux-samsung-soc, 'Bartlomiej Zolnierkiewicz',
	'Lukasz Majewski', 'Amit Daniel Kachhap',
	'Abhilash Kesavan', 'Kyungmin Park',
	'Chanwoo Choi', 'Abhilash Kesavan'

[-- Attachment #1: Type: text/plain, Size: 7452 bytes --]

Hi Kukjin,

On Fri, Jan 23, 2015 at 08:00:07PM +0900, Kukjin Kim wrote:
> Lukasz Majewski wrote:
> > 
> > Hi Kukjin,
> > 
> Hi,
> 
> > > Lukasz Majewski wrote:
> > > >
> > > Hi,
> > >
> > > > 1. Introduction
> > > >
> > > > Following patches aim to clean up the current implementation of the
> > > > thermal framework on Exynos devices.
> > > >
> > > > The main goal was to use a generic code for reading thermal
> > > > configuration (of-thermal.c). Due to that redundant
> > > > exynos_thermal_common.[h|c] files were removed.
> > > >
> > > > Around 400 lines of code (LOC) were removed directly by this patch,
> > > > which is around 20% of the Exynos thermal code base.
> > > >
> > > > This work should NOT bring any functional changes to Exynos thermal
> > > > subsystem.
> > > >
> > > Sounds great to use generic some framework in kernel.
> > >
> > > > 2. Patch-set structure
> > > >
> > > > Then the cpu_cooling functionality has been preserved to allow
> > > > cooling devices by reducing operating frequency. Definition of trip
> > > > points and cpufreq's cooling properties were moved to device tree.
> > > >
> > > > Then the rework of the way in which configuration data is provided
> > > > to the Exynos thermal subsystem was performed. Now device tree is
> > > > used for configuration.
> > > >
> > > > 3. Dead code removal
> > > >
> > > > Thermal support for some SoCs, previously available in the
> > > > exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3,
> > > > they didn't have TMU bindings.
> > > >
> > > > Moreover, support for cpu_cooling devices was preserved only on
> > > > those SoCs which had available and working cpufreq driver.
> > > >
> > > > 4. Testing
> > > >
> > > > Test devices:
> > > > - Exynos4210 - Trats (TMU zone + cpu_cooling)
> > > > - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> > > > - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> > > > - Exynos5420 - Arndale-octa (only TMU zones)
> > > >
> > > Thanks for your check on the boards...
> > >
> > > > Unfortunately, I don't posses Exynos5440 for testing. Its
> > > > functionality has been preserved in the code, but not tested on the
> > > > hardware. I would be grateful for help in testing.
> > > >
> > > I think, Amit can do it on exynos5440 ;)
> > >
> > > >
> > > > 5. This work apply on the following tree:
> > > >
> > > > kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> > > > SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
> > > >
> > > >
> > > > Lukasz Majewski (17):
> > > >   thermal: exynos: cosmetic: Correct comment format
> > > >   thermal: exynos: Provide thermal_exynos.h file to be included in
> > > >     device tree files
> > > >   arm: dts: trats: Enable TMU on the Exynos4210 trats device
> > > >   arm: dts: odroid: Add LD010 regulator node necessary for TMU on
> > > > Odroid arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3
> > > > device arm: dts: Adding CPU cooling binding for Exynos SoCs
> > > >   thermal: exynos: Modify exynos thermal code to use device tree
> > > > for cpu cooling configuration
> > > >   thermal: exynos: dts: Add default definition of the TMU sensor
> > > >     parameter
> > > >   dts: Documentation: Extending documentation entry for
> > > > exynos-thermal thermal: dts: Default trip points definition for
> > > > Exynos5420 SoCs thermal: exynos: dts: Define default thermal-zones
> > > > for Exynos4 thermal: dts: exynos: Trip points and sensor
> > > > configuration data for Exynos5440
> > > >   dts: Documentation: Update exynos-thermal.txt example for
> > > > Exynos5440 thermal: exynos: dts: Provide device tree bindings
> > > > identical to the one in exynos_tmu_data.c
> > > >   thermal: samsung: core: Exynos TMU rework to use device tree for
> > > >     configuration
> > > >   thermal: exynos: Remove exynos_thermal_common.[c|h] files
> > > >   thermal: exynos: Remove exynos_tmu_data.c file
> > > >
> > > >  .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
> > > >  arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
> > > >  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
> > > >  arch/arm/boot/dts/exynos4.dtsi                     |   4 +
> > > >  arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
> > > >  arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
> > > >  arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
> > > >  arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
> > > >  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
> > > >  arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
> > > >  arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
> > > >  arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
> > > >  arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
> > > >  arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
> > > >  arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
> > > >  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
> > > >  arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
> > > >  arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
> > > >  drivers/cpufreq/exynos-cpufreq.c                   |  30 +-
> > > >  drivers/thermal/samsung/Makefile                   |   2 -
> > > >  drivers/thermal/samsung/exynos_thermal_common.c    | 427
> > > > ---------------------
> > > > drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
> > > > drivers/thermal/samsung/exynos_tmu.c               | 354
> > > > +++++++++++------
> > > > drivers/thermal/samsung/exynos_tmu.h               |  68 +---
> > > > drivers/thermal/samsung/exynos_tmu_data.c          | 264
> > > > ------------- include/dt-bindings/thermal/thermal_exynos.h       |
> > > > 28 ++ 26 files changed, 638 insertions(+), 1001 deletions(-) create
> > > > mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi create mode
> > > > 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi create
> > > > mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi create
> > > > mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
> > > > create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
> > > > delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
> > > > delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
> > > > delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c create
> > > > mode 100644 include/dt-bindings/thermal/thermal_exynos.h
> > > >
> > > > --
> > >
> > > I hope will apply DT changes in Samsung tree. Is it OK to thermal
> > > tree?
> > 
> > I think that it is up to you and Eduardo to decide :-).
> > 
> > I'd personally prefer to add this patch set at once to Eduardo's tree
> > (of course with your ACKs).
> > 
> If so, we could see too many useless merge conflicts. Because your patches
> touch most of exynos DT stuff and that's why DT changes should be handled in
> Samsung tree if there is no problem ;) Let's wait for thermal guys.

Let's target the latest version (v6) of this series. You can add my
Acked-by: Eduardo Valentin <edubezval@gmail.com>

in the DTS changes. And add them via your tree. I believe we will avoid
merge conflicts this way. I will handle the patches touching drivers/.

Thanks.

> 
> - Kukjin
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v3 00/16] thermal: exynos: Thermal code rework to use device tree
  2015-01-21  9:08             ` Eduardo Valentin
@ 2015-01-24  1:00               ` Tobias Jakobi
  0 siblings, 0 replies; 288+ messages in thread
From: Tobias Jakobi @ 2015-01-24  1:00 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Lukasz Majewski, Zhang Rui, Kukjin Kim, Kukjin Kim,
	Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Kyungmin Park, Chanwoo Choi, Thomas Abraham, tomasz.figa

Eduardo Valentin wrote:
> The reason is that hwmon sensor device drivers also register via
> of-thermal. So, adding hwmon interface by default will create a
> cyclic problem.
Hmm, I see. Would it still be possible to flag some thermal zones so
that hwmon nodes are created for them?


With best wishes,
Tobias

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v4 00/17] thermal: exynos: Thermal code rework to use device tree
  2015-01-23 14:45         ` Eduardo Valentin
@ 2015-01-24  4:04           ` Kukjin Kim
  0 siblings, 0 replies; 288+ messages in thread
From: Kukjin Kim @ 2015-01-24  4:04 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kukjin Kim, 'Lukasz Majewski', 'Zhang Rui',
	'Linux PM list',
	linux-samsung-soc, 'Bartlomiej Zolnierkiewicz',
	'Lukasz Majewski', 'Amit Daniel Kachhap',
	'Abhilash Kesavan', 'Kyungmin Park',
	'Chanwoo Choi', 'Abhilash Kesavan'

On 01/23/15 23:45, Eduardo Valentin wrote:
> Hi Kukjin,
> 
Hi Eduardo,

[...]

>>>> I hope will apply DT changes in Samsung tree. Is it OK to thermal
>>>> tree?
>>>
>>> I think that it is up to you and Eduardo to decide :-).
>>>
>>> I'd personally prefer to add this patch set at once to Eduardo's tree
>>> (of course with your ACKs).
>>>
>> If so, we could see too many useless merge conflicts. Because your patches
>> touch most of exynos DT stuff and that's why DT changes should be handled in
>> Samsung tree if there is no problem ;) Let's wait for thermal guys.
> 
> Let's target the latest version (v6) of this series. You can add my
> Acked-by: Eduardo Valentin <edubezval@gmail.com>
> 
OK, I'll take DT changes in my tree with your ack.

> in the DTS changes. And add them via your tree. I believe we will avoid
> merge conflicts this way. I will handle the patches touching drivers/.
> 
Sure, thanks.

- Kukjin

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v6 00/18] thermal: exynos: Thermal code rework to use device tree
  2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
                       ` (16 preceding siblings ...)
  2015-01-23 12:10     ` [PATCH v6 18/18] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
@ 2015-01-24 21:49     ` Eduardo Valentin
  2015-01-26  8:49       ` Lukasz Majewski
  2015-01-29 23:34       ` Kukjin Kim
  17 siblings, 2 replies; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-24 21:49 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Chanwoo Choi, Viresh Kumar

[-- Attachment #1: Type: text/plain, Size: 5952 bytes --]

On Fri, Jan 23, 2015 at 01:09:53PM +0100, Lukasz Majewski wrote:
> 1. Introduction
> 
> Following patches aim to clean up the current implementation of the thermal
> framework on Exynos devices.
> 
> The main goal was to use a generic code for reading thermal configuration
> (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
> were removed.
> 
> Around 400 lines of code (LOC) were removed directly by this patch, which
> is around 20% of the Exynos thermal code base.
> 
> This work should NOT bring any functional changes to Exynos thermal 
> subsystem.
> 
> 2. Patch-set structure
> 
> Then the cpu_cooling functionality has been preserved to allow cooling
> devices by reducing operating frequency. Definition of trip points and
> cpufreq's cooling properties were moved to device tree.
> 
> Then the rework of the way in which configuration data is provided to
> the Exynos thermal subsystem was performed. Now device tree is used for
> configuration.
> 
> 3. Dead code removal
> 
> Thermal support for some SoCs, previously available in the exynos_tmu_data.c 
> file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.
> 
> Moreover, support for cpu_cooling devices was preserved only on those
> SoCs which had available and working cpufreq driver.
> 
> 4. Testing
> 
> Test devices:
> - Exynos4210 - Trats (TMU zone + cpu_cooling)
> - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> - Exynos5420 - Arndale-octa (only TMU zones)
> 
> Unfortunately, I don't posses Exynos5440 for testing. Its functionality
> has been preserved in the code, but not tested on the hardware. I would
> be grateful for help in testing.
> 
> 
> 5. This work apply on the following tree:
> 
> kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
> 
> 
> Lukasz Majewski (18):

I have applied the following patches to my -fixes branch (for next rc
cycle)

>   thermal: exynos: cosmetic: Correct comment format
>   thermal: exynos: Provide thermal_exynos.h file to be included in
>     device tree files
>   thermal: exynos: Modify exynos thermal code to use device tree for cpu
>     cooling configuration
>   cpufreq: exynos: Use device tree to determine if cpufreq cooling
>     should be registered
>   dts: Documentation: Extending documentation entry for exynos-thermal
>   dts: Documentation: Update exynos-thermal.txt example for Exynos5440
>   thermal: samsung: core: Exynos TMU rework to use device tree for
>     configuration
>   thermal: exynos: Remove exynos_thermal_common.[c|h] files
>   thermal: exynos: Remove exynos_tmu_data.c file

The patches below should go via platform tree:

>   arm: dts: trats: Enable TMU on the Exynos4210 trats device
>   arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid
>   arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
>   arm: dts: Adding CPU cooling binding for Exynos SoCs
>   thermal: exynos: dts: Add default definition of the TMU sensor
>     parameter
>   thermal: dts: Default trip points definition for Exynos5420 SoCs
>   thermal: exynos: dts: Define default thermal-zones for Exynos4
>   thermal: dts: exynos: Trip points and sensor configuration data for
>     Exynos5440
>   thermal: exynos: dts: Provide device tree bindings identical to the
>     one in exynos_tmu_data.c


Thanks a lot.

> 
>  .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
>  arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
>  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
>  arch/arm/boot/dts/exynos4.dtsi                     |   4 +
>  arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
>  arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
>  arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
>  arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
>  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
>  arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
>  arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
>  arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
>  arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
>  arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
>  arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
>  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
>  arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
>  arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
>  drivers/cpufreq/exynos-cpufreq.c                   |  33 +-
>  drivers/thermal/samsung/Makefile                   |   2 -
>  drivers/thermal/samsung/exynos_thermal_common.c    | 427 ---------------------
>  drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
>  drivers/thermal/samsung/exynos_tmu.c               | 348 +++++++++++------
>  drivers/thermal/samsung/exynos_tmu.h               |  76 +---
>  drivers/thermal/samsung/exynos_tmu_data.c          | 264 -------------
>  include/dt-bindings/thermal/thermal_exynos.h       |  28 ++
>  26 files changed, 636 insertions(+), 1008 deletions(-)
>  create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
>  create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
>  delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
>  create mode 100644 include/dt-bindings/thermal/thermal_exynos.h
> 
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered
  2015-01-23 13:57       ` Lukasz Majewski
@ 2015-01-25 14:01         ` Viresh Kumar
  2015-01-25 16:27           ` Lukasz Majewski
  2015-01-25 16:46           ` Eduardo Valentin
  0 siblings, 2 replies; 288+ messages in thread
From: Viresh Kumar @ 2015-01-25 14:01 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kukjin Kim, Chanwoo Choi

On 23 January 2015 at 19:27, Lukasz Majewski <l.majewski@samsung.com> wrote:
> Please pay a note about following problem:
>
> Previously we got: cpu0: cpu@0 for all Exynos devices.
>
> Now, however, cpu numbering has changed (due to GIC rework).
> For example:
>
> Exynos4412:
>         cpus {
>                 cpu0: cpu@A00 {
>                         ...
>                         #cooling-cells = <2>; /* min followed by max */
>                 };
>
>                 cpu@A01 {
>                 };
>
>                 cpu@A02 {
>                 };
>
>                 cpu@A03 {
>                 };
>         }
>
> Exynos 4210:
>         cpus {
>                 cpu0: cpu@900 {
>                         #cooling-cells = <2>; /* min followed by max */
>                 };
>
>                 cpu@901 {
>                 };
>         };
>
> Exynos 5250:
>         cpus {
>                 cpu0: cpu@0 {
>                         #cooling-cells = <2>; /* min followed by max */
>                 };
>
>                 cpu@1 {
>                 };
>         };
>
>
> As you can see different cpu@XXY nodes we have and simply calling cpu@0
> won't work.

I wasn't asked you to get the cpu0 node from dt but this:

cpu_dev = get_cpu_dev(0);
np = of_node_get(cpu_dev->of_node);

Wouldn't this work? You only need to guarantee that the cooling-cells is added
onto the boot CPUs node.

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered
  2015-01-25 14:01         ` Viresh Kumar
@ 2015-01-25 16:27           ` Lukasz Majewski
  2015-01-25 16:46           ` Eduardo Valentin
  1 sibling, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-25 16:27 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Lukasz Majewski, Eduardo Valentin, Zhang Rui, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kukjin Kim, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 1732 bytes --]

On Sun, 25 Jan 2015 19:31:14 +0530
Viresh Kumar <viresh.kumar@linaro.org> wrote:

> On 23 January 2015 at 19:27, Lukasz Majewski <l.majewski@samsung.com>
> wrote:
> > Please pay a note about following problem:
> >
> > Previously we got: cpu0: cpu@0 for all Exynos devices.
> >
> > Now, however, cpu numbering has changed (due to GIC rework).
> > For example:
> >
> > Exynos4412:
> >         cpus {
> >                 cpu0: cpu@A00 {
> >                         ...
> >                         #cooling-cells = <2>; /* min followed by
> > max */ };
> >
> >                 cpu@A01 {
> >                 };
> >
> >                 cpu@A02 {
> >                 };
> >
> >                 cpu@A03 {
> >                 };
> >         }
> >
> > Exynos 4210:
> >         cpus {
> >                 cpu0: cpu@900 {
> >                         #cooling-cells = <2>; /* min followed by
> > max */ };
> >
> >                 cpu@901 {
> >                 };
> >         };
> >
> > Exynos 5250:
> >         cpus {
> >                 cpu0: cpu@0 {
> >                         #cooling-cells = <2>; /* min followed by
> > max */ };
> >
> >                 cpu@1 {
> >                 };
> >         };
> >
> >
> > As you can see different cpu@XXY nodes we have and simply calling
> > cpu@0 won't work.
> 
> I wasn't asked you to get the cpu0 node from dt but this:
> 
> cpu_dev = get_cpu_dev(0);
> np = of_node_get(cpu_dev->of_node);

Ingenious simplicity :-)

> 
> Wouldn't this work? You only need to guarantee that the cooling-cells
> is added onto the boot CPUs node.

I will test it tomorrow and share results.

Viresh, thanks for tip.

Best regards,
Lukasz Majewski

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered
  2015-01-25 14:01         ` Viresh Kumar
  2015-01-25 16:27           ` Lukasz Majewski
@ 2015-01-25 16:46           ` Eduardo Valentin
  2015-01-25 21:55             ` Lukasz Majewski
  1 sibling, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-01-25 16:46 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Lukasz Majewski, Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kukjin Kim, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 1954 bytes --]

On Sun, Jan 25, 2015 at 07:31:14PM +0530, Viresh Kumar wrote:
> On 23 January 2015 at 19:27, Lukasz Majewski <l.majewski@samsung.com> wrote:
> > Please pay a note about following problem:
> >
> > Previously we got: cpu0: cpu@0 for all Exynos devices.
> >
> > Now, however, cpu numbering has changed (due to GIC rework).
> > For example:
> >
> > Exynos4412:
> >         cpus {
> >                 cpu0: cpu@A00 {
> >                         ...
> >                         #cooling-cells = <2>; /* min followed by max */
> >                 };
> >
> >                 cpu@A01 {
> >                 };
> >
> >                 cpu@A02 {
> >                 };
> >
> >                 cpu@A03 {
> >                 };
> >         }
> >
> > Exynos 4210:
> >         cpus {
> >                 cpu0: cpu@900 {
> >                         #cooling-cells = <2>; /* min followed by max */
> >                 };
> >
> >                 cpu@901 {
> >                 };
> >         };
> >
> > Exynos 5250:
> >         cpus {
> >                 cpu0: cpu@0 {
> >                         #cooling-cells = <2>; /* min followed by max */
> >                 };
> >
> >                 cpu@1 {
> >                 };
> >         };
> >
> >
> > As you can see different cpu@XXY nodes we have and simply calling cpu@0
> > won't work.
> 
> I wasn't asked you to get the cpu0 node from dt but this:
> 
> cpu_dev = get_cpu_dev(0);
> np = of_node_get(cpu_dev->of_node);
> 
> Wouldn't this work? You only need to guarantee that the cooling-cells is added
> onto the boot CPUs node.

Lukasz,

I agree with Viresh here, you can simplify your code.

I, somehow, missed this conversation and already applied v6 of this
patch in my -fixes branch. Can you please fix this by sending a
differential patch on top of this one applying Viresh's commit?

Viresh, my bad, I missed your comments.

Thanks


Eduardo 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered
  2015-01-25 16:46           ` Eduardo Valentin
@ 2015-01-25 21:55             ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-25 21:55 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Viresh Kumar, Lukasz Majewski, Zhang Rui, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kukjin Kim, Chanwoo Choi

[-- Attachment #1: Type: text/plain, Size: 2211 bytes --]

On Sun, 25 Jan 2015 12:46:21 -0400
Eduardo Valentin <edubezval@gmail.com> wrote:

> On Sun, Jan 25, 2015 at 07:31:14PM +0530, Viresh Kumar wrote:
> > On 23 January 2015 at 19:27, Lukasz Majewski
> > <l.majewski@samsung.com> wrote:
> > > Please pay a note about following problem:
> > >
> > > Previously we got: cpu0: cpu@0 for all Exynos devices.
> > >
> > > Now, however, cpu numbering has changed (due to GIC rework).
> > > For example:
> > >
> > > Exynos4412:
> > >         cpus {
> > >                 cpu0: cpu@A00 {
> > >                         ...
> > >                         #cooling-cells = <2>; /* min followed by
> > > max */ };
> > >
> > >                 cpu@A01 {
> > >                 };
> > >
> > >                 cpu@A02 {
> > >                 };
> > >
> > >                 cpu@A03 {
> > >                 };
> > >         }
> > >
> > > Exynos 4210:
> > >         cpus {
> > >                 cpu0: cpu@900 {
> > >                         #cooling-cells = <2>; /* min followed by
> > > max */ };
> > >
> > >                 cpu@901 {
> > >                 };
> > >         };
> > >
> > > Exynos 5250:
> > >         cpus {
> > >                 cpu0: cpu@0 {
> > >                         #cooling-cells = <2>; /* min followed by
> > > max */ };
> > >
> > >                 cpu@1 {
> > >                 };
> > >         };
> > >
> > >
> > > As you can see different cpu@XXY nodes we have and simply calling
> > > cpu@0 won't work.
> > 
> > I wasn't asked you to get the cpu0 node from dt but this:
> > 
> > cpu_dev = get_cpu_dev(0);
> > np = of_node_get(cpu_dev->of_node);
> > 
> > Wouldn't this work? You only need to guarantee that the
> > cooling-cells is added onto the boot CPUs node.
> 
> Lukasz,
> 
> I agree with Viresh here, you can simplify your code.
> 
> I, somehow, missed this conversation and already applied v6 of this
> patch in my -fixes branch. Can you please fix this by sending a
> differential patch on top of this one applying Viresh's commit?

No problem, I will check this in my office tomorrow.

Thanks.

> 
> Viresh, my bad, I missed your comments.
> 
> Thanks
> 
> 
> Eduardo 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v6 00/18] thermal: exynos: Thermal code rework to use device tree
  2015-01-24 21:49     ` [PATCH v6 00/18] thermal: exynos: Thermal code rework to use device tree Eduardo Valentin
@ 2015-01-26  8:49       ` Lukasz Majewski
  2015-01-29 23:34       ` Kukjin Kim
  1 sibling, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-26  8:49 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Kukjin Kim, Kukjin Kim, Linux PM list,
	linux-samsung-soc, Bartlomiej Zolnierkiewicz, Lukasz Majewski,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Chanwoo Choi, Viresh Kumar

Hi Eduardo,

> On Fri, Jan 23, 2015 at 01:09:53PM +0100, Lukasz Majewski wrote:
> > 1. Introduction
> > 
> > Following patches aim to clean up the current implementation of the
> > thermal framework on Exynos devices.
> > 
> > The main goal was to use a generic code for reading thermal
> > configuration (of-thermal.c). Due to that redundant
> > exynos_thermal_common.[h|c] files were removed.
> > 
> > Around 400 lines of code (LOC) were removed directly by this patch,
> > which is around 20% of the Exynos thermal code base.
> > 
> > This work should NOT bring any functional changes to Exynos thermal 
> > subsystem.
> > 
> > 2. Patch-set structure
> > 
> > Then the cpu_cooling functionality has been preserved to allow
> > cooling devices by reducing operating frequency. Definition of trip
> > points and cpufreq's cooling properties were moved to device tree.
> > 
> > Then the rework of the way in which configuration data is provided
> > to the Exynos thermal subsystem was performed. Now device tree is
> > used for configuration.
> > 
> > 3. Dead code removal
> > 
> > Thermal support for some SoCs, previously available in the
> > exynos_tmu_data.c file, was removed since, as of (almost) 3.19-rc3,
> > they didn't have TMU bindings.
> > 
> > Moreover, support for cpu_cooling devices was preserved only on
> > those SoCs which had available and working cpufreq driver.
> > 
> > 4. Testing
> > 
> > Test devices:
> > - Exynos4210 - Trats (TMU zone + cpu_cooling)
> > - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> > - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> > - Exynos5420 - Arndale-octa (only TMU zones)
> > 
> > Unfortunately, I don't posses Exynos5440 for testing. Its
> > functionality has been preserved in the code, but not tested on the
> > hardware. I would be grateful for help in testing.
> > 
> > 
> > 5. This work apply on the following tree:
> > 
> > kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> > SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
> > 
> > 
> > Lukasz Majewski (18):
> 
> I have applied the following patches to my -fixes branch (for next rc
> cycle)
> 
> >   thermal: exynos: cosmetic: Correct comment format
> >   thermal: exynos: Provide thermal_exynos.h file to be included in
> >     device tree files
> >   thermal: exynos: Modify exynos thermal code to use device tree
> > for cpu cooling configuration
> >   cpufreq: exynos: Use device tree to determine if cpufreq cooling
> >     should be registered
> >   dts: Documentation: Extending documentation entry for
> > exynos-thermal dts: Documentation: Update exynos-thermal.txt
> > example for Exynos5440 thermal: samsung: core: Exynos TMU rework to
> > use device tree for configuration
> >   thermal: exynos: Remove exynos_thermal_common.[c|h] files
> >   thermal: exynos: Remove exynos_tmu_data.c file
      
	By some mishap the last patch "thermal: exynos: Remove
	exynos_tmu_data.c file" was not applied to neither
	linux-soc-thermal/next nor linux-soc-thermal/fixes.

Eduardo, could you apply it?

> 
> The patches below should go via platform tree:
> 
> >   arm: dts: trats: Enable TMU on the Exynos4210 trats device
> >   arm: dts: odroid: Add LDO10 regulator node necessary for TMU on
> > Odroid arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3
> > device arm: dts: Adding CPU cooling binding for Exynos SoCs
> >   thermal: exynos: dts: Add default definition of the TMU sensor
> >     parameter
> >   thermal: dts: Default trip points definition for Exynos5420 SoCs
> >   thermal: exynos: dts: Define default thermal-zones for Exynos4
> >   thermal: dts: exynos: Trip points and sensor configuration data
> > for Exynos5440
> >   thermal: exynos: dts: Provide device tree bindings identical to
> > the one in exynos_tmu_data.c
> 
> 
> Thanks a lot.
> 
> > 
> >  .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
> >  arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
> >  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
> >  arch/arm/boot/dts/exynos4.dtsi                     |   4 +
> >  arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
> >  arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
> >  arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
> >  arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
> >  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
> >  arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
> >  arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
> >  arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
> >  arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
> >  arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
> >  arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
> >  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
> >  arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
> >  arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
> >  drivers/cpufreq/exynos-cpufreq.c                   |  33 +-
> >  drivers/thermal/samsung/Makefile                   |   2 -
> >  drivers/thermal/samsung/exynos_thermal_common.c    | 427
> > ---------------------
> > drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
> > drivers/thermal/samsung/exynos_tmu.c               | 348
> > +++++++++++------
> > drivers/thermal/samsung/exynos_tmu.h               |  76 +---
> > drivers/thermal/samsung/exynos_tmu_data.c          | 264
> > ------------- include/dt-bindings/thermal/thermal_exynos.h       |
> > 28 ++ 26 files changed, 636 insertions(+), 1008 deletions(-) create
> > mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi create mode
> > 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi create
> > mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi create
> > mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
> > create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
> > delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
> > delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
> > delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c create
> > mode 100644 include/dt-bindings/thermal/thermal_exynos.h
> > 
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used
  2015-01-23 12:14   ` [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered Lukasz Majewski
  2015-01-23 12:59     ` Viresh Kumar
@ 2015-01-26  9:25     ` Lukasz Majewski
  2015-01-27  3:44       ` Viresh Kumar
  1 sibling, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-01-26  9:25 UTC (permalink / raw)
  To: Eduardo Valentin, Viresh Kumar
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kukjin Kim, Chanwoo Choi, Lukasz Majewski

Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility to
use device tree to asses if cpu can be used as cooling device. Since the
code was somewhat awkward, simpler approach has been proposed.

Test HW: Exynos 4412 - Odroid U3.

Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 5e98c6b..b640da0 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
-	struct device_node *cpus, *np;
+	struct device_node *cpu0, *np;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_cpufreq_reg;
 
-	cpus = of_find_node_by_path("/cpus");
-	if (!cpus) {
-		pr_err("failed to find cpus node\n");
+	cpu0 = of_get_cpu_node(0, NULL);
+	if (!cpu0) {
+		pr_err("failed to find cpu0 node\n");
 		return 0;
 	}
 
-	np = of_get_next_child(cpus, NULL);
-	if (!np) {
-		pr_err("failed to find cpus child node\n");
-		of_node_put(cpus);
-		return 0;
-	}
-
-	if (of_find_property(np, "#cooling-cells", NULL)) {
-		cdev = of_cpufreq_cooling_register(np,
+	if (of_find_property(cpu0, "#cooling-cells", NULL)) {
+		cdev = of_cpufreq_cooling_register(cpu0,
 						   cpu_present_mask);
 		if (IS_ERR(cdev))
 			pr_err("running cpufreq without cooling device: %ld\n",
 			       PTR_ERR(cdev));
 	}
-	of_node_put(np);
-	of_node_put(cpus);
 
 	return 0;
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* Re: [PATCH] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used
  2015-01-26  9:25     ` [PATCH] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used Lukasz Majewski
@ 2015-01-27  3:44       ` Viresh Kumar
  2015-02-04  9:00         ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Viresh Kumar @ 2015-01-27  3:44 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kukjin Kim, Chanwoo Choi

On 26 January 2015 at 14:55, Lukasz Majewski <l.majewski@samsung.com> wrote:
> Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility to
> use device tree to asses if cpu can be used as cooling device. Since the
> code was somewhat awkward, simpler approach has been proposed.
>
> Test HW: Exynos 4412 - Odroid U3.
>
> Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
>  1 file changed, 6 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
> index 5e98c6b..b640da0 100644
> --- a/drivers/cpufreq/exynos-cpufreq.c
> +++ b/drivers/cpufreq/exynos-cpufreq.c
> @@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
>
>  static int exynos_cpufreq_probe(struct platform_device *pdev)
>  {
> -       struct device_node *cpus, *np;
> +       struct device_node *cpu0, *np;
>         int ret = -EINVAL;
>
>         exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
> @@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
>         if (ret)
>                 goto err_cpufreq_reg;
>
> -       cpus = of_find_node_by_path("/cpus");
> -       if (!cpus) {
> -               pr_err("failed to find cpus node\n");
> +       cpu0 = of_get_cpu_node(0, NULL);
> +       if (!cpu0) {
> +               pr_err("failed to find cpu0 node\n");
>                 return 0;
>         }
>
> -       np = of_get_next_child(cpus, NULL);
> -       if (!np) {
> -               pr_err("failed to find cpus child node\n");
> -               of_node_put(cpus);
> -               return 0;
> -       }
> -
> -       if (of_find_property(np, "#cooling-cells", NULL)) {
> -               cdev = of_cpufreq_cooling_register(np,
> +       if (of_find_property(cpu0, "#cooling-cells", NULL)) {
> +               cdev = of_cpufreq_cooling_register(cpu0,
>                                                    cpu_present_mask);
>                 if (IS_ERR(cdev))
>                         pr_err("running cpufreq without cooling device: %ld\n",
>                                PTR_ERR(cdev));
>         }
> -       of_node_put(np);
> -       of_node_put(cpus);
>
>         return 0;

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v6 00/18] thermal: exynos: Thermal code rework to use device tree
  2015-01-24 21:49     ` [PATCH v6 00/18] thermal: exynos: Thermal code rework to use device tree Eduardo Valentin
  2015-01-26  8:49       ` Lukasz Majewski
@ 2015-01-29 23:34       ` Kukjin Kim
  2015-02-23 10:13         ` Lukasz Majewski
  1 sibling, 1 reply; 288+ messages in thread
From: Kukjin Kim @ 2015-01-29 23:34 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Lukasz Majewski, Zhang Rui, Kukjin Kim, Kukjin Kim,
	Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar

On 01/25/15 06:49, Eduardo Valentin wrote:
> On Fri, Jan 23, 2015 at 01:09:53PM +0100, Lukasz Majewski wrote:
>> 1. Introduction
>>
>> Following patches aim to clean up the current implementation of the thermal
>> framework on Exynos devices.
>>
>> The main goal was to use a generic code for reading thermal configuration
>> (of-thermal.c). Due to that redundant exynos_thermal_common.[h|c] files
>> were removed.
>>
>> Around 400 lines of code (LOC) were removed directly by this patch, which
>> is around 20% of the Exynos thermal code base.
>>
>> This work should NOT bring any functional changes to Exynos thermal 
>> subsystem.
>>
>> 2. Patch-set structure
>>
>> Then the cpu_cooling functionality has been preserved to allow cooling
>> devices by reducing operating frequency. Definition of trip points and
>> cpufreq's cooling properties were moved to device tree.
>>
>> Then the rework of the way in which configuration data is provided to
>> the Exynos thermal subsystem was performed. Now device tree is used for
>> configuration.
>>
>> 3. Dead code removal
>>
>> Thermal support for some SoCs, previously available in the exynos_tmu_data.c 
>> file, was removed since, as of (almost) 3.19-rc3, they didn't have TMU bindings.
>>
>> Moreover, support for cpu_cooling devices was preserved only on those
>> SoCs which had available and working cpufreq driver.
>>
>> 4. Testing
>>
>> Test devices:
>> - Exynos4210 - Trats (TMU zone + cpu_cooling)
>> - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
>> - Exynos5250 - Arndale (TMU zone + cpu_cooling)
>> - Exynos5420 - Arndale-octa (only TMU zones)
>>
>> Unfortunately, I don't posses Exynos5440 for testing. Its functionality
>> has been preserved in the code, but not tested on the hardware. I would
>> be grateful for help in testing.
>>
>>
>> 5. This work apply on the following tree:
>>
>> kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
>> SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
>>
>>
>> Lukasz Majewski (18):
> 
> I have applied the following patches to my -fixes branch (for next rc
> cycle)
> 
>>   thermal: exynos: cosmetic: Correct comment format
>>   thermal: exynos: Provide thermal_exynos.h file to be included in
>>     device tree files
>>   thermal: exynos: Modify exynos thermal code to use device tree for cpu
>>     cooling configuration
>>   cpufreq: exynos: Use device tree to determine if cpufreq cooling
>>     should be registered
>>   dts: Documentation: Extending documentation entry for exynos-thermal
>>   dts: Documentation: Update exynos-thermal.txt example for Exynos5440
>>   thermal: samsung: core: Exynos TMU rework to use device tree for
>>     configuration
>>   thermal: exynos: Remove exynos_thermal_common.[c|h] files
>>   thermal: exynos: Remove exynos_tmu_data.c file
> 
> The patches below should go via platform tree:
> 
>>   arm: dts: trats: Enable TMU on the Exynos4210 trats device
>>   arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid
>>   arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device
>>   arm: dts: Adding CPU cooling binding for Exynos SoCs
>>   thermal: exynos: dts: Add default definition of the TMU sensor
>>     parameter
>>   thermal: dts: Default trip points definition for Exynos5420 SoCs
>>   thermal: exynos: dts: Define default thermal-zones for Exynos4
>>   thermal: dts: exynos: Trip points and sensor configuration data for
>>     Exynos5440
>>   thermal: exynos: dts: Provide device tree bindings identical to the
>>     one in exynos_tmu_data.c
> 

I've applied above patches with small subject changes.

BTW unfortunately, since missing the
"include/dt-bindings/thermal/thermal_exynos.h" in my tree, I couldn't
merge it into for-next yet.

Can you please provide a topic branch for it? If not, this cannot be
handled in arm-soc tree in this time, I think.

- Kukjin

> 
> Thanks a lot.
> 
>>
>>  .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
>>  arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
>>  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
>>  arch/arm/boot/dts/exynos4.dtsi                     |   4 +
>>  arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
>>  arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
>>  arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
>>  arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
>>  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
>>  arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
>>  arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
>>  arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
>>  arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
>>  arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
>>  arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
>>  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
>>  arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
>>  arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
>>  drivers/cpufreq/exynos-cpufreq.c                   |  33 +-
>>  drivers/thermal/sam`sung/Makefile                   |   2 -
>>  drivers/thermal/samsung/exynos_thermal_common.c    | 427 ---------------------
>>  drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
>>  drivers/thermal/samsung/exynos_tmu.c               | 348 +++++++++++------
>>  drivers/thermal/samsung/exynos_tmu.h               |  76 +---
>>  drivers/thermal/samsung/exynos_tmu_data.c          | 264 -------------
>>  include/dt-bindings/thermal/thermal_exynos.h       |  28 ++
>>  26 files changed, 636 insertions(+), 1008 deletions(-)
>>  create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
>>  create mode 100644 arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi
>>  create mode 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi
>>  create mode 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
>>  create mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi
>>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
>>  delete mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
>>  delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
>>  create mode 100644 include/dt-bindings/thermal/thermal_exynos.h

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used
  2015-01-27  3:44       ` Viresh Kumar
@ 2015-02-04  9:00         ` Lukasz Majewski
  2015-02-05 15:54           ` [PATCH v2] " Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-02-04  9:00 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Viresh Kumar, Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Kukjin Kim,
	Amit Daniel Kachhap, Abhilash Kesavan, Abhilash Kesavan,
	Kukjin Kim, Chanwoo Choi

Hi Eduardo,

> On 26 January 2015 at 14:55, Lukasz Majewski <l.majewski@samsung.com>
> wrote:
> > Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided
> > possibility to use device tree to asses if cpu can be used as
> > cooling device. Since the code was somewhat awkward, simpler
> > approach has been proposed.
> >
> > Test HW: Exynos 4412 - Odroid U3.
> >
> > Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
> >  1 file changed, 6 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/cpufreq/exynos-cpufreq.c
> > b/drivers/cpufreq/exynos-cpufreq.c index 5e98c6b..b640da0 100644
> > --- a/drivers/cpufreq/exynos-cpufreq.c
> > +++ b/drivers/cpufreq/exynos-cpufreq.c
> > @@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
> >
> >  static int exynos_cpufreq_probe(struct platform_device *pdev)
> >  {
> > -       struct device_node *cpus, *np;
> > +       struct device_node *cpu0, *np;
> >         int ret = -EINVAL;
> >
> >         exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
> > @@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct
> > platform_device *pdev) if (ret)
> >                 goto err_cpufreq_reg;
> >
> > -       cpus = of_find_node_by_path("/cpus");
> > -       if (!cpus) {
> > -               pr_err("failed to find cpus node\n");
> > +       cpu0 = of_get_cpu_node(0, NULL);
> > +       if (!cpu0) {
> > +               pr_err("failed to find cpu0 node\n");
> >                 return 0;
> >         }
> >
> > -       np = of_get_next_child(cpus, NULL);
> > -       if (!np) {
> > -               pr_err("failed to find cpus child node\n");
> > -               of_node_put(cpus);
> > -               return 0;
> > -       }
> > -
> > -       if (of_find_property(np, "#cooling-cells", NULL)) {
> > -               cdev = of_cpufreq_cooling_register(np,
> > +       if (of_find_property(cpu0, "#cooling-cells", NULL)) {
> > +               cdev = of_cpufreq_cooling_register(cpu0,
> >                                                    cpu_present_mask);
> >                 if (IS_ERR(cdev))
> >                         pr_err("running cpufreq without cooling
> > device: %ld\n", PTR_ERR(cdev));
> >         }
> > -       of_node_put(np);
> > -       of_node_put(cpus);
> >
> >         return 0;
> 
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

Could you apply this patch to yours linux-soc-thermal tree?


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* [PATCH v2] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used
  2015-02-04  9:00         ` Lukasz Majewski
@ 2015-02-05 15:54           ` Lukasz Majewski
  2015-02-26 10:36             ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-02-05 15:54 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: Linux PM list, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
	Lukasz Majewski, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar, Lukasz Majewski

Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility to
use device tree to asses if cpu can be used as cooling device. Since the
code was somewhat awkward, simpler approach has been proposed.

Test HW: Exynos 4412 - Odroid U3.

Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
---
Changes for v2:
- Remove superfluous *np pointer
---
 drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 5e98c6b..82d2fbb 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
-	struct device_node *cpus, *np;
+	struct device_node *cpu0;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_cpufreq_reg;
 
-	cpus = of_find_node_by_path("/cpus");
-	if (!cpus) {
-		pr_err("failed to find cpus node\n");
+	cpu0 = of_get_cpu_node(0, NULL);
+	if (!cpu0) {
+		pr_err("failed to find cpu0 node\n");
 		return 0;
 	}
 
-	np = of_get_next_child(cpus, NULL);
-	if (!np) {
-		pr_err("failed to find cpus child node\n");
-		of_node_put(cpus);
-		return 0;
-	}
-
-	if (of_find_property(np, "#cooling-cells", NULL)) {
-		cdev = of_cpufreq_cooling_register(np,
+	if (of_find_property(cpu0, "#cooling-cells", NULL)) {
+		cdev = of_cpufreq_cooling_register(cpu0,
 						   cpu_present_mask);
 		if (IS_ERR(cdev))
 			pr_err("running cpufreq without cooling device: %ld\n",
 			       PTR_ERR(cdev));
 	}
-	of_node_put(np);
-	of_node_put(cpus);
 
 	return 0;
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 288+ messages in thread

* Re: [PATCH v6 00/18] thermal: exynos: Thermal code rework to use device tree
  2015-01-29 23:34       ` Kukjin Kim
@ 2015-02-23 10:13         ` Lukasz Majewski
  2015-02-23 11:18           ` Kukjin Kim
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-02-23 10:13 UTC (permalink / raw)
  To: Kukjin Kim, Eduardo Valentin
  Cc: Zhang Rui, Kukjin Kim, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Chanwoo Choi, Viresh Kumar

Hi Kukjin, Eduardo

> On 01/25/15 06:49, Eduardo Valentin wrote:
> > On Fri, Jan 23, 2015 at 01:09:53PM +0100, Lukasz Majewski wrote:
> >> 1. Introduction
> >>
> >> Following patches aim to clean up the current implementation of
> >> the thermal framework on Exynos devices.
> >>
> >> The main goal was to use a generic code for reading thermal
> >> configuration (of-thermal.c). Due to that redundant
> >> exynos_thermal_common.[h|c] files were removed.
> >>
> >> Around 400 lines of code (LOC) were removed directly by this
> >> patch, which is around 20% of the Exynos thermal code base.
> >>
> >> This work should NOT bring any functional changes to Exynos
> >> thermal subsystem.
> >>
> >> 2. Patch-set structure
> >>
> >> Then the cpu_cooling functionality has been preserved to allow
> >> cooling devices by reducing operating frequency. Definition of
> >> trip points and cpufreq's cooling properties were moved to device
> >> tree.
> >>
> >> Then the rework of the way in which configuration data is provided
> >> to the Exynos thermal subsystem was performed. Now device tree is
> >> used for configuration.
> >>
> >> 3. Dead code removal
> >>
> >> Thermal support for some SoCs, previously available in the
> >> exynos_tmu_data.c file, was removed since, as of (almost)
> >> 3.19-rc3, they didn't have TMU bindings.
> >>
> >> Moreover, support for cpu_cooling devices was preserved only on
> >> those SoCs which had available and working cpufreq driver.
> >>
> >> 4. Testing
> >>
> >> Test devices:
> >> - Exynos4210 - Trats (TMU zone + cpu_cooling)
> >> - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> >> - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> >> - Exynos5420 - Arndale-octa (only TMU zones)
> >>
> >> Unfortunately, I don't posses Exynos5440 for testing. Its
> >> functionality has been preserved in the code, but not tested on
> >> the hardware. I would be grateful for help in testing.
> >>
> >>
> >> 5. This work apply on the following tree:
> >>
> >> kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> >> SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
> >>
> >>
> >> Lukasz Majewski (18):
> > 
> > I have applied the following patches to my -fixes branch (for next
> > rc cycle)
> > 
> >>   thermal: exynos: cosmetic: Correct comment format
> >>   thermal: exynos: Provide thermal_exynos.h file to be included in
> >>     device tree files
> >>   thermal: exynos: Modify exynos thermal code to use device tree
> >> for cpu cooling configuration
> >>   cpufreq: exynos: Use device tree to determine if cpufreq cooling
> >>     should be registered
> >>   dts: Documentation: Extending documentation entry for
> >> exynos-thermal dts: Documentation: Update exynos-thermal.txt
> >> example for Exynos5440 thermal: samsung: core: Exynos TMU rework
> >> to use device tree for configuration
> >>   thermal: exynos: Remove exynos_thermal_common.[c|h] files
> >>   thermal: exynos: Remove exynos_tmu_data.c file
> > 
> > The patches below should go via platform tree:
> > 
> >>   arm: dts: trats: Enable TMU on the Exynos4210 trats device
> >>   arm: dts: odroid: Add LDO10 regulator node necessary for TMU on
> >> Odroid arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3
> >> device arm: dts: Adding CPU cooling binding for Exynos SoCs
> >>   thermal: exynos: dts: Add default definition of the TMU sensor
> >>     parameter
> >>   thermal: dts: Default trip points definition for Exynos5420 SoCs
> >>   thermal: exynos: dts: Define default thermal-zones for Exynos4
> >>   thermal: dts: exynos: Trip points and sensor configuration data
> >> for Exynos5440
> >>   thermal: exynos: dts: Provide device tree bindings identical to
> >> the one in exynos_tmu_data.c
> > 
> 
> I've applied above patches with small subject changes.
> 
> BTW unfortunately, since missing the
> "include/dt-bindings/thermal/thermal_exynos.h" in my tree, I couldn't
> merge it into for-next yet.

As of this writing: (Kernel 4.0-rc1) the
"include/dt-bindings/thermal/thermal_exynos.h" file is in the kernel
tree.

Kukjin, could you add missing DTS files and send this to upstream.

Thanks in advance.

> 
> Can you please provide a topic branch for it? If not, this cannot be
> handled in arm-soc tree in this time, I think.
> 
> - Kukjin
> 
> > 
> > Thanks a lot.
> > 
> >>
> >>  .../devicetree/bindings/thermal/exynos-thermal.txt |  17 +
> >>  arch/arm/boot/dts/exynos3250.dtsi                  |   2 +
> >>  arch/arm/boot/dts/exynos4-cpu-thermal.dtsi         |  52 +++
> >>  arch/arm/boot/dts/exynos4.dtsi                     |   4 +
> >>  arch/arm/boot/dts/exynos4210-trats.dts             |  19 +
> >>  arch/arm/boot/dts/exynos4210.dtsi                  |  30 +-
> >>  arch/arm/boot/dts/exynos4212.dtsi                  |   5 +-
> >>  arch/arm/boot/dts/exynos4412-odroid-common.dtsi    |  27 ++
> >>  arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi  |  24 ++
> >>  arch/arm/boot/dts/exynos4412-trats2.dts            |  15 +
> >>  arch/arm/boot/dts/exynos4412.dtsi                  |   5 +-
> >>  arch/arm/boot/dts/exynos4x12.dtsi                  |   1 +
> >>  arch/arm/boot/dts/exynos5250.dtsi                  |  29 +-
> >>  arch/arm/boot/dts/exynos5420-trip-points.dtsi      |  35 ++
> >>  arch/arm/boot/dts/exynos5420.dtsi                  |  28 ++
> >>  arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi  |  24 ++
> >>  arch/arm/boot/dts/exynos5440-trip-points.dtsi      |  25 ++
> >>  arch/arm/boot/dts/exynos5440.dtsi                  |  18 +
> >>  drivers/cpufreq/exynos-cpufreq.c                   |  33 +-
> >>  drivers/thermal/sam`sung/Makefile                   |   2 -
> >>  drivers/thermal/samsung/exynos_thermal_common.c    | 427
> >> ---------------------
> >> drivers/thermal/samsung/exynos_thermal_common.h    | 106 -----
> >> drivers/thermal/samsung/exynos_tmu.c               | 348
> >> +++++++++++------
> >> drivers/thermal/samsung/exynos_tmu.h               |  76 +---
> >> drivers/thermal/samsung/exynos_tmu_data.c          | 264
> >> ------------- include/dt-bindings/thermal/thermal_exynos.h
> >> |  28 ++ 26 files changed, 636 insertions(+), 1008 deletions(-)
> >> create mode 100644 arch/arm/boot/dts/exynos4-cpu-thermal.dtsi
> >> create mode 100644
> >> arch/arm/boot/dts/exynos4412-tmu-sensor-conf.dtsi create mode
> >> 100644 arch/arm/boot/dts/exynos5420-trip-points.dtsi create mode
> >> 100644 arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi create
> >> mode 100644 arch/arm/boot/dts/exynos5440-trip-points.dtsi delete
> >> mode 100644 drivers/thermal/samsung/exynos_thermal_common.c delete
> >> mode 100644 drivers/thermal/samsung/exynos_thermal_common.h delete
> >> mode 100644 drivers/thermal/samsung/exynos_tmu_data.c create mode
> >> 100644 include/dt-bindings/thermal/thermal_exynos.h


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* RE: [PATCH v6 00/18] thermal: exynos: Thermal code rework to use device tree
  2015-02-23 10:13         ` Lukasz Majewski
@ 2015-02-23 11:18           ` Kukjin Kim
  2015-02-23 12:28             ` Lukasz Majewski
  2015-02-26 15:56             ` Lukasz Majewski
  0 siblings, 2 replies; 288+ messages in thread
From: Kukjin Kim @ 2015-02-23 11:18 UTC (permalink / raw)
  To: 'Lukasz Majewski', 'Kukjin Kim',
	'Eduardo Valentin'
  Cc: 'Zhang Rui', 'Linux PM list',
	linux-samsung-soc, 'Bartlomiej Zolnierkiewicz',
	'Lukasz Majewski', 'Amit Daniel Kachhap',
	'Abhilash Kesavan', 'Abhilash Kesavan',
	'Chanwoo Choi', 'Viresh Kumar'

Lukasz Majewski wrote:
> 
> Hi Kukjin, Eduardo
> 
Hi,

> > On 01/25/15 06:49, Eduardo Valentin wrote:
> > > On Fri, Jan 23, 2015 at 01:09:53PM +0100, Lukasz Majewski wrote:
> > >> 1. Introduction
> > >>
> > >> Following patches aim to clean up the current implementation of
> > >> the thermal framework on Exynos devices.
> > >>
> > >> The main goal was to use a generic code for reading thermal
> > >> configuration (of-thermal.c). Due to that redundant
> > >> exynos_thermal_common.[h|c] files were removed.
> > >>
> > >> Around 400 lines of code (LOC) were removed directly by this
> > >> patch, which is around 20% of the Exynos thermal code base.
> > >>
> > >> This work should NOT bring any functional changes to Exynos
> > >> thermal subsystem.
> > >>
> > >> 2. Patch-set structure
> > >>
> > >> Then the cpu_cooling functionality has been preserved to allow
> > >> cooling devices by reducing operating frequency. Definition of
> > >> trip points and cpufreq's cooling properties were moved to device
> > >> tree.
> > >>
> > >> Then the rework of the way in which configuration data is provided
> > >> to the Exynos thermal subsystem was performed. Now device tree is
> > >> used for configuration.
> > >>
> > >> 3. Dead code removal
> > >>
> > >> Thermal support for some SoCs, previously available in the
> > >> exynos_tmu_data.c file, was removed since, as of (almost)
> > >> 3.19-rc3, they didn't have TMU bindings.
> > >>
> > >> Moreover, support for cpu_cooling devices was preserved only on
> > >> those SoCs which had available and working cpufreq driver.
> > >>
> > >> 4. Testing
> > >>
> > >> Test devices:
> > >> - Exynos4210 - Trats (TMU zone + cpu_cooling)
> > >> - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> > >> - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> > >> - Exynos5420 - Arndale-octa (only TMU zones)
> > >>
> > >> Unfortunately, I don't posses Exynos5440 for testing. Its
> > >> functionality has been preserved in the code, but not tested on
> > >> the hardware. I would be grateful for help in testing.
> > >>
> > >>
> > >> 5. This work apply on the following tree:
> > >>
> > >> kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> > >> SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
> > >>
> > >>
> > >> Lukasz Majewski (18):
> > >
> > > I have applied the following patches to my -fixes branch (for next
> > > rc cycle)
> > >
> > >>   thermal: exynos: cosmetic: Correct comment format
> > >>   thermal: exynos: Provide thermal_exynos.h file to be included in
> > >>     device tree files
> > >>   thermal: exynos: Modify exynos thermal code to use device tree
> > >> for cpu cooling configuration
> > >>   cpufreq: exynos: Use device tree to determine if cpufreq cooling
> > >>     should be registered
> > >>   dts: Documentation: Extending documentation entry for
> > >> exynos-thermal dts: Documentation: Update exynos-thermal.txt
> > >> example for Exynos5440 thermal: samsung: core: Exynos TMU rework
> > >> to use device tree for configuration
> > >>   thermal: exynos: Remove exynos_thermal_common.[c|h] files
> > >>   thermal: exynos: Remove exynos_tmu_data.c file
> > >
> > > The patches below should go via platform tree:
> > >
> > >>   arm: dts: trats: Enable TMU on the Exynos4210 trats device
> > >>   arm: dts: odroid: Add LDO10 regulator node necessary for TMU on
> > >> Odroid arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3
> > >> device arm: dts: Adding CPU cooling binding for Exynos SoCs
> > >>   thermal: exynos: dts: Add default definition of the TMU sensor
> > >>     parameter
> > >>   thermal: dts: Default trip points definition for Exynos5420 SoCs
> > >>   thermal: exynos: dts: Define default thermal-zones for Exynos4
> > >>   thermal: dts: exynos: Trip points and sensor configuration data
> > >> for Exynos5440
> > >>   thermal: exynos: dts: Provide device tree bindings identical to
> > >> the one in exynos_tmu_data.c
> > >
> >
> > I've applied above patches with small subject changes.
> >
> > BTW unfortunately, since missing the
> > "include/dt-bindings/thermal/thermal_exynos.h" in my tree, I couldn't
> > merge it into for-next yet.
> 
> As of this writing: (Kernel 4.0-rc1) the
> "include/dt-bindings/thermal/thermal_exynos.h" file is in the kernel
> tree.
> 
I know.

> Kukjin, could you add missing DTS files and send this to upstream.
> 
Unfortunately, I couldn't take the DT changes in Samsung tree at that time
because of missing header file and it causes build error. Now I can pick
them into Samsung tree but I'm not sure it can be sent to upstream during
this -rc...

Eduardo, Lukasz,
Do you guys think the DT changes are really fixes for 4.0?

> Thanks in advance.
> 
> >
> > Can you please provide a topic branch for it? If not, this cannot be
> > handled in arm-soc tree in this time, I think.
> >
> > - Kukjin


^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v6 00/18] thermal: exynos: Thermal code rework to use device tree
  2015-02-23 11:18           ` Kukjin Kim
@ 2015-02-23 12:28             ` Lukasz Majewski
  2015-02-26 15:56             ` Lukasz Majewski
  1 sibling, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-02-23 12:28 UTC (permalink / raw)
  To: Kukjin Kim
  Cc: 'Eduardo Valentin', 'Zhang Rui',
	'Linux PM list',
	linux-samsung-soc, 'Bartlomiej Zolnierkiewicz',
	'Lukasz Majewski', 'Amit Daniel Kachhap',
	'Abhilash Kesavan', 'Abhilash Kesavan',
	'Chanwoo Choi', 'Viresh Kumar'

Hi Kukjin,

> Lukasz Majewski wrote:
> > 
> > Hi Kukjin, Eduardo
> > 
> Hi,
> 
> > > On 01/25/15 06:49, Eduardo Valentin wrote:
> > > > On Fri, Jan 23, 2015 at 01:09:53PM +0100, Lukasz Majewski wrote:
> > > >> 1. Introduction
> > > >>
> > > >> Following patches aim to clean up the current implementation of
> > > >> the thermal framework on Exynos devices.
> > > >>
> > > >> The main goal was to use a generic code for reading thermal
> > > >> configuration (of-thermal.c). Due to that redundant
> > > >> exynos_thermal_common.[h|c] files were removed.
> > > >>
> > > >> Around 400 lines of code (LOC) were removed directly by this
> > > >> patch, which is around 20% of the Exynos thermal code base.
> > > >>
> > > >> This work should NOT bring any functional changes to Exynos
> > > >> thermal subsystem.
> > > >>
> > > >> 2. Patch-set structure
> > > >>
> > > >> Then the cpu_cooling functionality has been preserved to allow
> > > >> cooling devices by reducing operating frequency. Definition of
> > > >> trip points and cpufreq's cooling properties were moved to
> > > >> device tree.
> > > >>
> > > >> Then the rework of the way in which configuration data is
> > > >> provided to the Exynos thermal subsystem was performed. Now
> > > >> device tree is used for configuration.
> > > >>
> > > >> 3. Dead code removal
> > > >>
> > > >> Thermal support for some SoCs, previously available in the
> > > >> exynos_tmu_data.c file, was removed since, as of (almost)
> > > >> 3.19-rc3, they didn't have TMU bindings.
> > > >>
> > > >> Moreover, support for cpu_cooling devices was preserved only on
> > > >> those SoCs which had available and working cpufreq driver.
> > > >>
> > > >> 4. Testing
> > > >>
> > > >> Test devices:
> > > >> - Exynos4210 - Trats (TMU zone + cpu_cooling)
> > > >> - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> > > >> - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> > > >> - Exynos5420 - Arndale-octa (only TMU zones)
> > > >>
> > > >> Unfortunately, I don't posses Exynos5440 for testing. Its
> > > >> functionality has been preserved in the code, but not tested on
> > > >> the hardware. I would be grateful for help in testing.
> > > >>
> > > >>
> > > >> 5. This work apply on the following tree:
> > > >>
> > > >> kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> > > >> SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
> > > >>
> > > >>
> > > >> Lukasz Majewski (18):
> > > >
> > > > I have applied the following patches to my -fixes branch (for
> > > > next rc cycle)
> > > >
> > > >>   thermal: exynos: cosmetic: Correct comment format
> > > >>   thermal: exynos: Provide thermal_exynos.h file to be
> > > >> included in device tree files
> > > >>   thermal: exynos: Modify exynos thermal code to use device
> > > >> tree for cpu cooling configuration
> > > >>   cpufreq: exynos: Use device tree to determine if cpufreq
> > > >> cooling should be registered
> > > >>   dts: Documentation: Extending documentation entry for
> > > >> exynos-thermal dts: Documentation: Update exynos-thermal.txt
> > > >> example for Exynos5440 thermal: samsung: core: Exynos TMU
> > > >> rework to use device tree for configuration
> > > >>   thermal: exynos: Remove exynos_thermal_common.[c|h] files
> > > >>   thermal: exynos: Remove exynos_tmu_data.c file
> > > >
> > > > The patches below should go via platform tree:
> > > >
> > > >>   arm: dts: trats: Enable TMU on the Exynos4210 trats device
> > > >>   arm: dts: odroid: Add LDO10 regulator node necessary for TMU
> > > >> on Odroid arm: dts: odroid: Enable TMU at Exynos4412 based
> > > >> Odroid U3 device arm: dts: Adding CPU cooling binding for
> > > >> Exynos SoCs thermal: exynos: dts: Add default definition of
> > > >> the TMU sensor parameter
> > > >>   thermal: dts: Default trip points definition for Exynos5420
> > > >> SoCs thermal: exynos: dts: Define default thermal-zones for
> > > >> Exynos4 thermal: dts: exynos: Trip points and sensor
> > > >> configuration data for Exynos5440
> > > >>   thermal: exynos: dts: Provide device tree bindings identical
> > > >> to the one in exynos_tmu_data.c
> > > >
> > >
> > > I've applied above patches with small subject changes.
> > >
> > > BTW unfortunately, since missing the
> > > "include/dt-bindings/thermal/thermal_exynos.h" in my tree, I
> > > couldn't merge it into for-next yet.
> > 
> > As of this writing: (Kernel 4.0-rc1) the
> > "include/dt-bindings/thermal/thermal_exynos.h" file is in the kernel
> > tree.
> > 
> I know.
> 
> > Kukjin, could you add missing DTS files and send this to upstream.
> > 
> Unfortunately, I couldn't take the DT changes in Samsung tree at that
> time because of missing header file and it causes build error. 

The header problem was due to splitting this patch set to -samsung and
-thermal trees.
The intention was to merge it all at once, but unfortunately it was
split.

> Now I
> can pick them into Samsung tree but I'm not sure it can be sent to
> upstream during this -rc...
> 
> Eduardo, Lukasz,
> Do you guys think the DT changes are really fixes for 4.0?

The thermal Samsung rework has been merged, so without this DTS files
we have regression, since boards like Trats2, Odroid will not have
thermal support in 4.0 final release.

Additionally we are now at -rc1 state, so some extra time is left to
handle unexpected situation (although there shouldn't be any).

> 
> > Thanks in advance.
> > 
> > >
> > > Can you please provide a topic branch for it? If not, this cannot
> > > be handled in arm-soc tree in this time, I think.
> > >
> > > - Kukjin
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used
  2015-02-05 15:54           ` [PATCH v2] " Lukasz Majewski
@ 2015-02-26 10:36             ` Lukasz Majewski
  2015-02-26 18:25               ` Eduardo Valentin
  0 siblings, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-02-26 10:36 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Chanwoo Choi, Viresh Kumar

Hi Eduardo,

> Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility
> to use device tree to asses if cpu can be used as cooling device.
> Since the code was somewhat awkward, simpler approach has been
> proposed.
> 
> Test HW: Exynos 4412 - Odroid U3.
> 
> Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

This patch is also missing from linux-thermal-soc tree.

I will add it to samsung thermal tree, since Viresh has ACK'ed it.

> ---
> Changes for v2:
> - Remove superfluous *np pointer
> ---
>  drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
>  1 file changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/cpufreq/exynos-cpufreq.c
> b/drivers/cpufreq/exynos-cpufreq.c index 5e98c6b..82d2fbb 100644
> --- a/drivers/cpufreq/exynos-cpufreq.c
> +++ b/drivers/cpufreq/exynos-cpufreq.c
> @@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
>  
>  static int exynos_cpufreq_probe(struct platform_device *pdev)
>  {
> -	struct device_node *cpus, *np;
> +	struct device_node *cpu0;
>  	int ret = -EINVAL;
>  
>  	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
> @@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct
> platform_device *pdev) if (ret)
>  		goto err_cpufreq_reg;
>  
> -	cpus = of_find_node_by_path("/cpus");
> -	if (!cpus) {
> -		pr_err("failed to find cpus node\n");
> +	cpu0 = of_get_cpu_node(0, NULL);
> +	if (!cpu0) {
> +		pr_err("failed to find cpu0 node\n");
>  		return 0;
>  	}
>  
> -	np = of_get_next_child(cpus, NULL);
> -	if (!np) {
> -		pr_err("failed to find cpus child node\n");
> -		of_node_put(cpus);
> -		return 0;
> -	}
> -
> -	if (of_find_property(np, "#cooling-cells", NULL)) {
> -		cdev = of_cpufreq_cooling_register(np,
> +	if (of_find_property(cpu0, "#cooling-cells", NULL)) {
> +		cdev = of_cpufreq_cooling_register(cpu0,
>  						   cpu_present_mask);
>  		if (IS_ERR(cdev))
>  			pr_err("running cpufreq without cooling
> device: %ld\n", PTR_ERR(cdev));
>  	}
> -	of_node_put(np);
> -	of_node_put(cpus);
>  
>  	return 0;
>  



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v6 00/18] thermal: exynos: Thermal code rework to use device tree
  2015-02-23 11:18           ` Kukjin Kim
  2015-02-23 12:28             ` Lukasz Majewski
@ 2015-02-26 15:56             ` Lukasz Majewski
  2015-02-26 21:21               ` Kukjin Kim
  1 sibling, 1 reply; 288+ messages in thread
From: Lukasz Majewski @ 2015-02-26 15:56 UTC (permalink / raw)
  To: Kukjin Kim
  Cc: 'Eduardo Valentin', 'Zhang Rui',
	'Linux PM list',
	linux-samsung-soc, 'Bartlomiej Zolnierkiewicz',
	'Lukasz Majewski', 'Amit Daniel Kachhap',
	'Abhilash Kesavan', 'Abhilash Kesavan',
	'Chanwoo Choi'

Hi Kukjin,

> Lukasz Majewski wrote:
> > 
> > Hi Kukjin, Eduardo
> > 
> Hi,
> 
> > > On 01/25/15 06:49, Eduardo Valentin wrote:
> > > > On Fri, Jan 23, 2015 at 01:09:53PM +0100, Lukasz Majewski wrote:
> > > >> 1. Introduction
> > > >>
> > > >> Following patches aim to clean up the current implementation of
> > > >> the thermal framework on Exynos devices.
> > > >>
> > > >> The main goal was to use a generic code for reading thermal
> > > >> configuration (of-thermal.c). Due to that redundant
> > > >> exynos_thermal_common.[h|c] files were removed.
> > > >>
> > > >> Around 400 lines of code (LOC) were removed directly by this
> > > >> patch, which is around 20% of the Exynos thermal code base.
> > > >>
> > > >> This work should NOT bring any functional changes to Exynos
> > > >> thermal subsystem.
> > > >>
> > > >> 2. Patch-set structure
> > > >>
> > > >> Then the cpu_cooling functionality has been preserved to allow
> > > >> cooling devices by reducing operating frequency. Definition of
> > > >> trip points and cpufreq's cooling properties were moved to
> > > >> device tree.
> > > >>
> > > >> Then the rework of the way in which configuration data is
> > > >> provided to the Exynos thermal subsystem was performed. Now
> > > >> device tree is used for configuration.
> > > >>
> > > >> 3. Dead code removal
> > > >>
> > > >> Thermal support for some SoCs, previously available in the
> > > >> exynos_tmu_data.c file, was removed since, as of (almost)
> > > >> 3.19-rc3, they didn't have TMU bindings.
> > > >>
> > > >> Moreover, support for cpu_cooling devices was preserved only on
> > > >> those SoCs which had available and working cpufreq driver.
> > > >>
> > > >> 4. Testing
> > > >>
> > > >> Test devices:
> > > >> - Exynos4210 - Trats (TMU zone + cpu_cooling)
> > > >> - Exynos4412 - Trats2/Odroid U3 (TMU zone + cpu_cooling)
> > > >> - Exynos5250 - Arndale (TMU zone + cpu_cooling)
> > > >> - Exynos5420 - Arndale-octa (only TMU zones)
> > > >>
> > > >> Unfortunately, I don't posses Exynos5440 for testing. Its
> > > >> functionality has been preserved in the code, but not tested on
> > > >> the hardware. I would be grateful for help in testing.
> > > >>
> > > >>
> > > >> 5. This work apply on the following tree:
> > > >>
> > > >> kernel.org: 'linux-soc-thermal/next' - Eduardo Velentin's tree
> > > >> SHA1: 1813d80874699145f04af6b05ebab0a6419001fb
> > > >>
> > > >>
> > > >> Lukasz Majewski (18):
> > > >
> > > > I have applied the following patches to my -fixes branch (for
> > > > next rc cycle)
> > > >
> > > >>   thermal: exynos: cosmetic: Correct comment format
> > > >>   thermal: exynos: Provide thermal_exynos.h file to be
> > > >> included in device tree files
> > > >>   thermal: exynos: Modify exynos thermal code to use device
> > > >> tree for cpu cooling configuration
> > > >>   cpufreq: exynos: Use device tree to determine if cpufreq
> > > >> cooling should be registered
> > > >>   dts: Documentation: Extending documentation entry for
> > > >> exynos-thermal dts: Documentation: Update exynos-thermal.txt
> > > >> example for Exynos5440 thermal: samsung: core: Exynos TMU
> > > >> rework to use device tree for configuration
> > > >>   thermal: exynos: Remove exynos_thermal_common.[c|h] files
> > > >>   thermal: exynos: Remove exynos_tmu_data.c file
> > > >
> > > > The patches below should go via platform tree:
> > > >
> > > >>   arm: dts: trats: Enable TMU on the Exynos4210 trats device
> > > >>   arm: dts: odroid: Add LDO10 regulator node necessary for TMU
> > > >> on Odroid arm: dts: odroid: Enable TMU at Exynos4412 based
> > > >> Odroid U3 device arm: dts: Adding CPU cooling binding for
> > > >> Exynos SoCs thermal: exynos: dts: Add default definition of
> > > >> the TMU sensor parameter
> > > >>   thermal: dts: Default trip points definition for Exynos5420
> > > >> SoCs thermal: exynos: dts: Define default thermal-zones for
> > > >> Exynos4 thermal: dts: exynos: Trip points and sensor
> > > >> configuration data for Exynos5440
> > > >>   thermal: exynos: dts: Provide device tree bindings identical
> > > >> to the one in exynos_tmu_data.c
> > > >
> > >
> > > I've applied above patches with small subject changes.
> > >
> > > BTW unfortunately, since missing the
> > > "include/dt-bindings/thermal/thermal_exynos.h" in my tree, I
> > > couldn't merge it into for-next yet.
> > 
> > As of this writing: (Kernel 4.0-rc1) the
> > "include/dt-bindings/thermal/thermal_exynos.h" file is in the kernel
> > tree.
> > 
> I know.
> 
> > Kukjin, could you add missing DTS files and send this to upstream.
> > 
> Unfortunately, I couldn't take the DT changes in Samsung tree at that
> time because of missing header file and it causes build error. Now I
> can pick them into Samsung tree but I'm not sure it can be sent to
> upstream during this -rc...
> 
> Eduardo, Lukasz,
> Do you guys think the DT changes are really fixes for 4.0?

I've created following repository with DTS files:

https://github.com/lmajewski/linux-samsung-thermal.git

Branch: devel.

On top of the v4.0-rc1 tag you will find all necessary patches for
fixing thermal regression at Samsung Exynos boards.

I hope, that organizing all patches in a separate repository will
facilitate and speed up the inclusion process.


> 
> > Thanks in advance.
> > 
> > >
> > > Can you please provide a topic branch for it? If not, this cannot
> > > be handled in arm-soc tree in this time, I think.
> > >
> > > - Kukjin
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used
  2015-02-26 10:36             ` Lukasz Majewski
@ 2015-02-26 18:25               ` Eduardo Valentin
  2015-02-26 21:23                 ` Lukasz Majewski
  0 siblings, 1 reply; 288+ messages in thread
From: Eduardo Valentin @ 2015-02-26 18:25 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Lukasz Majewski, Amit Daniel Kachhap,
	Abhilash Kesavan, Abhilash Kesavan, Chanwoo Choi, Viresh Kumar

[-- Attachment #1: Type: text/plain, Size: 2734 bytes --]

On Thu, Feb 26, 2015 at 11:36:24AM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility
> > to use device tree to asses if cpu can be used as cooling device.
> > Since the code was somewhat awkward, simpler approach has been
> > proposed.
> > 
> > Test HW: Exynos 4412 - Odroid U3.
> > 
> > Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> 
> This patch is also missing from linux-thermal-soc tree.
> 
> I will add it to samsung thermal tree, since Viresh has ACK'ed it.

Do we have any dependency with something which is only in the thermal
tree(s)? If not, I suggest the cpufreq changes go via cpufreq tree(s).


BR,

Eduardo Valentin

> 
> > ---
> > Changes for v2:
> > - Remove superfluous *np pointer
> > ---
> >  drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
> >  1 file changed, 6 insertions(+), 15 deletions(-)
> > 
> > diff --git a/drivers/cpufreq/exynos-cpufreq.c
> > b/drivers/cpufreq/exynos-cpufreq.c index 5e98c6b..82d2fbb 100644
> > --- a/drivers/cpufreq/exynos-cpufreq.c
> > +++ b/drivers/cpufreq/exynos-cpufreq.c
> > @@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
> >  
> >  static int exynos_cpufreq_probe(struct platform_device *pdev)
> >  {
> > -	struct device_node *cpus, *np;
> > +	struct device_node *cpu0;
> >  	int ret = -EINVAL;
> >  
> >  	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
> > @@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct
> > platform_device *pdev) if (ret)
> >  		goto err_cpufreq_reg;
> >  
> > -	cpus = of_find_node_by_path("/cpus");
> > -	if (!cpus) {
> > -		pr_err("failed to find cpus node\n");
> > +	cpu0 = of_get_cpu_node(0, NULL);
> > +	if (!cpu0) {
> > +		pr_err("failed to find cpu0 node\n");
> >  		return 0;
> >  	}
> >  
> > -	np = of_get_next_child(cpus, NULL);
> > -	if (!np) {
> > -		pr_err("failed to find cpus child node\n");
> > -		of_node_put(cpus);
> > -		return 0;
> > -	}
> > -
> > -	if (of_find_property(np, "#cooling-cells", NULL)) {
> > -		cdev = of_cpufreq_cooling_register(np,
> > +	if (of_find_property(cpu0, "#cooling-cells", NULL)) {
> > +		cdev = of_cpufreq_cooling_register(cpu0,
> >  						   cpu_present_mask);
> >  		if (IS_ERR(cdev))
> >  			pr_err("running cpufreq without cooling
> > device: %ld\n", PTR_ERR(cdev));
> >  	}
> > -	of_node_put(np);
> > -	of_node_put(cpus);
> >  
> >  	return 0;
> >  
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v6 00/18] thermal: exynos: Thermal code rework to use device tree
  2015-02-26 15:56             ` Lukasz Majewski
@ 2015-02-26 21:21               ` Kukjin Kim
  0 siblings, 0 replies; 288+ messages in thread
From: Kukjin Kim @ 2015-02-26 21:21 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kukjin Kim, 'Eduardo Valentin', 'Zhang Rui',
	'Linux PM list',
	linux-samsung-soc, 'Bartlomiej Zolnierkiewicz',
	'Lukasz Majewski', 'Amit Daniel Kachhap',
	'Abhilash Kesavan', 'Abhilash Kesavan',
	'Chanwoo Choi'

On 02/27/15 00:56, Lukasz Majewski wrote:
> Hi Kukjin,
> 
>> Lukasz Majewski wrote:
>>>
>>> Hi Kukjin, Eduardo
>>>
>> Hi,

[...]

>>> Kukjin, could you add missing DTS files and send this to upstream.
>>>
>> Unfortunately, I couldn't take the DT changes in Samsung tree at that
>> time because of missing header file and it causes build error. Now I
>> can pick them into Samsung tree but I'm not sure it can be sent to
>> upstream during this -rc...
>>
>> Eduardo, Lukasz,
>> Do you guys think the DT changes are really fixes for 4.0?
> 
> I've created following repository with DTS files:
> 
> https://github.com/lmajewski/linux-samsung-thermal.git
> 
> Branch: devel.
> 
> On top of the v4.0-rc1 tag you will find all necessary patches for
> fixing thermal regression at Samsung Exynos boards.
> 
> I hope, that organizing all patches in a separate repository will
> facilitate and speed up the inclusion process.

I already did :-) If any problems on the branch
(v4.0-samsung-dt-tmu-hdmi) in my tree, please kindly let me know.

Thanks,
Kukjin

^ permalink raw reply	[flat|nested] 288+ messages in thread

* Re: [PATCH v2] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used
  2015-02-26 18:25               ` Eduardo Valentin
@ 2015-02-26 21:23                 ` Lukasz Majewski
  0 siblings, 0 replies; 288+ messages in thread
From: Lukasz Majewski @ 2015-02-26 21:23 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Lukasz Majewski, Zhang Rui, Linux PM list, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Amit Daniel Kachhap, Abhilash Kesavan,
	Abhilash Kesavan, Chanwoo Choi, Viresh Kumar

[-- Attachment #1: Type: text/plain, Size: 3410 bytes --]

Hi Eduardo,

> On Thu, Feb 26, 2015 at 11:36:24AM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided
> > > possibility to use device tree to asses if cpu can be used as
> > > cooling device. Since the code was somewhat awkward, simpler
> > > approach has been proposed.
> > > 
> > > Test HW: Exynos 4412 - Odroid U3.
> > > 
> > > Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> > 
> > This patch is also missing from linux-thermal-soc tree.
> > 
> > I will add it to samsung thermal tree, since Viresh has ACK'ed it.
> 
> Do we have any dependency with something which is only in the thermal
> tree(s)? If not, I suggest the cpufreq changes go via cpufreq tree(s).

As fair as I remember, Viresh didn't mind if this patch would go via
thermal tree, since it is an integral part of the thermal solution for
Exynos.

Frankly, I'm for keeping all "related" patches in one tree
(especially when somebody already ACKed the patch) and not split them
into several trees.

Look how bad things look now with thermal DTS patches .... If we would
have taken them all at once, we hadn't had current problems.

Best regards,
Lukasz Majewski

> 
> 
> BR,
> 
> Eduardo Valentin
> 
> > 
> > > ---
> > > Changes for v2:
> > > - Remove superfluous *np pointer
> > > ---
> > >  drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
> > >  1 file changed, 6 insertions(+), 15 deletions(-)
> > > 
> > > diff --git a/drivers/cpufreq/exynos-cpufreq.c
> > > b/drivers/cpufreq/exynos-cpufreq.c index 5e98c6b..82d2fbb 100644
> > > --- a/drivers/cpufreq/exynos-cpufreq.c
> > > +++ b/drivers/cpufreq/exynos-cpufreq.c
> > > @@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
> > >  
> > >  static int exynos_cpufreq_probe(struct platform_device *pdev)
> > >  {
> > > -	struct device_node *cpus, *np;
> > > +	struct device_node *cpu0;
> > >  	int ret = -EINVAL;
> > >  
> > >  	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
> > > @@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct
> > > platform_device *pdev) if (ret)
> > >  		goto err_cpufreq_reg;
> > >  
> > > -	cpus = of_find_node_by_path("/cpus");
> > > -	if (!cpus) {
> > > -		pr_err("failed to find cpus node\n");
> > > +	cpu0 = of_get_cpu_node(0, NULL);
> > > +	if (!cpu0) {
> > > +		pr_err("failed to find cpu0 node\n");
> > >  		return 0;
> > >  	}
> > >  
> > > -	np = of_get_next_child(cpus, NULL);
> > > -	if (!np) {
> > > -		pr_err("failed to find cpus child node\n");
> > > -		of_node_put(cpus);
> > > -		return 0;
> > > -	}
> > > -
> > > -	if (of_find_property(np, "#cooling-cells", NULL)) {
> > > -		cdev = of_cpufreq_cooling_register(np,
> > > +	if (of_find_property(cpu0, "#cooling-cells", NULL)) {
> > > +		cdev = of_cpufreq_cooling_register(cpu0,
> > >  						   cpu_present_mask);
> > >  		if (IS_ERR(cdev))
> > >  			pr_err("running cpufreq without cooling
> > > device: %ld\n", PTR_ERR(cdev));
> > >  	}
> > > -	of_node_put(np);
> > > -	of_node_put(cpus);
> > >  
> > >  	return 0;
> > >  
> > 
> > 
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 288+ messages in thread

end of thread, other threads:[~2015-02-26 21:23 UTC | newest]

Thread overview: 288+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-09 16:38 [PATCH 00/21] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
2014-10-09 16:38 ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 01/21] thermal: of: Extend of-thermal.c to provide number of trip points Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-11-07  1:34   ` Eduardo Valentin
2014-11-07  1:34     ` Eduardo Valentin
2014-11-07  9:14     ` Lukasz Majewski
2014-11-07  9:14       ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 02/21] thermal: of: Extend of-thermal.c to provide check if trip point is enabled Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-11-07  1:37   ` Eduardo Valentin
2014-11-07  1:37     ` Eduardo Valentin
2014-11-07  9:15     ` Lukasz Majewski
2014-11-07  9:15       ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 03/21] thermal: of: Extend of-thermal.c to provide number of non critical trip points Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-11-07  1:41   ` Eduardo Valentin
2014-11-07  1:41     ` Eduardo Valentin
2014-11-07 10:05     ` Lukasz Majewski
2014-11-07 10:05       ` Lukasz Majewski
2014-11-07 16:06       ` Eduardo Valentin
2014-11-07 16:06         ` Eduardo Valentin
2014-11-07 16:43         ` Lukasz Majewski
2014-11-07 16:43           ` Lukasz Majewski
2014-11-12  9:42         ` Lukasz Majewski
2014-11-12  9:42           ` Lukasz Majewski
2014-11-18 15:20           ` Eduardo Valentin
2014-11-18 15:20             ` Eduardo Valentin
2014-11-18 20:25             ` Lukasz Majewski
2014-11-18 20:25               ` Lukasz Majewski
2014-11-07 23:04       ` Dmitry Torokhov
2014-11-07 23:04         ` Dmitry Torokhov
2014-10-09 16:38 ` [PATCH 04/21] thermal: of: Extend current of-thermal.c code to allow setting emulated temp Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-11-07  1:44   ` Eduardo Valentin
2014-11-07  1:44     ` Eduardo Valentin
2014-11-07 11:20     ` Lukasz Majewski
2014-11-07 11:20       ` Lukasz Majewski
2014-11-18 15:23       ` Eduardo Valentin
2014-11-18 15:23         ` Eduardo Valentin
2014-11-18 20:28         ` Lukasz Majewski
2014-11-18 20:28           ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 05/21] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 06/21] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 07/21] thermal: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 08/21] thermal: dts: exynos: Adding LD010 regulator node necessary for TMU on Odroid U3 board Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 09/21] thermal: dts: Provide bindings and enable TMU at Exynos4x12 devices Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 10/21] thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu cooling functionality Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 11/21] thermal: cpu_cooling: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 12/21] thermal: exynos: dts: Add default definition for the TMU sensor Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 13/21] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 14/21] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 15/21] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 16/21] thermal: exynos: dts: Provide device tree bindings identical to one in exynos_tmu_data.c Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 17/21] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 18/21] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 19/21] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 20/21] thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412 Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 16:38 ` [PATCH 21/21] thermal: exynos: Make Exynos3250 " Lukasz Majewski
2014-10-09 16:38   ` Lukasz Majewski
2014-10-09 23:34   ` Chanwoo Choi
2014-10-09 23:34     ` Chanwoo Choi
2014-10-10  8:51     ` Lukasz Majewski
2014-10-10  8:51       ` Lukasz Majewski
2014-10-23  8:50 ` [PATCH 00/21] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
2014-10-23  8:50   ` Lukasz Majewski
2014-11-20 16:21 ` [PATCH v2 0/4] thermal: of: of-thermal.c API extensions Lukasz Majewski
2014-11-20 16:21   ` [PATCH v2 1/4] thermal: of: Extend of-thermal.c to provide number of trip points Lukasz Majewski
2014-11-25  6:04     ` Eduardo Valentin
2014-11-26  8:28       ` Lukasz Majewski
2014-11-20 16:21   ` [PATCH v2 2/4] thermal: of: Extend of-thermal.c to provide check if trip point is enabled Lukasz Majewski
2014-11-25  8:25     ` Eduardo Valentin
2014-11-26  8:31       ` Lukasz Majewski
2014-11-20 16:21   ` [PATCH v2 3/4] thermal: of: Extend of-thermal to export table of trip points Lukasz Majewski
2014-11-25 20:36     ` Eduardo Valentin
2014-11-26  8:35       ` Lukasz Majewski
2014-11-26 15:18         ` Eduardo Valentin
2014-11-26 20:43           ` navneet kumar
2014-11-26 20:43             ` navneet kumar
2014-11-26 21:12             ` Guenter Roeck
2014-11-26 23:12               ` navneet kumar
2014-11-26 23:12                 ` navneet kumar
2014-11-26 23:09             ` Eduardo Valentin
2014-11-27  9:42               ` Lukasz Majewski
2014-11-27  9:42                 ` Lukasz Majewski
2014-11-25 20:38     ` Eduardo Valentin
2014-11-26  8:39       ` Lukasz Majewski
2014-11-20 16:21   ` [PATCH v2 4/4] thermal: of: Extend current of-thermal.c code to allow setting emulated temp Lukasz Majewski
2014-11-25 20:44     ` Eduardo Valentin
2014-11-26  8:47       ` Lukasz Majewski
2014-12-08 17:04   ` [PATCH v3 0/5] thermal: of: of-thermal.c API extensions Lukasz Majewski
2014-12-08 17:04     ` [PATCH v3 1/5] thermal: of: Extend of-thermal.c to provide number of trip points Lukasz Majewski
2014-12-08 19:52       ` Eduardo Valentin
2014-12-08 23:02         ` Lukasz Majewski
2014-12-08 17:04     ` [PATCH v3 2/5] thermal: of: Extend of-thermal.c to provide check if trip point is valid Lukasz Majewski
2014-12-08 17:04     ` [PATCH v3 3/5] thermal: of: Rename struct __thermal_trip to struct thermal_trip Lukasz Majewski
2014-12-08 17:04     ` [PATCH v3 4/5] thermal: of: Extend of-thermal to export table of trip points Lukasz Majewski
2014-12-08 17:04     ` [PATCH v3 5/5] thermal: of: Extend current of-thermal.c code to allow setting emulated temp Lukasz Majewski
2014-12-09  1:21     ` [PATCH v3 0/5] thermal: of: of-thermal.c API extensions Eduardo Valentin
2014-12-10 12:09 ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Lukasz Majewski
2014-12-10 10:27   ` Eduardo Valentin
2014-12-10 14:19     ` Lukasz Majewski
2014-12-22 15:50       ` Abhilash Kesavan
2014-12-22 16:21         ` Lukasz Majewski
2014-12-23 15:27           ` Abhilash Kesavan
2014-12-10 12:09   ` [PATCH v2 01/17] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 02/17] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 03/17] thermal: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 04/17] thermal: dts: exynos: Add LD010 regulator node necessary for TMU on Odroid Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 05/17] thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 06/17] thermal: cpu_cooling: dts: Define device tree bindings for Exynos cpu cooling functionality Lukasz Majewski
2015-01-02 18:15     ` Eduardo Valentin
2015-01-12 14:09       ` Lukasz Majewski
2015-01-12 14:24         ` Eduardo Valentin
2015-01-13  8:22           ` Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 07/17] thermal: cpu_cooling: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
2015-01-02 18:18     ` Eduardo Valentin
2015-01-12 17:08       ` Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 08/17] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
2015-01-02 18:11     ` Eduardo Valentin
2015-01-02 18:26       ` Eduardo Valentin
2015-01-12 14:42         ` Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 09/17] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 10/17] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 11/17] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 12/17] thermal: exynos: dts: Provide device tree bindings identical to one in exynos_tmu_data.c Lukasz Majewski
2015-01-02 18:13     ` Eduardo Valentin
2015-01-12 15:36       ` Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 13/17] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 14/17] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 15/17] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 16/17] thermal: exynos: Make Exynos5250 TMU compatible with Exynos4412 Lukasz Majewski
2014-12-10 12:09   ` [PATCH v2 17/17] thermal: exynos: Make Exynos3250 " Lukasz Majewski
2015-01-02 18:25   ` [PATCH v2 00/17] thermal: exynos: Thermal code rework to use device tree Eduardo Valentin
2015-01-03 19:53     ` Lukasz Majewski
2015-01-05 21:11       ` Eduardo Valentin
2015-01-14 13:40 ` [PATCH v3 00/16] " Lukasz Majewski
2015-01-14 13:40   ` [PATCH v3 01/16] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
2015-01-14 13:41   ` [PATCH v3 02/16] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
2015-01-14 13:41   ` [PATCH v3 03/16] arm: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
2015-01-14 13:41   ` [PATCH v3 04/16] arm: dts: odroid: Add LD010 regulator node necessary for TMU on Odroid Lukasz Majewski
2015-01-14 13:41   ` [PATCH v3 05/16] thermal: dts: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
2015-01-14 18:48     ` Eduardo Valentin
2015-01-14 13:41   ` [PATCH v3 06/16] arm: dts: Adding CPU cooling binding for Exynos SoCs Lukasz Majewski
2015-01-14 18:57     ` Eduardo Valentin
2015-01-14 13:41   ` [PATCH v3 07/16] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
2015-01-14 13:41   ` [PATCH v3 08/16] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
2015-01-14 13:41   ` [PATCH v3 09/16] dts: Documentation: Extending documentation entry for exynos-thermal Lukasz Majewski
2015-01-14 18:52     ` Eduardo Valentin
2015-01-14 19:01       ` Eduardo Valentin
2015-01-14 13:41   ` [PATCH v3 10/16] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
2015-01-14 13:41   ` [PATCH v3 11/16] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
2015-01-14 13:41   ` [PATCH v3 12/16] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
2015-01-14 13:41   ` [PATCH v3 13/16] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c Lukasz Majewski
2015-01-14 19:05     ` Eduardo Valentin
2015-01-15 16:03       ` Lukasz Majewski
2015-01-14 13:41   ` [PATCH v3 14/16] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
2015-01-14 18:46     ` Eduardo Valentin
2015-01-15 15:17       ` Lukasz Majewski
2015-01-21  1:23         ` Eduardo Valentin
2015-01-21  8:10           ` Lukasz Majewski
2015-01-21  9:20             ` Eduardo Valentin
2015-01-22 14:17               ` Lukasz Majewski
2015-01-14 13:41   ` [PATCH v3 15/16] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
2015-01-14 13:41   ` [PATCH v3 16/16] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
2015-01-16  0:00   ` [PATCH v3 00/16] thermal: exynos: Thermal code rework to use device tree Tobias Jakobi
2015-01-16  8:29     ` Lukasz Majewski
2015-01-19 23:29       ` Tobias Jakobi
2015-01-20  8:17         ` Lukasz Majewski
2015-01-22  1:06           ` Tobias Jakobi
2015-01-21  9:08             ` Eduardo Valentin
2015-01-24  1:00               ` Tobias Jakobi
2015-01-16 11:30 ` [PATCH v4 00/17] " Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 01/17] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 02/17] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 03/17] arm: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 04/17] arm: dts: odroid: Add LD010 regulator node necessary for TMU on Odroid Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 05/17] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 06/17] arm: dts: Adding CPU cooling binding for Exynos SoCs Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 07/17] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 08/17] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 09/17] dts: Documentation: Extending documentation entry for exynos-thermal Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 10/17] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 11/17] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 12/17] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 13/17] dts: Documentation: Update exynos-thermal.txt example " Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 14/17] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c Lukasz Majewski
2015-01-16 11:30   ` [PATCH v4 15/17] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
2015-01-16 11:31   ` [PATCH v4 16/17] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
2015-01-16 11:31   ` [PATCH v4 17/17] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
2015-01-17  7:17   ` [PATCH v4 00/17] thermal: exynos: Thermal code rework to use device tree Abhilash Kesavan
2015-01-19  7:57     ` Lukasz Majewski
2015-01-23  7:42   ` Kukjin Kim
2015-01-23  9:59     ` Lukasz Majewski
2015-01-23 11:00       ` Kukjin Kim
2015-01-23 14:45         ` Eduardo Valentin
2015-01-24  4:04           ` Kukjin Kim
2015-01-19 11:20 ` [PATCH v5 00/18] " Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 01/18] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 02/18] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 03/18] arm: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 04/18] arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 05/18] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 06/18] arm: dts: Adding CPU cooling binding for Exynos SoCs Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
2015-01-21  2:18     ` Eduardo Valentin
2015-01-21  8:21       ` Lukasz Majewski
2015-01-21  8:33     ` Lukasz Majewski
2015-01-21  9:08       ` Viresh Kumar
2015-01-21  9:47         ` Lukasz Majewski
2015-01-21  9:55           ` Viresh Kumar
2015-01-21 10:09             ` Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 08/18] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 09/18] dts: Documentation: Extending documentation entry for exynos-thermal Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 10/18] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 11/18] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 12/18] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 13/18] dts: Documentation: Update exynos-thermal.txt example " Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 14/18] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c Lukasz Majewski
2015-01-19 11:20   ` [PATCH v5 15/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
2015-01-21  3:18     ` Eduardo Valentin
2015-01-21  8:40       ` Lukasz Majewski
2015-01-21  9:14         ` Eduardo Valentin
2015-01-21  3:25     ` Eduardo Valentin
2015-01-21  8:48       ` Lukasz Majewski
2015-01-19 11:21   ` [PATCH v5 16/18] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
2015-01-19 11:21   ` [PATCH v5 17/18] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
2015-01-19 11:21   ` [PATCH v5 18/18] thermal: exynos: Remove not needed exynos_tmu_init_data declarations from exynos_tmu.h Lukasz Majewski
2015-01-21  3:30     ` Eduardo Valentin
2015-01-21  9:00       ` Lukasz Majewski
2015-01-21  1:55   ` [PATCH v5 00/18] thermal: exynos: Thermal code rework to use device tree Eduardo Valentin
2015-01-23 12:09   ` [PATCH v6 " Lukasz Majewski
2015-01-23 12:09     ` [PATCH v6 01/18] thermal: exynos: cosmetic: Correct comment format Lukasz Majewski
2015-01-23 12:09     ` [PATCH v6 02/18] thermal: exynos: Provide thermal_exynos.h file to be included in device tree files Lukasz Majewski
2015-01-23 12:09     ` [PATCH v6 03/18] arm: dts: trats: Enable TMU on the Exynos4210 trats device Lukasz Majewski
2015-01-23 12:09     ` [PATCH v6 04/18] arm: dts: odroid: Add LDO10 regulator node necessary for TMU on Odroid Lukasz Majewski
2015-01-23 12:09     ` [PATCH v6 05/18] arm: dts: odroid: Enable TMU at Exynos4412 based Odroid U3 device Lukasz Majewski
2015-01-23 12:23       ` Aw: " Tobias Jakobi
2015-01-23 12:09     ` [PATCH v6 06/18] arm: dts: Adding CPU cooling binding for Exynos SoCs Lukasz Majewski
2015-01-23 12:10     ` [PATCH v6 07/18] thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration Lukasz Majewski
2015-01-23 12:10     ` [PATCH v6 09/18] thermal: exynos: dts: Add default definition of the TMU sensor parameter Lukasz Majewski
2015-01-23 12:10     ` [PATCH v6 10/18] dts: Documentation: Extending documentation entry for exynos-thermal Lukasz Majewski
2015-01-23 12:10     ` [PATCH v6 11/18] thermal: dts: Default trip points definition for Exynos5420 SoCs Lukasz Majewski
2015-01-23 12:10     ` [PATCH v6 12/18] thermal: exynos: dts: Define default thermal-zones for Exynos4 Lukasz Majewski
2015-01-23 12:10     ` [PATCH v6 13/18] thermal: dts: exynos: Trip points and sensor configuration data for Exynos5440 Lukasz Majewski
2015-01-23 12:10     ` [PATCH v6 14/18] dts: Documentation: Update exynos-thermal.txt example " Lukasz Majewski
2015-01-23 12:10     ` [PATCH v6 15/18] thermal: exynos: dts: Provide device tree bindings identical to the one in exynos_tmu_data.c Lukasz Majewski
2015-01-23 12:10     ` [PATCH v6 16/18] thermal: samsung: core: Exynos TMU rework to use device tree for configuration Lukasz Majewski
2015-01-23 12:10     ` [PATCH v6 17/18] thermal: exynos: Remove exynos_thermal_common.[c|h] files Lukasz Majewski
2015-01-23 12:10     ` [PATCH v6 18/18] thermal: exynos: Remove exynos_tmu_data.c file Lukasz Majewski
2015-01-24 21:49     ` [PATCH v6 00/18] thermal: exynos: Thermal code rework to use device tree Eduardo Valentin
2015-01-26  8:49       ` Lukasz Majewski
2015-01-29 23:34       ` Kukjin Kim
2015-02-23 10:13         ` Lukasz Majewski
2015-02-23 11:18           ` Kukjin Kim
2015-02-23 12:28             ` Lukasz Majewski
2015-02-26 15:56             ` Lukasz Majewski
2015-02-26 21:21               ` Kukjin Kim
2015-01-23 12:14   ` [PATCH v6 08/18] cpufreq: exynos: Use device tree to determine if cpufreq cooling should be registered Lukasz Majewski
2015-01-23 12:59     ` Viresh Kumar
2015-01-23 13:57       ` Lukasz Majewski
2015-01-25 14:01         ` Viresh Kumar
2015-01-25 16:27           ` Lukasz Majewski
2015-01-25 16:46           ` Eduardo Valentin
2015-01-25 21:55             ` Lukasz Majewski
2015-01-26  9:25     ` [PATCH] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used Lukasz Majewski
2015-01-27  3:44       ` Viresh Kumar
2015-02-04  9:00         ` Lukasz Majewski
2015-02-05 15:54           ` [PATCH v2] " Lukasz Majewski
2015-02-26 10:36             ` Lukasz Majewski
2015-02-26 18:25               ` Eduardo Valentin
2015-02-26 21:23                 ` Lukasz Majewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.