Skip to contentSkip to conversation

thermal: exynos: Add thermal driver for exynos5440

PATCH Superseded Amit Daniel Kachhap 3 participants 48 messages May 14, 2013 – Jun 6, 2013

Subsystems (7)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v4 cover thermal: exynos: Add thermal driver for exynos5440

Changes in V4:
Almost all the changes in this version is as per suggestion from Eduardo.The major ones are listed below,
* Added kconfig symbol ARCH_HAS_TMU which needs to be enabled by platform. With this change existing symbol EXYNOS_TMU_DATA is not needed.
* Movement of freq_clip_table from exynos_tmu.h to exynos_thermal_common.h is explained in the commit logs.
* Wrote all register description documentation.
* Split 5440 TMU support patch into controller change, configuration data and feature addition patches.
* Remove all *LINUX_* in the header files.
* Still regulator enable is kept optional but a TODO: comment is added to fix it later.

Changes in V3:
* Added proper dependency of different exynos thermal Kconfig symbols. Basically 3 Kconfig can be enabled now and corresponds to tmu driver. exynos common part and exynos configuration data. This issue was raised by Rui Zhang.

Changes in V2:
* Separated SOC data from TMU driver. This is as per suggestion from Eduardo.
* Merged the new file created for exynos5440 TMU controller with the existing TMU controller code.
* Removed the DT parsing code as now the SOC specific data are cleanly put inside the data specific file.
* Even the register definations/bitfields are treated as data as there is some variation across SOC's.

This patchset adds TMU(Thermal management Unit) driver support for exynos5440 platform. There are 3 instances of the TMU controllers so necessary cleanup/re-structure is done to handle multiple thermal zone.

Patch (exynos4: Add documentation for Exynos SoC thermal bindings) from Lukasz Majewski is already posted to mainline. Adding it here for completeness.
(http://www.mail-archive.com/[email protected]/msg17817.html)

Patch (thermal: exynos: Support thermal tripping ) from Jonghwan Choi is added here with some changes.
(https://patchwork.kernel.org/patch/1668371/)

Patch (thermal: exynos: Support for TMU regulator defined at device tree) is a repost of my earlier patch(https://patchwork-mail1.kernel.org/patch/2510771/) and adds regulator support.

Patch (ARM: dts: Add device tree node for exynos5440 TMU controller) and patch (arm: exynos: enable ARCH_HAS_TMU) can be merged through exynos platform maintainer as this can cause merge conflict.

All these patches are based on thermal maintainers git tree,
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next.

Amit Daniel Kachhap (29):
thermal: exynos: Moving exynos thermal files into samsung directory
thermal: exynos: Add ARCH_HAS_TMU config to know the supported soc's
thermal: exynos: Remove CPU_THERMAL dependency for using TMU driver
thermal: exynos: Bifurcate exynos thermal common and tmu controller
code
thermal: exynos: Rename exynos_thermal.c to exynos_tmu.c
thermal: exynos: Move exynos_thermal.h from include/* to driver/*
folder
thermal: exynos: Bifurcate exynos tmu driver and configuration data
thermal: exynos: Add missing definations and code cleanup
thermal: exynos: Add extra entries in the tmu platform data
thermal: exynos: Support thermal tripping
thermal: exynos: Move register definitions from driver file to data
file
thermal: exynos: Fix to clear only the generated interrupts
thermal: exynos: Add support for instance based register/unregister
thermal: exynos: Modify private_data to appropriate name driver_data
thermal: exynos: Return success even if no cooling data supplied
thermal: exynos: Make the zone handling dependent on trip count
thermal: exynos: Add support to handle many instances of TMU
thermal: exynos: Add TMU features to check instead of using SOC type
thermal: exynos: use device resource management infrastructure
thermal: exynos: Add support to access common register for
multistance
thermal: exynos: Add support for exynos5440 TMU sensor.
thermal: exynos: Fix to set the second point correction value
properly
thermal: exynos: Add thermal configuration data for exynos5440 TMU
sensor
thermal: exynos: Add a compensation logic on swapped e-fuse values
thermal: exynos: Add hardware mode thermal calibration support
Documentation: thermal: Explain the exynos thermal driver model
thermal: exynos: Support for TMU regulator defined at device tree
ARM: dts: Add device tree node for exynos5440 TMU controller
arm: exynos: enable ARCH_HAS_TMU

Lukasz Majewski (1):
ARM: dts: thermal: exynos4: Add documentation for Exynos SoC thermal
bindings

 .../devicetree/bindings/thermal/exynos-thermal.txt |   53 +
 Documentation/thermal/exynos_thermal               |   43 +-
 arch/arm/boot/dts/exynos5440.dtsi                  |   30 +
 arch/arm/mach-exynos/Kconfig                       |    5 +
 drivers/thermal/Kconfig                            |   13 +-
 drivers/thermal/Makefile                           |    2 +-
 drivers/thermal/exynos_thermal.c                   | 1066 --------------------
 drivers/thermal/samsung/Kconfig                    |   21 +
 drivers/thermal/samsung/Makefile                   |    7 +
 drivers/thermal/samsung/exynos_thermal_common.c    |  407 ++++++++
 drivers/thermal/samsung/exynos_thermal_common.h    |   98 ++
 drivers/thermal/samsung/exynos_tmu.c               |  741 ++++++++++++++
 drivers/thermal/samsung/exynos_tmu.h               |  294 ++++++
 drivers/thermal/samsung/exynos_tmu_data.c          |  225 ++++
 drivers/thermal/samsung/exynos_tmu_data.h          |  155 +++
 include/linux/platform_data/exynos_thermal.h       |  119 ---
 16 files changed, 2076 insertions(+), 1203 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/exynos-thermal.txt
 delete mode 100644 drivers/thermal/exynos_thermal.c
 create mode 100644 drivers/thermal/samsung/Kconfig
 create mode 100644 drivers/thermal/samsung/Makefile
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 create mode 100644 drivers/thermal/samsung/exynos_tmu.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu.h
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.h
 delete mode 100644 include/linux/platform_data/exynos_thermal.h
#1 lore raw

PATCH v4 1/30 thermal: exynos: Moving exynos thermal files into samsung directory

This movement of files is done for easy maintenance and adding more new sensor's support for exynos platform easily . This will also help in bifurcating exynos common, sensor driver and sensor data related parts.

---
 drivers/thermal/Kconfig                        |   13 +++++--------
 drivers/thermal/Makefile                       |    2 +-
 drivers/thermal/samsung/Kconfig                |    9 +++++++++
 drivers/thermal/samsung/Makefile               |    4 ++++
 drivers/thermal/{ => samsung}/exynos_thermal.c |    0
 5 files changed, 19 insertions(+), 9 deletions(-)
 create mode 100644 drivers/thermal/samsung/Kconfig
 create mode 100644 drivers/thermal/samsung/Makefile
 rename drivers/thermal/{ => samsung}/exynos_thermal.c (100%)
drivers/thermal/Kconfig +5 -8
index 5e3c025..4414df1 100644
@@ -114,14 +114,6 @@ config KIRKWOOD_THERMAL
 	  Support for the Kirkwood thermal sensor driver into the Linux thermal
 	  framework. Only kirkwood 88F6282 and 88F6283 have this sensor.
 
-config EXYNOS_THERMAL
-	tristate "Temperature sensor on Samsung EXYNOS"
-	depends on (ARCH_EXYNOS4 || ARCH_EXYNOS5)
-	depends on CPU_THERMAL
-	help
-	  If you say yes here you get support for TMU (Thermal Management
-	  Unit) on SAMSUNG EXYNOS series of SoC.
-
 config DOVE_THERMAL
 	tristate "Temperature sensor on Marvell Dove SoCs"
 	depends on ARCH_DOVE
@@ -169,4 +161,9 @@ config INTEL_POWERCLAMP
 	  enforce idle time which results in more package C-state residency. The
 	  user interface is exposed via generic thermal framework.
 
+menu "Samsung thermal drivers"
+depends on PLAT_SAMSUNG
+source "drivers/thermal/samsung/Kconfig"
+endmenu
+
 endif
drivers/thermal/Makefile +1 -1
index c054d41..b3063a9 100644
@@ -17,7 +17,7 @@ thermal_sys-$(CONFIG_CPU_THERMAL)	+= cpu_cooling.o
 obj-$(CONFIG_SPEAR_THERMAL)	+= spear_thermal.o
 obj-$(CONFIG_RCAR_THERMAL)	+= rcar_thermal.o
 obj-$(CONFIG_KIRKWOOD_THERMAL)  += kirkwood_thermal.o
-obj-$(CONFIG_EXYNOS_THERMAL)	+= exynos_thermal.o
+obj-y				+= samsung/
 obj-$(CONFIG_DOVE_THERMAL)  	+= dove_thermal.o
 obj-$(CONFIG_DB8500_THERMAL)	+= db8500_thermal.o
 obj-$(CONFIG_ARMADA_THERMAL)	+= armada_thermal.o
drivers/thermal/samsung/Kconfig new file +9 -0
new file mode 100644
index 0000000..2d3d9dc
@@ -0,0 +1,9 @@
+config EXYNOS_THERMAL
+	tristate "Temperature sensor on Samsung EXYNOS"
+	depends on (ARCH_EXYNOS4 || ARCH_EXYNOS5)
+	depends on CPU_THERMAL
+	help
+	  If you say yes here you get support for TMU (Thermal Management
+	  Unit) on SAMSUNG EXYNOS series of SoC. This helps in registering
+	  the exynos thermal driver with the core thermal layer and cpu
+	  cooling API's.
drivers/thermal/samsung/Makefile new file +4 -0
new file mode 100644
index 0000000..1fe6d93
@@ -0,0 +1,4 @@
+#
+# Samsung thermal specific Makefile
+#
+obj-$(CONFIG_EXYNOS_THERMAL)	+= exynos_thermal.o
drivers/thermal/samsung/exynos_thermal.c renamed from drivers/thermal/exynos_thermal.c +0 -0
similarity index 100%
rename from drivers/thermal/exynos_thermal.c
rename to drivers/thermal/samsung/exynos_thermal.c
Signature · 1 line
1.7.1
#2 lore raw

PATCH v4 2/30 thermal: exynos: Add ARCH_HAS_TMU config to know the supported soc's

In reply to Amit Daniel Kachhap

This patch adds config sybmol ARCH_HAS_TMU to enable the TMU driver. This will allow adding support for new soc easily as now it is the platform responsibility to enable this config symbol.

---
 drivers/thermal/samsung/Kconfig |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/thermal/samsung/Kconfig +4 -1
index 2d3d9dc..145a55d 100644
@@ -1,6 +1,9 @@
+config ARCH_HAS_TMU
+	bool
+
 config EXYNOS_THERMAL
 	tristate "Temperature sensor on Samsung EXYNOS"
-	depends on (ARCH_EXYNOS4 || ARCH_EXYNOS5)
+	depends on ARCH_HAS_TMU
 	depends on CPU_THERMAL
 	help
 	  If you say yes here you get support for TMU (Thermal Management
Signature · 1 line
1.7.1
#3 lore raw

PATCH v4 3/30 thermal: exynos: Remove CPU_THERMAL dependency for using TMU driver

In reply to Amit Daniel Kachhap

This patch removes the dependency on CPU_THERMAL for compiling TMU driver. This is useful for cases when only TMU controller needs to be initialised without cpu cooling action.

---
 drivers/thermal/samsung/Kconfig |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/thermal/samsung/Kconfig +0 -1
index 145a55d..b5ab971 100644
@@ -4,7 +4,6 @@ config ARCH_HAS_TMU
 config EXYNOS_THERMAL
 	tristate "Temperature sensor on Samsung EXYNOS"
 	depends on ARCH_HAS_TMU
-	depends on CPU_THERMAL
 	help
 	  If you say yes here you get support for TMU (Thermal Management
 	  Unit) on SAMSUNG EXYNOS series of SoC. This helps in registering
Signature · 1 line
1.7.1
#4 lore raw

Re: [PATCH V4 03/30] thermal: exynos: Remove CPU_THERMAL dependency for using TMU driver

Quoted 3 lines · Amit Daniel Kachhap

This patch removes the dependency on CPU_THERMAL for compiling TMU driver. This is useful for cases when only TMU controller needs to be initialised without cpu cooling action.

Agreed with your intention. I just do not know if it makes sense to make this change at this point. Maybe after you have split the code?

The above concern is simply from a non-functional perspective. If you do this at this point of your series, your driver may have compilation issues at this specific commit, in case your config does not have CONFIG_CPU_THERMAL.

I recommend you moving this patch further in your series, to a place where you have isolated the code that depends on CPU_THERMAL.

Quoted 20 lines
---
 drivers/thermal/samsung/Kconfig |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/thermal/samsung/Kconfig +0 -1
index 145a55d..b5ab971 100644
@@ -4,7 +4,6 @@ config ARCH_HAS_TMU
 config EXYNOS_THERMAL
 	tristate "Temperature sensor on Samsung EXYNOS"
 	depends on ARCH_HAS_TMU
-	depends on CPU_THERMAL
 	help
 	  If you say yes here you get support for TMU (Thermal Management
 	  Unit) on SAMSUNG EXYNOS series of SoC. This helps in registering
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#5 lore raw

PATCH v4 4/30 thermal: exynos: Bifurcate exynos thermal common and tmu controller code

In reply to Amit Daniel Kachhap

This code bifurcates exynos thermal implementation into common and sensor specific parts. The common thermal code interacts with core thermal layer and core cpufreq cooling parts and is independent of SOC specific driver. This change is needed to cleanly add support for new TMU sensors.

---
 drivers/thermal/samsung/Kconfig                 |   19 +-
 drivers/thermal/samsung/Makefile                |    4 +-
 drivers/thermal/samsung/exynos_thermal.c        |  419 +----------------------
 drivers/thermal/samsung/exynos_thermal_common.c |  384 +++++++++++++++++++++
 drivers/thermal/samsung/exynos_thermal_common.h |   83 +++++
 5 files changed, 490 insertions(+), 419 deletions(-)
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
drivers/thermal/samsung/Kconfig +14 -5
index b5ab971..178a1ad 100644
@@ -2,10 +2,19 @@ config ARCH_HAS_TMU
 	bool
 
 config EXYNOS_THERMAL
-	tristate "Temperature sensor on Samsung EXYNOS"
+	tristate "Exynos thermal management unit driver"
 	depends on ARCH_HAS_TMU
 	help
-	  If you say yes here you get support for TMU (Thermal Management
-	  Unit) on SAMSUNG EXYNOS series of SoC. This helps in registering
-	  the exynos thermal driver with the core thermal layer and cpu
-	  cooling API's.
+	  If you say yes here you get support for the TMU (Thermal Management
+	  Unit) driver for SAMSUNG EXYNOS series of soc. This driver initialises
+	  the TMU, reports temperature and handles cooling action if defined.
+	  This driver uses the exynos core thermal API's.
+
+config EXYNOS_THERMAL_CORE
+	bool "Core thermal framework support for EXYNOS SOC's"
+	depends on EXYNOS_THERMAL
+	help
+	  If you say yes here you get support for EXYNOS TMU
+	  (Thermal Management Unit) common registration/unregistration
+	  functions to the core thermal layer and also to use the generic
+	  cpu cooling API's.
drivers/thermal/samsung/Makefile +3 -1
index 1fe6d93..6227d4f 100644
@@ -1,4 +1,6 @@
 #
 # Samsung thermal specific Makefile
 #
-obj-$(CONFIG_EXYNOS_THERMAL)	+= exynos_thermal.o
+obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_soc_thermal.o
+exynos_soc_thermal-y				:= exynos_thermal.o
+exynos_soc_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) += exynos_thermal_common.o
drivers/thermal/samsung/exynos_thermal.c +6 -413

446 lines not on this page · raw message

drivers/thermal/samsung/exynos_thermal_common.c new file +384 -0

384 lines not on this page · raw message

drivers/thermal/samsung/exynos_thermal_common.h new file +83 -0

83 lines not on this page · raw message

Signature · 1 line
1.7.1
#6 lore raw

PATCH v4 5/30 thermal: exynos: Rename exynos_thermal.c to exynos_tmu.c

In reply to Amit Daniel Kachhap

This patch renames exynos_thermal.c to exynos_tmu.c. This change is needed as this file now just contains exynos tmu driver related codes and thermal zone or cpufreq cooling registration related changes are not there anymore.

---
 drivers/thermal/samsung/Makefile                   |    6 +++---
 .../samsung/{exynos_thermal.c => exynos_tmu.c}     |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
 rename drivers/thermal/samsung/{exynos_thermal.c => exynos_tmu.c} (99%)
drivers/thermal/samsung/Makefile +3 -3
index 6227d4f..22528d6 100644
@@ -1,6 +1,6 @@
 #
 # Samsung thermal specific Makefile
 #
-obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_soc_thermal.o
-exynos_soc_thermal-y				:= exynos_thermal.o
-exynos_soc_thermal-$(CONFIG_EXYNOS_THERMAL_CORE) += exynos_thermal_common.o
+obj-$(CONFIG_EXYNOS_THERMAL)			+= exynos_thermal.o
+exynos_thermal-y				:= exynos_tmu.o
+exynos_thermal-$(CONFIG_EXYNOS_THERMAL_CORE)	+= exynos_thermal_common.o
drivers/thermal/samsung/exynos_tmu.c renamed from drivers/thermal/samsung/exynos_thermal.c +1 -1
similarity index 99%
rename from drivers/thermal/samsung/exynos_thermal.c
rename to drivers/thermal/samsung/exynos_tmu.c
index 228a4dc..5948f3c 100644
@@ -1,5 +1,5 @@
 /*
- * exynos_thermal.c - Samsung EXYNOS TMU (Thermal Management Unit)
+ * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
  *
  *  Copyright (C) 2011 Samsung Electronics
  *  Donggeun Kim <[email protected]>
Signature · 1 line
1.7.1
#7 lore raw

PATCH v4 6/30 thermal: exynos: Move exynos_thermal.h from include/* to driver/* folder

In reply to Amit Daniel Kachhap

This patch renames and moves include/linux/platform_data/exynos_thermal.h to drivers/thermal/samsung/exynos_tmu.h. This file movement is needed as exynos SOC's are not supporting non-DT based platforms and this file now just contains exynos tmu driver related definations.
Also struct freq_clip_table is now moved to exynos_thermal_common.c as it fixes the compilation issue occuring because now this new tmu header file is included in tmu driver c file and not in the common thermal header file.

---
 drivers/thermal/samsung/exynos_thermal_common.c    |    1 -
 drivers/thermal/samsung/exynos_thermal_common.h    |   15 ++++++++++++
 drivers/thermal/samsung/exynos_tmu.c               |    2 +-
 .../thermal/samsung/exynos_tmu.h                   |   24 ++++---------------
 4 files changed, 21 insertions(+), 21 deletions(-)
 rename include/linux/platform_data/exynos_thermal.h => drivers/thermal/samsung/exynos_tmu.h (84%)
drivers/thermal/samsung/exynos_thermal_common.c +0 -1
index 92e50bc..dd49c9f 100644
@@ -21,7 +21,6 @@
  */
 
 #include <linux/cpu_cooling.h>
-#include <linux/platform_data/exynos_thermal.h>
 #include <linux/slab.h>
 #include <linux/thermal.h>
 
drivers/thermal/samsung/exynos_thermal_common.h +15 -0
index 8df1848..068f56c 100644
@@ -44,6 +44,21 @@
 
 #define EXYNOS_ZONE_COUNT	3
 
+/**
+ * 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_count;
drivers/thermal/samsung/exynos_tmu.c +1 -1
index 5948f3c..50952e2 100644
@@ -27,9 +27,9 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
-#include <linux/platform_data/exynos_thermal.h>
 
 #include "exynos_thermal_common.h"
+#include "exynos_tmu.h"
 
 /* Exynos generic registers */
 #define EXYNOS_TMU_REG_TRIMINFO		0x0
drivers/thermal/samsung/exynos_tmu.h renamed from include/linux/platform_data/exynos_thermal.h +5 -19
similarity index 84%
rename from include/linux/platform_data/exynos_thermal.h
rename to drivers/thermal/samsung/exynos_tmu.h
index da7e627..9e0f887 100644
@@ -1,8 +1,9 @@
 /*
- * exynos_thermal.h - Samsung EXYNOS TMU (Thermal Management Unit)
+ * exynos_tmu.h - Samsung EXYNOS TMU (Thermal Management Unit)
  *
  *  Copyright (C) 2011 Samsung Electronics
  *  Donggeun Kim <[email protected]>
+ *  Amit Daniel Kachhap <[email protected]>
  *
  * 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
@@ -19,8 +20,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#ifndef _LINUX_EXYNOS_THERMAL_H
-#define _LINUX_EXYNOS_THERMAL_H
+#ifndef _EXYNOS_TMU_H
+#define _EXYNOS_TMU_H
 #include <linux/cpu_cooling.h>
 
 enum calibration_type {
@@ -33,21 +34,6 @@ enum soc_type {
 	SOC_ARCH_EXYNOS4210 = 1,
 	SOC_ARCH_EXYNOS,
 };
-/**
- * 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 exynos_tmu_platform_data
@@ -116,4 +102,4 @@ struct exynos_tmu_platform_data {
 	struct freq_clip_table freq_tab[4];
 	unsigned int freq_tab_count;
 };
-#endif /* _LINUX_EXYNOS_THERMAL_H */
+#endif /* _EXYNOS_TMU_H */
Signature · 1 line
1.7.1
#8 lore raw

PATCH v4 7/30 thermal: exynos: Bifurcate exynos tmu driver and configuration data

In reply to Amit Daniel Kachhap

This code splits the exynos tmu driver code into SOC specific data parts. This will simplify adding new SOC specific data to the same TMU controller.

---
 drivers/thermal/samsung/Kconfig           |    3 +-
 drivers/thermal/samsung/Makefile          |    1 +
 drivers/thermal/samsung/exynos_tmu.c      |   67 ++-----------------------
 drivers/thermal/samsung/exynos_tmu_data.c |   78 +++++++++++++++++++++++++++++
 drivers/thermal/samsung/exynos_tmu_data.h |   40 +++++++++++++++
 5 files changed, 125 insertions(+), 64 deletions(-)
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.h
drivers/thermal/samsung/Kconfig +2 -1
index 178a1ad..a13e093 100644
@@ -8,7 +8,8 @@ config EXYNOS_THERMAL
 	  If you say yes here you get support for the TMU (Thermal Management
 	  Unit) driver for SAMSUNG EXYNOS series of soc. This driver initialises
 	  the TMU, reports temperature and handles cooling action if defined.
-	  This driver uses the exynos core thermal API's.
+	  This driver uses the exynos core thermal API's and TMU configuration
+	  data from the supported soc's.
 
 config EXYNOS_THERMAL_CORE
 	bool "Core thermal framework support for EXYNOS SOC's"
drivers/thermal/samsung/Makefile +1 -0
index 22528d6..c09d830 100644
@@ -3,4 +3,5 @@
 #
 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
drivers/thermal/samsung/exynos_tmu.c +4 -63

94 lines not on this page · raw message

drivers/thermal/samsung/exynos_tmu_data.c new file +78 -0

78 lines not on this page · raw message

drivers/thermal/samsung/exynos_tmu_data.h new file +40 -0
new file mode 100644
index 0000000..b7835fe
@@ -0,0 +1,40 @@
+/*
+ * exynos_tmu_data.h - Samsung EXYNOS tmu data header file
+ *
+ *  Copyright (C) 2013 Samsung Electronics
+ *  Amit Daniel Kachhap <[email protected]>
+ *
+ * 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_TMU_DATA_H
+#define _EXYNOS_TMU_DATA_H
+
+#if defined(CONFIG_CPU_EXYNOS4210)
+extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data;
+#define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)
+#else
+#define EXYNOS4210_TMU_DRV_DATA (NULL)
+#endif
+
+#if (defined(CONFIG_SOC_EXYNOS5250) || defined(CONFIG_SOC_EXYNOS4412))
+extern struct exynos_tmu_platform_data const exynos5250_default_tmu_data;
+#define EXYNOS5250_TMU_DRV_DATA (&exynos5250_default_tmu_data)
+#else
+#define EXYNOS5250_TMU_DRV_DATA (NULL)
+#endif
+
+#endif /*_EXYNOS_TMU_DATA_H*/
Signature · 1 line
1.7.1
#9 lore raw

PATCH v4 8/30 thermal: exynos: Add missing definations and code cleanup

In reply to Amit Daniel Kachhap

This patch adds some extra register bitfield definations and cleans up the code to prepare for moving register macros and definations inside the TMU data section.

---
 drivers/thermal/samsung/exynos_tmu.c |   62 +++++++++++++++++++++++++---------
 1 files changed, 46 insertions(+), 16 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +46 -16
index 9aaab15..aba92f2 100644
@@ -43,9 +43,12 @@
 
 #define EXYNOS_TMU_TRIM_TEMP_MASK	0xff
 #define EXYNOS_TMU_GAIN_SHIFT		8
+#define EXYNOS_TMU_GAIN_MASK		0xf
 #define EXYNOS_TMU_REF_VOLTAGE_SHIFT	24
-#define EXYNOS_TMU_CORE_ON		3
-#define EXYNOS_TMU_CORE_OFF		2
+#define EXYNOS_TMU_REF_VOLTAGE_MASK	0x1f
+#define EXYNOS_TMU_BUF_SLOPE_SEL_MASK	0xf
+#define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT	8
+#define EXYNOS_TMU_CORE_EN_SHIFT	0
 #define EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET	50
 
 /* Exynos4210 specific registers */
@@ -63,6 +66,7 @@
 #define EXYNOS4210_TMU_TRIG_LEVEL1_MASK	0x10
 #define EXYNOS4210_TMU_TRIG_LEVEL2_MASK	0x100
 #define EXYNOS4210_TMU_TRIG_LEVEL3_MASK	0x1000
+#define EXYNOS4210_TMU_TRIG_LEVEL_MASK	0x1111
 #define EXYNOS4210_TMU_INTCLEAR_VAL	0x1111
 
 /* Exynos5250 and Exynos4412 specific registers */
@@ -72,17 +76,30 @@
 #define EXYNOS_EMUL_CON		0x80
 
 #define EXYNOS_TRIMINFO_RELOAD		0x1
+#define EXYNOS_TRIMINFO_SHIFT		0x0
+#define EXYNOS_TMU_RISE_INT_MASK	0x111
+#define EXYNOS_TMU_RISE_INT_SHIFT	0
+#define EXYNOS_TMU_FALL_INT_MASK	0x111
+#define EXYNOS_TMU_FALL_INT_SHIFT	12
 #define EXYNOS_TMU_CLEAR_RISE_INT	0x111
 #define EXYNOS_TMU_CLEAR_FALL_INT	(0x111 << 12)
-#define EXYNOS_MUX_ADDR_VALUE		6
-#define EXYNOS_MUX_ADDR_SHIFT		20
 #define EXYNOS_TMU_TRIP_MODE_SHIFT	13
+#define EXYNOS_TMU_TRIP_MODE_MASK	0x7
+
+#define EXYNOS_TMU_INTEN_RISE0_SHIFT	0
+#define EXYNOS_TMU_INTEN_RISE1_SHIFT	4
+#define EXYNOS_TMU_INTEN_RISE2_SHIFT	8
+#define EXYNOS_TMU_INTEN_RISE3_SHIFT	12
+#define EXYNOS_TMU_INTEN_FALL0_SHIFT	16
+#define EXYNOS_TMU_INTEN_FALL1_SHIFT	20
+#define EXYNOS_TMU_INTEN_FALL2_SHIFT	24
 
 #define EFUSE_MIN_VALUE 40
 #define EFUSE_MAX_VALUE 100
 
 #ifdef CONFIG_THERMAL_EMULATION
 #define EXYNOS_EMUL_TIME	0x57F0
+#define EXYNOS_EMUL_TIME_MASK	0xffff
 #define EXYNOS_EMUL_TIME_SHIFT	16
 #define EXYNOS_EMUL_DATA_SHIFT	8
 #define EXYNOS_EMUL_DATA_MASK	0xFF
@@ -261,24 +278,37 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
-	con = pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT |
-		pdata->gain << EXYNOS_TMU_GAIN_SHIFT;
+	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
 
-	if (data->soc == SOC_ARCH_EXYNOS) {
-		con |= pdata->noise_cancel_mode << EXYNOS_TMU_TRIP_MODE_SHIFT;
-		con |= (EXYNOS_MUX_ADDR_VALUE << EXYNOS_MUX_ADDR_SHIFT);
+	if (pdata->reference_voltage) {
+		con &= ~(EXYNOS_TMU_REF_VOLTAGE_MASK <<
+				EXYNOS_TMU_REF_VOLTAGE_SHIFT);
+		con |= pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT;
+	}
+
+	if (pdata->gain) {
+		con &= ~(EXYNOS_TMU_GAIN_MASK << EXYNOS_TMU_GAIN_SHIFT);
+		con |= (pdata->gain << EXYNOS_TMU_GAIN_SHIFT);
+	}
+
+	if (pdata->noise_cancel_mode) {
+		con &= ~(EXYNOS_TMU_TRIP_MODE_MASK <<
+					EXYNOS_TMU_TRIP_MODE_SHIFT);
+		con |= (pdata->noise_cancel_mode << EXYNOS_TMU_TRIP_MODE_SHIFT);
 	}
 
 	if (on) {
-		con |= EXYNOS_TMU_CORE_ON;
-		interrupt_en = pdata->trigger_level3_en << 12 |
-			pdata->trigger_level2_en << 8 |
-			pdata->trigger_level1_en << 4 |
-			pdata->trigger_level0_en;
+		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
+		interrupt_en =
+		pdata->trigger_level3_en << EXYNOS_TMU_INTEN_RISE3_SHIFT |
+		pdata->trigger_level2_en << EXYNOS_TMU_INTEN_RISE2_SHIFT |
+		pdata->trigger_level1_en << EXYNOS_TMU_INTEN_RISE1_SHIFT |
+		pdata->trigger_level0_en << EXYNOS_TMU_INTEN_RISE0_SHIFT;
 		if (pdata->threshold_falling)
-			interrupt_en |= interrupt_en << 16;
+			interrupt_en |=
+				interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
 	} else {
-		con |= EXYNOS_TMU_CORE_OFF;
+		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en = 0; /* Disable all interrupts */
 	}
 	writel(interrupt_en, data->base + EXYNOS_TMU_REG_INTEN);
Signature · 1 line
1.7.1
#10 lore raw

PATCH v4 9/30 thermal: exynos: Add extra entries in the tmu platform data

In reply to Amit Daniel Kachhap

This patch adds entries min_efuse_value, max_efuse_value, default_temp_offset, trigger_type, cal_type, trim_first_point, trim_second_point and trigger_enable in the TMU platform data structure. Also the driver is modified to use the data passed by these new platform memebers instead of the constant macros. All these changes helps in separating the SOC specific data part from the TMU driver.

---
 drivers/thermal/samsung/exynos_tmu.c      |   43 +++++++++++------------
 drivers/thermal/samsung/exynos_tmu.h      |   52 +++++++++++++++++++----------
 drivers/thermal/samsung/exynos_tmu_data.c |   33 ++++++++++++++----
 3 files changed, 80 insertions(+), 48 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +21 -22
index aba92f2..5f8f189 100644
@@ -49,7 +49,6 @@
 #define EXYNOS_TMU_BUF_SLOPE_SEL_MASK	0xf
 #define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT	8
 #define EXYNOS_TMU_CORE_EN_SHIFT	0
-#define EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET	50
 
 /* Exynos4210 specific registers */
 #define EXYNOS4210_TMU_REG_THRESHOLD_TEMP	0x44
@@ -94,9 +93,6 @@
 #define EXYNOS_TMU_INTEN_FALL1_SHIFT	20
 #define EXYNOS_TMU_INTEN_FALL2_SHIFT	24
 
-#define EFUSE_MIN_VALUE 40
-#define EFUSE_MAX_VALUE 100
-
 #ifdef CONFIG_THERMAL_EMULATION
 #define EXYNOS_EMUL_TIME	0x57F0
 #define EXYNOS_EMUL_TIME_MASK	0xffff
@@ -136,15 +132,16 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
 
 	switch (pdata->cal_type) {
 	case TYPE_TWO_POINT_TRIMMING:
-		temp_code = (temp - 25) *
-		    (data->temp_error2 - data->temp_error1) /
-		    (85 - 25) + data->temp_error1;
+		temp_code = (temp - pdata->first_point_trim) *
+			(data->temp_error2 - data->temp_error1) /
+			(pdata->second_point_trim - pdata->first_point_trim) +
+			data->temp_error1;
 		break;
 	case TYPE_ONE_POINT_TRIMMING:
-		temp_code = temp + data->temp_error1 - 25;
+		temp_code = temp + data->temp_error1 - pdata->first_point_trim;
 		break;
 	default:
-		temp_code = temp + EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET;
+		temp_code = temp + pdata->default_temp_offset;
 		break;
 	}
 out:
@@ -169,14 +166,16 @@ static int code_to_temp(struct exynos_tmu_data *data, u8 temp_code)
 
 	switch (pdata->cal_type) {
 	case TYPE_TWO_POINT_TRIMMING:
-		temp = (temp_code - data->temp_error1) * (85 - 25) /
-		    (data->temp_error2 - data->temp_error1) + 25;
+		temp = (temp_code - data->temp_error1) *
+			(pdata->second_point_trim - pdata->first_point_trim) /
+			(data->temp_error2 - data->temp_error1) +
+			pdata->first_point_trim;
 		break;
 	case TYPE_ONE_POINT_TRIMMING:
-		temp = temp_code - data->temp_error1 + 25;
+		temp = temp_code - data->temp_error1 + pdata->first_point_trim;
 		break;
 	default:
-		temp = temp_code - EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET;
+		temp = temp_code - pdata->default_temp_offset;
 		break;
 	}
 out:
@@ -209,8 +208,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 	data->temp_error1 = trim_info & EXYNOS_TMU_TRIM_TEMP_MASK;
 	data->temp_error2 = ((trim_info >> 8) & EXYNOS_TMU_TRIM_TEMP_MASK);
 
-	if ((EFUSE_MIN_VALUE > data->temp_error1) ||
-			(data->temp_error1 > EFUSE_MAX_VALUE) ||
+	if ((pdata->min_efuse_value > data->temp_error1) ||
+			(data->temp_error1 > pdata->max_efuse_value) ||
 			(data->temp_error2 != 0))
 		data->temp_error1 = pdata->efuse_value;
 
@@ -300,10 +299,10 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 	if (on) {
 		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
 		interrupt_en =
-		pdata->trigger_level3_en << EXYNOS_TMU_INTEN_RISE3_SHIFT |
-		pdata->trigger_level2_en << EXYNOS_TMU_INTEN_RISE2_SHIFT |
-		pdata->trigger_level1_en << EXYNOS_TMU_INTEN_RISE1_SHIFT |
-		pdata->trigger_level0_en << EXYNOS_TMU_INTEN_RISE0_SHIFT;
+		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;
 		if (pdata->threshold_falling)
 			interrupt_en |=
 				interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
@@ -538,9 +537,9 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 
 	/* Register the sensor with thermal management interface */
 	(&exynos_sensor_conf)->private_data = data;
-	exynos_sensor_conf.trip_data.trip_count = pdata->trigger_level0_en +
-			pdata->trigger_level1_en + pdata->trigger_level2_en +
-			pdata->trigger_level3_en;
+	exynos_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 < exynos_sensor_conf.trip_data.trip_count; i++)
 		exynos_sensor_conf.trip_data.trip_val[i] =
drivers/thermal/samsung/exynos_tmu.h +34 -18

83 lines not on this page · raw message

drivers/thermal/samsung/exynos_tmu_data.c +25 -8
index 13a60ca..ee6a3c9 100644
@@ -22,6 +22,7 @@
 
 #include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
+#include "exynos_tmu_data.h"
 
 #if defined(CONFIG_CPU_EXYNOS4210)
 struct exynos_tmu_platform_data const exynos4210_default_tmu_data = {
@@ -29,13 +30,21 @@ struct exynos_tmu_platform_data const exynos4210_default_tmu_data = {
 	.trigger_levels[0] = 5,
 	.trigger_levels[1] = 20,
 	.trigger_levels[2] = 30,
-	.trigger_level0_en = 1,
-	.trigger_level1_en = 1,
-	.trigger_level2_en = 1,
-	.trigger_level3_en = 0,
+	.trigger_enable[0] = 1,
+	.trigger_enable[1] = 1,
+	.trigger_enable[2] = 1,
+	.trigger_enable[3] = 0,
+	.trigger_type[0] = 0,
+	.trigger_type[1] = 0,
+	.trigger_type[2] = 1,
 	.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,
 	.freq_tab[0] = {
 		.freq_clip_max = 800 * 1000,
 		.temp_level = 85,
@@ -55,15 +64,23 @@ struct exynos_tmu_platform_data const exynos5250_default_tmu_data = {
 	.trigger_levels[0] = 85,
 	.trigger_levels[1] = 103,
 	.trigger_levels[2] = 110,
-	.trigger_level0_en = 1,
-	.trigger_level1_en = 1,
-	.trigger_level2_en = 1,
-	.trigger_level3_en = 0,
+	.trigger_enable[0] = 1,
+	.trigger_enable[1] = 1,
+	.trigger_enable[2] = 1,
+	.trigger_enable[3] = 0,
+	.trigger_type[0] = 0,
+	.trigger_type[1] = 0,
+	.trigger_type[2] = 1,
 	.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,
 	.freq_tab[0] = {
 		.freq_clip_max = 800 * 1000,
 		.temp_level = 85,
Signature · 1 line
1.7.1
#11 lore raw

PATCH v4 10/30 thermal: exynos: Support thermal tripping

In reply to Amit Daniel Kachhap

TMU urgently sends active-high signal (thermal trip) to PMU, and thermal tripping by hardware logic. Thermal tripping means that PMU cuts off the whole power of SoC by controlling external voltage regulator.

---
 drivers/thermal/samsung/exynos_tmu.c      |    8 +++++++-
 drivers/thermal/samsung/exynos_tmu_data.c |    2 ++
 2 files changed, 9 insertions(+), 1 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +7 -1
index 5f8f189..479d61e 100644
@@ -84,6 +84,7 @@
 #define EXYNOS_TMU_CLEAR_FALL_INT	(0x111 << 12)
 #define EXYNOS_TMU_TRIP_MODE_SHIFT	13
 #define EXYNOS_TMU_TRIP_MODE_MASK	0x7
+#define EXYNOS_TMU_THERM_TRIP_EN_SHIFT	12
 
 #define EXYNOS_TMU_INTEN_RISE0_SHIFT	0
 #define EXYNOS_TMU_INTEN_RISE1_SHIFT	4
@@ -186,7 +187,7 @@ static int exynos_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;
+	unsigned int status, trim_info, con;
 	unsigned int rising_threshold = 0, falling_threshold = 0;
 	int ret = 0, threshold_code, i, trigger_levs = 0;
 
@@ -251,6 +252,11 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 					falling_threshold |=
 						threshold_code << 8 * i;
 			}
+			if (pdata->trigger_type[i] != HW_TRIP)
+				continue;
+			con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
+			con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
+			writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
 		}
 
 		writel(rising_threshold,
drivers/thermal/samsung/exynos_tmu_data.c +2 -0
index ee6a3c9..6b937f5 100644
@@ -64,6 +64,7 @@ struct exynos_tmu_platform_data const exynos5250_default_tmu_data = {
 	.trigger_levels[0] = 85,
 	.trigger_levels[1] = 103,
 	.trigger_levels[2] = 110,
+	.trigger_levels[3] = 120,
 	.trigger_enable[0] = 1,
 	.trigger_enable[1] = 1,
 	.trigger_enable[2] = 1,
@@ -71,6 +72,7 @@ struct exynos_tmu_platform_data const exynos5250_default_tmu_data = {
 	.trigger_type[0] = 0,
 	.trigger_type[1] = 0,
 	.trigger_type[2] = 1,
+	.trigger_type[3] = 2,
 	.gain = 8,
 	.reference_voltage = 16,
 	.noise_cancel_mode = 4,
Signature · 1 line
1.7.1
#12 lore raw

Re: [PATCH V4 10/30] thermal: exynos: Support thermal tripping

Hi, Amit

Quoted 34 lines · Amit Daniel Kachhap

TMU urgently sends active-high signal (thermal trip) to PMU, and thermal tripping by hardware logic. Thermal tripping means that PMU cuts off the whole power of SoC by controlling external voltage regulator.

---
 drivers/thermal/samsung/exynos_tmu.c      |    8 +++++++-
 drivers/thermal/samsung/exynos_tmu_data.c |    2 ++
 2 files changed, 9 insertions(+), 1 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +2 -1
index 5f8f189..479d61e 100644
@@ -84,6 +84,7 @@
 #define EXYNOS_TMU_CLEAR_FALL_INT	(0x111 << 12)
 #define EXYNOS_TMU_TRIP_MODE_SHIFT	13
 #define EXYNOS_TMU_TRIP_MODE_MASK	0x7
+#define EXYNOS_TMU_THERM_TRIP_EN_SHIFT	12
 
 #define EXYNOS_TMU_INTEN_RISE0_SHIFT	0
 #define EXYNOS_TMU_INTEN_RISE1_SHIFT	4
@@ -186,7 +187,7 @@ static int exynos_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;
+	unsigned int status, trim_info, con;
 	unsigned int rising_threshold = 0, falling_threshold = 0;
 	int ret = 0, threshold_code, i, trigger_levs = 0;
 

drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_initialize(struct platform_device *pdev) · line 256

Quoted 5 lines
drivers/thermal/samsung/exynos_tmu.c +2 -0
@@ -251,6 +252,11 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 					falling_threshold |=
 						threshold_code << 8 * i;
 			}
+			if (pdata->trigger_type[i] != HW_TRIP)
+				continue;

As you know, HW trip can be used when only the most last level of threshold temperature is set. (exynos4412 : 4th, exynos 5440 : 5th threshold level). So it wouldn't work properly, even if we enable HW trip according to pre-defined trigger type not to HW trip threshold temperature. To enable HW trip, we just need to check whether if HW trip threshold temperature level is defined.

if (trigger_level[HW_TRIP_LEVEL])
enable HW trip

Thanks,
Jonghwa

Quoted 26 lines
drivers/thermal/samsung/exynos_tmu.c +3 -0
+			con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
+			con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
+			writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
 		}
 
 		writel(rising_threshold,
drivers/thermal/samsung/exynos_tmu_data.c +2 -0
index ee6a3c9..6b937f5 100644
@@ -64,6 +64,7 @@ struct exynos_tmu_platform_data const exynos5250_default_tmu_data = {
 	.trigger_levels[0] = 85,
 	.trigger_levels[1] = 103,
 	.trigger_levels[2] = 110,
+	.trigger_levels[3] = 120,
 	.trigger_enable[0] = 1,
 	.trigger_enable[1] = 1,
 	.trigger_enable[2] = 1,
@@ -71,6 +72,7 @@ struct exynos_tmu_platform_data const exynos5250_default_tmu_data = {
 	.trigger_type[0] = 0,
 	.trigger_type[1] = 0,
 	.trigger_type[2] = 1,
+	.trigger_type[3] = 2,
 	.gain = 8,
 	.reference_voltage = 16,
 	.noise_cancel_mode = 4,
#13 lore raw

Re: [PATCH V4 10/30] thermal: exynos: Support thermal tripping

Hi .

Quoted 50 lines · On Fri, May 17, 2013 at 5:26 PM, <[email protected]> wrote:

Hi, Amit

Quoted 34 lines · Amit Daniel Kachhap

TMU urgently sends active-high signal (thermal trip) to PMU, and thermal tripping by hardware logic. Thermal tripping means that PMU cuts off the whole power of SoC by controlling external voltage regulator.

---
 drivers/thermal/samsung/exynos_tmu.c      |    8 +++++++-
 drivers/thermal/samsung/exynos_tmu_data.c |    2 ++
 2 files changed, 9 insertions(+), 1 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +2 -1
index 5f8f189..479d61e 100644
@@ -84,6 +84,7 @@
 #define EXYNOS_TMU_CLEAR_FALL_INT    (0x111 << 12)
 #define EXYNOS_TMU_TRIP_MODE_SHIFT   13
 #define EXYNOS_TMU_TRIP_MODE_MASK    0x7
+#define EXYNOS_TMU_THERM_TRIP_EN_SHIFT       12
 
 #define EXYNOS_TMU_INTEN_RISE0_SHIFT 0
 #define EXYNOS_TMU_INTEN_RISE1_SHIFT 4
@@ -186,7 +187,7 @@ static int exynos_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;
+     unsigned int status, trim_info, con;
      unsigned int rising_threshold = 0, falling_threshold = 0;
      int ret = 0, threshold_code, i, trigger_levs = 0;
 

drivers/thermal/samsung/exynos_tmu.c static int exynos_tmu_initialize(struct platform_device *pdev) · line 256

Quoted 5 lines
drivers/thermal/samsung/exynos_tmu.c +2 -0
@@ -251,6 +252,11 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
                                      falling_threshold |=
                                              threshold_code << 8 * i;
                      }
+                     if (pdata->trigger_type[i] != HW_TRIP)
+                             continue;

As you know, HW trip can be used when only the most last level of threshold temperature is set. (exynos4412 : 4th, exynos 5440 : 5th threshold level). So it wouldn't work properly, even if we enable HW trip according to pre-defined trigger type not to HW trip threshold temperature. To enable HW trip, we just need to check whether if HW trip threshold temperature level is defined.

Quoted 2 lines

if (trigger_level[HW_TRIP_LEVEL])
enable HW trip

Yes you are right. I will include this change in the next version.

Thanks,
Amit Daniel

Quoted 32 lines

Thanks,
Jonghwa

Quoted 26 lines
drivers/thermal/samsung/exynos_tmu.c +3 -0
+                     con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
+                     con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
+                     writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
              }
 
              writel(rising_threshold,
drivers/thermal/samsung/exynos_tmu_data.c +2 -0
index ee6a3c9..6b937f5 100644
@@ -64,6 +64,7 @@ struct exynos_tmu_platform_data const exynos5250_default_tmu_data = {
      .trigger_levels[0] = 85,
      .trigger_levels[1] = 103,
      .trigger_levels[2] = 110,
+     .trigger_levels[3] = 120,
      .trigger_enable[0] = 1,
      .trigger_enable[1] = 1,
      .trigger_enable[2] = 1,
@@ -71,6 +72,7 @@ struct exynos_tmu_platform_data const exynos5250_default_tmu_data = {
      .trigger_type[0] = 0,
      .trigger_type[1] = 0,
      .trigger_type[2] = 1,
+     .trigger_type[3] = 2,
      .gain = 8,
      .reference_voltage = 16,
      .noise_cancel_mode = 4,
#14 lore raw

PATCH v4 11/30 thermal: exynos: Move register definitions from driver file to data file

In reply to Amit Daniel Kachhap

This patch migrates the TMU register definition/bitfields to data file. This is needed to support SoC's which use the same TMU controller but register validity, offsets or bitfield may slightly vary across SOC's.

---
 drivers/thermal/samsung/exynos_tmu.c      |  179 +++++++++-------------------
 drivers/thermal/samsung/exynos_tmu.h      |  133 +++++++++++++++++++++
 drivers/thermal/samsung/exynos_tmu_data.c |   59 ++++++++++
 drivers/thermal/samsung/exynos_tmu_data.h |   68 +++++++++++
 4 files changed, 318 insertions(+), 121 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +58 -121
index 479d61e..3ad97ff 100644
@@ -32,77 +32,6 @@
 #include "exynos_tmu.h"
 #include "exynos_tmu_data.h"
 
-/* Exynos generic registers */
-#define EXYNOS_TMU_REG_TRIMINFO		0x0
-#define EXYNOS_TMU_REG_CONTROL		0x20
-#define EXYNOS_TMU_REG_STATUS		0x28
-#define EXYNOS_TMU_REG_CURRENT_TEMP	0x40
-#define EXYNOS_TMU_REG_INTEN		0x70
-#define EXYNOS_TMU_REG_INTSTAT		0x74
-#define EXYNOS_TMU_REG_INTCLEAR		0x78
-
-#define EXYNOS_TMU_TRIM_TEMP_MASK	0xff
-#define EXYNOS_TMU_GAIN_SHIFT		8
-#define EXYNOS_TMU_GAIN_MASK		0xf
-#define EXYNOS_TMU_REF_VOLTAGE_SHIFT	24
-#define EXYNOS_TMU_REF_VOLTAGE_MASK	0x1f
-#define EXYNOS_TMU_BUF_SLOPE_SEL_MASK	0xf
-#define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT	8
-#define EXYNOS_TMU_CORE_EN_SHIFT	0
-
-/* Exynos4210 specific registers */
-#define EXYNOS4210_TMU_REG_THRESHOLD_TEMP	0x44
-#define EXYNOS4210_TMU_REG_TRIG_LEVEL0	0x50
-#define EXYNOS4210_TMU_REG_TRIG_LEVEL1	0x54
-#define EXYNOS4210_TMU_REG_TRIG_LEVEL2	0x58
-#define EXYNOS4210_TMU_REG_TRIG_LEVEL3	0x5C
-#define EXYNOS4210_TMU_REG_PAST_TEMP0	0x60
-#define EXYNOS4210_TMU_REG_PAST_TEMP1	0x64
-#define EXYNOS4210_TMU_REG_PAST_TEMP2	0x68
-#define EXYNOS4210_TMU_REG_PAST_TEMP3	0x6C
-
-#define EXYNOS4210_TMU_TRIG_LEVEL0_MASK	0x1
-#define EXYNOS4210_TMU_TRIG_LEVEL1_MASK	0x10
-#define EXYNOS4210_TMU_TRIG_LEVEL2_MASK	0x100
-#define EXYNOS4210_TMU_TRIG_LEVEL3_MASK	0x1000
-#define EXYNOS4210_TMU_TRIG_LEVEL_MASK	0x1111
-#define EXYNOS4210_TMU_INTCLEAR_VAL	0x1111
-
-/* Exynos5250 and Exynos4412 specific registers */
-#define EXYNOS_TMU_TRIMINFO_CON	0x14
-#define EXYNOS_THD_TEMP_RISE		0x50
-#define EXYNOS_THD_TEMP_FALL		0x54
-#define EXYNOS_EMUL_CON		0x80
-
-#define EXYNOS_TRIMINFO_RELOAD		0x1
-#define EXYNOS_TRIMINFO_SHIFT		0x0
-#define EXYNOS_TMU_RISE_INT_MASK	0x111
-#define EXYNOS_TMU_RISE_INT_SHIFT	0
-#define EXYNOS_TMU_FALL_INT_MASK	0x111
-#define EXYNOS_TMU_FALL_INT_SHIFT	12
-#define EXYNOS_TMU_CLEAR_RISE_INT	0x111
-#define EXYNOS_TMU_CLEAR_FALL_INT	(0x111 << 12)
-#define EXYNOS_TMU_TRIP_MODE_SHIFT	13
-#define EXYNOS_TMU_TRIP_MODE_MASK	0x7
-#define EXYNOS_TMU_THERM_TRIP_EN_SHIFT	12
-
-#define EXYNOS_TMU_INTEN_RISE0_SHIFT	0
-#define EXYNOS_TMU_INTEN_RISE1_SHIFT	4
-#define EXYNOS_TMU_INTEN_RISE2_SHIFT	8
-#define EXYNOS_TMU_INTEN_RISE3_SHIFT	12
-#define EXYNOS_TMU_INTEN_FALL0_SHIFT	16
-#define EXYNOS_TMU_INTEN_FALL1_SHIFT	20
-#define EXYNOS_TMU_INTEN_FALL2_SHIFT	24
-
-#ifdef CONFIG_THERMAL_EMULATION
-#define EXYNOS_EMUL_TIME	0x57F0
-#define EXYNOS_EMUL_TIME_MASK	0xffff
-#define EXYNOS_EMUL_TIME_SHIFT	16
-#define EXYNOS_EMUL_DATA_SHIFT	8
-#define EXYNOS_EMUL_DATA_MASK	0xFF
-#define EXYNOS_EMUL_ENABLE	0x1
-#endif /* CONFIG_THERMAL_EMULATION */
-
 struct exynos_tmu_data {
 	struct exynos_tmu_platform_data *pdata;
 	struct resource *mem;
@@ -187,6 +116,7 @@ static int exynos_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 exynos_tmu_registers *reg = pdata->registers;
 	unsigned int status, trim_info, con;
 	unsigned int rising_threshold = 0, falling_threshold = 0;
 	int ret = 0, threshold_code, i, trigger_levs = 0;
@@ -194,20 +124,20 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
-	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
+	status = readb(data->base + reg->tmu_status);
 	if (!status) {
 		ret = -EBUSY;
 		goto out;
 	}
 
-	if (data->soc == SOC_ARCH_EXYNOS) {
-		__raw_writel(EXYNOS_TRIMINFO_RELOAD,
-				data->base + EXYNOS_TMU_TRIMINFO_CON);
-	}
+	if (data->soc == SOC_ARCH_EXYNOS)
+		__raw_writel(1, data->base + reg->triminfo_ctrl);
+
 	/* Save trimming info in order to perform calibration */
-	trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
-	data->temp_error1 = trim_info & EXYNOS_TMU_TRIM_TEMP_MASK;
-	data->temp_error2 = ((trim_info >> 8) & EXYNOS_TMU_TRIM_TEMP_MASK);
+	trim_info = readl(data->base + reg->triminfo_data);
+	data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK;
+	data->temp_error2 = ((trim_info >> reg->triminfo_85_shift) &
+				EXYNOS_TMU_TEMP_MASK);
 
 	if ((pdata->min_efuse_value > data->temp_error1) ||
 			(data->temp_error1 > pdata->max_efuse_value) ||
@@ -227,13 +157,12 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 			goto out;
 		}
 		writeb(threshold_code,
-			data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
+			data->base + reg->threshold_temp);
 		for (i = 0; i < trigger_levs; i++)
-			writeb(pdata->trigger_levels[i],
-			data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
+			writeb(pdata->trigger_levels[i], data->base +
+			reg->threshold_th0 + i * sizeof(reg->threshold_th0));
 
-		writel(EXYNOS4210_TMU_INTCLEAR_VAL,
-			data->base + EXYNOS_TMU_REG_INTCLEAR);
+		writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
 	} else if (data->soc == SOC_ARCH_EXYNOS) {
 		/* Write temperature code for rising and falling threshold */
 		for (i = 0; i < trigger_levs; i++) {
@@ -254,18 +183,19 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 			}
 			if (pdata->trigger_type[i] != HW_TRIP)
 				continue;
-			con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
-			con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
-			writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+			con = readl(data->base + reg->tmu_ctrl);
+			con |= (1 << reg->therm_trip_en_shift);
+			writel(con, data->base + reg->tmu_ctrl);
 		}
 
 		writel(rising_threshold,
-				data->base + EXYNOS_THD_TEMP_RISE);
+				data->base + reg->threshold_th0);
 		writel(falling_threshold,
-				data->base + EXYNOS_THD_TEMP_FALL);
+				data->base + reg->threshold_th1);
 
-		writel(EXYNOS_TMU_CLEAR_RISE_INT | EXYNOS_TMU_CLEAR_FALL_INT,
-				data->base + EXYNOS_TMU_REG_INTCLEAR);
+		writel((reg->inten_rise_mask << reg->inten_rise_shift) |
+			(reg->inten_fall_mask << reg->inten_fall_shift),
+				data->base + reg->tmu_intclear);
 	}
 out:
 	clk_disable(data->clk);
@@ -278,46 +208,46 @@ static void exynos_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;
+	const struct exynos_tmu_registers *reg = pdata->registers;
 	unsigned int con, interrupt_en;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
-	con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
+	con = readl(data->base + reg->tmu_ctrl);
 
 	if (pdata->reference_voltage) {
-		con &= ~(EXYNOS_TMU_REF_VOLTAGE_MASK <<
-				EXYNOS_TMU_REF_VOLTAGE_SHIFT);
-		con |= pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT;
+		con &= ~(reg->buf_vref_sel_mask << reg->buf_vref_sel_shift);
+		con |= pdata->reference_voltage << reg->buf_vref_sel_shift;
 	}
 
 	if (pdata->gain) {
-		con &= ~(EXYNOS_TMU_GAIN_MASK << EXYNOS_TMU_GAIN_SHIFT);
-		con |= (pdata->gain << EXYNOS_TMU_GAIN_SHIFT);
+		con &= ~(reg->buf_slope_sel_mask << reg->buf_slope_sel_shift);
+		con |= (pdata->gain << reg->buf_slope_sel_shift);
 	}
 
 	if (pdata->noise_cancel_mode) {
-		con &= ~(EXYNOS_TMU_TRIP_MODE_MASK <<
-					EXYNOS_TMU_TRIP_MODE_SHIFT);
-		con |= (pdata->noise_cancel_mode << EXYNOS_TMU_TRIP_MODE_SHIFT);
+		con &= ~(reg->therm_trip_mode_mask <<
+					reg->therm_trip_mode_shift);
+		con |= (pdata->noise_cancel_mode << reg->therm_trip_mode_shift);
 	}
 
 	if (on) {
-		con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
+		con |= (1 << reg->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;
+			pdata->trigger_enable[3] << reg->inten_rise3_shift |
+			pdata->trigger_enable[2] << reg->inten_rise2_shift |
+			pdata->trigger_enable[1] << reg->inten_rise1_shift |
+			pdata->trigger_enable[0] << reg->inten_rise0_shift;
 		if (pdata->threshold_falling)
 			interrupt_en |=
-				interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
+				interrupt_en << reg->inten_fall0_shift;
 	} else {
-		con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
+		con &= ~(1 << reg->core_en_shift);
 		interrupt_en = 0; /* Disable all interrupts */
 	}
-	writel(interrupt_en, data->base + EXYNOS_TMU_REG_INTEN);
-	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+	writel(interrupt_en, data->base + reg->tmu_inten);
+	writel(con, data->base + reg->tmu_ctrl);
 
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
@@ -325,13 +255,15 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 
 static int exynos_tmu_read(struct exynos_tmu_data *data)
 {
+	struct exynos_tmu_platform_data *pdata = data->pdata;
+	const struct exynos_tmu_registers *reg = pdata->registers;
 	u8 temp_code;
 	int temp;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
-	temp_code = readb(data->base + EXYNOS_TMU_REG_CURRENT_TEMP);
+	temp_code = readb(data->base + reg->tmu_cur_temp);
 	temp = code_to_temp(data, temp_code);
 
 	clk_disable(data->clk);
@@ -344,7 +276,9 @@ static int exynos_tmu_read(struct exynos_tmu_data *data)
 static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp)
 {
 	struct exynos_tmu_data *data = drv_data;
-	unsigned int reg;
+	struct exynos_tmu_platform_data *pdata = data->pdata;
+	const struct exynos_tmu_registers *reg = pdata->registers;
+	unsigned int val;
 	int ret = -EINVAL;
 
 	if (data->soc == SOC_ARCH_EXYNOS4210)
@@ -356,19 +290,19 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp)
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
-	reg = readl(data->base + EXYNOS_EMUL_CON);
+	val = readl(data->base + reg->emul_con);
 
 	if (temp) {
 		temp /= MCELSIUS;
 
-		reg = (EXYNOS_EMUL_TIME << EXYNOS_EMUL_TIME_SHIFT) |
+		val = (EXYNOS_EMUL_TIME << reg->emul_time_shift) |
 			(temp_to_code(data, temp)
-			 << EXYNOS_EMUL_DATA_SHIFT) | EXYNOS_EMUL_ENABLE;
+			 << reg->emul_temp_shift) | EXYNOS_EMUL_ENABLE;
 	} else {
-		reg &= ~EXYNOS_EMUL_ENABLE;
+		val &= ~EXYNOS_EMUL_ENABLE;
 	}
 
-	writel(reg, data->base + EXYNOS_EMUL_CON);
+	writel(val, data->base + reg->emul_con);
 
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
@@ -385,17 +319,20 @@ static void exynos_tmu_work(struct work_struct *work)
 {
 	struct exynos_tmu_data *data = container_of(work,
 			struct exynos_tmu_data, irq_work);
+	struct exynos_tmu_platform_data *pdata = data->pdata;
+	const struct exynos_tmu_registers *reg = pdata->registers;
 
 	exynos_report_trigger();
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
+
 	if (data->soc == SOC_ARCH_EXYNOS)
-		writel(EXYNOS_TMU_CLEAR_RISE_INT |
-				EXYNOS_TMU_CLEAR_FALL_INT,
-				data->base + EXYNOS_TMU_REG_INTCLEAR);
+		writel((reg->inten_rise_mask << reg->inten_rise_shift) |
+			(reg->inten_fall_mask << reg->inten_fall_shift),
+				data->base + reg->tmu_intclear);
 	else
-		writel(EXYNOS4210_TMU_INTCLEAR_VAL,
-				data->base + EXYNOS_TMU_REG_INTCLEAR);
+		writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
+
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
 
drivers/thermal/samsung/exynos_tmu.h +133 -0

150 lines not on this page · raw message

drivers/thermal/samsung/exynos_tmu_data.c +59 -0

80 lines not on this page · raw message

drivers/thermal/samsung/exynos_tmu_data.h +68 -0

74 lines not on this page · raw message

Signature · 1 line
1.7.1
#15 lore raw

PATCH v4 12/30 thermal: exynos: Fix to clear only the generated interrupts

In reply to Amit Daniel Kachhap

This patch uses the TMU status register to know the generated interrupts and only clear them in the interrupt handler.

---
 drivers/thermal/samsung/exynos_tmu.c      |   11 +++++------
 drivers/thermal/samsung/exynos_tmu_data.c |    2 ++
 2 files changed, 7 insertions(+), 6 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +5 -6
index 3ad97ff..41e0bf9 100644
@@ -321,17 +321,16 @@ static void exynos_tmu_work(struct work_struct *work)
 			struct exynos_tmu_data, irq_work);
 	struct exynos_tmu_platform_data *pdata = data->pdata;
 	const struct exynos_tmu_registers *reg = pdata->registers;
+	unsigned int val_irq;
 
 	exynos_report_trigger();
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
-	if (data->soc == SOC_ARCH_EXYNOS)
-		writel((reg->inten_rise_mask << reg->inten_rise_shift) |
-			(reg->inten_fall_mask << reg->inten_fall_shift),
-				data->base + reg->tmu_intclear);
-	else
-		writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
+	/* TODO: take action based on particular interrupt */
+	val_irq = readl(data->base + reg->tmu_intstat);
+	/* clear the interrupts */
+	writel(val_irq, data->base + reg->tmu_intclear);
 
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
drivers/thermal/samsung/exynos_tmu_data.c +2 -0
index bdefd14..bf01210 100644
@@ -45,6 +45,7 @@ static const struct exynos_tmu_registers exynos4210_tmu_registers = {
 	.inten_rise1_shift = EXYNOS_TMU_INTEN_RISE1_SHIFT,
 	.inten_rise2_shift = EXYNOS_TMU_INTEN_RISE2_SHIFT,
 	.inten_rise3_shift = EXYNOS_TMU_INTEN_RISE3_SHIFT,
+	.tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
 	.tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
 };
 struct exynos_tmu_platform_data const exynos4210_default_tmu_data = {
@@ -111,6 +112,7 @@ static const struct exynos_tmu_registers exynos5250_tmu_registers = {
 	.inten_rise2_shift = EXYNOS_TMU_INTEN_RISE2_SHIFT,
 	.inten_rise3_shift = EXYNOS_TMU_INTEN_RISE3_SHIFT,
 	.inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT,
+	.tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
 	.tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
 	.emul_con = EXYNOS_EMUL_CON,
 	.emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
Signature · 1 line
1.7.1
#16 lore raw

PATCH v4 13/30 thermal: exynos: Add support for instance based register/unregister

In reply to Amit Daniel Kachhap

This code modifies the thermal driver to have multiple thermal zone support by replacing the global thermal zone variable with device data member of thermal_zone_device.

---
 drivers/thermal/samsung/exynos_thermal_common.c |   36 ++++++++++++++--------
 drivers/thermal/samsung/exynos_thermal_common.h |    9 +++--
 drivers/thermal/samsung/exynos_tmu.c            |   15 +++++----
 3 files changed, 36 insertions(+), 24 deletions(-)
drivers/thermal/samsung/exynos_thermal_common.c +23 -13
index dd49c9f..2af1e3b 100644
@@ -36,12 +36,11 @@ struct exynos_thermal_zone {
 	bool bind;
 };
 
-static struct exynos_thermal_zone *th_zone;
-
 /* 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;
@@ -51,25 +50,26 @@ static int exynos_get_mode(struct thermal_zone_device *thermal,
 static int exynos_set_mode(struct thermal_zone_device *thermal,
 			enum thermal_device_mode mode)
 {
-	if (!th_zone->therm_dev) {
+	struct exynos_thermal_zone *th_zone = thermal->devdata;
+	if (!th_zone) {
 		pr_notice("thermal zone not registered\n");
 		return 0;
 	}
 
-	mutex_lock(&th_zone->therm_dev->lock);
+	mutex_lock(&thermal->lock);
 
 	if (mode == THERMAL_DEVICE_ENABLED &&
 		!th_zone->sensor_conf->trip_data.trigger_falling)
-		th_zone->therm_dev->polling_delay = IDLE_INTERVAL;
+		thermal->polling_delay = IDLE_INTERVAL;
 	else
-		th_zone->therm_dev->polling_delay = 0;
+		thermal->polling_delay = 0;
 
-	mutex_unlock(&th_zone->therm_dev->lock);
+	mutex_unlock(&thermal->lock);
 
 	th_zone->mode = mode;
-	thermal_zone_device_update(th_zone->therm_dev);
+	thermal_zone_device_update(thermal);
 	pr_info("thermal polling set for duration=%d msec\n",
-				th_zone->therm_dev->polling_delay);
+				thermal->polling_delay);
 	return 0;
 }
 
@@ -96,6 +96,8 @@ static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
 static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
 				unsigned long *temp)
 {
+	struct exynos_thermal_zone *th_zone = thermal->devdata;
+
 	if (trip < GET_TRIP(MONITOR_ZONE) || trip > GET_TRIP(PANIC_ZONE))
 		return -EINVAL;
 
@@ -122,6 +124,7 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 {
 	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;
 
 	tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data;
@@ -168,6 +171,7 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
 			struct thermal_cooling_device *cdev)
 {
 	int ret = 0, i, tab_size;
+	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	struct thermal_sensor_conf *data = th_zone->sensor_conf;
 
 	if (th_zone->bind == false)
@@ -210,6 +214,7 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
 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) {
@@ -229,6 +234,7 @@ static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
 {
 	void *data;
 	int ret = -EINVAL;
+	struct exynos_thermal_zone *th_zone = thermal->devdata;
 
 	if (!th_zone->sensor_conf) {
 		pr_info("Temperature sensor not initialised\n");
@@ -276,11 +282,12 @@ static struct thermal_zone_device_ops const exynos_dev_ops = {
  * This function may be called from interrupt based temperature sensor
  * when threshold is changed.
  */
-void exynos_report_trigger(void)
+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 = conf->pzone_data;
 
 	if (!th_zone || !th_zone->therm_dev)
 		return;
@@ -321,6 +328,7 @@ 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");
@@ -342,7 +350,7 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
 	th_zone->cool_dev_size++;
 
 	th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name,
-			EXYNOS_ZONE_COUNT, 0, NULL, &exynos_dev_ops, NULL, 0,
+			EXYNOS_ZONE_COUNT, 0, th_zone, &exynos_dev_ops, NULL, 0,
 			sensor_conf->trip_data.trigger_falling ?
 			0 : IDLE_INTERVAL);
 
@@ -352,20 +360,22 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
 		goto err_unregister;
 	}
 	th_zone->mode = THERMAL_DEVICE_ENABLED;
+	sensor_conf->pzone_data = th_zone;
 
 	pr_info("Exynos: Kernel Thermal management registered\n");
 
 	return 0;
 
 err_unregister:
-	exynos_unregister_thermal();
+	exynos_unregister_thermal(sensor_conf);
 	return ret;
 }
 
 /* Un-Register with the in-kernel thermal management */
-void exynos_unregister_thermal(void)
+void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 {
 	int i;
+	struct exynos_thermal_zone *th_zone = sensor_conf->pzone_data;
 
 	if (!th_zone)
 		return;
drivers/thermal/samsung/exynos_thermal_common.h +5 -4
index 068f56c..89ae078 100644
@@ -77,22 +77,23 @@ struct thermal_sensor_conf {
 	struct thermal_trip_point_conf trip_data;
 	struct thermal_cooling_conf cooling_data;
 	void *private_data;
+	void *pzone_data;
 };
 
 /*Functions used exynos based thermal sensor driver*/
 #ifdef CONFIG_EXYNOS_THERMAL_CORE
-void exynos_unregister_thermal(void);
+void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf);
 int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf);
-void exynos_report_trigger(void);
+void exynos_report_trigger(struct thermal_sensor_conf *sensor_conf);
 #else
 static inline void
-exynos_unregister_thermal(void) { return; }
+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(void) { return; }
+exynos_report_trigger(struct thermal_sensor_conf *sensor_conf) { return; }
 
 #endif /* CONFIG_EXYNOS_THERMAL_CORE */
 #endif /* _EXYNOS_THERMAL_COMMON_H */
drivers/thermal/samsung/exynos_tmu.c +8 -7
index 41e0bf9..a1dc402 100644
@@ -315,6 +315,12 @@ static int exynos_tmu_set_emulation(void *drv_data,	unsigned long temp)
 	{ return -EINVAL; }
 #endif/*CONFIG_THERMAL_EMULATION*/
 
+static struct thermal_sensor_conf exynos_sensor_conf = {
+	.name			= "exynos-therm",
+	.read_temperature	= (int (*)(void *))exynos_tmu_read,
+	.write_emul_temp	= exynos_tmu_set_emulation,
+};
+
 static void exynos_tmu_work(struct work_struct *work)
 {
 	struct exynos_tmu_data *data = container_of(work,
@@ -323,7 +329,7 @@ static void exynos_tmu_work(struct work_struct *work)
 	const struct exynos_tmu_registers *reg = pdata->registers;
 	unsigned int val_irq;
 
-	exynos_report_trigger();
+	exynos_report_trigger(&exynos_sensor_conf);
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
@@ -347,11 +353,6 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 
 	return IRQ_HANDLED;
 }
-static struct thermal_sensor_conf exynos_sensor_conf = {
-	.name			= "exynos-therm",
-	.read_temperature	= (int (*)(void *))exynos_tmu_read,
-	.write_emul_temp	= exynos_tmu_set_emulation,
-};
 
 #ifdef CONFIG_OF
 static const struct of_device_id exynos_tmu_match[] = {
@@ -517,7 +518,7 @@ static int exynos_tmu_remove(struct platform_device *pdev)
 
 	exynos_tmu_control(pdev, false);
 
-	exynos_unregister_thermal();
+	exynos_unregister_thermal(&exynos_sensor_conf);
 
 	clk_unprepare(data->clk);
 
Signature · 1 line
1.7.1
#17 lore raw

PATCH v4 14/30 thermal: exynos: Modify private_data to appropriate name driver_data

In reply to Amit Daniel Kachhap

This patch renames member private_data to driver_data of the thermal zone registration structure as this item stores the driver related data and uses it to call the driver related callbacks.

---
 drivers/thermal/samsung/exynos_thermal_common.c |    4 ++--
 drivers/thermal/samsung/exynos_thermal_common.h |    2 +-
 drivers/thermal/samsung/exynos_tmu.c            |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/thermal/samsung/exynos_thermal_common.c +2 -2
index 2af1e3b..7064eb7 100644
@@ -221,7 +221,7 @@ static int exynos_get_temp(struct thermal_zone_device *thermal,
 		pr_info("Temperature sensor not initialised\n");
 		return -EINVAL;
 	}
-	data = th_zone->sensor_conf->private_data;
+	data = th_zone->sensor_conf->driver_data;
 	*temp = th_zone->sensor_conf->read_temperature(data);
 	/* convert the temperature into millicelsius */
 	*temp = *temp * MCELSIUS;
@@ -240,7 +240,7 @@ static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
 		pr_info("Temperature sensor not initialised\n");
 		return -EINVAL;
 	}
-	data = th_zone->sensor_conf->private_data;
+	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;
drivers/thermal/samsung/exynos_thermal_common.h +1 -1
index 89ae078..59138ae 100644
@@ -76,7 +76,7 @@ struct thermal_sensor_conf {
 	int (*write_emul_temp)(void *drv_data, unsigned long temp);
 	struct thermal_trip_point_conf trip_data;
 	struct thermal_cooling_conf cooling_data;
-	void *private_data;
+	void *driver_data;
 	void *pzone_data;
 };
 
drivers/thermal/samsung/exynos_tmu.c +1 -1
index a1dc402..3855515 100644
@@ -479,7 +479,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	exynos_tmu_control(pdev, true);
 
 	/* Register the sensor with thermal management interface */
-	(&exynos_sensor_conf)->private_data = data;
+	(&exynos_sensor_conf)->driver_data = data;
 	exynos_sensor_conf.trip_data.trip_count = pdata->trigger_enable[0] +
 			pdata->trigger_enable[1] + pdata->trigger_enable[2]+
 			pdata->trigger_enable[3];
Signature · 1 line
1.7.1
#18 lore raw

PATCH v4 15/30 thermal: exynos: Return success even if no cooling data supplied

In reply to Amit Daniel Kachhap

This patch removes the error return in the bind/unbind routine as the platform may not register any cpufreq cooling data.

---
 drivers/thermal/samsung/exynos_thermal_common.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/thermal/samsung/exynos_thermal_common.c +2 -2
index 7064eb7..86d39aa 100644
@@ -131,7 +131,7 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 	tab_size = data->cooling_data.freq_clip_count;
 
 	if (tab_ptr == NULL || tab_size == 0)
-		return -EINVAL;
+		return 0;
 
 	/* find the cooling device registered*/
 	for (i = 0; i < th_zone->cool_dev_size; i++)
@@ -180,7 +180,7 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
 	tab_size = data->cooling_data.freq_clip_count;
 
 	if (tab_size == 0)
-		return -EINVAL;
+		return 0;
 
 	/* find the cooling device registered*/
 	for (i = 0; i < th_zone->cool_dev_size; i++)
Signature · 1 line
1.7.1
#19 lore raw

PATCH v4 16/30 thermal: exynos: Make the zone handling dependent on trip count

In reply to Amit Daniel Kachhap

This code simplifies the zone handling to use the trip count passed by the TMU driver. This also helps in adding more zone support.

---
 drivers/thermal/samsung/exynos_thermal_common.c |   55 ++++++++++++-----------
 drivers/thermal/samsung/exynos_thermal_common.h |    2 -
 2 files changed, 29 insertions(+), 28 deletions(-)
drivers/thermal/samsung/exynos_thermal_common.c +29 -26
index 86d39aa..2369417 100644
@@ -78,17 +78,16 @@ static int exynos_set_mode(struct thermal_zone_device *thermal,
 static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
 				 enum thermal_trip_type *type)
 {
-	switch (GET_ZONE(trip)) {
-	case MONITOR_ZONE:
-	case WARN_ZONE:
-		*type = THERMAL_TRIP_ACTIVE;
-		break;
-	case PANIC_ZONE:
-		*type = THERMAL_TRIP_CRITICAL;
-		break;
-	default:
+	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;
-	}
+	else if (trip == (max_trip - 1))
+		*type = THERMAL_TRIP_CRITICAL;
+	else
+		*type = THERMAL_TRIP_ACTIVE;
+
 	return 0;
 }
 
@@ -97,8 +96,9 @@ 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 < GET_TRIP(MONITOR_ZONE) || trip > GET_TRIP(PANIC_ZONE))
+	if (trip < 0 || trip >= max_trip)
 		return -EINVAL;
 
 	*temp = th_zone->sensor_conf->trip_data.trip_val[trip];
@@ -112,10 +112,10 @@ static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
 static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
 				unsigned long *temp)
 {
-	int ret;
-	/* Panic zone */
-	ret = exynos_get_trip_temp(thermal, GET_TRIP(PANIC_ZONE), temp);
-	return ret;
+	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 */
@@ -340,19 +340,22 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
 		return -ENOMEM;
 
 	th_zone->sensor_conf = sensor_conf;
-	cpumask_set_cpu(0, &mask_val);
-	th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val);
-	if (IS_ERR(th_zone->cool_dev[0])) {
-		pr_err("Failed to register cpufreq cooling device\n");
-		ret = -EINVAL;
-		goto err_unregister;
+	if (sensor_conf->cooling_data.freq_clip_count > 0) {
+		cpumask_set_cpu(0, &mask_val);
+		th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val);
+		if (IS_ERR(th_zone->cool_dev[0])) {
+			pr_err("Failed to register cpufreq cooling device\n");
+			ret = -EINVAL;
+			goto err_unregister;
+		}
+		th_zone->cool_dev_size++;
 	}
-	th_zone->cool_dev_size++;
 
-	th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name,
-			EXYNOS_ZONE_COUNT, 0, th_zone, &exynos_dev_ops, NULL, 0,
-			sensor_conf->trip_data.trigger_falling ?
-			0 : IDLE_INTERVAL);
+	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)) {
 		pr_err("Failed to register thermal zone device\n");
drivers/thermal/samsung/exynos_thermal_common.h +0 -2
index 59138ae..7b938e1 100644
@@ -42,8 +42,6 @@
 #define GET_ZONE(trip) (trip + 2)
 #define GET_TRIP(zone) (zone - 2)
 
-#define EXYNOS_ZONE_COUNT	3
-
 /**
  * struct freq_clip_table
  * @freq_clip_max: maximum frequency allowed for this cooling state.
Signature · 1 line
1.7.1
#20 lore raw

Re: [PATCH V4 16/30] thermal: exynos: Make the zone handling dependent on trip count

Quoted 28 lines · Amit Daniel Kachhap

This code simplifies the zone handling to use the trip count passed by the TMU driver. This also helps in adding more zone support.

---
 drivers/thermal/samsung/exynos_thermal_common.c |   55 ++++++++++++-----------
 drivers/thermal/samsung/exynos_thermal_common.h |    2 -
 2 files changed, 29 insertions(+), 28 deletions(-)
drivers/thermal/samsung/exynos_thermal_common.c +1 -9
index 86d39aa..2369417 100644
@@ -78,17 +78,16 @@ static int exynos_set_mode(struct thermal_zone_device *thermal,
 static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
 				 enum thermal_trip_type *type)
 {
-	switch (GET_ZONE(trip)) {
-	case MONITOR_ZONE:
-	case WARN_ZONE:
-		*type = THERMAL_TRIP_ACTIVE;
-		break;
-	case PANIC_ZONE:
-		*type = THERMAL_TRIP_CRITICAL;
-		break;
-	default:
+	struct exynos_thermal_zone *th_zone = thermal->devdata;

drivers/thermal/samsung/exynos_thermal_common.c static int exynos_set_mode(struct thermal_zone_device *thermal, · line 90

Quoted 10 lines
drivers/thermal/samsung/exynos_thermal_common.c +8 -1
+	int max_trip = th_zone->sensor_conf->trip_data.trip_count;
+
+	if (trip < 0 || trip >= max_trip)
 		return -EINVAL;
-	}
+	else if (trip == (max_trip - 1))
+		*type = THERMAL_TRIP_CRITICAL;
+	else
+		*type = THERMAL_TRIP_ACTIVE;
+

In current exynos_thermal driver, it is hard to set various trip type for each
trip, especially passive type. (not impossible, but complicated)

What do you think we just keep trip information with trip temperature in private data? I mean if we just make trip level information to driver's private data (like exynos_thermal_zone), it might be helpful to control trip type and trip temperature. Like this,

struct exynos_thermal_trip_info {
	int trip_temp;
	enum thermal_trip_type type;
};
struct exynos_thermal_device {	
	.
	struct exynos_thermal_trip_info *trips;
	int num_trips;
};

Thanks,
Jonghwa

Quoted 76 lines
drivers/thermal/samsung/exynos_thermal_common.c +20 -16
 	return 0;
 }
 
@@ -97,8 +96,9 @@ 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 < GET_TRIP(MONITOR_ZONE) || trip > GET_TRIP(PANIC_ZONE))
+	if (trip < 0 || trip >= max_trip)
 		return -EINVAL;
 
 	*temp = th_zone->sensor_conf->trip_data.trip_val[trip];
@@ -112,10 +112,10 @@ static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
 static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
 				unsigned long *temp)
 {
-	int ret;
-	/* Panic zone */
-	ret = exynos_get_trip_temp(thermal, GET_TRIP(PANIC_ZONE), temp);
-	return ret;
+	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 */
@@ -340,19 +340,22 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
 		return -ENOMEM;
 
 	th_zone->sensor_conf = sensor_conf;
-	cpumask_set_cpu(0, &mask_val);
-	th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val);
-	if (IS_ERR(th_zone->cool_dev[0])) {
-		pr_err("Failed to register cpufreq cooling device\n");
-		ret = -EINVAL;
-		goto err_unregister;
+	if (sensor_conf->cooling_data.freq_clip_count > 0) {
+		cpumask_set_cpu(0, &mask_val);
+		th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val);
+		if (IS_ERR(th_zone->cool_dev[0])) {
+			pr_err("Failed to register cpufreq cooling device\n");
+			ret = -EINVAL;
+			goto err_unregister;
+		}
+		th_zone->cool_dev_size++;
 	}
-	th_zone->cool_dev_size++;
 
-	th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name,
-			EXYNOS_ZONE_COUNT, 0, th_zone, &exynos_dev_ops, NULL, 0,
-			sensor_conf->trip_data.trigger_falling ?
-			0 : IDLE_INTERVAL);
+	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)) {
 		pr_err("Failed to register thermal zone device\n");
drivers/thermal/samsung/exynos_thermal_common.h +0 -2
index 59138ae..7b938e1 100644
@@ -42,8 +42,6 @@
 #define GET_ZONE(trip) (trip + 2)
 #define GET_TRIP(zone) (zone - 2)
 
-#define EXYNOS_ZONE_COUNT	3
-
 /**
  * struct freq_clip_table
  * @freq_clip_max: maximum frequency allowed for this cooling state.
#21 lore raw

PATCH v4 17/30 thermal: exynos: Add support to handle many instances of TMU

In reply to Amit Daniel Kachhap

This patch adds support to handle multiple instances of the TMU controllers. This is done by removing the static structure to register with the core thermal and creating it dynamically for each instance of the TMU controller. The interrupt is made shared type to handle interrupts for all the TMU. Also the identifier of the TMU controller is extracted from device tree alias.

---
 drivers/thermal/samsung/exynos_tmu.c |  126 +++++++++++++++++++++++-----------
 1 files changed, 85 insertions(+), 41 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +85 -41
index 3855515..a9c5d8b 100644
@@ -26,15 +26,32 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
 #include <linux/platform_device.h>
 
 #include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
 #include "exynos_tmu_data.h"
 
+/**
+ * struct exynos_tmu_data : A structure to hold the private data of the TMU
+	driver
+ * @id: identifier of the one instance of the TMU controller.
+ * @pdata: pointer to the tmu platform/configuration data
+ * @base: base address of the single instance of the TMU controller.
+ * @irq: irq number of the TMU controller.
+ * @soc: id of the SOC type.
+ * @irq_work: pointer to the irq work structure.
+ * @lock: lock to implement synchronization.
+ * @clk: pointer to the clock structure.
+ * @temp_error1: fused value of the first point trim.
+ * @temp_error2: fused value of the second point trim.
+ * @reg_conf: pointer to structure to register with core thermal.
+ */
 struct exynos_tmu_data {
+	int id;
 	struct exynos_tmu_platform_data *pdata;
-	struct resource *mem;
 	void __iomem *base;
 	int irq;
 	enum soc_type soc;
@@ -42,6 +59,7 @@ struct exynos_tmu_data {
 	struct mutex lock;
 	struct clk *clk;
 	u8 temp_error1, temp_error2;
+	struct thermal_sensor_conf *reg_conf;
 };
 
 /*
@@ -315,12 +333,6 @@ static int exynos_tmu_set_emulation(void *drv_data,	unsigned long temp)
 	{ return -EINVAL; }
 #endif/*CONFIG_THERMAL_EMULATION*/
 
-static struct thermal_sensor_conf exynos_sensor_conf = {
-	.name			= "exynos-therm",
-	.read_temperature	= (int (*)(void *))exynos_tmu_read,
-	.write_emul_temp	= exynos_tmu_set_emulation,
-};
-
 static void exynos_tmu_work(struct work_struct *work)
 {
 	struct exynos_tmu_data *data = container_of(work,
@@ -329,7 +341,7 @@ static void exynos_tmu_work(struct work_struct *work)
 	const struct exynos_tmu_registers *reg = pdata->registers;
 	unsigned int val_irq;
 
-	exynos_report_trigger(&exynos_sensor_conf);
+	exynos_report_trigger(data->reg_conf);
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
@@ -402,10 +414,43 @@ static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
 			platform_get_device_id(pdev)->driver_data;
 }
 
+static int exynos_map_dt_data(struct platform_device *pdev)
+{
+	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	struct resource res;
+
+	if (!data)
+		return -ENODEV;
+
+	data->id = of_alias_get_id(pdev->dev.of_node, "tmuctrl");
+	if (data->id < 0)
+		data->id = 0;
+
+	data->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+	if (data->irq <= 0) {
+		dev_err(&pdev->dev, "failed to get IRQ\n");
+		return -ENODEV;
+	}
+
+	if (of_address_to_resource(pdev->dev.of_node, 0, &res)) {
+		dev_err(&pdev->dev, "failed to get Resource\n");
+		return -ENODEV;
+	}
+
+	data->base = devm_ioremap(&pdev->dev, res.start, resource_size(&res));
+	if (!data->base) {
+		dev_err(&pdev->dev, "Failed to ioremap memory\n");
+		return -EADDRNOTAVAIL;
+	}
+
+	return 0;
+}
+
 static int exynos_tmu_probe(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data;
 	struct exynos_tmu_platform_data *pdata = pdev->dev.platform_data;
+	struct thermal_sensor_conf *sensor_conf;
 	int ret, i;
 
 	if (!pdata)
@@ -422,26 +467,17 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	data->irq = platform_get_irq(pdev, 0);
-	if (data->irq < 0) {
-		dev_err(&pdev->dev, "Failed to get platform irq\n");
-		return data->irq;
-	}
-
-	INIT_WORK(&data->irq_work, exynos_tmu_work);
-
-	data->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!data->mem) {
-		dev_err(&pdev->dev, "Failed to get platform resource\n");
-		return -ENOENT;
-	}
+	data->pdata = pdata;
+	platform_set_drvdata(pdev, data);
+	mutex_init(&data->lock);
 
-	data->base = devm_ioremap_resource(&pdev->dev, data->mem);
-	if (IS_ERR(data->base))
-		return PTR_ERR(data->base);
+	ret = exynos_map_dt_data(pdev);
+	if (ret)
+		return ret;
 
+	INIT_WORK(&data->irq_work, exynos_tmu_work);
 	ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
-		IRQF_TRIGGER_RISING, "exynos-tmu", data);
+		IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq);
 		return ret;
@@ -466,10 +502,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	data->pdata = pdata;
-	platform_set_drvdata(pdev, data);
-	mutex_init(&data->lock);
-
 	ret = exynos_tmu_initialize(pdev);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to initialize TMU\n");
@@ -478,28 +510,40 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 
 	exynos_tmu_control(pdev, true);
 
-	/* Register the sensor with thermal management interface */
-	(&exynos_sensor_conf)->driver_data = data;
-	exynos_sensor_conf.trip_data.trip_count = pdata->trigger_enable[0] +
+	/* 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) {
+		dev_err(&pdev->dev, "Failed to allocate registration struct\n");
+		ret = -ENOMEM;
+		goto err_clk;
+	}
+	data->reg_conf = sensor_conf;
+	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 < exynos_sensor_conf.trip_data.trip_count; i++)
-		exynos_sensor_conf.trip_data.trip_val[i] =
+	for (i = 0; i < sensor_conf->trip_data.trip_count; i++)
+		sensor_conf->trip_data.trip_val[i] =
 			pdata->threshold + pdata->trigger_levels[i];
 
-	exynos_sensor_conf.trip_data.trigger_falling = pdata->threshold_falling;
+	sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
 
-	exynos_sensor_conf.cooling_data.freq_clip_count =
-						pdata->freq_tab_count;
+	sensor_conf->cooling_data.freq_clip_count = pdata->freq_tab_count;
 	for (i = 0; i < pdata->freq_tab_count; i++) {
-		exynos_sensor_conf.cooling_data.freq_data[i].freq_clip_max =
+		sensor_conf->cooling_data.freq_data[i].freq_clip_max =
 					pdata->freq_tab[i].freq_clip_max;
-		exynos_sensor_conf.cooling_data.freq_data[i].temp_level =
+		sensor_conf->cooling_data.freq_data[i].temp_level =
 					pdata->freq_tab[i].temp_level;
 	}
 
-	ret = exynos_register_thermal(&exynos_sensor_conf);
+	/* 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;
@@ -518,7 +562,7 @@ static int exynos_tmu_remove(struct platform_device *pdev)
 
 	exynos_tmu_control(pdev, false);
 
-	exynos_unregister_thermal(&exynos_sensor_conf);
+	exynos_unregister_thermal(data->reg_conf);
 
 	clk_unprepare(data->clk);
 
Signature · 1 line
1.7.1
#22 lore raw

PATCH v4 18/30 thermal: exynos: Add TMU features to check instead of using SOC type

In reply to Amit Daniel Kachhap

This patch adds several features supported by TMU as bitfields. This features varies across different SOC type and comparing the features present in the TMU is more logical than comparing the soc itself.

---
 drivers/thermal/samsung/exynos_tmu.c      |   24 ++++++++++++++----------
 drivers/thermal/samsung/exynos_tmu.h      |   28 ++++++++++++++++++++++++++++
 drivers/thermal/samsung/exynos_tmu_data.c |    4 ++++
 3 files changed, 46 insertions(+), 10 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +14 -10
index a9c5d8b..de98312 100644
@@ -142,13 +142,15 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
-	status = readb(data->base + reg->tmu_status);
-	if (!status) {
-		ret = -EBUSY;
-		goto out;
+	if (TMU_SUPPORTS(pdata, READY_STATUS)) {
+		status = readb(data->base + reg->tmu_status);
+		if (!status) {
+			ret = -EBUSY;
+			goto out;
+		}
 	}
 
-	if (data->soc == SOC_ARCH_EXYNOS)
+	if (TMU_SUPPORTS(pdata, TRIM_RELOAD))
 		__raw_writel(1, data->base + reg->triminfo_ctrl);
 
 	/* Save trimming info in order to perform calibration */
@@ -257,7 +259,7 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 			pdata->trigger_enable[2] << reg->inten_rise2_shift |
 			pdata->trigger_enable[1] << reg->inten_rise1_shift |
 			pdata->trigger_enable[0] << reg->inten_rise0_shift;
-		if (pdata->threshold_falling)
+		if (TMU_SUPPORTS(pdata, FALLING_TRIP))
 			interrupt_en |=
 				interrupt_en << reg->inten_fall0_shift;
 	} else {
@@ -299,7 +301,7 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp)
 	unsigned int val;
 	int ret = -EINVAL;
 
-	if (data->soc == SOC_ARCH_EXYNOS4210)
+	if (!TMU_SUPPORTS(pdata, EMULATION))
 		goto out;
 
 	if (temp && temp < MCELSIUS)
@@ -313,9 +315,11 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp)
 	if (temp) {
 		temp /= MCELSIUS;
 
-		val = (EXYNOS_EMUL_TIME << reg->emul_time_shift) |
-			(temp_to_code(data, temp)
-			 << reg->emul_temp_shift) | EXYNOS_EMUL_ENABLE;
+		if (TMU_SUPPORTS(pdata, EMUL_TIME))
+			val |= (EXYNOS_EMUL_TIME << reg->emul_time_shift);
+
+		val |= (temp_to_code(data, temp) << reg->emul_temp_shift) |
+			EXYNOS_EMUL_ENABLE;
 	} else {
 		val &= ~EXYNOS_EMUL_ENABLE;
 	}
drivers/thermal/samsung/exynos_tmu.h +28 -0
index 5d80a32..65443d7 100644
@@ -47,6 +47,31 @@ enum soc_type {
 };
 
 /**
+ * EXYNOS TMU supported features.
+ * TMU_SUPPORT_EMULATION - This features is used to set user defined
+ *			temperature to the TMU controller.
+ * TMU_SUPPORT_MULTI_INST - This features denotes that the soc
+ *			has many instances of TMU.
+ * TMU_SUPPORT_TRIM_RELOAD - This features shows that trimming can
+ *			be reloaded.
+ * TMU_SUPPORT_FALLING_TRIP - This features shows that interrupt can
+ *			be registered for falling trips also.
+ * TMU_SUPPORT_READY_STATUS - This feature tells that the TMU current
+ *			state(active/idle) can be checked.
+ * TMU_SUPPORT_EMUL_TIME - This features allows to set next temp emulation
+ *			sample time.
+ * TMU_SUPPORT - macro to compare the above features with the supplied.
+ */
+#define TMU_SUPPORT_EMULATION			BIT(0)
+#define TMU_SUPPORT_MULTI_INST			BIT(1)
+#define TMU_SUPPORT_TRIM_RELOAD			BIT(2)
+#define TMU_SUPPORT_FALLING_TRIP		BIT(3)
+#define TMU_SUPPORT_READY_STATUS		BIT(4)
+#define TMU_SUPPORT_EMUL_TIME			BIT(5)
+
+#define TMU_SUPPORTS(a, b)	(a->features & TMU_SUPPORT_ ## b)
+
+/**
  * struct exynos_tmu_register - register descriptors to access registers and
  * bitfields. The register validity, offsets and bitfield values may vary
  * slightly across different exynos SOC's.
@@ -224,6 +249,8 @@ struct exynos_tmu_registers {
  *	applicable to only some of the trigger levels.
  * @registers: Pointer to structure containing all the TMU controller registers
  *	and bitfields shifts and masks.
+ * @features: a bitfield value indicating the features supported in SOC like
+ *	emulation, multi instance etc
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
@@ -250,5 +277,6 @@ struct exynos_tmu_platform_data {
 	struct freq_clip_table freq_tab[4];
 	unsigned int freq_tab_count;
 	const struct exynos_tmu_registers *registers;
+	unsigned int features;
 };
 #endif /* _EXYNOS_TMU_H */
drivers/thermal/samsung/exynos_tmu_data.c +4 -0
index bf01210..b4bfa61 100644
@@ -79,6 +79,7 @@ struct exynos_tmu_platform_data const exynos4210_default_tmu_data = {
 	.freq_tab_count = 2,
 	.type = SOC_ARCH_EXYNOS4210,
 	.registers = &exynos4210_tmu_registers,
+	.features = TMU_SUPPORT_READY_STATUS,
 };
 #endif
 
@@ -154,5 +155,8 @@ struct exynos_tmu_platform_data const exynos5250_default_tmu_data = {
 	.freq_tab_count = 2,
 	.type = SOC_ARCH_EXYNOS,
 	.registers = &exynos5250_tmu_registers,
+	.features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD |
+			TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS |
+			TMU_SUPPORT_EMUL_TIME),
 };
 #endif
Signature · 1 line
1.7.1
#23 lore raw

PATCH v4 19/30 thermal: exynos: use device resource management infrastructure

In reply to Amit Daniel Kachhap

This patch stores the device pointer in the configuration structure and uses it for dev_* prints and devm API's.

---
 drivers/thermal/samsung/exynos_thermal_common.c |   39 ++++++++++++++--------
 drivers/thermal/samsung/exynos_thermal_common.h |    1 +
 drivers/thermal/samsung/exynos_tmu.c            |    2 +-
 3 files changed, 27 insertions(+), 15 deletions(-)
drivers/thermal/samsung/exynos_thermal_common.c +25 -14
index 2369417..f41390e 100644
@@ -52,7 +52,8 @@ static int exynos_set_mode(struct thermal_zone_device *thermal,
 {
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 	if (!th_zone) {
-		pr_notice("thermal zone not registered\n");
+		dev_err(th_zone->sensor_conf->dev,
+			"thermal zone not registered\n");
 		return 0;
 	}
 
@@ -68,8 +69,9 @@ static int exynos_set_mode(struct thermal_zone_device *thermal,
 
 	th_zone->mode = mode;
 	thermal_zone_device_update(thermal);
-	pr_info("thermal polling set for duration=%d msec\n",
-				thermal->polling_delay);
+	dev_dbg(th_zone->sensor_conf->dev,
+		"thermal polling set for duration=%d msec\n",
+		thermal->polling_delay);
 	return 0;
 }
 
@@ -153,7 +155,8 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 		case WARN_ZONE:
 			if (thermal_zone_bind_cooling_device(thermal, i, cdev,
 								level, 0)) {
-				pr_err("error binding cdev inst %d\n", i);
+				dev_err(data->dev,
+					"error unbinding cdev inst=%d\n", i);
 				ret = -EINVAL;
 			}
 			th_zone->bind = true;
@@ -198,7 +201,8 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
 		case WARN_ZONE:
 			if (thermal_zone_unbind_cooling_device(thermal, i,
 								cdev)) {
-				pr_err("error unbinding cdev inst=%d\n", i);
+				dev_err(data->dev,
+					"error unbinding cdev inst=%d\n", i);
 				ret = -EINVAL;
 			}
 			th_zone->bind = false;
@@ -218,7 +222,8 @@ static int exynos_get_temp(struct thermal_zone_device *thermal,
 	void *data;
 
 	if (!th_zone->sensor_conf) {
-		pr_info("Temperature sensor not initialised\n");
+		dev_err(th_zone->sensor_conf->dev,
+			"Temperature sensor not initialised\n");
 		return -EINVAL;
 	}
 	data = th_zone->sensor_conf->driver_data;
@@ -237,7 +242,8 @@ static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
 	struct exynos_thermal_zone *th_zone = thermal->devdata;
 
 	if (!th_zone->sensor_conf) {
-		pr_info("Temperature sensor not initialised\n");
+		dev_err(th_zone->sensor_conf->dev,
+			"Temperature sensor not initialised\n");
 		return -EINVAL;
 	}
 	data = th_zone->sensor_conf->driver_data;
@@ -331,11 +337,13 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
 	struct exynos_thermal_zone *th_zone;
 
 	if (!sensor_conf || !sensor_conf->read_temperature) {
-		pr_err("Temperature sensor not initialised\n");
+		dev_err(sensor_conf->dev,
+				"Temperature sensor not initialised\n");
 		return -EINVAL;
 	}
 
-	th_zone = kzalloc(sizeof(struct exynos_thermal_zone), GFP_KERNEL);
+	th_zone = devm_kzalloc(sensor_conf->dev,
+				sizeof(struct exynos_thermal_zone), GFP_KERNEL);
 	if (!th_zone)
 		return -ENOMEM;
 
@@ -344,7 +352,8 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
 		cpumask_set_cpu(0, &mask_val);
 		th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val);
 		if (IS_ERR(th_zone->cool_dev[0])) {
-			pr_err("Failed to register cpufreq cooling device\n");
+			dev_err(sensor_conf->dev,
+				"Failed to register cpufreq cooling device\n");
 			ret = -EINVAL;
 			goto err_unregister;
 		}
@@ -358,14 +367,16 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
 			IDLE_INTERVAL);
 
 	if (IS_ERR(th_zone->therm_dev)) {
-		pr_err("Failed to register thermal zone device\n");
+		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;
 
-	pr_info("Exynos: Kernel Thermal management registered\n");
+	dev_info(sensor_conf->dev,
+		"Exynos: Thermal zone(%s) registered\n", sensor_conf->name);
 
 	return 0;
 
@@ -391,6 +402,6 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 	}
 
-	kfree(th_zone);
-	pr_info("Exynos: Kernel Thermal management unregistered\n");
+	dev_info(sensor_conf->dev,
+		"Exynos: Kernel Thermal management unregistered\n");
 }
drivers/thermal/samsung/exynos_thermal_common.h +1 -0
index 7b938e1..ea4cd3f 100644
@@ -76,6 +76,7 @@ struct thermal_sensor_conf {
 	struct thermal_cooling_conf cooling_data;
 	void *driver_data;
 	void *pzone_data;
+	struct device *dev;
 };
 
 /*Functions used exynos based thermal sensor driver*/
drivers/thermal/samsung/exynos_tmu.c +1 -1
index de98312..e627150 100644
@@ -545,7 +545,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		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);
 	if (ret) {
Signature · 1 line
1.7.1
#24 lore raw

PATCH v4 20/30 ARM: dts: thermal: exynos4: Add documentation for Exynos SoC thermal bindings

In reply to Amit Daniel Kachhap

From: Lukasz Majewski <[email protected]>

Proper description for Exynos4 bindings added to Documentation/devicetree/ bindings

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   25 ++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/exynos-thermal.txt
Documentation/devicetree/bindings/thermal/exynos-thermal.txt new file +25 -0
new file mode 100644
index 0000000..535fd0e
@@ -0,0 +1,25 @@
+* Exynos Thermal Management Unit (TMU)
+
+** Required properties:
+
+- compatible : One of the following:
+	       "samsung,exynos4412-tmu"
+	       "samsung,exynos4210-tmu"
+	       "samsung,exynos5250-tmu"
+- interrupt-parent : The phandle for the interrupt controller
+- reg : Address range of the thermal registers
+- interrupts : Should contain interrupt for thermal system
+- clocks : The main clock for TMU device
+- clock-names : Thermal system clock name
+
+Example:
+
+	tmu@100C0000 {
+		compatible = "samsung,exynos4412-tmu";
+		interrupt-parent = <&combiner>;
+		reg = <0x100C0000 0x100>;
+		interrupts = <2 4>;
+		clocks = <&clock 383>;
+		clock-names = "tmu_apbif";
+		status = "disabled";
+	};
Signature · 1 line
1.7.1
#25 lore raw

PATCH v4 21/30 thermal: exynos: Add support to access common register for multistance

In reply to Amit Daniel Kachhap

This patch adds support to parse one more common set of TMU register. First set of register belongs to each instance of TMU and second set belongs to common TMU registers.

---
 drivers/thermal/samsung/exynos_tmu.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +23 -1
index e627150..7f7b1cf 100644
@@ -40,6 +40,7 @@
  * @id: identifier of the one instance of the TMU controller.
  * @pdata: pointer to the tmu platform/configuration data
  * @base: base address of the single instance of the TMU controller.
+ * @base_common: base address of the common registers of the TMU controller.
  * @irq: irq number of the TMU controller.
  * @soc: id of the SOC type.
  * @irq_work: pointer to the irq work structure.
@@ -53,6 +54,7 @@ struct exynos_tmu_data {
 	int id;
 	struct exynos_tmu_platform_data *pdata;
 	void __iomem *base;
+	void __iomem *base_common;
 	int irq;
 	enum soc_type soc;
 	struct work_struct irq_work;
@@ -421,6 +423,7 @@ static inline struct  exynos_tmu_platform_data *exynos_get_driver_data(
 static int exynos_map_dt_data(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	struct exynos_tmu_platform_data *pdata = data->pdata;
 	struct resource res;
 
 	if (!data)
@@ -437,7 +440,7 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 	}
 
 	if (of_address_to_resource(pdev->dev.of_node, 0, &res)) {
-		dev_err(&pdev->dev, "failed to get Resource\n");
+		dev_err(&pdev->dev, "failed to get Resource 0\n");
 		return -ENODEV;
 	}
 
@@ -447,6 +450,25 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 		return -EADDRNOTAVAIL;
 	}
 
+	/*
+	 * Check if the TMU is multi instance type and then try to map the
+	 * memory of common registers.
+	 */
+	if (!TMU_SUPPORTS(pdata, MULTI_INST))
+		return 0;
+
+	if (of_address_to_resource(pdev->dev.of_node, 1, &res)) {
+		dev_err(&pdev->dev, "failed to get Resource 1\n");
+		return -ENODEV;
+	}
+
+	data->base_common = devm_ioremap(&pdev->dev, res.start,
+					resource_size(&res));
+	if (!data->base) {
+		dev_err(&pdev->dev, "Failed to ioremap memory\n");
+		return -ENOMEM;
+	}
+
 	return 0;
 }
 
Signature · 1 line
1.7.1
#26 lore raw

PATCH v4 22/30 thermal: exynos: Add support for exynos5440 TMU sensor.

In reply to Amit Daniel Kachhap

This patch modifies TMU controller to add changes needed to work with exynos5440 platform. This sensor registers 3 instance of the tmu controller with the thermal zone and hence reports 3 temperature output. This controller supports upto five trip points. For critical threshold the driver uses the core driver thermal framework for shutdown.

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   28 ++++++++++++-
 drivers/thermal/samsung/exynos_tmu.c               |   43 +++++++++++++++++--
 drivers/thermal/samsung/exynos_tmu.h               |    6 +++
 drivers/thermal/samsung/exynos_tmu_data.h          |    2 +
 4 files changed, 72 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +26 -2
index 535fd0e..970eeba 100644
@@ -6,13 +6,16 @@
 	       "samsung,exynos4412-tmu"
 	       "samsung,exynos4210-tmu"
 	       "samsung,exynos5250-tmu"
+	       "samsung,exynos5440-tmu"
 - interrupt-parent : The phandle for the interrupt controller
-- reg : Address range of the thermal registers
+- reg : Address range of the thermal registers. For exynos5440-tmu which has 3
+	instances of TMU, 2 set of register has to supplied. First set belongs
+	to each instance of TMU and second set belongs to common TMU registers.
 - interrupts : Should contain interrupt for thermal system
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
 
-Example:
+Example 1):
 
 	tmu@100C0000 {
 		compatible = "samsung,exynos4412-tmu";
@@ -23,3 +26,24 @@ Example:
 		clock-names = "tmu_apbif";
 		status = "disabled";
 	};
+
+Example 2):
+
+	tmuctrl_0: tmuctrl@160118 {
+		compatible = "samsung,exynos5440-tmu";
+		reg = <0x160118 0x230>, <0x160368 0x10>;
+		interrupts = <0 58 0>;
+		clocks = <&clock 21>;
+		clock-names = "tmu_apbif";
+	};
+
+Note: For multi-instance tmu each instance should have an alias correctly
+numbered in "aliases" node.
+
+Example:
+
+aliases {
+	tmuctrl0 = &tmuctrl_0;
+	tmuctrl1 = &tmuctrl_1;
+	tmuctrl2 = &tmuctrl_2;
+};
drivers/thermal/samsung/exynos_tmu.c +38 -5

75 lines not on this page · raw message

drivers/thermal/samsung/exynos_tmu.h +6 -0
index 65443d7..9151a30 100644
@@ -44,6 +44,7 @@ enum trigger_type {
 enum soc_type {
 	SOC_ARCH_EXYNOS4210 = 1,
 	SOC_ARCH_EXYNOS,
+	SOC_ARCH_EXYNOS5440,
 };
 
 /**
@@ -132,6 +133,8 @@ enum soc_type {
  * @emul_temp_shift: shift bits of emulation temperature.
  * @emul_time_shift: shift bits of emulation time.
  * @emul_time_mask: mask bits of emulation time.
+ * @tmu_irqstatus: register to find which TMU generated interrupts.
+ * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
 	u32	triminfo_data;
@@ -199,6 +202,9 @@ struct exynos_tmu_registers {
 	u32	emul_temp_shift;
 	u32	emul_time_shift;
 	u32	emul_time_mask;
+
+	u32	tmu_irqstatus;
+	u32	tmu_pmin;
 };
 
 /**
drivers/thermal/samsung/exynos_tmu_data.h +2 -0
index 0e2244f..4acf070 100644
@@ -91,6 +91,8 @@
 #define EXYNOS_EMUL_DATA_MASK	0xFF
 #define EXYNOS_EMUL_ENABLE	0x1
 
+#define EXYNOS_MAX_TRIGGER_PER_REG	4
+
 #if defined(CONFIG_CPU_EXYNOS4210)
 extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data;
 #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)
Signature · 1 line
1.7.1
#27 lore raw

Re: [PATCH V4 22/30] thermal: exynos: Add support for exynos5440 TMU sensor.

Quoted 114 lines · Amit Daniel Kachhap

This patch modifies TMU controller to add changes needed to work with exynos5440 platform. This sensor registers 3 instance of the tmu controller with the thermal zone and hence reports 3 temperature output. This controller supports upto five trip points. For critical threshold the driver uses the core driver thermal framework for shutdown.

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   28 ++++++++++++-
 drivers/thermal/samsung/exynos_tmu.c               |   43 +++++++++++++++++--
 drivers/thermal/samsung/exynos_tmu.h               |    6 +++
 drivers/thermal/samsung/exynos_tmu_data.h          |    2 +
 4 files changed, 72 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +26 -2
index 535fd0e..970eeba 100644
@@ -6,13 +6,16 @@
 	       "samsung,exynos4412-tmu"
 	       "samsung,exynos4210-tmu"
 	       "samsung,exynos5250-tmu"
+	       "samsung,exynos5440-tmu"
 - interrupt-parent : The phandle for the interrupt controller
-- reg : Address range of the thermal registers
+- reg : Address range of the thermal registers. For exynos5440-tmu which has 3
+	instances of TMU, 2 set of register has to supplied. First set belongs
+	to each instance of TMU and second set belongs to common TMU registers.
 - interrupts : Should contain interrupt for thermal system
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
 
-Example:
+Example 1):
 
 	tmu@100C0000 {
 		compatible = "samsung,exynos4412-tmu";
@@ -23,3 +26,24 @@ Example:
 		clock-names = "tmu_apbif";
 		status = "disabled";
 	};
+
+Example 2):
+
+	tmuctrl_0: tmuctrl@160118 {
+		compatible = "samsung,exynos5440-tmu";
+		reg = <0x160118 0x230>, <0x160368 0x10>;
+		interrupts = <0 58 0>;
+		clocks = <&clock 21>;
+		clock-names = "tmu_apbif";
+	};
+
+Note: For multi-instance tmu each instance should have an alias correctly
+numbered in "aliases" node.
+
+Example:
+
+aliases {
+	tmuctrl0 = &tmuctrl_0;
+	tmuctrl1 = &tmuctrl_1;
+	tmuctrl2 = &tmuctrl_2;
+};
drivers/thermal/samsung/exynos_tmu.c +27 -2
index 7f7b1cf..7ca9c4d 100644
@@ -185,9 +185,11 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 			reg->threshold_th0 + i * sizeof(reg->threshold_th0));
 
 		writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
-	} else if (data->soc == SOC_ARCH_EXYNOS) {
+	} else if (data->soc == SOC_ARCH_EXYNOS ||
+			data->soc == SOC_ARCH_EXYNOS5440) {
 		/* Write temperature code for rising and falling threshold */
-		for (i = 0; i < trigger_levs; i++) {
+		for (i = 0;
+		i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
 			threshold_code = temp_to_code(data,
 						pdata->trigger_levels[i]);
 			if (threshold_code < 0) {
@@ -218,7 +220,30 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 		writel((reg->inten_rise_mask << reg->inten_rise_shift) |
 			(reg->inten_fall_mask << reg->inten_fall_shift),
 				data->base + reg->tmu_intclear);
+
+		/* if 5th threshold limit is also present, use TH2 register */
+		i = EXYNOS_MAX_TRIGGER_PER_REG;
+		if (pdata->trigger_levels[i]) {
+			threshold_code = temp_to_code(data,
+						pdata->trigger_levels[i]);
+			if (threshold_code < 0) {
+				ret = threshold_code;
+				goto out;
+			}
+			rising_threshold =
+				threshold_code << reg->threshold_th3_l0_shift;
+			writel(rising_threshold,
+				data->base + reg->threshold_th2);
+			if (pdata->trigger_type[i] == HW_TRIP) {
+				con = readl(data->base + reg->tmu_ctrl);
+				con |= (1 << reg->therm_trip_en_shift);
+				writel(con, data->base + reg->tmu_ctrl);
+			}
+		}
 	}
+	/*Clear the PMIN in the common TMU register*/
+	if (reg->tmu_pmin && !data->id)
+		writel(0, data->base_common + reg->tmu_pmin);
 out:
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
@@ -345,7 +370,14 @@ static void exynos_tmu_work(struct work_struct *work)
 			struct exynos_tmu_data, irq_work);

drivers/thermal/samsung/exynos_tmu.c static void exynos_tmu_work(struct work_struct *work) · line 379

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.c +7 -1
 	struct exynos_tmu_platform_data *pdata = data->pdata;
 	const struct exynos_tmu_registers *reg = pdata->registers;
-	unsigned int val_irq;
+	unsigned int val_irq, val_type;
+
+	/* Find which sensor generated this interrupt */
+	if (reg->tmu_irqstatus) {
+		val_type = readl(data->base_common + reg->tmu_irqstatus);
+		if (!((val_type >> data->id) & 0x1))
+			goto out;

I have a question about your implementation for supporting EXYNOS5440. I don't know exactly how EXYNO5440's tmu is working, but just guess it would be similar with other EXYNOS series's without number of thermal sensors. (exclusive register map and threshold level). Due to the multiple number of thermal sensor in EXYNOS5440, it have multiple thermal zone devices and that's why it just leave interrupt pin in pending if interrupt is not its, right?

So, my curious is, why we make all platform devices for each of thermal zone devices? Why don't you just handle all thermal zone devices with one platform device?

Yes, It's probably right to make multiple devices node to support them, because it has different physical hardware(sensors). But we have one TMU , don't we? (Maybe my assumption is wrong, I assume that it has one TMU because it looks like it has only one irq line.). If I'm right, I think it is better to manage all thermal zone devices with one platform device. Then, we don't need to leave irq handler with leaving it pendded like above and also we may not need other your patches like adding base_common iomem variable.

I'd like to listen your opinion about this.

Thanks,
Jonghwa

Quoted 67 lines
drivers/thermal/samsung/exynos_tmu.c +4 -2
+	}
 
 	exynos_report_trigger(data->reg_conf);
 	mutex_lock(&data->lock);
@@ -358,7 +390,7 @@ static void exynos_tmu_work(struct work_struct *work)
 
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
-
+out:
 	enable_irq(data->irq);
 }
 
@@ -520,7 +552,8 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		return ret;
 
 	if (pdata->type == SOC_ARCH_EXYNOS ||
-				pdata->type == SOC_ARCH_EXYNOS4210)
+		pdata->type == SOC_ARCH_EXYNOS4210 ||
+				pdata->type == SOC_ARCH_EXYNOS5440)
 		data->soc = pdata->type;
 	else {
 		ret = -EINVAL;
drivers/thermal/samsung/exynos_tmu.h +6 -0
index 65443d7..9151a30 100644
@@ -44,6 +44,7 @@ enum trigger_type {
 enum soc_type {
 	SOC_ARCH_EXYNOS4210 = 1,
 	SOC_ARCH_EXYNOS,
+	SOC_ARCH_EXYNOS5440,
 };
 
 /**
@@ -132,6 +133,8 @@ enum soc_type {
  * @emul_temp_shift: shift bits of emulation temperature.
  * @emul_time_shift: shift bits of emulation time.
  * @emul_time_mask: mask bits of emulation time.
+ * @tmu_irqstatus: register to find which TMU generated interrupts.
+ * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
 	u32	triminfo_data;
@@ -199,6 +202,9 @@ struct exynos_tmu_registers {
 	u32	emul_temp_shift;
 	u32	emul_time_shift;
 	u32	emul_time_mask;
+
+	u32	tmu_irqstatus;
+	u32	tmu_pmin;
 };
 
 /**
drivers/thermal/samsung/exynos_tmu_data.h +2 -0
index 0e2244f..4acf070 100644
@@ -91,6 +91,8 @@
 #define EXYNOS_EMUL_DATA_MASK	0xFF
 #define EXYNOS_EMUL_ENABLE	0x1
 
+#define EXYNOS_MAX_TRIGGER_PER_REG	4
+
 #if defined(CONFIG_CPU_EXYNOS4210)
 extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data;
 #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)
#28 lore raw

Re: [PATCH V4 22/30] thermal: exynos: Add support for exynos5440 TMU sensor.

Amit and Jonghwa,

Quoted 19 lines · On 18-05-2013 01:23, [email protected] wrote:
Quoted 17 lines · Amit Daniel Kachhap

This patch modifies TMU controller to add changes needed to work with exynos5440 platform. This sensor registers 3 instance of the tmu controller with the thermal zone and hence reports 3 temperature output. This controller supports upto five trip points. For critical threshold the driver uses the core driver thermal framework for shutdown.

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   28 ++++++++++++-
 drivers/thermal/samsung/exynos_tmu.c               |   43 +++++++++++++++++--
 drivers/thermal/samsung/exynos_tmu.h               |    6 +++
 drivers/thermal/samsung/exynos_tmu_data.h          |    2 +
 4 files changed, 72 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +0 -0
index 535fd0e..970eeba 100644

<cut>

Quoted 22 lines

Documentation/devicetree/bindings/thermal/exynos-thermal.txt

Quoted 1 line
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +1 -0
+			goto out;

I have a question about your implementation for supporting EXYNOS5440. I don't know exactly how EXYNO5440's tmu is working, but just guess it would be similar with other EXYNOS series's without number of thermal sensors. (exclusive register map and threshold level). Due to the multiple number of thermal sensor in EXYNOS5440, it have multiple thermal zone devices and that's why it just leave interrupt pin in pending if interrupt is not its, right?

So, my curious is, why we make all platform devices for each of thermal zone devices? Why don't you just handle all thermal zone devices with one platform device?

Yes, It's probably right to make multiple devices node to support them, because it has different physical hardware(sensors). But we have one TMU , don't we? (Maybe my assumption is wrong, I assume that it has one TMU because it looks like it has only one irq line.). If I'm right, I think it is better to manage all thermal zone devices with one platform device. Then, we don't need to leave irq handler with leaving it pendded like above and also we may not need other your patches like adding base_common iomem variable.

Quoted 2 lines

I'd like to listen your opinion about this.

I understand the concern risen by Jonghwa. In fact, this is a bit confusing. The way I have decided to design the driver for TI (drivers/thermal/ti-soc-thermal under thermal tree next branch) is to have one platform device for the bandgap IP (that would be probably equivalent of your TMU).

Reasoning is to have a exact match between platform device and real HW device interface. Thus its device resources are belonging to one single device node. In TIs case, the resources, regarding IRQs, IO map area, registers, etc, are belonging to the bandgap IP not to sensors. That alone convinced me to use one single device node, instead of several, per sensor. In fact, for OMAP devices it is a bit more complicated as the bandgap is actually behind the control module, which holds the interface. But that is another story.

So, in this case I decided to have 1 single platform device representing the bandgap IP, which exposes and handles several thermal zones (one per sensor). And of course, owns and manages all related resources (IRQ, gpio and IO mem area).

To what I have understood of your case, I believe it is the very same case, so I would recommend reusing the proposed design.

Keep in mind that this obviously does not stop you of having different policies or trip setups per sensor. The framework is flexible in this sense.

I hope this helps.

Quoted 74 lines

Thanks,
Jonghwa

Quoted 67 lines
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +4 -2
+	}
 
 	exynos_report_trigger(data->reg_conf);
 	mutex_lock(&data->lock);
@@ -358,7 +390,7 @@ static void exynos_tmu_work(struct work_struct *work)
 
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
-
+out:
 	enable_irq(data->irq);
 }
 
@@ -520,7 +552,8 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		return ret;
 
 	if (pdata->type == SOC_ARCH_EXYNOS ||
-				pdata->type == SOC_ARCH_EXYNOS4210)
+		pdata->type == SOC_ARCH_EXYNOS4210 ||
+				pdata->type == SOC_ARCH_EXYNOS5440)
 		data->soc = pdata->type;
 	else {
 		ret = -EINVAL;
drivers/thermal/samsung/exynos_tmu.h +6 -0
index 65443d7..9151a30 100644
@@ -44,6 +44,7 @@ enum trigger_type {
 enum soc_type {
 	SOC_ARCH_EXYNOS4210 = 1,
 	SOC_ARCH_EXYNOS,
+	SOC_ARCH_EXYNOS5440,
 };
 
 /**
@@ -132,6 +133,8 @@ enum soc_type {
  * @emul_temp_shift: shift bits of emulation temperature.
  * @emul_time_shift: shift bits of emulation time.
  * @emul_time_mask: mask bits of emulation time.
+ * @tmu_irqstatus: register to find which TMU generated interrupts.
+ * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
 	u32	triminfo_data;
@@ -199,6 +202,9 @@ struct exynos_tmu_registers {
 	u32	emul_temp_shift;
 	u32	emul_time_shift;
 	u32	emul_time_mask;
+
+	u32	tmu_irqstatus;
+	u32	tmu_pmin;
 };
 
 /**
drivers/thermal/samsung/exynos_tmu_data.h +2 -0
index 0e2244f..4acf070 100644
@@ -91,6 +91,8 @@
 #define EXYNOS_EMUL_DATA_MASK	0xFF
 #define EXYNOS_EMUL_ENABLE	0x1
 
+#define EXYNOS_MAX_TRIGGER_PER_REG	4
+
 #if defined(CONFIG_CPU_EXYNOS4210)
 extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data;
 #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#29 lore raw

Re: [PATCH V4 22/30] thermal: exynos: Add support for exynos5440 TMU sensor.

In reply to [email protected]

Hi Jonghwa,

Sorry for the late reply as I was on leave.

Quoted 128 lines · On Sat, May 18, 2013 at 10:53 AM, <[email protected]> wrote:
Quoted 114 lines · Amit Daniel Kachhap

This patch modifies TMU controller to add changes needed to work with exynos5440 platform. This sensor registers 3 instance of the tmu controller with the thermal zone and hence reports 3 temperature output. This controller supports upto five trip points. For critical threshold the driver uses the core driver thermal framework for shutdown.

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   28 ++++++++++++-
 drivers/thermal/samsung/exynos_tmu.c               |   43 +++++++++++++++++--
 drivers/thermal/samsung/exynos_tmu.h               |    6 +++
 drivers/thermal/samsung/exynos_tmu_data.h          |    2 +
 4 files changed, 72 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +26 -2
index 535fd0e..970eeba 100644
@@ -6,13 +6,16 @@
             "samsung,exynos4412-tmu"
             "samsung,exynos4210-tmu"
             "samsung,exynos5250-tmu"
+            "samsung,exynos5440-tmu"
 - interrupt-parent : The phandle for the interrupt controller
-- reg : Address range of the thermal registers
+- reg : Address range of the thermal registers. For exynos5440-tmu which has 3
+     instances of TMU, 2 set of register has to supplied. First set belongs
+     to each instance of TMU and second set belongs to common TMU registers.
 - interrupts : Should contain interrupt for thermal system
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
 
-Example:
+Example 1):
 
      tmu@100C0000 {
              compatible = "samsung,exynos4412-tmu";
@@ -23,3 +26,24 @@ Example:
              clock-names = "tmu_apbif";
              status = "disabled";
      };
+
+Example 2):
+
+     tmuctrl_0: tmuctrl@160118 {
+             compatible = "samsung,exynos5440-tmu";
+             reg = <0x160118 0x230>, <0x160368 0x10>;
+             interrupts = <0 58 0>;
+             clocks = <&clock 21>;
+             clock-names = "tmu_apbif";
+     };
+
+Note: For multi-instance tmu each instance should have an alias correctly
+numbered in "aliases" node.
+
+Example:
+
+aliases {
+     tmuctrl0 = &tmuctrl_0;
+     tmuctrl1 = &tmuctrl_1;
+     tmuctrl2 = &tmuctrl_2;
+};
drivers/thermal/samsung/exynos_tmu.c +27 -2
index 7f7b1cf..7ca9c4d 100644
@@ -185,9 +185,11 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
                      reg->threshold_th0 + i * sizeof(reg->threshold_th0));
 
              writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
-     } else if (data->soc == SOC_ARCH_EXYNOS) {
+     } else if (data->soc == SOC_ARCH_EXYNOS ||
+                     data->soc == SOC_ARCH_EXYNOS5440) {
              /* Write temperature code for rising and falling threshold */
-             for (i = 0; i < trigger_levs; i++) {
+             for (i = 0;
+             i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
                      threshold_code = temp_to_code(data,
                                              pdata->trigger_levels[i]);
                      if (threshold_code < 0) {
@@ -218,7 +220,30 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
              writel((reg->inten_rise_mask << reg->inten_rise_shift) |
                      (reg->inten_fall_mask << reg->inten_fall_shift),
                              data->base + reg->tmu_intclear);
+
+             /* if 5th threshold limit is also present, use TH2 register */
+             i = EXYNOS_MAX_TRIGGER_PER_REG;
+             if (pdata->trigger_levels[i]) {
+                     threshold_code = temp_to_code(data,
+                                             pdata->trigger_levels[i]);
+                     if (threshold_code < 0) {
+                             ret = threshold_code;
+                             goto out;
+                     }
+                     rising_threshold =
+                             threshold_code << reg->threshold_th3_l0_shift;
+                     writel(rising_threshold,
+                             data->base + reg->threshold_th2);
+                     if (pdata->trigger_type[i] == HW_TRIP) {
+                             con = readl(data->base + reg->tmu_ctrl);
+                             con |= (1 << reg->therm_trip_en_shift);
+                             writel(con, data->base + reg->tmu_ctrl);
+                     }
+             }
      }
+     /*Clear the PMIN in the common TMU register*/
+     if (reg->tmu_pmin && !data->id)
+             writel(0, data->base_common + reg->tmu_pmin);
 out:
      clk_disable(data->clk);
      mutex_unlock(&data->lock);
@@ -345,7 +370,14 @@ static void exynos_tmu_work(struct work_struct *work)
                      struct exynos_tmu_data, irq_work);

drivers/thermal/samsung/exynos_tmu.c static void exynos_tmu_work(struct work_struct *work) · line 379

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.c +7 -1
      struct exynos_tmu_platform_data *pdata = data->pdata;
      const struct exynos_tmu_registers *reg = pdata->registers;
-     unsigned int val_irq;
+     unsigned int val_irq, val_type;
+
+     /* Find which sensor generated this interrupt */
+     if (reg->tmu_irqstatus) {
+             val_type = readl(data->base_common + reg->tmu_irqstatus);
+             if (!((val_type >> data->id) & 0x1))
+                     goto out;
Quoted 6 lines

I have a question about your implementation for supporting EXYNOS5440. I don't know exactly how EXYNO5440's tmu is working, but just guess it would be similar with other EXYNOS series's without number of thermal sensors. (exclusive register map and threshold level). Due to the multiple number of thermal sensor in EXYNOS5440, it have multiple thermal zone devices and that's why it just leave interrupt pin in pending if interrupt is not its, right?

Yes in 5440 the interrupt line is shared so pending bit is left uncleared.

Quoted 4 lines

So, my curious is, why we make all platform devices for each of thermal zone devices? Why don't you just handle all thermal zone devices with one platform device?

Your doubt is genuine. Let me justify my design decision. Initially I also thought of making a single platform device but since there are 3 different TMU controllers and register maps for 4 more so I followed this design as the driver looks clean and can be scalable easily. Also I agree that some resources like IRQ line is shared but it is due to h/w limitation.
Also it is easy to cleanly control each TMU instance with the device tree data similar to I2C/SPI/MMC instance based device driver. Say I do not want to use 2nd sensor then just pass device tree data for 1st and 3rd sensor.

Quoted 8 lines

Yes, It's probably right to make multiple devices node to support them, because it has different physical hardware(sensors). But we have one TMU , don't we? (Maybe my assumption is wrong, I assume that it has one TMU because it looks like it has only one irq line.). If I'm right, I think it is better to manage all thermal zone devices with one platform device. Then, we don't need to leave irq handler with leaving it pendded like above and also we may not need other your patches like adding base_common iomem variable.

Agreed that base_common variables is extra and present to handle the common part. I will further analyse your suggestion.

Thanks,
Amit Daniel

Quoted 75 lines

I'd like to listen your opinion about this.

Thanks,
Jonghwa

Quoted 67 lines
drivers/thermal/samsung/exynos_tmu.c +4 -2
+     }
 
      exynos_report_trigger(data->reg_conf);
      mutex_lock(&data->lock);
@@ -358,7 +390,7 @@ static void exynos_tmu_work(struct work_struct *work)
 
      clk_disable(data->clk);
      mutex_unlock(&data->lock);
-
+out:
      enable_irq(data->irq);
 }
 
@@ -520,7 +552,8 @@ static int exynos_tmu_probe(struct platform_device *pdev)
              return ret;
 
      if (pdata->type == SOC_ARCH_EXYNOS ||
-                             pdata->type == SOC_ARCH_EXYNOS4210)
+             pdata->type == SOC_ARCH_EXYNOS4210 ||
+                             pdata->type == SOC_ARCH_EXYNOS5440)
              data->soc = pdata->type;
      else {
              ret = -EINVAL;
drivers/thermal/samsung/exynos_tmu.h +6 -0
index 65443d7..9151a30 100644
@@ -44,6 +44,7 @@ enum trigger_type {
 enum soc_type {
      SOC_ARCH_EXYNOS4210 = 1,
      SOC_ARCH_EXYNOS,
+     SOC_ARCH_EXYNOS5440,
 };
 
 /**
@@ -132,6 +133,8 @@ enum soc_type {
  * @emul_temp_shift: shift bits of emulation temperature.
  * @emul_time_shift: shift bits of emulation time.
  * @emul_time_mask: mask bits of emulation time.
+ * @tmu_irqstatus: register to find which TMU generated interrupts.
+ * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
      u32     triminfo_data;
@@ -199,6 +202,9 @@ struct exynos_tmu_registers {
      u32     emul_temp_shift;
      u32     emul_time_shift;
      u32     emul_time_mask;
+
+     u32     tmu_irqstatus;
+     u32     tmu_pmin;
 };
 
 /**
drivers/thermal/samsung/exynos_tmu_data.h +2 -0
index 0e2244f..4acf070 100644
@@ -91,6 +91,8 @@
 #define EXYNOS_EMUL_DATA_MASK        0xFF
 #define EXYNOS_EMUL_ENABLE   0x1
 
+#define EXYNOS_MAX_TRIGGER_PER_REG   4
+
 #if defined(CONFIG_CPU_EXYNOS4210)
 extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data;
 #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)
#30 lore raw

Re: [PATCH V4 22/30] thermal: exynos: Add support for exynos5440 TMU sensor.

Quoted 162 lines · amit daniel kachhap

Hi Jonghwa,

Sorry for the late reply as I was on leave.

Quoted 128 lines · On Sat, May 18, 2013 at 10:53 AM, <[email protected]> wrote:
Quoted 114 lines · Amit Daniel Kachhap

This patch modifies TMU controller to add changes needed to work with exynos5440 platform. This sensor registers 3 instance of the tmu controller with the thermal zone and hence reports 3 temperature output. This controller supports upto five trip points. For critical threshold the driver uses the core driver thermal framework for shutdown.

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   28 ++++++++++++-
 drivers/thermal/samsung/exynos_tmu.c               |   43 +++++++++++++++++--
 drivers/thermal/samsung/exynos_tmu.h               |    6 +++
 drivers/thermal/samsung/exynos_tmu_data.h          |    2 +
 4 files changed, 72 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +26 -2
index 535fd0e..970eeba 100644
@@ -6,13 +6,16 @@
             "samsung,exynos4412-tmu"
             "samsung,exynos4210-tmu"
             "samsung,exynos5250-tmu"
+            "samsung,exynos5440-tmu"
 - interrupt-parent : The phandle for the interrupt controller
-- reg : Address range of the thermal registers
+- reg : Address range of the thermal registers. For exynos5440-tmu which has 3
+     instances of TMU, 2 set of register has to supplied. First set belongs
+     to each instance of TMU and second set belongs to common TMU registers.
 - interrupts : Should contain interrupt for thermal system
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
 
-Example:
+Example 1):
 
      tmu@100C0000 {
              compatible = "samsung,exynos4412-tmu";
@@ -23,3 +26,24 @@ Example:
              clock-names = "tmu_apbif";
              status = "disabled";
      };
+
+Example 2):
+
+     tmuctrl_0: tmuctrl@160118 {
+             compatible = "samsung,exynos5440-tmu";
+             reg = <0x160118 0x230>, <0x160368 0x10>;
+             interrupts = <0 58 0>;
+             clocks = <&clock 21>;
+             clock-names = "tmu_apbif";
+     };
+
+Note: For multi-instance tmu each instance should have an alias correctly
+numbered in "aliases" node.
+
+Example:
+
+aliases {
+     tmuctrl0 = &tmuctrl_0;
+     tmuctrl1 = &tmuctrl_1;
+     tmuctrl2 = &tmuctrl_2;
+};
drivers/thermal/samsung/exynos_tmu.c +27 -2
index 7f7b1cf..7ca9c4d 100644
@@ -185,9 +185,11 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
                      reg->threshold_th0 + i * sizeof(reg->threshold_th0));
 
              writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
-     } else if (data->soc == SOC_ARCH_EXYNOS) {
+     } else if (data->soc == SOC_ARCH_EXYNOS ||
+                     data->soc == SOC_ARCH_EXYNOS5440) {
              /* Write temperature code for rising and falling threshold */
-             for (i = 0; i < trigger_levs; i++) {
+             for (i = 0;
+             i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
                      threshold_code = temp_to_code(data,
                                              pdata->trigger_levels[i]);
                      if (threshold_code < 0) {
@@ -218,7 +220,30 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
              writel((reg->inten_rise_mask << reg->inten_rise_shift) |
                      (reg->inten_fall_mask << reg->inten_fall_shift),
                              data->base + reg->tmu_intclear);
+
+             /* if 5th threshold limit is also present, use TH2 register */
+             i = EXYNOS_MAX_TRIGGER_PER_REG;
+             if (pdata->trigger_levels[i]) {
+                     threshold_code = temp_to_code(data,
+                                             pdata->trigger_levels[i]);
+                     if (threshold_code < 0) {
+                             ret = threshold_code;
+                             goto out;
+                     }
+                     rising_threshold =
+                             threshold_code << reg->threshold_th3_l0_shift;
+                     writel(rising_threshold,
+                             data->base + reg->threshold_th2);
+                     if (pdata->trigger_type[i] == HW_TRIP) {
+                             con = readl(data->base + reg->tmu_ctrl);
+                             con |= (1 << reg->therm_trip_en_shift);
+                             writel(con, data->base + reg->tmu_ctrl);
+                     }
+             }
      }
+     /*Clear the PMIN in the common TMU register*/
+     if (reg->tmu_pmin && !data->id)
+             writel(0, data->base_common + reg->tmu_pmin);
 out:
      clk_disable(data->clk);
      mutex_unlock(&data->lock);
@@ -345,7 +370,14 @@ static void exynos_tmu_work(struct work_struct *work)
                      struct exynos_tmu_data, irq_work);

drivers/thermal/samsung/exynos_tmu.c static void exynos_tmu_work(struct work_struct *work) · line 379

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.c +7 -1
      struct exynos_tmu_platform_data *pdata = data->pdata;
      const struct exynos_tmu_registers *reg = pdata->registers;
-     unsigned int val_irq;
+     unsigned int val_irq, val_type;
+
+     /* Find which sensor generated this interrupt */
+     if (reg->tmu_irqstatus) {
+             val_type = readl(data->base_common + reg->tmu_irqstatus);
+             if (!((val_type >> data->id) & 0x1))
+                     goto out;
Quoted 6 lines

I have a question about your implementation for supporting EXYNOS5440. I don't know exactly how EXYNO5440's tmu is working, but just guess it would be similar with other EXYNOS series's without number of thermal sensors. (exclusive register map and threshold level). Due to the multiple number of thermal sensor in EXYNOS5440, it have multiple thermal zone devices and that's why it just leave interrupt pin in pending if interrupt is not its, right?

Yes in 5440 the interrupt line is shared so pending bit is left uncleared.

Quoted 4 lines

So, my curious is, why we make all platform devices for each of thermal zone devices? Why don't you just handle all thermal zone devices with one platform device?

Your doubt is genuine. Let me justify my design decision. Initially I also thought of making a single platform device but since there are 3 different TMU controllers and register maps for 4 more so I followed this design as the driver looks clean and can be scalable easily. Also I agree that some resources like IRQ line is shared but it is due to h/w limitation.
Also it is easy to cleanly control each TMU instance with the device tree data similar to I2C/SPI/MMC instance based device driver. Say I do not want to use 2nd sensor then just pass device tree data for 1st and 3rd sensor.

Quoted 8 lines

Yes, It's probably right to make multiple devices node to support them, because it has different physical hardware(sensors). But we have one TMU , don't we? (Maybe my assumption is wrong, I assume that it has one TMU because it looks like it has only one irq line.). If I'm right, I think it is better to manage all thermal zone devices with one platform device. Then, we don't need to leave irq handler with leaving it pendded like above and also we may not need other your patches like adding base_common iomem variable.

Quoted 3 lines

Agreed that base_common variables is extra and present to handle the common part. I will further analyse your suggestion.

What is the relation TMU <--> temperature sensor? Is it one to one or one to many?

Quoted 79 lines

Thanks,
Amit Daniel

Quoted 75 lines

I'd like to listen your opinion about this.

Thanks,
Jonghwa

Quoted 67 lines
drivers/thermal/samsung/exynos_tmu.c +4 -2
+     }
 
      exynos_report_trigger(data->reg_conf);
      mutex_lock(&data->lock);
@@ -358,7 +390,7 @@ static void exynos_tmu_work(struct work_struct *work)
 
      clk_disable(data->clk);
      mutex_unlock(&data->lock);
-
+out:
      enable_irq(data->irq);
 }
 
@@ -520,7 +552,8 @@ static int exynos_tmu_probe(struct platform_device *pdev)
              return ret;
 
      if (pdata->type == SOC_ARCH_EXYNOS ||
-                             pdata->type == SOC_ARCH_EXYNOS4210)
+             pdata->type == SOC_ARCH_EXYNOS4210 ||
+                             pdata->type == SOC_ARCH_EXYNOS5440)
              data->soc = pdata->type;
      else {
              ret = -EINVAL;
drivers/thermal/samsung/exynos_tmu.h +6 -0
index 65443d7..9151a30 100644
@@ -44,6 +44,7 @@ enum trigger_type {
 enum soc_type {
      SOC_ARCH_EXYNOS4210 = 1,
      SOC_ARCH_EXYNOS,
+     SOC_ARCH_EXYNOS5440,
 };
 
 /**
@@ -132,6 +133,8 @@ enum soc_type {
  * @emul_temp_shift: shift bits of emulation temperature.
  * @emul_time_shift: shift bits of emulation time.
  * @emul_time_mask: mask bits of emulation time.
+ * @tmu_irqstatus: register to find which TMU generated interrupts.
+ * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
      u32     triminfo_data;
@@ -199,6 +202,9 @@ struct exynos_tmu_registers {
      u32     emul_temp_shift;
      u32     emul_time_shift;
      u32     emul_time_mask;
+
+     u32     tmu_irqstatus;
+     u32     tmu_pmin;
 };
 
 /**
drivers/thermal/samsung/exynos_tmu_data.h +2 -0
index 0e2244f..4acf070 100644
@@ -91,6 +91,8 @@
 #define EXYNOS_EMUL_DATA_MASK        0xFF
 #define EXYNOS_EMUL_ENABLE   0x1
 
+#define EXYNOS_MAX_TRIGGER_PER_REG   4
+
 #if defined(CONFIG_CPU_EXYNOS4210)
 extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data;
 #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#31 lore raw

Re: [PATCH V4 22/30] thermal: exynos: Add support for exynos5440 TMU sensor.

Hi Eduardo,

Quoted 163 lines · Eduardo Valentin
Quoted 162 lines · amit daniel kachhap

Hi Jonghwa,

Sorry for the late reply as I was on leave.

Quoted 128 lines · On Sat, May 18, 2013 at 10:53 AM, <[email protected]> wrote:
Quoted 114 lines · Amit Daniel Kachhap

This patch modifies TMU controller to add changes needed to work with exynos5440 platform. This sensor registers 3 instance of the tmu controller with the thermal zone and hence reports 3 temperature output. This controller supports upto five trip points. For critical threshold the driver uses the core driver thermal framework for shutdown.

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   28 ++++++++++++-
 drivers/thermal/samsung/exynos_tmu.c               |   43 +++++++++++++++++--
 drivers/thermal/samsung/exynos_tmu.h               |    6 +++
 drivers/thermal/samsung/exynos_tmu_data.h          |    2 +
 4 files changed, 72 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +26 -2
index 535fd0e..970eeba 100644
@@ -6,13 +6,16 @@
             "samsung,exynos4412-tmu"
             "samsung,exynos4210-tmu"
             "samsung,exynos5250-tmu"
+            "samsung,exynos5440-tmu"
 - interrupt-parent : The phandle for the interrupt controller
-- reg : Address range of the thermal registers
+- reg : Address range of the thermal registers. For exynos5440-tmu which has 3
+     instances of TMU, 2 set of register has to supplied. First set belongs
+     to each instance of TMU and second set belongs to common TMU registers.
 - interrupts : Should contain interrupt for thermal system
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
 
-Example:
+Example 1):
 
      tmu@100C0000 {
              compatible = "samsung,exynos4412-tmu";
@@ -23,3 +26,24 @@ Example:
              clock-names = "tmu_apbif";
              status = "disabled";
      };
+
+Example 2):
+
+     tmuctrl_0: tmuctrl@160118 {
+             compatible = "samsung,exynos5440-tmu";
+             reg = <0x160118 0x230>, <0x160368 0x10>;
+             interrupts = <0 58 0>;
+             clocks = <&clock 21>;
+             clock-names = "tmu_apbif";
+     };
+
+Note: For multi-instance tmu each instance should have an alias correctly
+numbered in "aliases" node.
+
+Example:
+
+aliases {
+     tmuctrl0 = &tmuctrl_0;
+     tmuctrl1 = &tmuctrl_1;
+     tmuctrl2 = &tmuctrl_2;
+};
drivers/thermal/samsung/exynos_tmu.c +27 -2
index 7f7b1cf..7ca9c4d 100644
@@ -185,9 +185,11 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
                      reg->threshold_th0 + i * sizeof(reg->threshold_th0));
 
              writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
-     } else if (data->soc == SOC_ARCH_EXYNOS) {
+     } else if (data->soc == SOC_ARCH_EXYNOS ||
+                     data->soc == SOC_ARCH_EXYNOS5440) {
              /* Write temperature code for rising and falling threshold */
-             for (i = 0; i < trigger_levs; i++) {
+             for (i = 0;
+             i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
                      threshold_code = temp_to_code(data,
                                              pdata->trigger_levels[i]);
                      if (threshold_code < 0) {
@@ -218,7 +220,30 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
              writel((reg->inten_rise_mask << reg->inten_rise_shift) |
                      (reg->inten_fall_mask << reg->inten_fall_shift),
                              data->base + reg->tmu_intclear);
+
+             /* if 5th threshold limit is also present, use TH2 register */
+             i = EXYNOS_MAX_TRIGGER_PER_REG;
+             if (pdata->trigger_levels[i]) {
+                     threshold_code = temp_to_code(data,
+                                             pdata->trigger_levels[i]);
+                     if (threshold_code < 0) {
+                             ret = threshold_code;
+                             goto out;
+                     }
+                     rising_threshold =
+                             threshold_code << reg->threshold_th3_l0_shift;
+                     writel(rising_threshold,
+                             data->base + reg->threshold_th2);
+                     if (pdata->trigger_type[i] == HW_TRIP) {
+                             con = readl(data->base + reg->tmu_ctrl);
+                             con |= (1 << reg->therm_trip_en_shift);
+                             writel(con, data->base + reg->tmu_ctrl);
+                     }
+             }
      }
+     /*Clear the PMIN in the common TMU register*/
+     if (reg->tmu_pmin && !data->id)
+             writel(0, data->base_common + reg->tmu_pmin);
 out:
      clk_disable(data->clk);
      mutex_unlock(&data->lock);
@@ -345,7 +370,14 @@ static void exynos_tmu_work(struct work_struct *work)
                      struct exynos_tmu_data, irq_work);

drivers/thermal/samsung/exynos_tmu.c static void exynos_tmu_work(struct work_struct *work) · line 379

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.c +7 -1
      struct exynos_tmu_platform_data *pdata = data->pdata;
      const struct exynos_tmu_registers *reg = pdata->registers;
-     unsigned int val_irq;
+     unsigned int val_irq, val_type;
+
+     /* Find which sensor generated this interrupt */
+     if (reg->tmu_irqstatus) {
+             val_type = readl(data->base_common + reg->tmu_irqstatus);
+             if (!((val_type >> data->id) & 0x1))
+                     goto out;
Quoted 6 lines

I have a question about your implementation for supporting EXYNOS5440. I don't know exactly how EXYNO5440's tmu is working, but just guess it would be similar with other EXYNOS series's without number of thermal sensors. (exclusive register map and threshold level). Due to the multiple number of thermal sensor in EXYNOS5440, it have multiple thermal zone devices and that's why it just leave interrupt pin in pending if interrupt is not its, right?

Yes in 5440 the interrupt line is shared so pending bit is left uncleared.

Quoted 4 lines

So, my curious is, why we make all platform devices for each of thermal zone devices? Why don't you just handle all thermal zone devices with one platform device?

Your doubt is genuine. Let me justify my design decision. Initially I also thought of making a single platform device but since there are 3 different TMU controllers and register maps for 4 more so I followed this design as the driver looks clean and can be scalable easily. Also I agree that some resources like IRQ line is shared but it is due to h/w limitation.
Also it is easy to cleanly control each TMU instance with the device tree data similar to I2C/SPI/MMC instance based device driver. Say I do not want to use 2nd sensor then just pass device tree data for 1st and 3rd sensor.

Quoted 8 lines

Yes, It's probably right to make multiple devices node to support them, because it has different physical hardware(sensors). But we have one TMU , don't we? (Maybe my assumption is wrong, I assume that it has one TMU because it looks like it has only one irq line.). If I'm right, I think it is better to manage all thermal zone devices with one platform device. Then, we don't need to leave irq handler with leaving it pendded like above and also we may not need other your patches like adding base_common iomem variable.

Quoted 6 lines
Quoted 3 lines

Agreed that base_common variables is extra and present to handle the common part. I will further analyse your suggestion.

What is the relation TMU <--> temperature sensor? Is it one to one or one to many?

1 TMU --- > 1 temp sensor.(one to one)

Thanks,
Amit Daniel

Quoted 87 lines
Quoted 80 lines

Thanks,
Amit Daniel

Quoted 75 lines

I'd like to listen your opinion about this.

Thanks,
Jonghwa

Quoted 67 lines
drivers/thermal/samsung/exynos_tmu.c +4 -2
+     }
 
      exynos_report_trigger(data->reg_conf);
      mutex_lock(&data->lock);
@@ -358,7 +390,7 @@ static void exynos_tmu_work(struct work_struct *work)
 
      clk_disable(data->clk);
      mutex_unlock(&data->lock);
-
+out:
      enable_irq(data->irq);
 }
 
@@ -520,7 +552,8 @@ static int exynos_tmu_probe(struct platform_device *pdev)
              return ret;
 
      if (pdata->type == SOC_ARCH_EXYNOS ||
-                             pdata->type == SOC_ARCH_EXYNOS4210)
+             pdata->type == SOC_ARCH_EXYNOS4210 ||
+                             pdata->type == SOC_ARCH_EXYNOS5440)
              data->soc = pdata->type;
      else {
              ret = -EINVAL;
drivers/thermal/samsung/exynos_tmu.h +6 -0
index 65443d7..9151a30 100644
@@ -44,6 +44,7 @@ enum trigger_type {
 enum soc_type {
      SOC_ARCH_EXYNOS4210 = 1,
      SOC_ARCH_EXYNOS,
+     SOC_ARCH_EXYNOS5440,
 };
 
 /**
@@ -132,6 +133,8 @@ enum soc_type {
  * @emul_temp_shift: shift bits of emulation temperature.
  * @emul_time_shift: shift bits of emulation time.
  * @emul_time_mask: mask bits of emulation time.
+ * @tmu_irqstatus: register to find which TMU generated interrupts.
+ * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
      u32     triminfo_data;
@@ -199,6 +202,9 @@ struct exynos_tmu_registers {
      u32     emul_temp_shift;
      u32     emul_time_shift;
      u32     emul_time_mask;
+
+     u32     tmu_irqstatus;
+     u32     tmu_pmin;
 };
 
 /**
drivers/thermal/samsung/exynos_tmu_data.h +2 -0
index 0e2244f..4acf070 100644
@@ -91,6 +91,8 @@
 #define EXYNOS_EMUL_DATA_MASK        0xFF
 #define EXYNOS_EMUL_ENABLE   0x1
 
+#define EXYNOS_MAX_TRIGGER_PER_REG   4
+
 #if defined(CONFIG_CPU_EXYNOS4210)
 extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data;
 #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)

--
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin

#32 lore raw

Re: [PATCH V4 22/30] thermal: exynos: Add support for exynos5440 TMU sensor.

Quoted 167 lines · amit daniel kachhap

Hi Eduardo,

Quoted 163 lines · Eduardo Valentin
Quoted 162 lines · amit daniel kachhap

Hi Jonghwa,

Sorry for the late reply as I was on leave.

Quoted 128 lines · On Sat, May 18, 2013 at 10:53 AM, <[email protected]> wrote:
Quoted 114 lines · Amit Daniel Kachhap

This patch modifies TMU controller to add changes needed to work with exynos5440 platform. This sensor registers 3 instance of the tmu controller with the thermal zone and hence reports 3 temperature output. This controller supports upto five trip points. For critical threshold the driver uses the core driver thermal framework for shutdown.

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   28 ++++++++++++-
 drivers/thermal/samsung/exynos_tmu.c               |   43 +++++++++++++++++--
 drivers/thermal/samsung/exynos_tmu.h               |    6 +++
 drivers/thermal/samsung/exynos_tmu_data.h          |    2 +
 4 files changed, 72 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +26 -2
index 535fd0e..970eeba 100644
@@ -6,13 +6,16 @@
             "samsung,exynos4412-tmu"
             "samsung,exynos4210-tmu"
             "samsung,exynos5250-tmu"
+            "samsung,exynos5440-tmu"
 - interrupt-parent : The phandle for the interrupt controller
-- reg : Address range of the thermal registers
+- reg : Address range of the thermal registers. For exynos5440-tmu which has 3
+     instances of TMU, 2 set of register has to supplied. First set belongs
+     to each instance of TMU and second set belongs to common TMU registers.
 - interrupts : Should contain interrupt for thermal system
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
 
-Example:
+Example 1):
 
      tmu@100C0000 {
              compatible = "samsung,exynos4412-tmu";
@@ -23,3 +26,24 @@ Example:
              clock-names = "tmu_apbif";
              status = "disabled";
      };
+
+Example 2):
+
+     tmuctrl_0: tmuctrl@160118 {
+             compatible = "samsung,exynos5440-tmu";
+             reg = <0x160118 0x230>, <0x160368 0x10>;
+             interrupts = <0 58 0>;
+             clocks = <&clock 21>;
+             clock-names = "tmu_apbif";
+     };
+
+Note: For multi-instance tmu each instance should have an alias correctly
+numbered in "aliases" node.
+
+Example:
+
+aliases {
+     tmuctrl0 = &tmuctrl_0;
+     tmuctrl1 = &tmuctrl_1;
+     tmuctrl2 = &tmuctrl_2;
+};
drivers/thermal/samsung/exynos_tmu.c +27 -2
index 7f7b1cf..7ca9c4d 100644
@@ -185,9 +185,11 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
                      reg->threshold_th0 + i * sizeof(reg->threshold_th0));
 
              writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
-     } else if (data->soc == SOC_ARCH_EXYNOS) {
+     } else if (data->soc == SOC_ARCH_EXYNOS ||
+                     data->soc == SOC_ARCH_EXYNOS5440) {
              /* Write temperature code for rising and falling threshold */
-             for (i = 0; i < trigger_levs; i++) {
+             for (i = 0;
+             i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
                      threshold_code = temp_to_code(data,
                                              pdata->trigger_levels[i]);
                      if (threshold_code < 0) {
@@ -218,7 +220,30 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
              writel((reg->inten_rise_mask << reg->inten_rise_shift) |
                      (reg->inten_fall_mask << reg->inten_fall_shift),
                              data->base + reg->tmu_intclear);
+
+             /* if 5th threshold limit is also present, use TH2 register */
+             i = EXYNOS_MAX_TRIGGER_PER_REG;
+             if (pdata->trigger_levels[i]) {
+                     threshold_code = temp_to_code(data,
+                                             pdata->trigger_levels[i]);
+                     if (threshold_code < 0) {
+                             ret = threshold_code;
+                             goto out;
+                     }
+                     rising_threshold =
+                             threshold_code << reg->threshold_th3_l0_shift;
+                     writel(rising_threshold,
+                             data->base + reg->threshold_th2);
+                     if (pdata->trigger_type[i] == HW_TRIP) {
+                             con = readl(data->base + reg->tmu_ctrl);
+                             con |= (1 << reg->therm_trip_en_shift);
+                             writel(con, data->base + reg->tmu_ctrl);
+                     }
+             }
      }
+     /*Clear the PMIN in the common TMU register*/
+     if (reg->tmu_pmin && !data->id)
+             writel(0, data->base_common + reg->tmu_pmin);
 out:
      clk_disable(data->clk);
      mutex_unlock(&data->lock);
@@ -345,7 +370,14 @@ static void exynos_tmu_work(struct work_struct *work)
                      struct exynos_tmu_data, irq_work);

drivers/thermal/samsung/exynos_tmu.c static void exynos_tmu_work(struct work_struct *work) · line 379

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.c +7 -1
      struct exynos_tmu_platform_data *pdata = data->pdata;
      const struct exynos_tmu_registers *reg = pdata->registers;
-     unsigned int val_irq;
+     unsigned int val_irq, val_type;
+
+     /* Find which sensor generated this interrupt */
+     if (reg->tmu_irqstatus) {
+             val_type = readl(data->base_common + reg->tmu_irqstatus);
+             if (!((val_type >> data->id) & 0x1))
+                     goto out;
Quoted 6 lines

I have a question about your implementation for supporting EXYNOS5440. I don't know exactly how EXYNO5440's tmu is working, but just guess it would be similar with other EXYNOS series's without number of thermal sensors. (exclusive register map and threshold level). Due to the multiple number of thermal sensor in EXYNOS5440, it have multiple thermal zone devices and that's why it just leave interrupt pin in pending if interrupt is not its, right?

Yes in 5440 the interrupt line is shared so pending bit is left uncleared.

Quoted 4 lines

So, my curious is, why we make all platform devices for each of thermal zone devices? Why don't you just handle all thermal zone devices with one platform device?

Your doubt is genuine. Let me justify my design decision. Initially I also thought of making a single platform device but since there are 3 different TMU controllers and register maps for 4 more so I followed this design as the driver looks clean and can be scalable easily. Also I agree that some resources like IRQ line is shared but it is due to h/w limitation.
Also it is easy to cleanly control each TMU instance with the device tree data similar to I2C/SPI/MMC instance based device driver. Say I do not want to use 2nd sensor then just pass device tree data for 1st and 3rd sensor.

Quoted 8 lines

Yes, It's probably right to make multiple devices node to support them, because it has different physical hardware(sensors). But we have one TMU , don't we? (Maybe my assumption is wrong, I assume that it has one TMU because it looks like it has only one irq line.). If I'm right, I think it is better to manage all thermal zone devices with one platform device. Then, we don't need to leave irq handler with leaving it pendded like above and also we may not need other your patches like adding base_common iomem variable.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Agreed that base_common variables is extra and present to handle the common part. I will further analyse your suggestion.

What is the relation TMU <--> temperature sensor? Is it one to one or one to many?

1 TMU --- > 1 temp sensor.(one to one)

OK. Then it is different to TI bandgap, which has one to many relation. Does every TMU has its own resources, like a register map and IRQ?

Quoted 91 lines

Thanks,
Amit Daniel

Quoted 87 lines
Quoted 80 lines

Thanks,
Amit Daniel

Quoted 75 lines

I'd like to listen your opinion about this.

Thanks,
Jonghwa

Quoted 67 lines
drivers/thermal/samsung/exynos_tmu.c +4 -2
+     }
 
      exynos_report_trigger(data->reg_conf);
      mutex_lock(&data->lock);
@@ -358,7 +390,7 @@ static void exynos_tmu_work(struct work_struct *work)
 
      clk_disable(data->clk);
      mutex_unlock(&data->lock);
-
+out:
      enable_irq(data->irq);
 }
 
@@ -520,7 +552,8 @@ static int exynos_tmu_probe(struct platform_device *pdev)
              return ret;
 
      if (pdata->type == SOC_ARCH_EXYNOS ||
-                             pdata->type == SOC_ARCH_EXYNOS4210)
+             pdata->type == SOC_ARCH_EXYNOS4210 ||
+                             pdata->type == SOC_ARCH_EXYNOS5440)
              data->soc = pdata->type;
      else {
              ret = -EINVAL;
drivers/thermal/samsung/exynos_tmu.h +6 -0
index 65443d7..9151a30 100644
@@ -44,6 +44,7 @@ enum trigger_type {
 enum soc_type {
      SOC_ARCH_EXYNOS4210 = 1,
      SOC_ARCH_EXYNOS,
+     SOC_ARCH_EXYNOS5440,
 };
 
 /**
@@ -132,6 +133,8 @@ enum soc_type {
  * @emul_temp_shift: shift bits of emulation temperature.
  * @emul_time_shift: shift bits of emulation time.
  * @emul_time_mask: mask bits of emulation time.
+ * @tmu_irqstatus: register to find which TMU generated interrupts.
+ * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
      u32     triminfo_data;
@@ -199,6 +202,9 @@ struct exynos_tmu_registers {
      u32     emul_temp_shift;
      u32     emul_time_shift;
      u32     emul_time_mask;
+
+     u32     tmu_irqstatus;
+     u32     tmu_pmin;
 };
 
 /**
drivers/thermal/samsung/exynos_tmu_data.h +2 -0
index 0e2244f..4acf070 100644
@@ -91,6 +91,8 @@
 #define EXYNOS_EMUL_DATA_MASK        0xFF
 #define EXYNOS_EMUL_ENABLE   0x1
 
+#define EXYNOS_MAX_TRIGGER_PER_REG   4
+
 #if defined(CONFIG_CPU_EXYNOS4210)
 extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data;
 #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)

--
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin

Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#33 lore raw

Re: [PATCH V4 22/30] thermal: exynos: Add support for exynos5440 TMU sensor.

Hi,

Quoted 172 lines · Eduardo Valentin
Quoted 171 lines · amit daniel kachhap

Hi Eduardo,

Quoted 167 lines · Eduardo Valentin
Quoted 165 lines · amit daniel kachhap

Hi Jonghwa,

Sorry for the late reply as I was on leave.

Quoted 128 lines · On Sat, May 18, 2013 at 10:53 AM, <[email protected]> wrote:
Quoted 114 lines · Amit Daniel Kachhap

This patch modifies TMU controller to add changes needed to work with exynos5440 platform. This sensor registers 3 instance of the tmu controller with the thermal zone and hence reports 3 temperature output. This controller supports upto five trip points. For critical threshold the driver uses the core driver thermal framework for shutdown.

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |   28 ++++++++++++-
 drivers/thermal/samsung/exynos_tmu.c               |   43 +++++++++++++++++--
 drivers/thermal/samsung/exynos_tmu.h               |    6 +++
 drivers/thermal/samsung/exynos_tmu_data.h          |    2 +
 4 files changed, 72 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +26 -2
index 535fd0e..970eeba 100644
@@ -6,13 +6,16 @@
             "samsung,exynos4412-tmu"
             "samsung,exynos4210-tmu"
             "samsung,exynos5250-tmu"
+            "samsung,exynos5440-tmu"
 - interrupt-parent : The phandle for the interrupt controller
-- reg : Address range of the thermal registers
+- reg : Address range of the thermal registers. For exynos5440-tmu which has 3
+     instances of TMU, 2 set of register has to supplied. First set belongs
+     to each instance of TMU and second set belongs to common TMU registers.
 - interrupts : Should contain interrupt for thermal system
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
 
-Example:
+Example 1):
 
      tmu@100C0000 {
              compatible = "samsung,exynos4412-tmu";
@@ -23,3 +26,24 @@ Example:
              clock-names = "tmu_apbif";
              status = "disabled";
      };
+
+Example 2):
+
+     tmuctrl_0: tmuctrl@160118 {
+             compatible = "samsung,exynos5440-tmu";
+             reg = <0x160118 0x230>, <0x160368 0x10>;
+             interrupts = <0 58 0>;
+             clocks = <&clock 21>;
+             clock-names = "tmu_apbif";
+     };
+
+Note: For multi-instance tmu each instance should have an alias correctly
+numbered in "aliases" node.
+
+Example:
+
+aliases {
+     tmuctrl0 = &tmuctrl_0;
+     tmuctrl1 = &tmuctrl_1;
+     tmuctrl2 = &tmuctrl_2;
+};
drivers/thermal/samsung/exynos_tmu.c +27 -2
index 7f7b1cf..7ca9c4d 100644
@@ -185,9 +185,11 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
                      reg->threshold_th0 + i * sizeof(reg->threshold_th0));
 
              writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
-     } else if (data->soc == SOC_ARCH_EXYNOS) {
+     } else if (data->soc == SOC_ARCH_EXYNOS ||
+                     data->soc == SOC_ARCH_EXYNOS5440) {
              /* Write temperature code for rising and falling threshold */
-             for (i = 0; i < trigger_levs; i++) {
+             for (i = 0;
+             i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
                      threshold_code = temp_to_code(data,
                                              pdata->trigger_levels[i]);
                      if (threshold_code < 0) {
@@ -218,7 +220,30 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
              writel((reg->inten_rise_mask << reg->inten_rise_shift) |
                      (reg->inten_fall_mask << reg->inten_fall_shift),
                              data->base + reg->tmu_intclear);
+
+             /* if 5th threshold limit is also present, use TH2 register */
+             i = EXYNOS_MAX_TRIGGER_PER_REG;
+             if (pdata->trigger_levels[i]) {
+                     threshold_code = temp_to_code(data,
+                                             pdata->trigger_levels[i]);
+                     if (threshold_code < 0) {
+                             ret = threshold_code;
+                             goto out;
+                     }
+                     rising_threshold =
+                             threshold_code << reg->threshold_th3_l0_shift;
+                     writel(rising_threshold,
+                             data->base + reg->threshold_th2);
+                     if (pdata->trigger_type[i] == HW_TRIP) {
+                             con = readl(data->base + reg->tmu_ctrl);
+                             con |= (1 << reg->therm_trip_en_shift);
+                             writel(con, data->base + reg->tmu_ctrl);
+                     }
+             }
      }
+     /*Clear the PMIN in the common TMU register*/
+     if (reg->tmu_pmin && !data->id)
+             writel(0, data->base_common + reg->tmu_pmin);
 out:
      clk_disable(data->clk);
      mutex_unlock(&data->lock);
@@ -345,7 +370,14 @@ static void exynos_tmu_work(struct work_struct *work)
                      struct exynos_tmu_data, irq_work);

drivers/thermal/samsung/exynos_tmu.c static void exynos_tmu_work(struct work_struct *work) · line 379

Quoted 10 lines
drivers/thermal/samsung/exynos_tmu.c +7 -1
      struct exynos_tmu_platform_data *pdata = data->pdata;
      const struct exynos_tmu_registers *reg = pdata->registers;
-     unsigned int val_irq;
+     unsigned int val_irq, val_type;
+
+     /* Find which sensor generated this interrupt */
+     if (reg->tmu_irqstatus) {
+             val_type = readl(data->base_common + reg->tmu_irqstatus);
+             if (!((val_type >> data->id) & 0x1))
+                     goto out;
Quoted 6 lines

I have a question about your implementation for supporting EXYNOS5440. I don't know exactly how EXYNO5440's tmu is working, but just guess it would be similar with other EXYNOS series's without number of thermal sensors. (exclusive register map and threshold level). Due to the multiple number of thermal sensor in EXYNOS5440, it have multiple thermal zone devices and that's why it just leave interrupt pin in pending if interrupt is not its, right?

Yes in 5440 the interrupt line is shared so pending bit is left uncleared.

Quoted 4 lines

So, my curious is, why we make all platform devices for each of thermal zone devices? Why don't you just handle all thermal zone devices with one platform device?

Your doubt is genuine. Let me justify my design decision. Initially I also thought of making a single platform device but since there are 3 different TMU controllers and register maps for 4 more so I followed this design as the driver looks clean and can be scalable easily. Also I agree that some resources like IRQ line is shared but it is due to h/w limitation.
Also it is easy to cleanly control each TMU instance with the device tree data similar to I2C/SPI/MMC instance based device driver. Say I do not want to use 2nd sensor then just pass device tree data for 1st and 3rd sensor.

Quoted 8 lines

Yes, It's probably right to make multiple devices node to support them, because it has different physical hardware(sensors). But we have one TMU , don't we? (Maybe my assumption is wrong, I assume that it has one TMU because it looks like it has only one irq line.). If I'm right, I think it is better to manage all thermal zone devices with one platform device. Then, we don't need to leave irq handler with leaving it pendded like above and also we may not need other your patches like adding base_common iomem variable.

Agreed that base_common variables is extra and present to handle the common part. I will further analyse your suggestion.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

What is the relation TMU <--> temperature sensor? Is it one to one or one to many?

1 TMU --- > 1 temp sensor.(one to one)

OK. Then it is different to TI bandgap, which has one to many relation. Does every TMU has its own resources, like a register map and IRQ?

Yes register maps are different but some registers are common like ISR related registers. IRQ line is common. However all TMU's are totally independent devices.

Quoted 99 lines
Quoted 92 lines

Thanks,
Amit Daniel

Quoted 87 lines
Quoted 80 lines

Thanks,
Amit Daniel

Quoted 75 lines

I'd like to listen your opinion about this.

Thanks,
Jonghwa

Quoted 67 lines
drivers/thermal/samsung/exynos_tmu.c +4 -2
+     }
 
      exynos_report_trigger(data->reg_conf);
      mutex_lock(&data->lock);
@@ -358,7 +390,7 @@ static void exynos_tmu_work(struct work_struct *work)
 
      clk_disable(data->clk);
      mutex_unlock(&data->lock);
-
+out:
      enable_irq(data->irq);
 }
 
@@ -520,7 +552,8 @@ static int exynos_tmu_probe(struct platform_device *pdev)
              return ret;
 
      if (pdata->type == SOC_ARCH_EXYNOS ||
-                             pdata->type == SOC_ARCH_EXYNOS4210)
+             pdata->type == SOC_ARCH_EXYNOS4210 ||
+                             pdata->type == SOC_ARCH_EXYNOS5440)
              data->soc = pdata->type;
      else {
              ret = -EINVAL;
drivers/thermal/samsung/exynos_tmu.h +6 -0
index 65443d7..9151a30 100644
@@ -44,6 +44,7 @@ enum trigger_type {
 enum soc_type {
      SOC_ARCH_EXYNOS4210 = 1,
      SOC_ARCH_EXYNOS,
+     SOC_ARCH_EXYNOS5440,
 };
 
 /**
@@ -132,6 +133,8 @@ enum soc_type {
  * @emul_temp_shift: shift bits of emulation temperature.
  * @emul_time_shift: shift bits of emulation time.
  * @emul_time_mask: mask bits of emulation time.
+ * @tmu_irqstatus: register to find which TMU generated interrupts.
+ * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
      u32     triminfo_data;
@@ -199,6 +202,9 @@ struct exynos_tmu_registers {
      u32     emul_temp_shift;
      u32     emul_time_shift;
      u32     emul_time_mask;
+
+     u32     tmu_irqstatus;
+     u32     tmu_pmin;
 };
 
 /**
drivers/thermal/samsung/exynos_tmu_data.h +2 -0
index 0e2244f..4acf070 100644
@@ -91,6 +91,8 @@
 #define EXYNOS_EMUL_DATA_MASK        0xFF
 #define EXYNOS_EMUL_ENABLE   0x1
 
+#define EXYNOS_MAX_TRIGGER_PER_REG   4
+
 #if defined(CONFIG_CPU_EXYNOS4210)
 extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data;
 #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)

--
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin

--
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin

#34 lore raw

PATCH v4 23/30 thermal: exynos: Fix to set the second point correction value properly

In reply to Amit Daniel Kachhap

This patch sets the second point trimming value according to the platform data if the register value is 0.

---
 drivers/thermal/samsung/exynos_tmu.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +9 -4
index 7ca9c4d..28804a5 100644
@@ -161,10 +161,15 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 	data->temp_error2 = ((trim_info >> reg->triminfo_85_shift) &
 				EXYNOS_TMU_TEMP_MASK);
 
-	if ((pdata->min_efuse_value > data->temp_error1) ||
-			(data->temp_error1 > pdata->max_efuse_value) ||
-			(data->temp_error2 != 0))
-		data->temp_error1 = pdata->efuse_value;
+	if (!data->temp_error1 ||
+		(pdata->min_efuse_value > data->temp_error1) ||
+		(data->temp_error1 > pdata->max_efuse_value))
+		data->temp_error1 = pdata->efuse_value & EXYNOS_TMU_TEMP_MASK;
+
+	if (!data->temp_error2)
+		data->temp_error2 =
+			(pdata->efuse_value >> reg->triminfo_85_shift) &
+			EXYNOS_TMU_TEMP_MASK;
 
 	/* Count trigger levels to be enabled */
 	for (i = 0; i < MAX_THRESHOLD_LEVS; i++)
Signature · 1 line
1.7.1
#35 lore raw

PATCH v4 24/30 thermal: exynos: Add thermal configuration data for exynos5440 TMU sensor

In reply to Amit Daniel Kachhap

This patch adds configuration data for exynos5440 soc. Also register definations for the controller are added.

---
 drivers/thermal/samsung/exynos_tmu.c      |    4 ++
 drivers/thermal/samsung/exynos_tmu_data.c |   61 +++++++++++++++++++++++++++++
 drivers/thermal/samsung/exynos_tmu_data.h |   42 ++++++++++++++++++++
 3 files changed, 107 insertions(+), 0 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +4 -0
index 28804a5..671061b 100644
@@ -423,6 +423,10 @@ static const struct of_device_id exynos_tmu_match[] = {
 		.compatible = "samsung,exynos5250-tmu",
 		.data = (void *)EXYNOS5250_TMU_DRV_DATA,
 	},
+	{
+		.compatible = "samsung,exynos5440-tmu",
+		.data = (void *)EXYNOS5440_TMU_DRV_DATA,
+	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
drivers/thermal/samsung/exynos_tmu_data.c +61 -0

64 lines not on this page · raw message

drivers/thermal/samsung/exynos_tmu_data.h +42 -0

52 lines not on this page · raw message

Signature · 1 line
1.7.1
#36 lore raw

PATCH v4 25/30 thermal: exynos: Add a compensation logic on swapped e-fuse values

In reply to Amit Daniel Kachhap

This patch adds compensation logic on swapped e-fuse values with boundary conditions. Currently, e-fused trim values for sensor0 is swapped with sensor2 so the logic in this patch is needed. sensor1 e-fused trim value is correct.

---
 drivers/thermal/samsung/exynos_tmu.c      |   23 +++++++++++++++++++++--
 drivers/thermal/samsung/exynos_tmu_data.h |    1 +
 2 files changed, 22 insertions(+), 2 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +21 -2
index 671061b..f32d275 100644
@@ -137,7 +137,7 @@ static int exynos_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 exynos_tmu_registers *reg = pdata->registers;
-	unsigned int status, trim_info, con;
+	unsigned int status, trim_info = 0, con;
 	unsigned int rising_threshold = 0, falling_threshold = 0;
 	int ret = 0, threshold_code, i, trigger_levs = 0;
 
@@ -156,7 +156,26 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 		__raw_writel(1, data->base + reg->triminfo_ctrl);
 
 	/* Save trimming info in order to perform calibration */
-	trim_info = readl(data->base + reg->triminfo_data);
+	if (data->soc == SOC_ARCH_EXYNOS5440) {
+		/*
+		 * For exynos5440 soc triminfo value is swapped between TMU0 and
+		 * TMU2, so the below logic is needed.
+		 */
+		switch (data->id) {
+		case 0:
+			trim_info = readl(data->base +
+			EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data);
+			break;
+		case 1:
+			trim_info = readl(data->base + reg->triminfo_data);
+			break;
+		case 2:
+			trim_info = readl(data->base -
+			EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data);
+		}
+	} else {
+		trim_info = readl(data->base + reg->triminfo_data);
+	}
 	data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK;
 	data->temp_error2 = ((trim_info >> reg->triminfo_85_shift) &
 				EXYNOS_TMU_TEMP_MASK);
drivers/thermal/samsung/exynos_tmu_data.h +1 -0
index eb7250d..a1cc8ab 100644
@@ -127,6 +127,7 @@
 #define EXYNOS5440_TMU_TH_RISE2_SHIFT		16
 #define EXYNOS5440_TMU_TH_RISE3_SHIFT		24
 #define EXYNOS5440_TMU_TH_RISE4_SHIFT		24
+#define EXYNOS5440_EFUSE_SWAP_OFFSET		8
 
 #if defined(CONFIG_CPU_EXYNOS4210)
 extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data;
Signature · 1 line
1.7.1
#37 lore raw

PATCH v4 26/30 thermal: exynos: Add hardware mode thermal calibration support

In reply to Amit Daniel Kachhap

This patch adds support for h/w mode calibration in the TMU controller. soc's like 5440 support this features.

---
 drivers/thermal/samsung/exynos_tmu.c      |   15 +++++++++++++++
 drivers/thermal/samsung/exynos_tmu.h      |    6 ++++++
 drivers/thermal/samsung/exynos_tmu_data.c |    2 ++
 drivers/thermal/samsung/exynos_tmu_data.h |    2 ++
 4 files changed, 25 insertions(+), 0 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +15 -0
index f32d275..ad57d2d 100644
@@ -73,6 +73,9 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
 	struct exynos_tmu_platform_data *pdata = data->pdata;
 	int temp_code;
 
+	if (pdata->cal_mode == HW_MODE)
+		return temp;
+
 	if (data->soc == SOC_ARCH_EXYNOS4210)
 		/* temp should range between 25 and 125 */
 		if (temp < 25 || temp > 125) {
@@ -107,6 +110,9 @@ static int code_to_temp(struct exynos_tmu_data *data, u8 temp_code)
 	struct exynos_tmu_platform_data *pdata = data->pdata;
 	int temp;
 
+	if (pdata->cal_mode == HW_MODE)
+		return temp_code;
+
 	if (data->soc == SOC_ARCH_EXYNOS4210)
 		/* temp_code should range between 75 and 175 */
 		if (temp_code < 75 || temp_code > 175) {
@@ -155,6 +161,9 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 	if (TMU_SUPPORTS(pdata, TRIM_RELOAD))
 		__raw_writel(1, data->base + reg->triminfo_ctrl);
 
+	if (pdata->cal_mode == HW_MODE)
+		goto skip_calib_data;
+
 	/* Save trimming info in order to perform calibration */
 	if (data->soc == SOC_ARCH_EXYNOS5440) {
 		/*
@@ -190,6 +199,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 			(pdata->efuse_value >> reg->triminfo_85_shift) &
 			EXYNOS_TMU_TEMP_MASK;
 
+skip_calib_data:
 	/* Count trigger levels to be enabled */
 	for (i = 0; i < MAX_THRESHOLD_LEVS; i++)
 		if (pdata->trigger_levels[i])
@@ -303,6 +313,11 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
 		con |= (pdata->noise_cancel_mode << reg->therm_trip_mode_shift);
 	}
 
+	if (pdata->cal_mode == HW_MODE) {
+		con &= ~(reg->calib_mode_mask << reg->calib_mode_shift);
+		con |= pdata->cal_type << reg->calib_mode_shift;
+	}
+
 	if (on) {
 		con |= (1 << reg->core_en_shift);
 		interrupt_en =
drivers/thermal/samsung/exynos_tmu.h +6 -0
index 9151a30..fa6a796 100644
@@ -91,6 +91,10 @@ enum soc_type {
  * @buf_slope_sel_shift: shift bits of amplifier gain value in tmu_ctrl
 	register.
  * @buf_slope_sel_mask: mask bits of amplifier gain value in tmu_ctrl register.
+ * @calib_mode_shift: shift bits of calibration mode value in tmu_ctrl
+	register.
+ * @calib_mode_mask: mask bits of calibration mode value in tmu_ctrl
+	register.
  * @therm_trip_tq_en_shift: shift bits of thermal trip enable by TQ pin in
 	tmu_ctrl register.
  * @core_en_shift: shift bits of TMU core enable bit in tmu_ctrl register.
@@ -152,6 +156,8 @@ struct exynos_tmu_registers {
 	u32	therm_trip_en_shift;
 	u32	buf_slope_sel_shift;
 	u32	buf_slope_sel_mask;
+	u32	calib_mode_shift;
+	u32	calib_mode_mask;
 	u32	therm_trip_tq_en_shift;
 	u32	core_en_shift;
 
drivers/thermal/samsung/exynos_tmu_data.c +2 -0
index d622cb4..60a4ca0 100644
@@ -174,6 +174,8 @@ static const struct exynos_tmu_registers exynos5440_tmu_registers = {
 	.therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
 	.buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT,
 	.buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK,
+	.calib_mode_shift = EXYNOS_TMU_CALIB_MODE_SHIFT,
+	.calib_mode_mask = EXYNOS_TMU_CALIB_MODE_MASK,
 	.core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT,
 	.tmu_status = EXYNOS5440_TMU_S0_7_STATUS,
 	.tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP,
drivers/thermal/samsung/exynos_tmu_data.h +2 -0
index a1cc8ab..d97ccf8 100644
@@ -75,6 +75,8 @@
 #define EXYNOS_TMU_TRIP_MODE_SHIFT	13
 #define EXYNOS_TMU_TRIP_MODE_MASK	0x7
 #define EXYNOS_TMU_THERM_TRIP_EN_SHIFT	12
+#define EXYNOS_TMU_CALIB_MODE_SHIFT	4
+#define EXYNOS_TMU_CALIB_MODE_MASK	0x3
 
 #define EXYNOS_TMU_INTEN_RISE0_SHIFT	0
 #define EXYNOS_TMU_INTEN_RISE1_SHIFT	4
Signature · 1 line
1.7.1
#38 lore raw

PATCH v4 27/30 Documentation: thermal: Explain the exynos thermal driver model

In reply to Amit Daniel Kachhap

This patch updates the documentation to explain the driver model and file layout.

---
 Documentation/thermal/exynos_thermal |   43 ++++++++++++++++++++++++++-------
 1 files changed, 34 insertions(+), 9 deletions(-)
Documentation/thermal/exynos_thermal +34 -9
index 2b46f67..9010c44 100644
@@ -1,17 +1,17 @@
-Kernel driver exynos4_tmu
+Kernel driver exynos_tmu
 =================
 
 Supported chips:
-* ARM SAMSUNG EXYNOS4 series of SoC
-  Prefix: 'exynos4-tmu'
+* ARM SAMSUNG EXYNOS4, EXYNOS5 series of SoC
   Datasheet: Not publicly available
 
 Authors: Donggeun Kim <[email protected]>
+Authors: Amit Daniel <[email protected]>
 
-Description
------------
+TMU controller Description:
+---------------------------
 
-This driver allows to read temperature inside SAMSUNG EXYNOS4 series of SoC.
+This driver allows to read temperature inside SAMSUNG EXYNOS4/5 series of SoC.
 
 The chip only exposes the measured 8-bit temperature code value
 through a register.
@@ -34,9 +34,9 @@ The three equations are:
   TI2: Trimming info for 85 degree Celsius (stored at TRIMINFO register)
        Temperature code measured at 85 degree Celsius which is unchanged
 
-TMU(Thermal Management Unit) in EXYNOS4 generates interrupt
+TMU(Thermal Management Unit) in EXYNOS4/5 generates interrupt
 when temperature exceeds pre-defined levels.
-The maximum number of configurable threshold is four.
+The maximum number of configurable threshold is five.
 The threshold levels are defined as follows:
   Level_0: current temperature > trigger_level_0 + threshold
   Level_1: current temperature > trigger_level_1 + threshold
@@ -47,6 +47,31 @@ The threshold levels are defined as follows:
   through the corresponding registers.
 
 When an interrupt occurs, this driver notify kernel thermal framework
-with the function exynos4_report_trigger.
+with the function exynos_report_trigger.
 Although an interrupt condition for level_0 can be set,
 it can be used to synchronize the cooling action.
+
+TMU driver description:
+-----------------------
+
+The exynos thermal driver is structured as,
+
+					Kernel Core thermal framework
+				(thermal_core.c, step_wise.c, cpu_cooling.c)
+								^
+								|
+								|
+TMU configuration data -------> TMU Driver  <------> Exynos Core thermal wrapper
+(exynos_tmu_data.c)	      (exynos_tmu.c)	   (exynos_thermal_common.c)
+(exynos_tmu_data.h)	      (exynos_tmu.h)	   (exynos_thermal_common.h)
+
+a) TMU configuration data: This consist of TMU register offsets/bitfields
+		described through structure exynos_tmu_registers. Also several
+		other platform data (struct exynos_tmu_platform_data) members
+		are used to configure the TMU.
+b) TMU driver: This component initialises the TMU controller and sets different
+		thresholds. It invokes core thermal implementation with the call
+		exynos_report_trigger.
+c) Exynos Core thermal wrapper: This provides 3 wrapper function to use the
+		Kernel core thermal framework. They are exynos_unregister_thermal,
+		exynos_register_thermal and exynos_report_trigger.
Signature · 1 line
1.7.1
#39 lore raw

PATCH v4 28/30 thermal: exynos: Support for TMU regulator defined at device tree

In reply to Amit Daniel Kachhap

TMU probe function now checks for a device tree defined regulator. For compatibility reasons it is allowed to probe driver even without this regulator defined.

---
 .../devicetree/bindings/thermal/exynos-thermal.txt |    4 +++
 drivers/thermal/samsung/exynos_tmu.c               |   23 ++++++++++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/thermal/exynos-thermal.txt +4 -0
index 970eeba..ff62f7a 100644
@@ -14,6 +14,9 @@
 - interrupts : Should contain interrupt for thermal system
 - clocks : The main clock for TMU device
 - clock-names : Thermal system clock name
+- 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.
 
 Example 1):
 
@@ -25,6 +28,7 @@ Example 1):
 		clocks = <&clock 383>;
 		clock-names = "tmu_apbif";
 		status = "disabled";
+		vtmu-supply = <&tmu_regulator_node>;
 	};
 
 Example 2):
drivers/thermal/samsung/exynos_tmu.c +23 -0
index ad57d2d..498ca56 100644
@@ -29,6 +29,7 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
 
 #include "exynos_thermal_common.h"
 #include "exynos_tmu.h"
@@ -48,6 +49,7 @@
  * @clk: pointer to the clock structure.
  * @temp_error1: fused value of the first point trim.
  * @temp_error2: fused value of the second point trim.
+ * @regulator: pointer to the TMU regulator structure.
  * @reg_conf: pointer to structure to register with core thermal.
  */
 struct exynos_tmu_data {
@@ -61,6 +63,7 @@ struct exynos_tmu_data {
 	struct mutex lock;
 	struct clk *clk;
 	u8 temp_error1, temp_error2;
+	struct regulator *regulator;
 	struct thermal_sensor_conf *reg_conf;
 };
 
@@ -500,10 +503,27 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
 	struct exynos_tmu_platform_data *pdata = data->pdata;
 	struct resource res;
+	int ret;
 
 	if (!data)
 		return -ENODEV;
 
+	/*
+	 * Try enabling the regulator if found
+	 * TODO: Add regulator as an SOC feature, so that regulator enable
+	 * is a compulsory call.
+	 */
+	data->regulator = devm_regulator_get(&pdev->dev, "vtmu");
+	if (!IS_ERR(data->regulator)) {
+		ret = regulator_enable(data->regulator);
+		if (ret) {
+			dev_err(&pdev->dev, "failed to enable vtmu\n");
+			return ret;
+		}
+	} else {
+		dev_info(&pdev->dev, "Regulator node (vtmu) not found\n");
+	}
+
 	data->id = of_alias_get_id(pdev->dev.of_node, "tmuctrl");
 	if (data->id < 0)
 		data->id = 0;
@@ -668,6 +688,9 @@ static int exynos_tmu_remove(struct platform_device *pdev)
 
 	clk_unprepare(data->clk);
 
+	if (!IS_ERR(data->regulator))
+		regulator_disable(data->regulator);
+
 	platform_set_drvdata(pdev, NULL);
 
 	return 0;
Signature · 1 line
1.7.1
#40 lore raw

PATCH v4 29/30 ARM: dts: Add device tree node for exynos5440 TMU controller

In reply to Amit Daniel Kachhap

This patch adds device node for TMU controller. There are 3 instances of the controllers so 3 nodes are created.

---
 arch/arm/boot/dts/exynos5440.dtsi |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
arch/arm/boot/dts/exynos5440.dtsi +30 -0
index 9a99755..433e92e 100644
@@ -16,6 +16,12 @@
 
 	interrupt-parent = <&gic>;
 
+	aliases {
+		tmuctrl0 = &tmuctrl_0;
+		tmuctrl1 = &tmuctrl_1;
+		tmuctrl2 = &tmuctrl_2;
+	};
+
 	gic:interrupt-controller@2E0000 {
 		compatible = "arm,cortex-a15-gic";
 		#interrupt-cells = <3>;
@@ -162,4 +168,28 @@
 		reg = <0x130000 0x1000>;
 		interrupts = <0 17 0>, <0 16 0>;
 	};
+
+	tmuctrl_0: tmuctrl@160118 {
+		compatible = "samsung,exynos5440-tmu";
+		reg = <0x160118 0x230>, <0x160368 0x10>;
+		interrupts = <0 58 0>;
+		clocks = <&clock 21>;
+		clock-names = "tmu_apbif";
+	};
+
+	tmuctrl_1: tmuctrl@16011C {
+		compatible = "samsung,exynos5440-tmu";
+		reg = <0x16011C 0x230>, <0x160368 0x10>;
+		interrupts = <0 58 0>;
+		clocks = <&clock 21>;
+		clock-names = "tmu_apbif";
+	};
+
+	tmuctrl_2: tmuctrl@160120 {
+		compatible = "samsung,exynos5440-tmu";
+		reg = <0x160120 0x230>, <0x160368 0x10>;
+		interrupts = <0 58 0>;
+		clocks = <&clock 21>;
+		clock-names = "tmu_apbif";
+	};
 };
Signature · 1 line
1.7.1
#41 lore raw

PATCH v4 30/30 arm: exynos: enable ARCH_HAS_TMU

In reply to Amit Daniel Kachhap

This patch enables ARCH_HAS_TMU config for exynos4210, 4212, 4412, 5250 and 5440 SOC.

---
 arch/arm/mach-exynos/Kconfig |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
arch/arm/mach-exynos/Kconfig +5 -0
index 70f94c8..919a2f2 100644
@@ -31,6 +31,7 @@ config CPU_EXYNOS4210
 	bool "SAMSUNG EXYNOS4210"
 	default y
 	depends on ARCH_EXYNOS4
+	select ARCH_HAS_TMU
 	select ARM_CPU_SUSPEND if PM
 	select PM_GENERIC_DOMAINS
 	select S5P_PM if PM
@@ -43,6 +44,7 @@ config SOC_EXYNOS4212
 	bool "SAMSUNG EXYNOS4212"
 	default y
 	depends on ARCH_EXYNOS4
+	select ARCH_HAS_TMU
 	select S5P_PM if PM
 	select S5P_SLEEP if PM
 	select SAMSUNG_DMADEV
@@ -53,6 +55,7 @@ config SOC_EXYNOS4412
 	bool "SAMSUNG EXYNOS4412"
 	default y
 	depends on ARCH_EXYNOS4
+	select ARCH_HAS_TMU
 	select SAMSUNG_DMADEV
 	help
 	  Enable EXYNOS4412 SoC support
@@ -61,6 +64,7 @@ config SOC_EXYNOS5250
 	bool "SAMSUNG EXYNOS5250"
 	default y
 	depends on ARCH_EXYNOS5
+	select ARCH_HAS_TMU
 	select S5P_PM if PM
 	select S5P_SLEEP if PM
 	select S5P_DEV_MFC
@@ -72,6 +76,7 @@ config SOC_EXYNOS5440
 	bool "SAMSUNG EXYNOS5440"
 	default y
 	depends on ARCH_EXYNOS5
+	select ARCH_HAS_TMU
 	select ARM_ARCH_TIMER
 	select AUTO_ZRELADDR
 	select PINCTRL
Signature · 1 line
1.7.1
#42 lore raw
In reply to Amit Daniel Kachhap
Quoted 5 lines · Amit Daniel Kachhap

Changes in V4:
Almost all the changes in this version is as per suggestion from Eduardo.The major ones are listed below,
* Added kconfig symbol ARCH_HAS_TMU which needs to be enabled by platform. With this change existing symbol EXYNOS_TMU_DATA is not needed.

I was more thinking if we could have a single flag that we could use in thermal drivers. Besides, my proposal for ARCH_HAS_BANDGAP is still not merged yet.

Quoted 118 lines

* Movement of freq_clip_table from exynos_tmu.h to exynos_thermal_common.h is explained in the commit logs.
* Wrote all register description documentation.
* Split 5440 TMU support patch into controller change, configuration data and feature addition patches.
* Remove all *LINUX_* in the header files.
* Still regulator enable is kept optional but a TODO: comment is added to fix it later.

Changes in V3:
* Added proper dependency of different exynos thermal Kconfig symbols. Basically 3 Kconfig can be enabled now and corresponds to tmu driver. exynos common part and exynos configuration data. This issue was raised by Rui Zhang.

Changes in V2:
* Separated SOC data from TMU driver. This is as per suggestion from Eduardo.
* Merged the new file created for exynos5440 TMU controller with the existing TMU controller code.
* Removed the DT parsing code as now the SOC specific data are cleanly put inside the data specific file.
* Even the register definations/bitfields are treated as data as there is some variation across SOC's.

This patchset adds TMU(Thermal management Unit) driver support for exynos5440 platform. There are 3 instances of the TMU controllers so necessary cleanup/re-structure is done to handle multiple thermal zone.

Patch (exynos4: Add documentation for Exynos SoC thermal bindings) from Lukasz Majewski is already posted to mainline. Adding it here for completeness.
(http://www.mail-archive.com/[email protected]/msg17817.html)

Patch (thermal: exynos: Support thermal tripping ) from Jonghwan Choi is added here with some changes.
(https://patchwork.kernel.org/patch/1668371/)

Patch (thermal: exynos: Support for TMU regulator defined at device tree) is a repost of my earlier patch(https://patchwork-mail1.kernel.org/patch/2510771/) and adds regulator support.

Patch (ARM: dts: Add device tree node for exynos5440 TMU controller) and patch (arm: exynos: enable ARCH_HAS_TMU) can be merged through exynos platform maintainer as this can cause merge conflict.

All these patches are based on thermal maintainers git tree,
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next.

Amit Daniel Kachhap (29):
thermal: exynos: Moving exynos thermal files into samsung directory
thermal: exynos: Add ARCH_HAS_TMU config to know the supported soc's
thermal: exynos: Remove CPU_THERMAL dependency for using TMU driver
thermal: exynos: Bifurcate exynos thermal common and tmu controller
code
thermal: exynos: Rename exynos_thermal.c to exynos_tmu.c
thermal: exynos: Move exynos_thermal.h from include/* to driver/*
folder
thermal: exynos: Bifurcate exynos tmu driver and configuration data
thermal: exynos: Add missing definations and code cleanup
thermal: exynos: Add extra entries in the tmu platform data
thermal: exynos: Support thermal tripping
thermal: exynos: Move register definitions from driver file to data
file
thermal: exynos: Fix to clear only the generated interrupts
thermal: exynos: Add support for instance based register/unregister
thermal: exynos: Modify private_data to appropriate name driver_data
thermal: exynos: Return success even if no cooling data supplied
thermal: exynos: Make the zone handling dependent on trip count
thermal: exynos: Add support to handle many instances of TMU
thermal: exynos: Add TMU features to check instead of using SOC type
thermal: exynos: use device resource management infrastructure
thermal: exynos: Add support to access common register for
multistance
thermal: exynos: Add support for exynos5440 TMU sensor.
thermal: exynos: Fix to set the second point correction value
properly
thermal: exynos: Add thermal configuration data for exynos5440 TMU
sensor
thermal: exynos: Add a compensation logic on swapped e-fuse values
thermal: exynos: Add hardware mode thermal calibration support
Documentation: thermal: Explain the exynos thermal driver model
thermal: exynos: Support for TMU regulator defined at device tree
ARM: dts: Add device tree node for exynos5440 TMU controller
arm: exynos: enable ARCH_HAS_TMU

Lukasz Majewski (1):
ARM: dts: thermal: exynos4: Add documentation for Exynos SoC thermal
bindings

 .../devicetree/bindings/thermal/exynos-thermal.txt |   53 +
 Documentation/thermal/exynos_thermal               |   43 +-
 arch/arm/boot/dts/exynos5440.dtsi                  |   30 +
 arch/arm/mach-exynos/Kconfig                       |    5 +
 drivers/thermal/Kconfig                            |   13 +-
 drivers/thermal/Makefile                           |    2 +-
 drivers/thermal/exynos_thermal.c                   | 1066 --------------------
 drivers/thermal/samsung/Kconfig                    |   21 +
 drivers/thermal/samsung/Makefile                   |    7 +
 drivers/thermal/samsung/exynos_thermal_common.c    |  407 ++++++++
 drivers/thermal/samsung/exynos_thermal_common.h    |   98 ++
 drivers/thermal/samsung/exynos_tmu.c               |  741 ++++++++++++++
 drivers/thermal/samsung/exynos_tmu.h               |  294 ++++++
 drivers/thermal/samsung/exynos_tmu_data.c          |  225 ++++
 drivers/thermal/samsung/exynos_tmu_data.h          |  155 +++
 include/linux/platform_data/exynos_thermal.h       |  119 ---
 16 files changed, 2076 insertions(+), 1203 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/exynos-thermal.txt
 delete mode 100644 drivers/thermal/exynos_thermal.c
 create mode 100644 drivers/thermal/samsung/Kconfig
 create mode 100644 drivers/thermal/samsung/Makefile
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 create mode 100644 drivers/thermal/samsung/exynos_tmu.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu.h
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.h
 delete mode 100644 include/linux/platform_data/exynos_thermal.h
#43 lore raw

Hi Eduardo,

Quoted 10 lines · Eduardo Valentin
Quoted 5 lines · Amit Daniel Kachhap

Changes in V4:
Almost all the changes in this version is as per suggestion from Eduardo.The major ones are listed below,
* Added kconfig symbol ARCH_HAS_TMU which needs to be enabled by platform. With this change existing symbol EXYNOS_TMU_DATA is not needed.

I was more thinking if we could have a single flag that we could use in thermal drivers. Besides, my proposal for ARCH_HAS_BANDGAP is still not merged yet.

yes a single flag might be useful such as ARCH_HAS_THERMAL but this patch can work as an intermediate solution.

Thanks,
Amit Daniel

Quoted 121 lines
Quoted 119 lines

* Movement of freq_clip_table from exynos_tmu.h to exynos_thermal_common.h is explained in the commit logs.
* Wrote all register description documentation.
* Split 5440 TMU support patch into controller change, configuration data and feature addition patches.
* Remove all *LINUX_* in the header files.
* Still regulator enable is kept optional but a TODO: comment is added to fix it later.

Changes in V3:
* Added proper dependency of different exynos thermal Kconfig symbols. Basically 3 Kconfig can be enabled now and corresponds to tmu driver. exynos common part and exynos configuration data. This issue was raised by Rui Zhang.

Changes in V2:
* Separated SOC data from TMU driver. This is as per suggestion from Eduardo.
* Merged the new file created for exynos5440 TMU controller with the existing TMU controller code.
* Removed the DT parsing code as now the SOC specific data are cleanly put inside the data specific file.
* Even the register definations/bitfields are treated as data as there is some variation across SOC's.

This patchset adds TMU(Thermal management Unit) driver support for exynos5440 platform. There are 3 instances of the TMU controllers so necessary cleanup/re-structure is done to handle multiple thermal zone.

Patch (exynos4: Add documentation for Exynos SoC thermal bindings) from Lukasz Majewski is already posted to mainline. Adding it here for completeness.
(http://www.mail-archive.com/[email protected]/msg17817.html)

Patch (thermal: exynos: Support thermal tripping ) from Jonghwan Choi is added here with some changes.
(https://patchwork.kernel.org/patch/1668371/)

Patch (thermal: exynos: Support for TMU regulator defined at device tree) is a repost of my earlier patch(https://patchwork-mail1.kernel.org/patch/2510771/) and adds regulator support.

Patch (ARM: dts: Add device tree node for exynos5440 TMU controller) and patch (arm: exynos: enable ARCH_HAS_TMU) can be merged through exynos platform maintainer as this can cause merge conflict.

All these patches are based on thermal maintainers git tree,
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next.

Amit Daniel Kachhap (29):
thermal: exynos: Moving exynos thermal files into samsung directory
thermal: exynos: Add ARCH_HAS_TMU config to know the supported soc's
thermal: exynos: Remove CPU_THERMAL dependency for using TMU driver
thermal: exynos: Bifurcate exynos thermal common and tmu controller
code
thermal: exynos: Rename exynos_thermal.c to exynos_tmu.c
thermal: exynos: Move exynos_thermal.h from include/* to driver/*
folder
thermal: exynos: Bifurcate exynos tmu driver and configuration data
thermal: exynos: Add missing definations and code cleanup
thermal: exynos: Add extra entries in the tmu platform data
thermal: exynos: Support thermal tripping
thermal: exynos: Move register definitions from driver file to data
file
thermal: exynos: Fix to clear only the generated interrupts
thermal: exynos: Add support for instance based register/unregister
thermal: exynos: Modify private_data to appropriate name driver_data
thermal: exynos: Return success even if no cooling data supplied
thermal: exynos: Make the zone handling dependent on trip count
thermal: exynos: Add support to handle many instances of TMU
thermal: exynos: Add TMU features to check instead of using SOC type
thermal: exynos: use device resource management infrastructure
thermal: exynos: Add support to access common register for
multistance
thermal: exynos: Add support for exynos5440 TMU sensor.
thermal: exynos: Fix to set the second point correction value
properly
thermal: exynos: Add thermal configuration data for exynos5440 TMU
sensor
thermal: exynos: Add a compensation logic on swapped e-fuse values
thermal: exynos: Add hardware mode thermal calibration support
Documentation: thermal: Explain the exynos thermal driver model
thermal: exynos: Support for TMU regulator defined at device tree
ARM: dts: Add device tree node for exynos5440 TMU controller
arm: exynos: enable ARCH_HAS_TMU

Lukasz Majewski (1):
ARM: dts: thermal: exynos4: Add documentation for Exynos SoC thermal
bindings

 .../devicetree/bindings/thermal/exynos-thermal.txt |   53 +
 Documentation/thermal/exynos_thermal               |   43 +-
 arch/arm/boot/dts/exynos5440.dtsi                  |   30 +
 arch/arm/mach-exynos/Kconfig                       |    5 +
 drivers/thermal/Kconfig                            |   13 +-
 drivers/thermal/Makefile                           |    2 +-
 drivers/thermal/exynos_thermal.c                   | 1066 --------------------
 drivers/thermal/samsung/Kconfig                    |   21 +
 drivers/thermal/samsung/Makefile                   |    7 +
 drivers/thermal/samsung/exynos_thermal_common.c    |  407 ++++++++
 drivers/thermal/samsung/exynos_thermal_common.h    |   98 ++
 drivers/thermal/samsung/exynos_tmu.c               |  741 ++++++++++++++
 drivers/thermal/samsung/exynos_tmu.h               |  294 ++++++
 drivers/thermal/samsung/exynos_tmu_data.c          |  225 ++++
 drivers/thermal/samsung/exynos_tmu_data.h          |  155 +++
 include/linux/platform_data/exynos_thermal.h       |  119 ---
 16 files changed, 2076 insertions(+), 1203 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/exynos-thermal.txt
 delete mode 100644 drivers/thermal/exynos_thermal.c
 create mode 100644 drivers/thermal/samsung/Kconfig
 create mode 100644 drivers/thermal/samsung/Makefile
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 create mode 100644 drivers/thermal/samsung/exynos_tmu.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu.h
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.h
 delete mode 100644 include/linux/platform_data/exynos_thermal.h
#44 lore raw
Quoted 11 lines · amit daniel kachhap

Hi Eduardo,

Quoted 7 lines · Eduardo Valentin
Quoted 5 lines · Amit Daniel Kachhap

Changes in V4:
Almost all the changes in this version is as per suggestion from Eduardo.The major ones are listed below,
* Added kconfig symbol ARCH_HAS_TMU which needs to be enabled by platform. With this change existing symbol EXYNOS_TMU_DATA is not needed.

Quoted 6 lines
Quoted 3 lines

I was more thinking if we could have a single flag that we could use in thermal drivers. Besides, my proposal for ARCH_HAS_BANDGAP is still not merged yet.

yes a single flag might be useful such as ARCH_HAS_THERMAL but this patch can work as an intermediate solution.

I think bandgap is a generic enough term IMO.

[1] - http://en.wikipedia.org/wiki/Bandgap_voltage_reference
[2] - http://en.wikipedia.org/wiki/Silicon_bandgap_temperature_sensor

Quoted 126 lines

Thanks,
Amit Daniel

Quoted 121 lines
Quoted 119 lines

* Movement of freq_clip_table from exynos_tmu.h to exynos_thermal_common.h is explained in the commit logs.
* Wrote all register description documentation.
* Split 5440 TMU support patch into controller change, configuration data and feature addition patches.
* Remove all *LINUX_* in the header files.
* Still regulator enable is kept optional but a TODO: comment is added to fix it later.

Changes in V3:
* Added proper dependency of different exynos thermal Kconfig symbols. Basically 3 Kconfig can be enabled now and corresponds to tmu driver. exynos common part and exynos configuration data. This issue was raised by Rui Zhang.

Changes in V2:
* Separated SOC data from TMU driver. This is as per suggestion from Eduardo.
* Merged the new file created for exynos5440 TMU controller with the existing TMU controller code.
* Removed the DT parsing code as now the SOC specific data are cleanly put inside the data specific file.
* Even the register definations/bitfields are treated as data as there is some variation across SOC's.

This patchset adds TMU(Thermal management Unit) driver support for exynos5440 platform. There are 3 instances of the TMU controllers so necessary cleanup/re-structure is done to handle multiple thermal zone.

Patch (exynos4: Add documentation for Exynos SoC thermal bindings) from Lukasz Majewski is already posted to mainline. Adding it here for completeness.
(http://www.mail-archive.com/[email protected]/msg17817.html)

Patch (thermal: exynos: Support thermal tripping ) from Jonghwan Choi is added here with some changes.
(https://patchwork.kernel.org/patch/1668371/)

Patch (thermal: exynos: Support for TMU regulator defined at device tree) is a repost of my earlier patch(https://patchwork-mail1.kernel.org/patch/2510771/) and adds regulator support.

Patch (ARM: dts: Add device tree node for exynos5440 TMU controller) and patch (arm: exynos: enable ARCH_HAS_TMU) can be merged through exynos platform maintainer as this can cause merge conflict.

All these patches are based on thermal maintainers git tree,
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next.

Amit Daniel Kachhap (29):
thermal: exynos: Moving exynos thermal files into samsung directory
thermal: exynos: Add ARCH_HAS_TMU config to know the supported soc's
thermal: exynos: Remove CPU_THERMAL dependency for using TMU driver
thermal: exynos: Bifurcate exynos thermal common and tmu controller
code
thermal: exynos: Rename exynos_thermal.c to exynos_tmu.c
thermal: exynos: Move exynos_thermal.h from include/* to driver/*
folder
thermal: exynos: Bifurcate exynos tmu driver and configuration data
thermal: exynos: Add missing definations and code cleanup
thermal: exynos: Add extra entries in the tmu platform data
thermal: exynos: Support thermal tripping
thermal: exynos: Move register definitions from driver file to data
file
thermal: exynos: Fix to clear only the generated interrupts
thermal: exynos: Add support for instance based register/unregister
thermal: exynos: Modify private_data to appropriate name driver_data
thermal: exynos: Return success even if no cooling data supplied
thermal: exynos: Make the zone handling dependent on trip count
thermal: exynos: Add support to handle many instances of TMU
thermal: exynos: Add TMU features to check instead of using SOC type
thermal: exynos: use device resource management infrastructure
thermal: exynos: Add support to access common register for
multistance
thermal: exynos: Add support for exynos5440 TMU sensor.
thermal: exynos: Fix to set the second point correction value
properly
thermal: exynos: Add thermal configuration data for exynos5440 TMU
sensor
thermal: exynos: Add a compensation logic on swapped e-fuse values
thermal: exynos: Add hardware mode thermal calibration support
Documentation: thermal: Explain the exynos thermal driver model
thermal: exynos: Support for TMU regulator defined at device tree
ARM: dts: Add device tree node for exynos5440 TMU controller
arm: exynos: enable ARCH_HAS_TMU

Lukasz Majewski (1):
ARM: dts: thermal: exynos4: Add documentation for Exynos SoC thermal
bindings

 .../devicetree/bindings/thermal/exynos-thermal.txt |   53 +
 Documentation/thermal/exynos_thermal               |   43 +-
 arch/arm/boot/dts/exynos5440.dtsi                  |   30 +
 arch/arm/mach-exynos/Kconfig                       |    5 +
 drivers/thermal/Kconfig                            |   13 +-
 drivers/thermal/Makefile                           |    2 +-
 drivers/thermal/exynos_thermal.c                   | 1066 --------------------
 drivers/thermal/samsung/Kconfig                    |   21 +
 drivers/thermal/samsung/Makefile                   |    7 +
 drivers/thermal/samsung/exynos_thermal_common.c    |  407 ++++++++
 drivers/thermal/samsung/exynos_thermal_common.h    |   98 ++
 drivers/thermal/samsung/exynos_tmu.c               |  741 ++++++++++++++
 drivers/thermal/samsung/exynos_tmu.h               |  294 ++++++
 drivers/thermal/samsung/exynos_tmu_data.c          |  225 ++++
 drivers/thermal/samsung/exynos_tmu_data.h          |  155 +++
 include/linux/platform_data/exynos_thermal.h       |  119 ---
 16 files changed, 2076 insertions(+), 1203 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/exynos-thermal.txt
 delete mode 100644 drivers/thermal/exynos_thermal.c
 create mode 100644 drivers/thermal/samsung/Kconfig
 create mode 100644 drivers/thermal/samsung/Makefile
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 create mode 100644 drivers/thermal/samsung/exynos_tmu.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu.h
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.h
 delete mode 100644 include/linux/platform_data/exynos_thermal.h
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#45 lore raw

Hi,

Quoted 16 lines · Eduardo Valentin
Quoted 15 lines · amit daniel kachhap

Hi Eduardo,

Quoted 10 lines · Eduardo Valentin
Quoted 5 lines · Amit Daniel Kachhap

Changes in V4:
Almost all the changes in this version is as per suggestion from Eduardo.The major ones are listed below,
* Added kconfig symbol ARCH_HAS_TMU which needs to be enabled by platform. With this change existing symbol EXYNOS_TMU_DATA is not needed.

I was more thinking if we could have a single flag that we could use in thermal drivers. Besides, my proposal for ARCH_HAS_BANDGAP is still not merged yet.

Quoted 8 lines
Quoted 2 lines

yes a single flag might be useful such as ARCH_HAS_THERMAL but this patch can work as an intermediate solution.

I think bandgap is a generic enough term IMO.

[1] - http://en.wikipedia.org/wiki/Bandgap_voltage_reference
[2] - http://en.wikipedia.org/wiki/Silicon_bandgap_temperature_sensor

Hit the send button too early. So, I think bandgap is a generic enough term. Using bandgap I believe it is better because its meaning has the implication of having a device to control thermal.

But if you feel more confident with the thermal term we can switch to something like HAS_THERMAL_CONTROL.

Quoted 129 lines
Quoted 127 lines

Thanks,
Amit Daniel

Quoted 121 lines
Quoted 119 lines

* Movement of freq_clip_table from exynos_tmu.h to exynos_thermal_common.h is explained in the commit logs.
* Wrote all register description documentation.
* Split 5440 TMU support patch into controller change, configuration data and feature addition patches.
* Remove all *LINUX_* in the header files.
* Still regulator enable is kept optional but a TODO: comment is added to fix it later.

Changes in V3:
* Added proper dependency of different exynos thermal Kconfig symbols. Basically 3 Kconfig can be enabled now and corresponds to tmu driver. exynos common part and exynos configuration data. This issue was raised by Rui Zhang.

Changes in V2:
* Separated SOC data from TMU driver. This is as per suggestion from Eduardo.
* Merged the new file created for exynos5440 TMU controller with the existing TMU controller code.
* Removed the DT parsing code as now the SOC specific data are cleanly put inside the data specific file.
* Even the register definations/bitfields are treated as data as there is some variation across SOC's.

This patchset adds TMU(Thermal management Unit) driver support for exynos5440 platform. There are 3 instances of the TMU controllers so necessary cleanup/re-structure is done to handle multiple thermal zone.

Patch (exynos4: Add documentation for Exynos SoC thermal bindings) from Lukasz Majewski is already posted to mainline. Adding it here for completeness.
(http://www.mail-archive.com/[email protected]/msg17817.html)

Patch (thermal: exynos: Support thermal tripping ) from Jonghwan Choi is added here with some changes.
(https://patchwork.kernel.org/patch/1668371/)

Patch (thermal: exynos: Support for TMU regulator defined at device tree) is a repost of my earlier patch(https://patchwork-mail1.kernel.org/patch/2510771/) and adds regulator support.

Patch (ARM: dts: Add device tree node for exynos5440 TMU controller) and patch (arm: exynos: enable ARCH_HAS_TMU) can be merged through exynos platform maintainer as this can cause merge conflict.

All these patches are based on thermal maintainers git tree,
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next.

Amit Daniel Kachhap (29):
thermal: exynos: Moving exynos thermal files into samsung directory
thermal: exynos: Add ARCH_HAS_TMU config to know the supported soc's
thermal: exynos: Remove CPU_THERMAL dependency for using TMU driver
thermal: exynos: Bifurcate exynos thermal common and tmu controller
code
thermal: exynos: Rename exynos_thermal.c to exynos_tmu.c
thermal: exynos: Move exynos_thermal.h from include/* to driver/*
folder
thermal: exynos: Bifurcate exynos tmu driver and configuration data
thermal: exynos: Add missing definations and code cleanup
thermal: exynos: Add extra entries in the tmu platform data
thermal: exynos: Support thermal tripping
thermal: exynos: Move register definitions from driver file to data
file
thermal: exynos: Fix to clear only the generated interrupts
thermal: exynos: Add support for instance based register/unregister
thermal: exynos: Modify private_data to appropriate name driver_data
thermal: exynos: Return success even if no cooling data supplied
thermal: exynos: Make the zone handling dependent on trip count
thermal: exynos: Add support to handle many instances of TMU
thermal: exynos: Add TMU features to check instead of using SOC type
thermal: exynos: use device resource management infrastructure
thermal: exynos: Add support to access common register for
multistance
thermal: exynos: Add support for exynos5440 TMU sensor.
thermal: exynos: Fix to set the second point correction value
properly
thermal: exynos: Add thermal configuration data for exynos5440 TMU
sensor
thermal: exynos: Add a compensation logic on swapped e-fuse values
thermal: exynos: Add hardware mode thermal calibration support
Documentation: thermal: Explain the exynos thermal driver model
thermal: exynos: Support for TMU regulator defined at device tree
ARM: dts: Add device tree node for exynos5440 TMU controller
arm: exynos: enable ARCH_HAS_TMU

Lukasz Majewski (1):
ARM: dts: thermal: exynos4: Add documentation for Exynos SoC thermal
bindings

 .../devicetree/bindings/thermal/exynos-thermal.txt |   53 +
 Documentation/thermal/exynos_thermal               |   43 +-
 arch/arm/boot/dts/exynos5440.dtsi                  |   30 +
 arch/arm/mach-exynos/Kconfig                       |    5 +
 drivers/thermal/Kconfig                            |   13 +-
 drivers/thermal/Makefile                           |    2 +-
 drivers/thermal/exynos_thermal.c                   | 1066 --------------------
 drivers/thermal/samsung/Kconfig                    |   21 +
 drivers/thermal/samsung/Makefile                   |    7 +
 drivers/thermal/samsung/exynos_thermal_common.c    |  407 ++++++++
 drivers/thermal/samsung/exynos_thermal_common.h    |   98 ++
 drivers/thermal/samsung/exynos_tmu.c               |  741 ++++++++++++++
 drivers/thermal/samsung/exynos_tmu.h               |  294 ++++++
 drivers/thermal/samsung/exynos_tmu_data.c          |  225 ++++
 drivers/thermal/samsung/exynos_tmu_data.h          |  155 +++
 include/linux/platform_data/exynos_thermal.h       |  119 ---
 16 files changed, 2076 insertions(+), 1203 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/exynos-thermal.txt
 delete mode 100644 drivers/thermal/exynos_thermal.c
 create mode 100644 drivers/thermal/samsung/Kconfig
 create mode 100644 drivers/thermal/samsung/Makefile
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 create mode 100644 drivers/thermal/samsung/exynos_tmu.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu.h
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.h
 delete mode 100644 include/linux/platform_data/exynos_thermal.h
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin
#46 lore raw
Quoted 29 lines · Eduardo Valentin

Hi,

Quoted 16 lines · Eduardo Valentin
Quoted 15 lines · amit daniel kachhap

Hi Eduardo,

Quoted 10 lines · Eduardo Valentin
Quoted 5 lines · Amit Daniel Kachhap

Changes in V4:
Almost all the changes in this version is as per suggestion from Eduardo.The major ones are listed below,
* Added kconfig symbol ARCH_HAS_TMU which needs to be enabled by platform. With this change existing symbol EXYNOS_TMU_DATA is not needed.

I was more thinking if we could have a single flag that we could use in thermal drivers. Besides, my proposal for ARCH_HAS_BANDGAP is still not merged yet.

Quoted 8 lines
Quoted 2 lines

yes a single flag might be useful such as ARCH_HAS_THERMAL but this patch can work as an intermediate solution.

I think bandgap is a generic enough term IMO.

[1] - http://en.wikipedia.org/wiki/Bandgap_voltage_reference
[2] - http://en.wikipedia.org/wiki/Silicon_bandgap_temperature_sensor

Quoted 6 lines

Hit the send button too early. So, I think bandgap is a generic enough term. Using bandgap I believe it is better because its meaning has the implication of having a device to control thermal.

But if you feel more confident with the thermal term we can switch to something like HAS_THERMAL_CONTROL.

Even in my case TMU uses bandgap voltage reference circuit. so ARCH_HAS_BANDGAP should be fine.

Thanks,
Amit Daniel

Quoted 137 lines
Quoted 120 lines
Quoted 120 lines

Thanks,
Amit Daniel

Quoted 115 lines
Quoted 115 lines

* Movement of freq_clip_table from exynos_tmu.h to exynos_thermal_common.h is explained in the commit logs.
* Wrote all register description documentation.
* Split 5440 TMU support patch into controller change, configuration data and feature addition patches.
* Remove all *LINUX_* in the header files.
* Still regulator enable is kept optional but a TODO: comment is added to fix it later.

Changes in V3:
* Added proper dependency of different exynos thermal Kconfig symbols. Basically 3 Kconfig can be enabled now and corresponds to tmu driver. exynos common part and exynos configuration data. This issue was raised by Rui Zhang.

Changes in V2:
* Separated SOC data from TMU driver. This is as per suggestion from Eduardo.
* Merged the new file created for exynos5440 TMU controller with the existing TMU controller code.
* Removed the DT parsing code as now the SOC specific data are cleanly put inside the data specific file.
* Even the register definations/bitfields are treated as data as there is some variation across SOC's.

This patchset adds TMU(Thermal management Unit) driver support for exynos5440 platform. There are 3 instances of the TMU controllers so necessary cleanup/re-structure is done to handle multiple thermal zone.

Patch (exynos4: Add documentation for Exynos SoC thermal bindings) from Lukasz Majewski is already posted to mainline. Adding it here for completeness.
(http://www.mail-archive.com/[email protected]/msg17817.html)

Patch (thermal: exynos: Support thermal tripping ) from Jonghwan Choi is added here with some changes.
(https://patchwork.kernel.org/patch/1668371/)

Patch (thermal: exynos: Support for TMU regulator defined at device tree) is a repost of my earlier patch(https://patchwork-mail1.kernel.org/patch/2510771/) and adds regulator support.

Patch (ARM: dts: Add device tree node for exynos5440 TMU controller) and patch (arm: exynos: enable ARCH_HAS_TMU) can be merged through exynos platform maintainer as this can cause merge conflict.

All these patches are based on thermal maintainers git tree,
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next.

Amit Daniel Kachhap (29):
thermal: exynos: Moving exynos thermal files into samsung directory
thermal: exynos: Add ARCH_HAS_TMU config to know the supported soc's
thermal: exynos: Remove CPU_THERMAL dependency for using TMU driver
thermal: exynos: Bifurcate exynos thermal common and tmu controller
code
thermal: exynos: Rename exynos_thermal.c to exynos_tmu.c
thermal: exynos: Move exynos_thermal.h from include/* to driver/*
folder
thermal: exynos: Bifurcate exynos tmu driver and configuration data
thermal: exynos: Add missing definations and code cleanup
thermal: exynos: Add extra entries in the tmu platform data
thermal: exynos: Support thermal tripping
thermal: exynos: Move register definitions from driver file to data
file
thermal: exynos: Fix to clear only the generated interrupts
thermal: exynos: Add support for instance based register/unregister
thermal: exynos: Modify private_data to appropriate name driver_data
thermal: exynos: Return success even if no cooling data supplied
thermal: exynos: Make the zone handling dependent on trip count
thermal: exynos: Add support to handle many instances of TMU
thermal: exynos: Add TMU features to check instead of using SOC type
thermal: exynos: use device resource management infrastructure
thermal: exynos: Add support to access common register for
multistance
thermal: exynos: Add support for exynos5440 TMU sensor.
thermal: exynos: Fix to set the second point correction value
properly
thermal: exynos: Add thermal configuration data for exynos5440 TMU
sensor
thermal: exynos: Add a compensation logic on swapped e-fuse values
thermal: exynos: Add hardware mode thermal calibration support
Documentation: thermal: Explain the exynos thermal driver model
thermal: exynos: Support for TMU regulator defined at device tree
ARM: dts: Add device tree node for exynos5440 TMU controller
arm: exynos: enable ARCH_HAS_TMU

Lukasz Majewski (1):
ARM: dts: thermal: exynos4: Add documentation for Exynos SoC thermal
bindings

 .../devicetree/bindings/thermal/exynos-thermal.txt |   53 +
 Documentation/thermal/exynos_thermal               |   43 +-
 arch/arm/boot/dts/exynos5440.dtsi                  |   30 +
 arch/arm/mach-exynos/Kconfig                       |    5 +
 drivers/thermal/Kconfig                            |   13 +-
 drivers/thermal/Makefile                           |    2 +-
 drivers/thermal/exynos_thermal.c                   | 1066 --------------------
 drivers/thermal/samsung/Kconfig                    |   21 +
 drivers/thermal/samsung/Makefile                   |    7 +
 drivers/thermal/samsung/exynos_thermal_common.c    |  407 ++++++++
 drivers/thermal/samsung/exynos_thermal_common.h    |   98 ++
 drivers/thermal/samsung/exynos_tmu.c               |  741 ++++++++++++++
 drivers/thermal/samsung/exynos_tmu.h               |  294 ++++++
 drivers/thermal/samsung/exynos_tmu_data.c          |  225 ++++
 drivers/thermal/samsung/exynos_tmu_data.h          |  155 +++
 include/linux/platform_data/exynos_thermal.h       |  119 ---
 16 files changed, 2076 insertions(+), 1203 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/exynos-thermal.txt
 delete mode 100644 drivers/thermal/exynos_thermal.c
 create mode 100644 drivers/thermal/samsung/Kconfig
 create mode 100644 drivers/thermal/samsung/Makefile
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 create mode 100644 drivers/thermal/samsung/exynos_tmu.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu.h
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.h
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
 delete mode 100644 include/linux/platform_data/exynos_thermal.h

--
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin

#47 lore raw

Hi,

Quoted 35 lines · amit daniel kachhap
Quoted 33 lines · Eduardo Valentin

Hi,

Quoted 16 lines · Eduardo Valentin
Quoted 15 lines · amit daniel kachhap

Hi Eduardo,

Quoted 10 lines · Eduardo Valentin
Quoted 5 lines · Amit Daniel Kachhap

Changes in V4:
Almost all the changes in this version is as per suggestion from Eduardo.The major ones are listed below,
* Added kconfig symbol ARCH_HAS_TMU which needs to be enabled by platform. With this change existing symbol EXYNOS_TMU_DATA is not needed.

I was more thinking if we could have a single flag that we could use in thermal drivers. Besides, my proposal for ARCH_HAS_BANDGAP is still not merged yet.

Quoted 8 lines
Quoted 2 lines

yes a single flag might be useful such as ARCH_HAS_THERMAL but this patch can work as an intermediate solution.

I think bandgap is a generic enough term IMO.

[1] - http://en.wikipedia.org/wiki/Bandgap_voltage_reference
[2] - http://en.wikipedia.org/wiki/Silicon_bandgap_temperature_sensor

Hit the send button too early. So, I think bandgap is a generic enough term. Using bandgap I believe it is better because its meaning has the implication of having a device to control thermal.

Quoted 6 lines
Quoted 2 lines

But if you feel more confident with the thermal term we can switch to something like HAS_THERMAL_CONTROL.

Even in my case TMU uses bandgap voltage reference circuit. so ARCH_HAS_BANDGAP should be fine.

OK cool! then we have a consensus.

I am trying for some time already to push this patch here:
https://patchwork.kernel.org/patch/2659001/

Tony, Arnd?

Any objections having the patch above in?

Quoted 141 lines

Thanks,
Amit Daniel

Quoted 137 lines
Quoted 120 lines
Quoted 120 lines

Thanks,
Amit Daniel

Quoted 115 lines
Quoted 115 lines

* Movement of freq_clip_table from exynos_tmu.h to exynos_thermal_common.h is explained in the commit logs.
* Wrote all register description documentation.
* Split 5440 TMU support patch into controller change, configuration data and feature addition patches.
* Remove all *LINUX_* in the header files.
* Still regulator enable is kept optional but a TODO: comment is added to fix it later.

Changes in V3:
* Added proper dependency of different exynos thermal Kconfig symbols. Basically 3 Kconfig can be enabled now and corresponds to tmu driver. exynos common part and exynos configuration data. This issue was raised by Rui Zhang.

Changes in V2:
* Separated SOC data from TMU driver. This is as per suggestion from Eduardo.
* Merged the new file created for exynos5440 TMU controller with the existing TMU controller code.
* Removed the DT parsing code as now the SOC specific data are cleanly put inside the data specific file.
* Even the register definations/bitfields are treated as data as there is some variation across SOC's.

This patchset adds TMU(Thermal management Unit) driver support for exynos5440 platform. There are 3 instances of the TMU controllers so necessary cleanup/re-structure is done to handle multiple thermal zone.

Patch (exynos4: Add documentation for Exynos SoC thermal bindings) from Lukasz Majewski is already posted to mainline. Adding it here for completeness.
(http://www.mail-archive.com/[email protected]/msg17817.html)

Patch (thermal: exynos: Support thermal tripping ) from Jonghwan Choi is added here with some changes.
(https://patchwork.kernel.org/patch/1668371/)

Patch (thermal: exynos: Support for TMU regulator defined at device tree) is a repost of my earlier patch(https://patchwork-mail1.kernel.org/patch/2510771/) and adds regulator support.

Patch (ARM: dts: Add device tree node for exynos5440 TMU controller) and patch (arm: exynos: enable ARCH_HAS_TMU) can be merged through exynos platform maintainer as this can cause merge conflict.

All these patches are based on thermal maintainers git tree,
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next.

Amit Daniel Kachhap (29):
thermal: exynos: Moving exynos thermal files into samsung directory
thermal: exynos: Add ARCH_HAS_TMU config to know the supported soc's
thermal: exynos: Remove CPU_THERMAL dependency for using TMU driver
thermal: exynos: Bifurcate exynos thermal common and tmu controller
code
thermal: exynos: Rename exynos_thermal.c to exynos_tmu.c
thermal: exynos: Move exynos_thermal.h from include/* to driver/*
folder
thermal: exynos: Bifurcate exynos tmu driver and configuration data
thermal: exynos: Add missing definations and code cleanup
thermal: exynos: Add extra entries in the tmu platform data
thermal: exynos: Support thermal tripping
thermal: exynos: Move register definitions from driver file to data
file
thermal: exynos: Fix to clear only the generated interrupts
thermal: exynos: Add support for instance based register/unregister
thermal: exynos: Modify private_data to appropriate name driver_data
thermal: exynos: Return success even if no cooling data supplied
thermal: exynos: Make the zone handling dependent on trip count
thermal: exynos: Add support to handle many instances of TMU
thermal: exynos: Add TMU features to check instead of using SOC type
thermal: exynos: use device resource management infrastructure
thermal: exynos: Add support to access common register for
multistance
thermal: exynos: Add support for exynos5440 TMU sensor.
thermal: exynos: Fix to set the second point correction value
properly
thermal: exynos: Add thermal configuration data for exynos5440 TMU
sensor
thermal: exynos: Add a compensation logic on swapped e-fuse values
thermal: exynos: Add hardware mode thermal calibration support
Documentation: thermal: Explain the exynos thermal driver model
thermal: exynos: Support for TMU regulator defined at device tree
ARM: dts: Add device tree node for exynos5440 TMU controller
arm: exynos: enable ARCH_HAS_TMU

Lukasz Majewski (1):
ARM: dts: thermal: exynos4: Add documentation for Exynos SoC thermal
bindings

 .../devicetree/bindings/thermal/exynos-thermal.txt |   53 +
 Documentation/thermal/exynos_thermal               |   43 +-
 arch/arm/boot/dts/exynos5440.dtsi                  |   30 +
 arch/arm/mach-exynos/Kconfig                       |    5 +
 drivers/thermal/Kconfig                            |   13 +-
 drivers/thermal/Makefile                           |    2 +-
 drivers/thermal/exynos_thermal.c                   | 1066 --------------------
 drivers/thermal/samsung/Kconfig                    |   21 +
 drivers/thermal/samsung/Makefile                   |    7 +
 drivers/thermal/samsung/exynos_thermal_common.c    |  407 ++++++++
 drivers/thermal/samsung/exynos_thermal_common.h    |   98 ++
 drivers/thermal/samsung/exynos_tmu.c               |  741 ++++++++++++++
 drivers/thermal/samsung/exynos_tmu.h               |  294 ++++++
 drivers/thermal/samsung/exynos_tmu_data.c          |  225 ++++
 drivers/thermal/samsung/exynos_tmu_data.h          |  155 +++
 include/linux/platform_data/exynos_thermal.h       |  119 ---
 16 files changed, 2076 insertions(+), 1203 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/exynos-thermal.txt
 delete mode 100644 drivers/thermal/exynos_thermal.c
 create mode 100644 drivers/thermal/samsung/Kconfig
 create mode 100644 drivers/thermal/samsung/Makefile
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.c
 create mode 100644 drivers/thermal/samsung/exynos_thermal_common.h
 create mode 100644 drivers/thermal/samsung/exynos_tmu.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu.h
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.c
 create mode 100644 drivers/thermal/samsung/exynos_tmu_data.h
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
 delete mode 100644 include/linux/platform_data/exynos_thermal.h

--
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin

Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin