All of lore.kernel.org
 help / color / mirror / Atom feed
From: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
To: linux-pm@vger.kernel.org, rui.zhang@intel.com, eduardo.valentin@ti.com
Cc: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
	amit.daniel@samsung.com, kgene.kim@samsung.com,
	naveenkrishna.ch@gmail.com
Subject: [PATCH] thermal: exynos: Handle the misplaced TRIMINFO register
Date: Thu, 01 Aug 2013 11:32:59 +0530	[thread overview]
Message-ID: <1375336979-14747-1-git-send-email-ch.naveen@samsung.com> (raw)

This patch adds code to handle the misplaced TRIMINFO register
incase of Exynos5420.

On Exynos5420 we have a TRIMINFO register being misplaced for
TMU channels 2, 3 and 4

TRIMINFO at 0x1006c000 contains data for TMU channel 3
TRIMINFO at 0x100a0000 contains data for TMU channel 4
TRIMINFO at 0x10068000 contains data for TMU channel 2

The misplaced register address is passed through devicetree and
map it seperately during probe.
Also, adds the documentation under devicetree/bindings/thermal/

Signed-off-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
Reviewed-by: Doug Anderson <dianders@chromium.org>
---

Rebased on http://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
master branch. I'm not sure which one is the right tree to rebase.

 .../devicetree/bindings/thermal/exynos-thermal.txt | 48 ++++++++++++++++++++++
 drivers/thermal/exynos_thermal.c                   | 26 +++++++++++-
 2 files changed, 72 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/exynos-thermal.txt

diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
new file mode 100644
index 0000000..1db279e
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
@@ -0,0 +1,48 @@
+* Exynos Thermal
+
+Required properties:
+- compatible: should be one of the following.
+    * "samsung,exynos4210-tmu" - for controllers compatible with exynos4210 tmu.
+    * "samsung,exynos5250-tmu" - for controllers compatible with exynos5250 tmu.
+    * "samsung,exynos5420-tmu" - for controllers compatible with exynos5420 tmu.
+
+- reg: physical base address of the controller and length of
+  memory mapped region.
+
+    ** NOTE FOR EXYNOS5420 **
+    TRIMINFO register is being misplaced for TMU channels 2, 3 and 4
+
+    TERMINFO for TMU channel 2 is present in address space of TMU channel 3
+    TERMINFO for TMU channel 3 is present in address space of TMU channel 4
+    TERMINFO for TMU channel 4 is present in address space of TMU channel 2
+
+    * In such cases the reg property contains the misplaced register address and
+      range as the second parameter.
+
+- interrupts : interrupt number to the cpu.
+- clocks : Clock number as per common clock framework for the cpu.
+- clock-names : clock name to be used in the driver
+
+Example:
+
+	/* tmu for CPU0 */
+	tmu@10060000 {
+		compatible = "samsung,exynos5420-tmu";
+		reg = <0x10060000 0x100>;
+		interrupts = <0 65 0>;
+		clocks = <&clock 318>;
+		clock-names = "tmu_apbif";
+	};
+
+Example: In case of Exynos5420 TMU channel 3
+
+	/* tmu for CPU3 */
+	tmu@1006c000 {
+		compatible = "samsung,exynos5420-tmu";
+		/* 2nd reg is for the misplaced TRIMINFO register */
+		reg = <0x1006c000 0x100>, <0x100a0000 0x4>;
+		interrupts = <0 185 0>;
+		clocks = <&clock 318>;
+		clock-names = "tmu_apbif";
+	};
+
diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
index cec3f1f..a229314 100644
--- a/drivers/thermal/exynos_thermal.c
+++ b/drivers/thermal/exynos_thermal.c
@@ -38,6 +38,7 @@
 #include <linux/cpufreq.h>
 #include <linux/cpu_cooling.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 
 #include <plat/cpu.h>
 #include <mach/regs-pmu.h>	/* for EXYNOS5_PS_HOLD_CONTROL */
@@ -123,7 +124,7 @@ struct exynos_thermal_zone;
 struct exynos_tmu_data {
 	struct exynos_tmu_platform_data *pdata;
 	struct resource *mem;
-	void __iomem *base;
+	void __iomem *base, *triminfo_base;
 	int irq;
 	enum soc_type soc;
 	struct work_struct irq_work;
@@ -665,8 +666,14 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 		__raw_writel(EXYNOS_TRIMINFO_RELOAD,
 				data->base + EXYNOS_TMU_TRIMINFO_CON);
 	}
+
 	/* Save trimming info in order to perform calibration */
-	trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
+	if (data->triminfo_base)
+		/* On exynos5420 TRIMINFO is misplaced for some channels */
+		trim_info = readl(data->triminfo_base);
+	else
+		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);
 
@@ -1016,6 +1023,15 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	/* For Exynos5420 The misplaced TERMINFO register address will be
+	 * passed from device tree node.
+	 *
+	 * We cannot use devm_request_and_ioremap, as the base address
+	 * over laps with the address space of the other TMU channel.
+	 * Check Documentation for details
+	 */
+	data->triminfo_base = of_iomap(pdev->dev.of_node, 1);
+
 	data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
 	if (IS_ERR(data->clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
@@ -1086,6 +1102,9 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 err_irq:
 	exynos_unregister_thermal(data);
 err_clk:
+	if (data->triminfo_base)
+		iounmap(data->triminfo_base);
+
 	platform_set_drvdata(pdev, NULL);
 	clk_unprepare(data->clk);
 	return ret;
@@ -1100,6 +1119,9 @@ static int exynos_tmu_remove(struct platform_device *pdev)
 
 	exynos_unregister_thermal(data);
 
+	if (data->triminfo_base)
+		iounmap(data->triminfo_base);
+
 	clk_unprepare(data->clk);
 
 	platform_set_drvdata(pdev, NULL);
-- 
1.7.12.4


             reply	other threads:[~2013-08-01  6:08 UTC|newest]

Thread overview: 141+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-01  6:02 Naveen Krishna Chatradhi [this message]
2013-08-01  8:32 ` [PATCH] thermal: exynos: Handle the misplaced TRIMINFO register amit daniel kachhap
2013-08-01  8:48   ` Naveen Krishna Ch
2013-08-01 10:36 ` [PATCH v2] " Naveen Krishna Chatradhi
2013-08-07  6:36   ` amit daniel kachhap
2013-08-07  6:43     ` Naveen Krishna Ch
2013-08-28  5:45 ` [PATCH 0/3] thermal: samsung: Add TMU for Exynos5420 Naveen Krishna Chatradhi
2013-08-28  5:45   ` [PATCH 1/3] thermal: samsung: correct the fall interrupt en, status bit fields Naveen Krishna Chatradhi
2013-08-28  5:57     ` amit daniel kachhap
2013-08-28  5:57       ` amit daniel kachhap
2013-09-04  4:23     ` Naveen Krishna Chatradhi
2013-09-04  4:23       ` [PATCH 2/3] thermal: samsung: change base_common to more meaningful base_second Naveen Krishna Chatradhi
2013-09-06  4:38         ` amit daniel kachhap
2013-09-06  4:38           ` amit daniel kachhap
2013-10-16  2:52         ` [PATCH 2/3 v5] " Naveen Krishna Chatradhi
2013-10-17  3:12         ` [PATCH 2/3 v6] " Naveen Krishna Chatradhi
2013-11-06 13:28         ` [PATCH 2/3 v7] " Naveen Krishna Chatradhi
2013-11-06 13:28           ` Naveen Krishna Chatradhi
2013-11-07  5:53         ` [PATCH 2/3 v8] " Naveen Krishna Chatradhi
2013-11-12  6:36         ` [PATCH 2/4 v9] " Naveen Krishna Chatradhi
2013-11-18  3:24           ` Naveen Krishna Ch
2013-11-18  3:24             ` Naveen Krishna Ch
2013-11-19 13:04         ` [PATCH 2/4 v10] " Naveen Krishna Chatradhi
2013-11-22  8:56           ` Naveen Krishna Ch
2013-11-22  8:56             ` Naveen Krishna Ch
2013-12-09 12:48           ` Tomasz Figa
2013-12-10  6:41         ` [PATCH v11 2/4] " Naveen Krishna Chatradhi
2013-12-18 15:51           ` Tomasz Figa
2013-12-19  6:06         ` [PATCH v12 " Naveen Krishna Chatradhi
2014-02-07  9:35           ` Naveen Krishna Ch
2014-02-07  9:35             ` Naveen Krishna Ch
2013-09-04  4:23       ` [PATCH 3/3] thermal: samsung: Add TMU support for Exynos5420 SoCs Naveen Krishna Chatradhi
2013-10-03 12:01         ` Naveen Krishna Ch
2013-10-03 12:01           ` Naveen Krishna Ch
2013-10-03 12:42           ` Bartlomiej Zolnierkiewicz
2013-10-03 12:42             ` Bartlomiej Zolnierkiewicz
2013-10-09 11:45             ` Naveen Krishna Ch
2013-10-09 11:45               ` Naveen Krishna Ch
2013-10-09 12:08         ` [PATCH 1/3 v4] thermal: samsung: correct the fall interrupt en, status bit fields Naveen Krishna Chatradhi
2013-10-09 12:08           ` [PATCH 2/3 v4] thermal: samsung: change base_common to more meaningful base_second Naveen Krishna Chatradhi
2013-10-14 13:47             ` Eduardo Valentin
2013-10-14 13:47               ` Eduardo Valentin
2013-10-09 12:08           ` [PATCH 3/3 v4] thermal: samsung: Add TMU support for Exynos5420 SoCs Naveen Krishna Chatradhi
2013-10-09 14:03           ` [PATCH 1/3 v4] thermal: samsung: correct the fall interrupt en, status bit fields Bartlomiej Zolnierkiewicz
2013-10-11 15:10             ` Eduardo Valentin
2013-10-11 15:10               ` Eduardo Valentin
2013-10-11 15:57               ` Bartlomiej Zolnierkiewicz
2013-10-14 14:18                 ` Eduardo Valentin
2013-10-14 14:18                   ` Eduardo Valentin
2013-10-14 16:01                   ` Bartlomiej Zolnierkiewicz
2013-10-15 11:39                     ` Naveen Krishna Ch
2013-10-15 11:39                       ` Naveen Krishna Ch
2013-10-14 13:56             ` Eduardo Valentin
2013-10-14 13:56               ` Eduardo Valentin
2013-11-06 13:28         ` [PATCH 3/3 v7] thermal: samsung: Add TMU support for Exynos5420 SoCs Naveen Krishna Chatradhi
2013-11-06 13:44           ` Bartlomiej Zolnierkiewicz
2013-11-07  5:53         ` [PATCH 3/3 v8] " Naveen Krishna Chatradhi
2013-11-07 15:09           ` Tomasz Figa
2013-11-12  6:19             ` Naveen Krishna Ch
2013-11-12  6:19               ` Naveen Krishna Ch
2013-11-12  6:37         ` [PATCH 3/4 v9] " Naveen Krishna Chatradhi
2013-11-18  3:22           ` Naveen Krishna Ch
2013-11-18  3:22             ` Naveen Krishna Ch
2013-11-18 11:27             ` Mark Rutland
2013-11-18 11:27               ` Mark Rutland
2013-12-09 12:43           ` Tomasz Figa
2013-11-19 13:05         ` [PATCH 3/4 v10] " Naveen Krishna Chatradhi
2013-11-22  8:55           ` Naveen Krishna Ch
2013-11-22  8:55             ` Naveen Krishna Ch
2013-12-09 12:46           ` Tomasz Figa
2013-12-10  6:42         ` [PATCH v11 3/4] " Naveen Krishna Chatradhi
2013-12-18 15:50           ` Tomasz Figa
2013-12-19  4:44             ` Naveen Krishna Ch
2013-12-19  4:44               ` Naveen Krishna Ch
2013-12-19  6:06         ` [PATCH v12 " Naveen Krishna Chatradhi
2013-12-19  6:06           ` Naveen Krishna Chatradhi
2013-12-19 11:34           ` Tomasz Figa
2014-02-07  9:34             ` Naveen Krishna Ch
2014-02-07  9:34               ` Naveen Krishna Ch
2013-10-16  2:51     ` [PATCH 1/3 v5] thermal: samsung: correct the fall interrupt en, status bit fields Naveen Krishna Chatradhi
2013-10-16 10:06       ` Bartlomiej Zolnierkiewicz
2013-10-16 11:05         ` Bartlomiej Zolnierkiewicz
2013-10-17  3:11     ` [PATCH 1/3 v6] thermal: samsung: add intclr_fall_shift bit in exynos_tmu_register Naveen Krishna Chatradhi
2013-10-17 10:03       ` Bartlomiej Zolnierkiewicz
2013-10-17 10:03         ` Bartlomiej Zolnierkiewicz
2013-11-06 13:17         ` Naveen Krishna Ch
2013-11-06 13:17           ` Naveen Krishna Ch
2013-11-06 13:36           ` Bartlomiej Zolnierkiewicz
2013-11-06 13:36             ` Bartlomiej Zolnierkiewicz
2013-11-06 13:27       ` [PATCH 1/3 v7] " Naveen Krishna Chatradhi
2013-11-07  5:52       ` [PATCH 1/3 v8] thermal: samsung: add intclr_fall_shift bit in exynos_tmu_register struct Naveen Krishna Chatradhi
2013-11-07 10:48         ` Bartlomiej Zolnierkiewicz
2013-11-07 10:58           ` Naveen Krishna Ch
2013-11-07 10:58             ` Naveen Krishna Ch
2013-11-07 14:47         ` Tomasz Figa
2013-11-07 14:47           ` Tomasz Figa
2013-11-12  6:36         ` [PATCH 1/4 v9] thermal: samsung: replace inten_ bit fields with intclr_ Naveen Krishna Chatradhi
2013-11-18  3:25           ` Naveen Krishna Ch
2013-11-18  3:25             ` Naveen Krishna Ch
2013-11-19 13:04           ` [PATCH 1/4 v10] " Naveen Krishna Chatradhi
2013-12-09 12:51             ` Tomasz Figa
2013-12-10  6:41           ` [PATCH v11 1/4] " Naveen Krishna Chatradhi
2013-12-18 15:51             ` Tomasz Figa
2013-12-19  6:05           ` [PATCH v12 " Naveen Krishna Chatradhi
2013-12-19  6:05             ` Naveen Krishna Chatradhi
2014-01-02  2:33             ` Zhang Rui
2014-02-07  9:33               ` Naveen Krishna Ch
2014-02-07  9:33                 ` Naveen Krishna Ch
2014-04-10 12:43                 ` Bartlomiej Zolnierkiewicz
2014-04-10 12:43                   ` Bartlomiej Zolnierkiewicz
2013-08-28  5:45   ` [PATCH 2/3] thermal: samsung: Add TMU support for Exynos5420 SoCs Naveen Krishna Chatradhi
2013-08-28  5:58     ` amit daniel kachhap
2013-08-28  5:58       ` amit daniel kachhap
2013-08-28  9:28     ` amit daniel kachhap
2013-08-28  9:28       ` amit daniel kachhap
2013-10-16  2:52     ` [PATCH 3/3 v5] " Naveen Krishna Chatradhi
2013-10-17  3:12     ` [PATCH 3/3 v6] " Naveen Krishna Chatradhi
2013-08-28  5:45   ` [PATCH 3/3] thermal: exynos: Handle the misplaced TRIMINFO register Naveen Krishna Chatradhi
2013-08-28  6:03     ` amit daniel kachhap
2013-08-28  6:03       ` amit daniel kachhap
2013-08-28  6:19       ` Naveen Krishna Ch
2013-08-28  6:19         ` Naveen Krishna Ch
2013-08-28  8:43         ` amit daniel kachhap
2013-08-28  8:43           ` amit daniel kachhap
2013-08-28  8:57           ` Naveen Krishna Ch
2013-08-28  8:57             ` Naveen Krishna Ch
2013-08-28  9:04             ` amit daniel kachhap
2013-08-28  9:04               ` amit daniel kachhap
2013-08-28 10:06     ` Bartlomiej Zolnierkiewicz
2013-11-12  6:35   ` [PATCH 0/3] thermal: samsung: Clean up and add support for Exynos5420 Naveen Krishna Chatradhi
2013-11-18  3:25     ` Naveen Krishna Ch
2013-11-18  3:25       ` Naveen Krishna Ch
2013-12-10  6:40     ` [PATCH v11 0/4] " Naveen Krishna Chatradhi
2014-03-19 11:19       ` Leela Krishna Amudala
2014-03-19 15:58         ` Tomasz Figa
2014-03-20  2:45           ` Naveen Krishna Ch
2014-04-08  9:33             ` Javi Merino
2013-08-28  9:16 ` [PATCH 1/3 v2] thermal: samsung: correct the fall interrupt en, status bit fields Naveen Krishna Chatradhi
2013-08-28  9:16   ` [PATCH 2/3] thermal: samsung: change base_common to more meaningful base_second Naveen Krishna Chatradhi
2013-08-28  9:16   ` [PATCH v2: 3/3] thermal: samsung: Add TMU support for Exynos5420 SoCs Naveen Krishna Chatradhi
2013-08-28 10:38     ` Bartlomiej Zolnierkiewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1375336979-14747-1-git-send-email-ch.naveen@samsung.com \
    --to=ch.naveen@samsung.com \
    --cc=amit.daniel@samsung.com \
    --cc=eduardo.valentin@ti.com \
    --cc=kgene.kim@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=naveenkrishna.ch@gmail.com \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.