From patchwork Thu May 28 13:32:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 6498781 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AC90CC0020 for ; Thu, 28 May 2015 13:39:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3A36E20627 for ; Thu, 28 May 2015 13:39:26 +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 347E420628 for ; Thu, 28 May 2015 13:39:21 +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 1YxxzR-0005KG-FI; Thu, 28 May 2015 13:36:53 +0000 Received: from mail-pa0-f42.google.com ([209.85.220.42]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YxxyE-0004ZA-DY for linux-arm-kernel@lists.infradead.org; Thu, 28 May 2015 13:35:39 +0000 Received: by padbw4 with SMTP id bw4so23750626pad.0 for ; Thu, 28 May 2015 06:35:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=H2PRXTmRIoEAiYNhAigcXPLyWkOFaFj3TWbGNBHdLSQ=; b=De1WFGB6ABagjIl5HAO9NhG7nnN0I1GymsyZkrgDMbXMiU/QNoLJDXk8sJ0DIn3kya 8hJOoN6vTc+uKFzqJFqb2OLAe7mjbx9/fA1ytAtNdeGCNwvN3TA7oTMdIfIx/kcJYZXV DeCKKvxeDv8uuUIxkY0kBBFJowVCnWpmkZYh98pNmbLj6yCNdmyZVpB4aoK++lOQF0nJ 0vC/NLgbOOHoQSOK/OlxbXIj2omql7mnGIWkoXP8UzofG9zTJ+7h6n5KwsQ/EJ/zL18t zELkWp1LjE0xWKihyQSa/yvV4kr7CN1cP22ODB8GXx6fDL7a8Z+gxAiHbdZJGmiqhJw1 OcLQ== X-Gm-Message-State: ALoCoQkIaJCr2sufGbWTNjHy/YG23N7jflk8QLoLuBZyqPtAySoxI6BI1jm837b+dzzo7xHDnUq1 X-Received: by 10.70.90.100 with SMTP id bv4mr5565397pdb.53.1432820116926; Thu, 28 May 2015 06:35:16 -0700 (PDT) Received: from localhost.localdomain ([202.62.77.106]) by mx.google.com with ESMTPSA id f1sm2473461pds.62.2015.05.28.06.35.13 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 May 2015 06:35:15 -0700 (PDT) From: Vaibhav Hiremath To: linux-i2c@vger.kernel.org Subject: [PATCH 3/3] i2c: pxa: Add pin ctrl support for CP core access Date: Thu, 28 May 2015 19:02:48 +0530 Message-Id: <1432819968-17515-4-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432819968-17515-1-git-send-email-vaibhav.hiremath@linaro.org> References: <1432819968-17515-1-git-send-email-vaibhav.hiremath@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150528_063538_487065_B39ED940 X-CRM114-Status: GOOD ( 13.65 ) X-Spam-Score: -0.7 (/) Cc: Haojian Zhuang , Shouming Wang , Vaibhav Hiremath , linux-arm-kernel@lists.infradead.org, Wolfram Sang X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 PMIC TWSI pins configuration for AP and CP is different on eden, it need to be set to function 0 when AP get RIPC lock. When AP release RIPC lock, it also need configure twsi pins to other state, otherwise pinctrl will assume pins configration is not changed even if it is changed by CP, so it will not change twsi pins configuration to AP state when AP get RIPC next time. Signed-off-by: Shouming Wang Signed-off-by: Haojian Zhuang Signed-off-by: Vaibhav Hiremath --- drivers/i2c/busses/i2c-pxa.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index eb26eb1..1340de1 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -184,6 +184,7 @@ struct pxa_i2c { struct pinctrl *pinctrl; struct pinctrl_state *pin_i2c; struct pinctrl_state *pin_gpio; + struct pinctrl_state *pin_i2c_cp; }; #define _IBMR(i2c) ((i2c)->reg_ibmr) @@ -405,6 +406,10 @@ void mmp_hwlock_lock(struct i2c_adapter *adap) ripc_status = true; spin_unlock_irqrestore(&lock_for_ripc, flags); + + if (pinctrl_select_state(i2c->pinctrl, i2c->pin_i2c) < 0) + dev_err(&i2c->adap.dev, "could not set i2c AP pins\n"); + } void mmp_hwlock_unlock(struct i2c_adapter *adap) @@ -413,6 +418,9 @@ void mmp_hwlock_unlock(struct i2c_adapter *adap) struct pxa_i2c *i2c = adap->algo_data; + if (pinctrl_select_state(i2c->pinctrl, i2c->pin_i2c_cp) < 0) + dev_err(&i2c->adap.dev, "could not set i2c CP pins\n"); + spin_lock_irqsave(&lock_for_ripc, flags); __raw_writel(1, i2c->hwlock_addr); ripc_status = false; @@ -430,6 +438,9 @@ int mmp_hwlock_trylock(struct i2c_adapter *adap) ripc_status = !__raw_readl(i2c->hwlock_addr); spin_unlock_irqrestore(&lock_for_ripc, flags); + if (ripc_status && (pinctrl_select_state(i2c->pinctrl, i2c->pin_i2c) < 0)) + dev_err(&i2c->adap.dev, "could not set i2c AP pins\n"); + return ripc_status; } @@ -1497,8 +1508,14 @@ static int i2c_pxa_probe(struct platform_device *dev) ret = IS_ERR(i2c->pin_gpio); } + /* pin ctrl for CP - optional */ + i2c->pin_i2c_cp = pinctrl_lookup_state(i2c->pinctrl, "i2c_cp"); + if (IS_ERR(i2c->pin_i2c_cp)) + dev_err(&dev->dev, "could not get i2c_cp pinstate\n"); + if (ret) { i2c->pin_i2c = NULL; + i2c->pin_i2c_cp = NULL; i2c->pin_gpio = NULL; i2c->pinctrl = NULL; ret = 0;