Skip to contentSkip to conversation

ARM: imx: Add basic imx6q thermal management

RFC PATCH Superseded Robert Lee 2 participants 3 messages Jan 19, 2012 – Jun 13, 2012

Subsystems (4)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Robert Lee

author
#0 lore raw

RFC PATCH v4 1/1 ARM: imx: Add basic imx6q thermal management

Based on v3.2 plus recently submitted cpu_cooling functionality here:

http://www.spinics.net/lists/linux-pm/msg26500.html

link to previous submissions:
v3: http://www.spinics.net/lists/arm-kernel/msg155955.html
v2: http://www.spinics.net/lists/arm-kernel/msg155790.html
v1: http://www.spinics.net/lists/arm-kernel/msg155111.html

Changes in v4:
1. Removed bad suspend/resume assignment into thermal class. After further examination and discussion with SoC designers, a sequence is now used for making measurements that is is unaffected by system suspendresumes. Temp Sensor automatically powers off in hardware during the low power mode caused by a system suspend.
2. Moved some structures from static to dynamic allocation.
3. Added some noise handling to temperatuer sensor readings.

Changes in v3:
1. Fixed the various issues pointed out in v2
2. Made other code cleanup and a bit of re-organizing
3. Removed unecessary platform driver and device.

Changes in v2:
1. Cleaned up some style issues pointed out in v1
2. Made various other code cleanup and re-organizing
3. Added temperature sensor calibration
4. Created platform driver and device to hook into pm suspend.

Performed some basic testing to ensure proper cooling operating. If you want to test this, full testing requires imx6q cpufreq implementation (not yet in v3.2) and requires an imx6q part that has temperature sensor calibration fuses correctly burned.

Robert Lee (1):
ARM: imx: Add basic imx6q thermal management

 arch/arm/boot/dts/imx6q.dtsi    |    1 +
 drivers/thermal/Kconfig         |    6 +
 drivers/thermal/Makefile        |    1 +
 drivers/thermal/imx6q_thermal.c |  540 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 548 insertions(+), 0 deletions(-)
 create mode 100644 drivers/thermal/imx6q_thermal.c
author
#1 lore raw

RFC PATCH v4 1/1 ARM: imx: Add basic imx6q thermal management

Adds support for temperature sensor readings, registers with common thermal framework, and uses the new common cpu_cooling interface.

---
 arch/arm/boot/dts/imx6q.dtsi    |    1 +
 drivers/thermal/Kconfig         |    6 +
 drivers/thermal/Makefile        |    1 +
 drivers/thermal/imx6q_thermal.c |  540 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 548 insertions(+), 0 deletions(-)
 create mode 100644 drivers/thermal/imx6q_thermal.c
arch/arm/boot/dts/imx6q.dtsi +1 -0
index 7dda599..d62b88d 100644
@@ -508,6 +508,7 @@
 			};
 
 			ocotp at 021bc000 {
+				compatible = "fsl,imx6q-ocotp";
 				reg = <0x021bc000 0x4000>;
 			};
 
drivers/thermal/Kconfig +6 -0
index 298c1cd..dd8cede 100644
@@ -29,3 +29,9 @@ config CPU_THERMAL
 	  This will be useful for platforms using the generic thermal interface
 	  and not the ACPI interface.
 	  If you want this support, you should say Y or M here.
+
+config IMX6Q_THERMAL
+	bool "IMX6Q Thermal interface support"
+	depends on THERMAL && CPU_THERMAL
+	help
+	  Adds thermal management for IMX6Q.
drivers/thermal/Makefile +1 -0
index 655cbc4..e2bcffe 100644
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_THERMAL)		+= thermal_sys.o
 obj-$(CONFIG_CPU_THERMAL)	+= cpu_cooling.o
+obj-$(CONFIG_IMX6Q_THERMAL)	+= imx6q_thermal.o
drivers/thermal/imx6q_thermal.c new file +540 -0

540 lines not on this page · raw message

Signature · 1 line
1.7.1
#2 lore raw
Quoted 11 lines · Robert Lee

Adds support for temperature sensor readings, registers with common thermal framework, and uses the new common cpu_cooling interface.

---
 arch/arm/boot/dts/imx6q.dtsi    |    1 +
 drivers/thermal/Kconfig         |    6 +
 drivers/thermal/Makefile        |    1 +
 drivers/thermal/imx6q_thermal.c |  540 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 548 insertions(+), 0 deletions(-)
 create mode 100644 drivers/thermal/imx6q_thermal.c

...

Quoted 19 lines
(quoted diff) +19 -0
+static int __init imx6q_thermal_init(void)
+{
+       struct device_node *np_ocotp, *np_anatop;
+       unsigned int fuse_data;
+       int ret;
+
+       np_ocotp = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ocotp");
+       np_anatop = of_find_compatible_node(NULL, NULL, "fsl,imx6q-anatop");
+
+       if (!(np_ocotp && np_anatop))
+               return -ENXIO; /* not a compatible platform */
+
+       ocotp_base = of_iomap(np_ocotp, 0);
+
+       if (!ocotp_base) {
+               pr_err("Could not retrieve ocotp-base\n");
+               ret = -ENXIO;
+               goto err_unregister;
+       }

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+       anatop_base = of_iomap(np_anatop, 0);
+
+       if (!anatop_base) {
+               pr_err("Could not retrieve anantop-base\n");
+               ret = -ENXIO;
+               goto err_unregister;
+       }
+
+       fuse_data = readl_relaxed(ocotp_base + HW_OCOTP_ANA1);

To be able to use this on non-calibrated sample devices, we had to add [1].

Best regards

Dirk

[1]

From: Ying-Chun Liu (PaulLiu) <[email protected]>
Subject: [PATCH] ARM: imx6: thermal: Add workaround for missing calibration data

Sample devices not calibrated in the production don't have the fuses containing the calibration data. Hardcode this value if the fuse data read is zero to be able to use the thermal functinality on these sample devices, too.

---
 drivers/thermal/imx6q_thermal.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/thermal/imx6q_thermal.c +2 -0
index 76b7ba1..543cd75 100644
@@ -446,6 +446,8 @@ static int __init imx6q_thermal_init(void)
 	}
 
 	fuse_data = readl_relaxed(ocotp_base + HW_OCOTP_ANA1);
+	if (fuse_data == 0)
+		fuse_data = 0x5704c67d;
 
 	th_zone = kzalloc(sizeof(struct imx6q_thermal_zone), GFP_KERNEL);
 	if (!th_zone) {
Signature · 1 line
1.7.0.4