From patchwork Thu May 28 13:03:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 49113 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8551A202A3 for ; Thu, 28 May 2015 13:07:26 +0000 (UTC) Received: by wgme6 with SMTP id e6sf10029443wgm.3 for ; Thu, 28 May 2015 06:07:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=quGnoJ9pB6+GiNQWT0/BuWq1in4bE2ZoLKCz762DTU0=; b=gK2Iz152ChMdzS7PyxH9TH9hfnHgMnvNxwvEfSh86ecLxnGCpqVGWuisf7qPJ7byPn M8s6HZOeD7iAQty9KOXKlOwtvw86LSyw6eP3XbdOXO2TEDJQjbh4JA/3rUMPFbX1++Pe YRn5epissSY/d/WnwPadhLlV2yQbbnS0lvDht6Rp39f/Z3oR0JS/GTWOOJlDEd4swhJW 7IyLfnqukLqaeAo6orDl+5NFb7bkchIczGMMFHGQYv1e8k1w1MU4Fqa9949g0k+sPv1O K+1jRRzGrODlEt6CgqcZdlZmu5TjSg7zV4JtGlKs5WXxwWU/4R6Bs8mMhFXngN1lh+1g 9V2w== X-Gm-Message-State: ALoCoQnjaYBWH7px5KEFkG4L1FBf13LACeWCdQQcTwQwNiLQjYSstmbkwZMxRxCTcVFCB3nBBIz9 X-Received: by 10.112.13.200 with SMTP id j8mr2596459lbc.14.1432818445805; Thu, 28 May 2015 06:07:25 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.22.72 with SMTP id b8ls196635laf.81.gmail; Thu, 28 May 2015 06:07:25 -0700 (PDT) X-Received: by 10.112.235.133 with SMTP id um5mr2779753lbc.7.1432818445656; Thu, 28 May 2015 06:07:25 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id w5si1925652lbb.37.2015.05.28.06.07.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 May 2015 06:07:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbbqq2 with SMTP id qq2so27746465lbb.3 for ; Thu, 28 May 2015 06:07:25 -0700 (PDT) X-Received: by 10.152.7.7 with SMTP id f7mr2746667laa.106.1432818445554; Thu, 28 May 2015 06:07:25 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1144869lbb; Thu, 28 May 2015 06:07:24 -0700 (PDT) X-Received: by 10.68.206.7 with SMTP id lk7mr5330610pbc.52.1432818443719; Thu, 28 May 2015 06:07:23 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12si3544786pdn.147.2015.05.28.06.07.22; Thu, 28 May 2015 06:07:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752287AbbE1NHQ (ORCPT + 1 other); Thu, 28 May 2015 09:07:16 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:33428 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753827AbbE1NHK (ORCPT ); Thu, 28 May 2015 09:07:10 -0400 Received: by padbw4 with SMTP id bw4so23216706pad.0 for ; Thu, 28 May 2015 06:07:09 -0700 (PDT) X-Received: by 10.68.57.200 with SMTP id k8mr5368537pbq.61.1432818429690; Thu, 28 May 2015 06:07:09 -0700 (PDT) Received: from localhost.localdomain ([202.62.77.106]) by mx.google.com with ESMTPSA id dc5sm2392557pbc.53.2015.05.28.06.07.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 May 2015 06:07:08 -0700 (PDT) From: Vaibhav Hiremath To: linux-i2c@vger.kernel.org Cc: Wolfram Sang , linux-arm-kernel@lists.infradead.org, Yi Zhang , Vaibhav Hiremath Subject: [PATCH 12/12] i2c: pxa: enable/disable i2c module across msg xfer Date: Thu, 28 May 2015 18:33:44 +0530 Message-Id: <1432818224-17070-13-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432818224-17070-1-git-send-email-vaibhav.hiremath@linaro.org> References: <1432818224-17070-1-git-send-email-vaibhav.hiremath@linaro.org> Sender: linux-i2c-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-i2c@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: vaibhav.hiremath@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Yi Zhang Enable i2c module/unit before transmission and disable when it finishes. why? It's because the i2c bus may be distrubed if the slave device, typically a touch, powers on. Signed-off-by: Yi Zhang [vaibhav.hiremath@linaro.org: ported to latest kernel & also improved changelog] Signed-off-by: Vaibhav Hiremath Signed-off-by: Vaibhav Hiremath --- drivers/i2c/busses/i2c-pxa.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 844e1fc..f51d512 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -368,6 +368,16 @@ static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why) static void i2c_pxa_master_complete(struct pxa_i2c *i2c, int ret); static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id); +/* enable/disable i2c unit */ +static inline void i2c_pxa_enable(struct pxa_i2c *i2c, bool enable) +{ + if (enable) + writel(readl(_ICR(i2c)) | ICR_IUE, _ICR(i2c)); + else + writel(readl(_ICR(i2c)) & ~ICR_IUE, _ICR(i2c)); + udelay(100); +} + static inline int i2c_pxa_is_slavemode(struct pxa_i2c *i2c) { return !(readl(_ICR(i2c)) & ICR_SCLE); @@ -575,8 +585,7 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c) i2c_pxa_set_slave(i2c, 0); /* enable unit */ - writel(readl(_ICR(i2c)) | ICR_IUE, _ICR(i2c)); - udelay(100); + i2c_pxa_enable(i2c, true); } @@ -933,6 +942,9 @@ static int i2c_pxa_pio_xfer(struct i2c_adapter *adap, struct pxa_i2c *i2c = adap->algo_data; int ret, i; + /* Enable i2c unit */ + i2c_pxa_enable(i2c, true); + /* If the I2C controller is disabled we need to reset it (probably due to a suspend/resume destroying state). We do this here as we can then avoid worrying about resuming the @@ -953,6 +965,10 @@ static int i2c_pxa_pio_xfer(struct i2c_adapter *adap, ret = -EREMOTEIO; out: i2c_pxa_set_slave(i2c, ret); + + /* disable i2c unit */ + i2c_pxa_enable(i2c, false); + return ret; } @@ -1168,6 +1184,9 @@ static int i2c_pxa_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num struct pxa_i2c *i2c = adap->algo_data; int ret, i; + /* Enable i2c unit */ + i2c_pxa_enable(i2c, true); + enable_irq(i2c->irq); for (i = adap->retries; i >= 0; i--) { ret = i2c_pxa_do_xfer(i2c, msgs, num); @@ -1183,6 +1202,9 @@ static int i2c_pxa_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num out: i2c_pxa_set_slave(i2c, ret); disable_irq(i2c->irq); + /* disable i2c unit */ + i2c_pxa_enable(i2c, false); + return ret; } @@ -1407,6 +1429,9 @@ static int i2c_pxa_probe(struct platform_device *dev) ret = 0; } } + + i2c_pxa_enable(i2c, false); + #ifdef CONFIG_I2C_PXA_SLAVE pr_info("I2C: %s: PXA I2C adapter, slave address %d\n", dev_name(&i2c->adap.dev), i2c->slave_addr);