From patchwork Thu Aug 1 06:02:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Krishna Chatradhi X-Patchwork-Id: 2836756 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CC6B5C0319 for ; Thu, 1 Aug 2013 06:08:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B5682201E4 for ; Thu, 1 Aug 2013 06:08:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0CF8C201B7 for ; Thu, 1 Aug 2013 06:08:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753632Ab3HAGIH (ORCPT ); Thu, 1 Aug 2013 02:08:07 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:13828 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752840Ab3HAGIE (ORCPT ); Thu, 1 Aug 2013 02:08:04 -0400 Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MQU003UI91EANG0@mailout4.samsung.com>; Thu, 01 Aug 2013 15:08:03 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id 0C.CA.11618.24BF9F15; Thu, 01 Aug 2013 15:08:02 +0900 (KST) X-AuditID: cbfee691-b7fef6d000002d62-01-51f9fb423859 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 64.EB.32250.24BF9F15; Thu, 01 Aug 2013 15:08:02 +0900 (KST) Received: from naveen-linux.sisodomain.com ([107.108.83.161]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MQU00B2L918PU20@mmp1.samsung.com>; Thu, 01 Aug 2013 15:08:02 +0900 (KST) From: Naveen Krishna Chatradhi 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 Message-id: <1375336979-14747-1-git-send-email-ch.naveen@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRmVeSWpSXmKPExsWyRsSkWtfp989Agy9dFhYNV0Ms1uz/yWTR u+Aqm8XlXXPYLD73HmG0mHF+H5PFom3/mS2ePOxjc+Dw2DnrLrvH4j0vmTz6tqxi9Dh+YzuT x+dNcgGsUVw2Kak5mWWpRfp2CVwZO18oFzzSqmi5x9PA2KbcxcjJISFgIvH3fAMbhC0mceHe eiCbi0NIYCmjxLcdC5lhik5NuMkMkVjEKPFw7VYWCKeHSaKlbykTSBWbgJnEwUWr2UFsEQEv iVkPrzKBFDELTGSUuLv2GCNIQljAQ+L14ldgNouAqsTmQzOAxnJw8Aq4Skz6YQFiSggoSMyZ ZAPSKiHQzS4xsXEmG0S5gMS3yYdYIGpkJTYdgDpOUuLgihssExgFFzAyrGIUTS1ILihOSi8y 1StOzC0uzUvXS87P3cQIDN3T/55N3MF4/4D1IcZkoHETmaVEk/OBoZ9XEm9obGZkYWpiamxk bmlGmrCSOK96i3WgkEB6YklqdmpqQWpRfFFpTmrxIUYmDk6pBsZ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pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Doug Anderson --- 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 #include #include +#include #include #include /* 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);