From: Vaibhav Hiremath <vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> To: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Yi Zhang <yizhang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>, Vaibhav Hiremath <vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Subject: [PATCH 12/12] i2c: pxa: enable/disable i2c module across msg xfer Date: Thu, 28 May 2015 18:33:44 +0530 [thread overview] Message-ID: <1432818224-17070-13-git-send-email-vaibhav.hiremath@linaro.org> (raw) In-Reply-To: <1432818224-17070-1-git-send-email-vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> From: Yi Zhang <yizhang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org> 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 <yizhang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org> [vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org: ported to latest kernel & also improved changelog] Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> --- 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); -- 1.9.1
WARNING: multiple messages have this Message-ID (diff)
From: vaibhav.hiremath@linaro.org (Vaibhav Hiremath) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 12/12] i2c: pxa: enable/disable i2c module across msg xfer Date: Thu, 28 May 2015 18:33:44 +0530 [thread overview] Message-ID: <1432818224-17070-13-git-send-email-vaibhav.hiremath@linaro.org> (raw) In-Reply-To: <1432818224-17070-1-git-send-email-vaibhav.hiremath@linaro.org> From: Yi Zhang <yizhang@marvell.com> 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 <yizhang@marvell.com> [vaibhav.hiremath at linaro.org: ported to latest kernel & also improved changelog] Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> --- 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); -- 1.9.1
next prev parent reply other threads:[~2015-05-28 13:03 UTC|newest] Thread overview: 116+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-05-28 13:03 [PATCH 00/12] i2c: pxa: Fixes, cleanup and support for pxa910 family Vaibhav Hiremath 2015-05-28 13:03 ` Vaibhav Hiremath [not found] ` <1432818224-17070-1-git-send-email-vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-05-28 13:03 ` [PATCH 01/12] i2c: pxa: keep i2c irq ON in suspend Vaibhav Hiremath 2015-05-28 13:03 ` Vaibhav Hiremath 2015-05-28 13:03 ` [PATCH 02/12] i2c: pxa: No need to set slave addr for i2c master mode reset Vaibhav Hiremath 2015-05-28 13:03 ` Vaibhav Hiremath 2015-05-29 19:21 ` Robert Jarzmik 2015-05-29 19:21 ` Robert Jarzmik [not found] ` <87d21jyyua.fsf-4ty26DBLk+jEm7gnYqmdkQ@public.gmane.org> 2015-05-29 19:25 ` Vaibhav Hiremath 2015-05-29 19:25 ` Vaibhav Hiremath 2015-05-28 13:03 ` [PATCH 03/12] i2c: pxa: Add reset operation when i2c bus busy Vaibhav Hiremath 2015-05-28 13:03 ` Vaibhav Hiremath [not found] ` <1432818224-17070-4-git-send-email-vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-05-29 19:39 ` Robert Jarzmik 2015-05-29 19:39 ` Robert Jarzmik [not found] ` <878uc7yxzx.fsf-4ty26DBLk+jEm7gnYqmdkQ@public.gmane.org> 2015-05-29 20:20 ` Vaibhav Hiremath 2015-05-29 20:20 ` Vaibhav Hiremath 2015-05-28 13:03 ` [PATCH 04/12] i2c: pxa: Add support for pxa910/988 & new configuration features Vaibhav Hiremath 2015-05-28 13:03 ` Vaibhav Hiremath [not found] ` <1432818224-17070-5-git-send-email-vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-05-29 20:22 ` Robert Jarzmik 2015-05-29 20:22 ` Robert Jarzmik [not found] ` <874mmvyvzw.fsf-4ty26DBLk+jEm7gnYqmdkQ@public.gmane.org> 2015-05-29 20:33 ` Vaibhav Hiremath 2015-05-29 20:33 ` Vaibhav Hiremath 2015-06-04 2:31 ` Yi Zhang 2015-06-04 2:31 ` Yi Zhang 2015-06-04 5:46 ` Vaibhav Hiremath 2015-06-04 5:46 ` Vaibhav Hiremath 2015-06-01 0:13 ` Wolfram Sang 2015-06-01 0:13 ` Wolfram Sang [not found] ` <4edfb7fe9edf4800e73c86a258fe4fd1-z923LK4zBo2bacvFa/9K2g@public.gmane.org> 2015-06-02 5:01 ` Vaibhav Hiremath 2015-06-02 5:01 ` Vaibhav Hiremath 2015-05-28 13:03 ` [PATCH 05/12] i2c: pxa: Add bus reset functionality Vaibhav Hiremath 2015-05-28 13:03 ` Vaibhav Hiremath [not found] ` <1432818224-17070-6-git-send-email-vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-05-29 13:59 ` Rob Herring 2015-05-29 13:59 ` Rob Herring [not found] ` <CAL_Jsq+-u7pf7JOXD7frB-ye9bk0NLAKhAJFvLYz1a1jzOCb9Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2015-05-29 15:40 ` Vaibhav Hiremath 2015-05-29 15:40 ` Vaibhav Hiremath 2015-05-29 20:31 ` Robert Jarzmik 2015-05-29 20:31 ` Robert Jarzmik 2015-06-02 13:12 ` Linus Walleij 2015-06-02 13:12 ` Linus Walleij [not found] ` <CACRpkdaxWsi8t6aUFJK-KCmQF1gEOLiOE8=fgDRxQDSi4G6FgQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2015-06-02 16:40 ` Vaibhav Hiremath 2015-06-02 16:40 ` Vaibhav Hiremath 2015-06-03 19:16 ` Vaibhav Hiremath 2015-06-03 19:16 ` Vaibhav Hiremath 2015-06-02 17:33 ` Wolfram Sang 2015-06-02 17:33 ` Wolfram Sang 2015-06-02 17:40 ` Vaibhav Hiremath 2015-06-02 17:40 ` Vaibhav Hiremath [not found] ` <556DEA90.3010001-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-06-02 17:48 ` Wolfram Sang 2015-06-02 17:48 ` Wolfram Sang 2015-06-02 17:57 ` Vaibhav Hiremath 2015-06-02 17:57 ` Vaibhav Hiremath [not found] ` <556DEE6C.1060300-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-06-02 18:02 ` Wolfram Sang 2015-06-02 18:02 ` Wolfram Sang 2015-06-02 18:06 ` Vaibhav Hiremath 2015-06-02 18:06 ` Vaibhav Hiremath [not found] ` <556DF0A0.30807-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-06-02 18:24 ` Wolfram Sang 2015-06-02 18:24 ` Wolfram Sang 2015-06-02 18:46 ` Vaibhav Hiremath 2015-06-02 18:46 ` Vaibhav Hiremath 2015-05-28 13:03 ` [PATCH 06/12] i2c: pxa: Return I2C_RETRY when timeout in pio mode Vaibhav Hiremath 2015-05-28 13:03 ` Vaibhav Hiremath [not found] ` <1432818224-17070-7-git-send-email-vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-05-29 20:46 ` Robert Jarzmik 2015-05-29 20:46 ` Robert Jarzmik [not found] ` <87vbfbxgb0.fsf-4ty26DBLk+jEm7gnYqmdkQ@public.gmane.org> 2015-05-29 21:23 ` Vaibhav Hiremath 2015-05-29 21:23 ` Vaibhav Hiremath 2015-05-28 13:03 ` [PATCH 07/12] i2c: pxa: Reset i2c controller on timeout in interrupt and " Vaibhav Hiremath 2015-05-28 13:03 ` Vaibhav Hiremath [not found] ` <1432818224-17070-8-git-send-email-vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-05-29 21:13 ` Robert Jarzmik 2015-05-29 21:13 ` Robert Jarzmik [not found] ` <87r3pzxf1s.fsf-4ty26DBLk+jEm7gnYqmdkQ@public.gmane.org> 2015-05-29 21:19 ` Vaibhav Hiremath 2015-05-29 21:19 ` Vaibhav Hiremath 2015-05-28 13:03 ` [PATCH 08/12] i2c: pxa: enable/disable irq across message xfer Vaibhav Hiremath 2015-05-28 13:03 ` Vaibhav Hiremath [not found] ` <1432818224-17070-9-git-send-email-vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-05-28 13:17 ` Russell King - ARM Linux 2015-05-28 13:17 ` Russell King - ARM Linux [not found] ` <20150528131707.GB2067-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org> 2015-05-28 13:29 ` Vaibhav Hiremath 2015-05-28 13:29 ` Vaibhav Hiremath 2015-05-28 13:03 ` [PATCH 09/12] i2c: pxa: Remove compile warnning in 64bit mode Vaibhav Hiremath 2015-05-28 13:03 ` Vaibhav Hiremath [not found] ` <1432818224-17070-10-git-send-email-vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-05-29 21:28 ` Robert Jarzmik 2015-05-29 21:28 ` Robert Jarzmik 2015-05-28 13:03 ` [PATCH 10/12] i2c: pxa: Update debug function to dump more info on error Vaibhav Hiremath 2015-05-28 13:03 ` Vaibhav Hiremath [not found] ` <1432818224-17070-11-git-send-email-vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-05-29 21:42 ` Robert Jarzmik 2015-05-29 21:42 ` Robert Jarzmik [not found] ` <87fv6fxdqu.fsf-4ty26DBLk+jEm7gnYqmdkQ@public.gmane.org> 2015-05-29 21:45 ` Vaibhav Hiremath 2015-05-29 21:45 ` Vaibhav Hiremath 2015-05-28 13:03 ` [PATCH 11/12] i2c:pxa: Use devm_ variants in probe function Vaibhav Hiremath 2015-05-28 13:03 ` Vaibhav Hiremath [not found] ` <1432818224-17070-12-git-send-email-vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-05-30 15:53 ` Robert Jarzmik 2015-05-30 15:53 ` Robert Jarzmik [not found] ` <878uc6xdsd.fsf-4ty26DBLk+jEm7gnYqmdkQ@public.gmane.org> 2015-05-31 7:36 ` Vaibhav Hiremath 2015-05-31 7:36 ` Vaibhav Hiremath 2015-05-28 13:03 ` Vaibhav Hiremath [this message] 2015-05-28 13:03 ` [PATCH 12/12] i2c: pxa: enable/disable i2c module across msg xfer Vaibhav Hiremath [not found] ` <1432818224-17070-13-git-send-email-vaibhav.hiremath-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-05-28 13:23 ` Russell King - ARM Linux 2015-05-28 13:23 ` Russell King - ARM Linux [not found] ` <20150528132312.GC2067-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org> 2015-06-02 16:52 ` Vaibhav Hiremath 2015-06-02 16:52 ` Vaibhav Hiremath [not found] ` <556DDF43.4050804-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-06-02 16:59 ` Vaibhav Hiremath 2015-06-02 16:59 ` Vaibhav Hiremath [not found] ` <556DE0EB.1010609-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-06-03 10:56 ` Yi Zhang 2015-06-03 10:56 ` Yi Zhang 2015-06-03 18:49 ` Vaibhav Hiremath 2015-06-03 18:49 ` Vaibhav Hiremath 2015-06-04 6:29 ` Yi Zhang 2015-06-04 6:29 ` Yi Zhang 2015-06-04 7:19 ` Vaibhav Hiremath 2015-06-04 7:19 ` Vaibhav Hiremath [not found] ` <556FFC14.3050901-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-06-04 7:58 ` Yi Zhang 2015-06-04 7:58 ` Yi Zhang 2015-06-01 0:07 ` [PATCH 00/12] i2c: pxa: Fixes, cleanup and support for pxa910 family Wolfram Sang 2015-06-01 0:07 ` Wolfram Sang [not found] ` <fb192019ec75e9aa10b04b79e87a6e79-z923LK4zBo2bacvFa/9K2g@public.gmane.org> 2015-06-02 4:58 ` Vaibhav Hiremath 2015-06-02 4:58 ` Vaibhav Hiremath
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1432818224-17070-13-git-send-email-vaibhav.hiremath@linaro.org \ --to=vaibhav.hiremath-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \ --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \ --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org \ --cc=yizhang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.