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@linaro.org X-Patchwork-Id: 11207 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 66B5E23F22 for ; Thu, 6 Sep 2012 09:05:01 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 606DBA18131 for ; Thu, 6 Sep 2012 09:04:05 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id k11so2430701iea.11 for ; Thu, 06 Sep 2012 02:05:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:x-auditid :from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-brightmail-tracker:x-gm-message-state; bh=kiCWZPpoutFALo7SqGc2N4LaFIM815vECjtcyzUva9A=; b=eEU+HK/ljQumUDRaeBKdZJXGBLwvYxmKg6vXIT1ic2AagxklOES+S+d59qTcXNKscE LzH28a3wXJ0u9vtaMjcqiboO7dcUm2y69gNyGsxP9Kv2FRPOb/+DaR98O8qsecckQocB qTUTU0N8C/WNHhziC+XyfBaqiesG2USrWFYAB7+EtFar3MaStGDoTw4/pmqCOfneywpi quG/k9+4gDD32U/8ij//ZBkxunMlNtr0wiYvyvS8baOaK/iVTRxF3xor3g+cN6bE2GLS QOHAYmFbD+PhtpW73h6rppNzEZfJHcMff9JLDUuM8SA+XDg+AGcp//bzByJiOvXzxpT4 1ECQ== Received: by 10.50.207.106 with SMTP id lv10mr1741166igc.0.1346922300720; Thu, 06 Sep 2012 02:05:00 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp305740igc; Thu, 6 Sep 2012 02:05:00 -0700 (PDT) Received: by 10.68.235.38 with SMTP id uj6mr4096927pbc.3.1346922299494; Thu, 06 Sep 2012 02:04:59 -0700 (PDT) Received: from mailout2.samsung.com (mailout2.samsung.com. [203.254.224.25]) by mx.google.com with ESMTP id px5si2763113pbb.82.2012.09.06.02.04.58; Thu, 06 Sep 2012 02:04:59 -0700 (PDT) Received-SPF: neutral (google.com: 203.254.224.25 is neither permitted nor denied by best guess record for domain of thomas.abraham@linaro.org) client-ip=203.254.224.25; Authentication-Results: mx.google.com; spf=neutral (google.com: 203.254.224.25 is neither permitted nor denied by best guess record for domain of thomas.abraham@linaro.org) smtp.mail=thomas.abraham@linaro.org Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M9X00I9T7W32CY0@mailout2.samsung.com>; Thu, 06 Sep 2012 18:04:57 +0900 (KST) X-AuditID: cbfee61b-b7f056d000002c30-73-504867395ad1 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 85.A9.11312.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>; Thu, 06 Sep 2012 18:04:57 +0900 (KST) From: Thomas Abraham To: linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: linux-samsung-soc@vger.kernel.org, linus.walleij@linaro.org, dong.aisheng@linaro.org, swarren@wwwdotorg.org, kgene.kim@samsung.com, patches@linaro.org, w.sang@pengutronix.de, ben-linux@fluff.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+NgFnrLJMWRmVeSWpSXmKPExsVy+t9jQV3LdI8Ag0MXVC2WnethtZjyZzmT xZTDX1gcmD3uXNvDFsAYxWWTkpqTWZZapG+XwJWx4Ntr1oIXfBXf1naxNjAu4+li5OSQEDCR mDT1IwuELSZx4d56ti5GLg4hgemMEpOfTYdy2pgk9v5dyApSxSZgIPFo4Tt2EFtEwFni/O4t jCBFzAKnGCUaTs8Hcjg4hAWiJdquiILUsAioSrw/dpYRxOYV8JTY9HoZE8Q2JYkNvUfBbE4B L4mfn9rB5gsB1fxf18Y0gZF3ASPDKkbR1ILkguKk9FwjveLE3OLSvHS95PzcTYzgQHgmvYNx VYPFIUYBDkYlHt6f+e4BQqyJZcWVuYcYJTiYlUR4LU09AoR4UxIrq1KL8uOLSnNSiw8xSnOw KInzOp2zCxASSE8sSc1OTS1ILYLJMnFwSjUwbml9l+f7+NPqqnkbO2pOyL2pK1qSzZi8a0uK 2No57saPVyy9u1nret3SIN3mH1WTZNbxaivseDOlY1fYsbDlxbP5+KOuXyqeyGn54XyOZEHx lOzfiQ8WHQmeYHjJ7obn53/vY3TKnq0Xv67J/OnWp2WT2CpvisZPb2WfVTG9T1r63v5fPLFb 7JRYijMSDbWYi4oTAchBo5AAAgAA X-Gm-Message-State: ALoCoQlhx4J8HmdKESToi0NtsUP7XPKOX5msX2fGxQiO+U4zcBYDcUk1qlqVg46lTN/Pg1Wo37OX 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);