From patchwork Thu Sep 6 09:23:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Abraham X-Patchwork-Id: 1412571 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id A87583FC71 for ; Thu, 6 Sep 2012 09:09:02 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T9Y1W-0000DU-Kw; Thu, 06 Sep 2012 09:05:18 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T9Y1S-0000Ca-Kf for linux-arm-kernel@lists.infradead.org; Thu, 06 Sep 2012 09:05:16 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M9X0039P7W2FZQ0@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 06 Sep 2012 18:04:57 +0900 (KST) X-AuditID: cbfee61a-b7fd26d000002b62-15-504867399075 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id AA.8A.11106.93768405; Thu, 06 Sep 2012 18:04:57 +0900 (KST) Received: from localhost.localdomain ([107.108.73.37]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M9X004YR7UR08A0@mmp2.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 06 Sep 2012 18:04:57 +0900 (KST) From: Thomas Abraham To: linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] i2c: s3c2410: add optional pin configuration using pinctrl interface Date: Thu, 06 Sep 2012 14:53:00 +0530 Message-id: <1346923381-14144-2-git-send-email-thomas.abraham@linaro.org> X-Mailer: git-send-email 1.6.6.rc2 In-reply-to: <1346923381-14144-1-git-send-email-thomas.abraham@linaro.org> References: <1346923381-14144-1-git-send-email-thomas.abraham@linaro.org> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEJMWRmVeSWpSXmKPExsVy+t9jQV3LdI8Ag/7HqhabHl9jdWD02Lyk PoAxissmJTUnsyy1SN8ugStjwbfXrAUv+Cq+re1ibWBcxtPFyMkhIWAi8av7DRuELSZx4d56 IJuLQ0hgOqPE2UetzBDOeiaJx7umgFWxCRhIPFr4jh3EFhFwlji/ewsjSBGzwClGiYbT84Ec Dg5hgWiJtiuiIDUsAqoS74+dZQSxeQU8JTa9XsYEsU1JYkPvUTCbU8BL4uendlYQWwio5v+6 NqYJjLwLGBlWMYqmFiQXFCel5xrqFSfmFpfmpesl5+duYgT7/JnUDsaVDRaHGAU4GJV4eH/l uwcIsSaWFVfmHmKU4GBWEuG1NPUIEOJNSaysSi3Kjy8qzUktPsQozcGiJM7rdM4uQEggPbEk NTs1tSC1CCbLxMEp1cA4ffPdXWwn3fZHBnZ+PvPsp9YSnr3pe6/2CzDu/f6j4ebtGTlBj2a+ zP/ziDmdJcTjaP6vjU1Wk487PrcuKIgtWLlmQ5iV+feshCWHj6trP38ZrytznGdRwIkSLz7B w5FX5H7YRq68eyCyX7O4guNY3ZO4Hx/fRXOd7urwuV1+4YHS2jOuew7sVWIpzkg01GIuKk4E ABvJMXf1AQAA X-Spam-Note: CRM114 invocation failed X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.24 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: kgene.kim@samsung.com, patches@linaro.org, linus.walleij@linaro.org, swarren@wwwdotorg.org, w.sang@pengutronix.de, linux-samsung-soc@vger.kernel.org, ben-linux@fluff.org, dong.aisheng@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add optional support for i2c bus pin configuration using pinctrl interface Cc: Ben Dooks Signed-off-by: Thomas Abraham --- drivers/i2c/busses/i2c-s3c2410.c | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 5ae3b02..f4b2d6f 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -38,6 +38,7 @@ #include #include #include +#include #include @@ -83,6 +84,8 @@ struct s3c24xx_i2c { struct s3c2410_platform_i2c *pdata; int gpios[2]; + struct pinctrl *pctrl; + struct pinctrl_state *pctrl_state; #ifdef CONFIG_CPU_FREQ struct notifier_block freq_transition; #endif @@ -859,11 +862,17 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c) /* inititalise the gpio */ - if (pdata->cfg_gpio) + if (pdata->cfg_gpio) { pdata->cfg_gpio(to_platform_device(i2c->dev)); - else - if (s3c24xx_i2c_parse_dt_gpio(i2c)) + } else if (!IS_ERR_OR_NULL(i2c->pctrl) && + !IS_ERR_OR_NULL(i2c->pctrl_state)) { + if (pinctrl_select_state(i2c->pctrl, i2c->pctrl_state)) { + dev_err(i2c->dev, "failed to configure io-pins\n"); + return -ENXIO; + } + } else if (s3c24xx_i2c_parse_dt_gpio(i2c)) { return -EINVAL; + } /* write slave address */ @@ -1013,6 +1022,10 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) i2c->adap.algo_data = i2c; i2c->adap.dev.parent = &pdev->dev; + i2c->pctrl = devm_pinctrl_get(i2c->dev); + if (!IS_ERR_OR_NULL(i2c->pctrl)) + i2c->pctrl_state = pinctrl_lookup_state(i2c->pctrl, "default"); + /* initialise the i2c controller */ ret = s3c24xx_i2c_init(i2c);