* [PATCH] i2c: imx: Add arbitration lost check @ 2014-09-01 8:58 Haibo Chen [not found] ` <1409561920-9939-1-git-send-email-haibo.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Haibo Chen @ 2014-09-01 8:58 UTC (permalink / raw) To: wsa-z923LK4zBo2bacvFa/9K2g Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, B38611-KZfg59tc24xl57MIdRCFDg According to the i.mx spec, for multimaster mode, if I2C is enabled when the bus is busy and asserts start, hardware inhibits the transmission, clears MSTA without signaling a stop, generate an interrupt, and set I2C_I2SR[IAL] to indicate a failed attempt to engage the bus, which means arbitration lost. In this case, we should first test I2C_I2SR[IAL], and clear this bit if it is set, and then I2C controller default to slave receive mode. This patch check the IAL bit every time before an I2c transmission. if IAL is set, clear it and make I2C controller to default mode. Signed-off-by: Haibo Chen <haibo.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org> --- drivers/i2c/busses/i2c-imx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 613069b..144b620 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -268,6 +268,14 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy) while (1) { temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR); + + /** check for arbitration lost **/ + if (temp & I2SR_IAL) { + temp &= ~I2SR_IAL; + imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2SR); + return -EIO; + } + if (for_busy && (temp & I2SR_IBB)) break; if (!for_busy && !(temp & I2SR_IBB)) -- 1.9.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
[parent not found: <1409561920-9939-1-git-send-email-haibo.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>]
* RE: [PATCH] i2c: imx: Add arbitration lost check [not found] ` <1409561920-9939-1-git-send-email-haibo.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org> @ 2014-09-02 2:53 ` fugang.duan-KZfg59tc24xl57MIdRCFDg 2014-09-02 10:43 ` Wolfram Sang 1 sibling, 0 replies; 3+ messages in thread From: fugang.duan-KZfg59tc24xl57MIdRCFDg @ 2014-09-02 2:53 UTC (permalink / raw) To: Haibo.Chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org, wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org From: Haibo Chen <haibo.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org> Sent: Monday, September 01, 2014 4:59 PM >To: wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org >Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; Duan Fugang-B38611 >Subject: [PATCH] i2c: imx: Add arbitration lost check > >According to the i.mx spec, for multimaster mode, if I2C is enabled when >the bus is busy and asserts start, hardware inhibits the transmission, >clears MSTA without signaling a stop, generate an interrupt, and set >I2C_I2SR[IAL] to indicate a failed attempt to engage the bus, which means >arbitration lost. In this case, we should first test I2C_I2SR[IAL], and >clear this bit if it is set, and then I2C controller default to slave >receive mode. > >This patch check the IAL bit every time before an I2c transmission. >if IAL is set, clear it and make I2C controller to default mode. > >Signed-off-by: Haibo Chen <haibo.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org> >--- > drivers/i2c/busses/i2c-imx.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > >diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c >index 613069b..144b620 100644 >--- a/drivers/i2c/busses/i2c-imx.c >+++ b/drivers/i2c/busses/i2c-imx.c >@@ -268,6 +268,14 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct >*i2c_imx, int for_busy) > > while (1) { > temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR); >+ >+ /** check for arbitration lost **/ >+ if (temp & I2SR_IAL) { >+ temp &= ~I2SR_IAL; >+ imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2SR); >+ return -EIO; >+ } >+ > if (for_busy && (temp & I2SR_IBB)) > break; > if (!for_busy && !(temp & I2SR_IBB)) >-- >1.9.1 Acked-by: Fugang Duan <B38611-KZfg59tc24xl57MIdRCFDg@public.gmane.org> Thanks, Andy ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: imx: Add arbitration lost check [not found] ` <1409561920-9939-1-git-send-email-haibo.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org> 2014-09-02 2:53 ` fugang.duan-KZfg59tc24xl57MIdRCFDg @ 2014-09-02 10:43 ` Wolfram Sang 1 sibling, 0 replies; 3+ messages in thread From: Wolfram Sang @ 2014-09-02 10:43 UTC (permalink / raw) To: Haibo Chen Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, B38611-KZfg59tc24xl57MIdRCFDg [-- Attachment #1: Type: text/plain, Size: 668 bytes --] > --- a/drivers/i2c/busses/i2c-imx.c > +++ b/drivers/i2c/busses/i2c-imx.c > @@ -268,6 +268,14 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy) > > while (1) { > temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR); > + > + /** check for arbitration lost **/ One '*' is enough on each side. > + if (temp & I2SR_IAL) { > + temp &= ~I2SR_IAL; > + imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2SR); > + return -EIO; Documentation/i2c/fault-codes defines 'EAGAIN' for arbitration lost. > + } > + > if (for_busy && (temp & I2SR_IBB)) > break; > if (!for_busy && !(temp & I2SR_IBB)) > -- > 1.9.1 > [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-02 10:43 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-09-01 8:58 [PATCH] i2c: imx: Add arbitration lost check Haibo Chen [not found] ` <1409561920-9939-1-git-send-email-haibo.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org> 2014-09-02 2:53 ` fugang.duan-KZfg59tc24xl57MIdRCFDg 2014-09-02 10:43 ` Wolfram Sang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).