From patchwork Tue Jun 2 18:45:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 6530761 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4829C9F1CC for ; Tue, 2 Jun 2015 18:49:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0DEAC20544 for ; Tue, 2 Jun 2015 18:49:21 +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 6BC4D20531 for ; Tue, 2 Jun 2015 18:49:19 +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 1YzrDc-0005iB-Ey; Tue, 02 Jun 2015 18:47:20 +0000 Received: from mail-pa0-f50.google.com ([209.85.220.50]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YzrCv-0005HC-P0 for linux-arm-kernel@lists.infradead.org; Tue, 02 Jun 2015 18:46:39 +0000 Received: by padjw17 with SMTP id jw17so66675622pad.2 for ; Tue, 02 Jun 2015 11:46:21 -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=O4m2j+GpyM9S2eNLbD9lw7ixLxM7EoSVesNf23RQPUz1O6VRkehNuTnYuKHH0uZbMA 8/NX5WPS7yRNoL5rm3KYFjbVxsvt5WiQBCKsyB5e+X93/Ns3vjH22GF3js4j/TZwMmig F+6yIDcGnkG/MCfWcmBu156yfzof8n/fkAVBtFzo3yDt+OktKxY0dsTqP4Lj5BsWE4td JdWSGeAAV6m4fjjJMmDFD7746DUDzikWS4FGMc39qijCEDlQMfJx3TRvWlb6Sg1xjpE8 5F3cdxf7bo13WCo/EQJutd4KHTdqsCd9pohaAj3fKbjj8nbsbpMod938I+u8bwI4lOoL 9HAA== X-Gm-Message-State: ALoCoQkxltURrfRIKv8pkkKb325DIQV8d5wFkvbUZobhLGm/PWJUjHNBq8OLYXZelufuxslTiqn5 X-Received: by 10.68.221.164 with SMTP id qf4mr14998309pbc.1.1433270781513; Tue, 02 Jun 2015 11:46:21 -0700 (PDT) Received: from localhost.localdomain ([223.190.86.187]) by mx.google.com with ESMTPSA id jx5sm18222527pbc.85.2015.06.02.11.46.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jun 2015 11:46:20 -0700 (PDT) From: Vaibhav Hiremath To: linux-i2c@vger.kernel.org Subject: [PATCH-RESEND 3/3] i2c: pxa: Add pin ctrl support for CP core access Date: Wed, 3 Jun 2015 00:15:31 +0530 Message-Id: <1433270731-23790-4-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433270731-23790-1-git-send-email-vaibhav.hiremath@linaro.org> References: <1433270731-23790-1-git-send-email-vaibhav.hiremath@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150602_114637_888330_81EEF4A6 X-CRM114-Status: GOOD ( 13.20 ) X-Spam-Score: -0.7 (/) Cc: Haojian Zhuang , Shouming Wang , Vaibhav Hiremath , linux-arm-kernel@lists.infradead.org, wsa@the-dreams.de 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;