i2c: imx: Add arbitration lost check
PATCH v2 1/1 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.
---
Changes for V2:
-Use 'EAGAIN' instead of 'EIO' for arbitration lost -Modify the comment style
drivers/i2c/busses/i2c-imx.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/i2c/busses/i2c-imx.c +8 -0
@@ -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 -EAGAIN ; + } +if (for_busy && (temp &I2SR_IBB ))break ;if (!for_busy && !(temp &I2SR_IBB ))
Signature · 1 line
1.9.1
A message that is not in the archive (sent off-list or not yet received): 1409723527-30603-1-git-send-email-haibo.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org
Hi, Wolfram,
From: Haibo Chen <[email protected]> Sent: Wednesday, September 03, 2014 1:52 PM + 0800
Quoted 48 lines
To: wsa-z923LK4zBo2bacvFa/[email protected]
Cc: Duan Fugang-B38611; [email protected]
Subject: [PATCH v2] i2c: imx: Add arbitration lost checkAccording 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 <[email protected]>Acked-by Fugang Duan <[email protected]>---
Changes for V2:
-Use 'EAGAIN' instead of 'EIO' for arbitration lost -Modify the comment styledrivers/i2c/busses/i2c-imx.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/i2c/busses/i2c-imx.c +8
-0@@ -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 -EAGAIN ; + } +if (for_busy && (temp &I2SR_IBB ))break ;if (!for_busy && !(temp &
I2SR_IBB))
--
1.9.1
Quoted 1 line
--
Can you apply the patch or other comments ?
Thanks,
Haibo
Wolfram Sang
Applieddrivers/i2c/busses/i2c-imx.c
Quoted 23 lines · Haibo Chen
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 <[email protected]>Acked-by Fugang Duan <[email protected]>---
Changes for V2:(quoted diff) +0
-2-Use 'EAGAIN' instead of 'EIO' for arbitration lost -Modify the comment style drivers/i2c/busses/i2c-imx.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/i2c/busses/i2c-imx.c +0
-0
Applied to for-next, thanks!