Use master-abort for slave probes
cover Use master-abort for slave probes
Hi,
This series allows us to use the "master abort" feature when probing slaves rather than resetting the controller, which allows more graceful recovery to bus free state after sending the address byte.
The i2c-pxa controller expects to send data after the address byte rather than a stop. Rather than resetting the bus (and thus forcing a bus-free state by releasing the SCL line) which may leave the bus in an indeterminant state, use the master-abort command instead.
This patch series applies on top of the previous posted cleanup patches, although it may also apply to -rc.
drivers/i2c/busses/i2c-pxa.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up
PATCH 1/2 i2c: pxa: clear all master action bits in i2c_pxa_stop_message()
If we timeout during a message transfer, the control register may contain bits that cause an action to be set. Read-modify-writing the register leaving these bits set may trigger the hardware to attempt one of these actions unintentionally.
Always clear these bits when cleaning up after a message or after a timeout.
--- drivers/i2c/busses/i2c-pxa.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-pxa.c +2 -4
@@ -795,11 +795,9 @@ static inline void i2c_pxa_stop_message(struct pxa_i2c *i2c) {u32 icr; -/* -* Clear the STOP and ACK flags -*/ +/* Clear the START, STOP, ACK, TB and MA flags */ icr =readl (_ICR (i2c)); - icr &= ~(ICR_STOP |ICR_ACKNAK ); + icr &= ~(ICR_START |ICR_STOP |ICR_ACKNAK |ICR_TB |ICR_MA );writel (icr,_ICR (i2c)); }
Signature · 1 line
2.20.1
Wolfram Sang
AppliedRe: [PATCH 1/2] i2c: pxa: clear all master action bits in i2c_pxa_stop_message()
Quoted 9 lines · Russell King
If we timeout during a message transfer, the control register may contain bits that cause an action to be set. Read-modify-writing the register leaving these bits set may trigger the hardware to attempt one of these actions unintentionally.
Always clear these bits when cleaning up after a message or after a timeout.
Signed-off-by Russell King <[email protected]>
Applied to for-next, thanks! I was considering for-current, though, but there have been no real bug reports, so for-next it is.
PATCH 2/2 i2c: pxa: use master-abort for device probes
In reply to Russell King - ARM Linux adminUse master-abort to send the stop condition after an address cycle rather than resetting the controller.
--- drivers/i2c/busses/i2c-pxa.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-pxa.c +2 -8
@@ -940,14 +940,8 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr) icr &= ~ICR_ALDIE ; icr |=ICR_START |ICR_TB ; }else { -if (i2c->msg->len ==0 ) { -/* -* Device probes have a message length of zero -* and need the bus to be reset before it can -* be used again. -*/ -i2c_pxa_reset (i2c); - } +if (i2c->msg->len ==0 ) + icr |=ICR_MA ;i2c_pxa_master_complete (i2c,0 ); }
Signature · 1 line
2.20.1
Wolfram Sang
AppliedRe: [PATCH 2/2] i2c: pxa: use master-abort for device probes
Quoted 4 lines · Russell King
Use master-abort to send the stop condition after an address cycle rather than resetting the controller.
Signed-off-by Russell King <[email protected]>
Applied to for-next, thanks!