From patchwork Tue May 6 08:51:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Dubey X-Patchwork-Id: 4120021 Return-Path: X-Original-To: patchwork-linux-arm@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 BD380BFF02 for ; Tue, 6 May 2014 08:36:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B60862020E for ; Tue, 6 May 2014 08:36:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9ABD920204 for ; Tue, 6 May 2014 08:36:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Whaot-0002gZ-9r; Tue, 06 May 2014 08:33:47 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Whaok-0002Zo-6U for linux-arm-kernel@lists.infradead.org; Tue, 06 May 2014 08:33:39 +0000 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N55007G893EVD60@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 06 May 2014 17:33:14 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.48]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 81.88.14563.A4E98635; Tue, 06 May 2014 17:33:14 +0900 (KST) X-AuditID: cbfee68e-b7fd86d0000038e3-6d-53689e4ac56a Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 8D.83.27725.A4E98635; Tue, 06 May 2014 17:33:14 +0900 (KST) Received: from localhost.localdomain ([12.36.165.191]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N5500HCR939SX00@mmp2.samsung.com>; Tue, 06 May 2014 17:33:14 +0900 (KST) From: Pankaj Dubey To: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 1/6] i2c: s3c2410: Moving I2C interrupt re-configuration code into i2c driver Date: Tue, 06 May 2014 17:51:17 +0900 Message-id: <1399366282-4191-2-git-send-email-pankaj.dubey@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1399366282-4191-1-git-send-email-pankaj.dubey@samsung.com> References: <1399366282-4191-1-git-send-email-pankaj.dubey@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRmVeSWpSXmKPExsVy+t8zA12veRnBBns/y1r8nXSM3WL+kXOs Fr0LrrJZbHp8jdViYdsSFouOv18YLS7vmsNmMeP8PiaL25d5LRZt/cJu8fbOdBaL1r1H2C3W z3jNYrHyxCxmBz6PluYeNo/fvyYxemxeoeWxaVUnm8fmJfUefVtWMXqcPPWExePzJrkAjigu m5TUnMyy1CJ9uwSujN3Hf7IWnLSo2DDtOXMD40ndLkZODgkBE4k739ewQ9hiEhfurWfrYuTi EBJYxiix4fYrVpii02dfMUIkpjNKfGw4A+W0MUm8XnSUBaSKTUBX4sn7ucwgtohAtsSVxvvM IEXMAheYJDo3L2IDSQgLJElc+3odyObgYBFQlfh/qRYkzCvgDjR0GjNIWEJAQWLOJBuQMKeA h8Sba2/BjhACKtlx/zbYdRICL9klfrU/B0uwCAhIfJt8iAWiV1Zi0wFmiKMlJQ6uuMEygV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iYNTqoFRsSlEoTeI9dGJnNsm3mbTbq96zfZKVZ5xXu9b76AStgX7Ewv3nM9peH2r3/X9 TZaDB9dz2DuolX53Cni2Rpt3B9e/dwEnV5558OYN7/w/oudDjnbbPGsMfLHQ2jzy4mET1yLn BV9nHl9udDlbQdHWN4SD98L/qe52h/lLm1Z279y0eEqTwwQxJZbijERDLeai4kQADyfZTxUD AAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140506_013338_416114_101C0386 X-CRM114-Status: GOOD ( 18.04 ) X-Spam-Score: -5.7 (-----) Cc: devicetree@vger.kernel.org, kgene.kim@samsung.com, Russell King , arnd@arndb.de, Wolfram Sang , Pankaj Dubey , t.figa@samsung.com, Randy Dunlap , linux-doc@vger.kernel.org, Rob Herring , linux-i2c@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,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 Let's move I2C interrupt re-configuration code from machine file exynos.c to I2C driver. Since only Exynos5250, and Exynos5420 need to do this, added syscon based phandle to i2c device nodes of respective SoC DT files. CC: Rob Herring CC: Randy Dunlap CC: Wolfram Sang CC: Russell King CC: devicetree@vger.kernel.org CC: linux-doc@vger.kernel.org CC: linux-i2c@vger.kernel.org Signed-off-by: Pankaj Dubey --- .../devicetree/bindings/arm/samsung/sysreg.txt | 1 + arch/arm/boot/dts/exynos5.dtsi | 5 ++++ arch/arm/boot/dts/exynos5250.dtsi | 4 +++ arch/arm/boot/dts/exynos5420.dtsi | 4 +++ arch/arm/mach-exynos/exynos.c | 26 ------------------- drivers/i2c/busses/i2c-s3c2410.c | 27 ++++++++++++++++++++ 6 files changed, 41 insertions(+), 26 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/samsung/sysreg.txt b/Documentation/devicetree/bindings/arm/samsung/sysreg.txt index 0ab3251..fd71581 100644 --- a/Documentation/devicetree/bindings/arm/samsung/sysreg.txt +++ b/Documentation/devicetree/bindings/arm/samsung/sysreg.txt @@ -3,6 +3,7 @@ SAMSUNG S5P/Exynos SoC series System Registers (SYSREG) Properties: - compatible : should contain "samsung,-sysreg", "syscon"; For Exynos4 SoC series it should be "samsung,exynos4-sysreg", "syscon"; + For Exynos5 SoC series it should be "samsung,exynos5-sysreg", "syscon"; - reg : offset and length of the register set. Example: diff --git a/arch/arm/boot/dts/exynos5.dtsi b/arch/arm/boot/dts/exynos5.dtsi index 79d0608..3027e37 100644 --- a/arch/arm/boot/dts/exynos5.dtsi +++ b/arch/arm/boot/dts/exynos5.dtsi @@ -99,4 +99,9 @@ #size-cells = <0>; status = "disabled"; }; + + sys_reg: syscon@10050000 { + compatible = "samsung,exynos5-sysreg", "syscon"; + reg = <0x10050000 0x400>; + }; }; diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi index 8d724d5..46f0233 100644 --- a/arch/arm/boot/dts/exynos5250.dtsi +++ b/arch/arm/boot/dts/exynos5250.dtsi @@ -285,6 +285,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c0_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; }; @@ -298,6 +299,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c1_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; }; @@ -311,6 +313,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c2_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; }; @@ -324,6 +327,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c3_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; }; diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi index ff496ad..762128c 100644 --- a/arch/arm/boot/dts/exynos5420.dtsi +++ b/arch/arm/boot/dts/exynos5420.dtsi @@ -517,6 +517,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c0_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; }; @@ -530,6 +531,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c1_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; }; @@ -543,6 +545,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c2_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; }; @@ -556,6 +559,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c3_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; }; diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c index 59eb1f1..54ae2e1 100644 --- a/arch/arm/mach-exynos/exynos.c +++ b/arch/arm/mach-exynos/exynos.c @@ -293,32 +293,6 @@ void __init exynos_map_pmu(void) static void __init exynos_dt_machine_init(void) { - struct device_node *i2c_np; - const char *i2c_compat = "samsung,s3c2440-i2c"; - unsigned int tmp; - int id; - - /* - * Exynos5's legacy i2c controller and new high speed i2c - * controller have muxed interrupt sources. By default the - * interrupts for 4-channel HS-I2C controller are enabled. - * If node for first four channels of legacy i2c controller - * are available then re-configure the interrupts via the - * system register. - */ - if (soc_is_exynos5()) { - for_each_compatible_node(i2c_np, NULL, i2c_compat) { - if (of_device_is_available(i2c_np)) { - id = of_alias_get_id(i2c_np, "i2c"); - if (id < 4) { - tmp = readl(EXYNOS5_SYS_I2C_CFG); - writel(tmp & ~(0x1 << id), - EXYNOS5_SYS_I2C_CFG); - } - } - } - } - exynos_map_pmu(); if (!soc_is_exynos5440()) diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index ae44910..0420150 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -39,6 +39,8 @@ #include #include #include +#include +#include #include @@ -91,6 +93,9 @@ /* Max time to wait for bus to become idle after a xfer (in us) */ #define S3C2410_IDLE_TIMEOUT 5000 +/* Exynos5 Sysreg offset */ +#define EXYNOS5_SYS_I2C_CFG 0x0234 + /* i2c controller state */ enum s3c24xx_i2c_state { STATE_IDLE, @@ -127,6 +132,7 @@ struct s3c24xx_i2c { #if defined(CONFIG_ARM_S3C24XX_CPUFREQ) struct notifier_block freq_transition; #endif + struct regmap *sysreg; }; static struct platform_device_id s3c24xx_driver_ids[] = { @@ -1075,6 +1081,8 @@ static void s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) { struct s3c2410_platform_i2c *pdata = i2c->pdata; + unsigned int tmp; + int id; if (!np) return; @@ -1084,6 +1092,25 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) of_property_read_u32(np, "samsung,i2c-slave-addr", &pdata->slave_addr); of_property_read_u32(np, "samsung,i2c-max-bus-freq", (u32 *)&pdata->frequency); + /* + * Exynos5's legacy i2c controller and new high speed i2c + * controller have muxed interrupt sources. By default the + * interrupts for 4-channel HS-I2C controller are enabled. + * If node for first four channels of legacy i2c controller + * are available then re-configure the interrupts via the + * system register. + */ + id = of_alias_get_id(np, "i2c"); + i2c->sysreg = syscon_regmap_lookup_by_phandle(np, + "samsung,syscon-phandle"); + if (IS_ERR(i2c->sysreg)) { + i2c->sysreg = NULL; + /* As this is not compulsary do not return error */ + pr_info("i2c-%d skipping re-configuration of interrutps\n", id); + return; + } + regmap_read(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, &tmp); + regmap_write(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, tmp & ~(0x1 << id)); } #else static void