diff options
-rw-r--r-- | drivers/i2c/busses/i2c-bfin-twi.c | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c index c2e6b7849e8d..4799c6886946 100644 --- a/drivers/i2c/busses/i2c-bfin-twi.c +++ b/drivers/i2c/busses/i2c-bfin-twi.c | |||
@@ -130,21 +130,25 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface, | |||
130 | } | 130 | } |
131 | iface->transPtr++; | 131 | iface->transPtr++; |
132 | iface->readNum--; | 132 | iface->readNum--; |
133 | } else if (iface->manual_stop) { | 133 | } |
134 | /* Temporary workaround to avoid possible bus stall - | 134 | |
135 | * Flush FIFO before issuing the STOP condition | 135 | if (iface->readNum == 0) { |
136 | */ | 136 | if (iface->manual_stop) { |
137 | read_RCV_DATA16(iface); | 137 | /* Temporary workaround to avoid possible bus stall - |
138 | write_MASTER_CTL(iface, | 138 | * Flush FIFO before issuing the STOP condition |
139 | read_MASTER_CTL(iface) | STOP); | 139 | */ |
140 | } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT && | 140 | read_RCV_DATA16(iface); |
141 | iface->cur_msg + 1 < iface->msg_num) { | ||
142 | if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD) | ||
143 | write_MASTER_CTL(iface, | ||
144 | read_MASTER_CTL(iface) | RSTART | MDIR); | ||
145 | else | ||
146 | write_MASTER_CTL(iface, | 141 | write_MASTER_CTL(iface, |
147 | (read_MASTER_CTL(iface) | RSTART) & ~MDIR); | 142 | read_MASTER_CTL(iface) | STOP); |
143 | } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT && | ||
144 | iface->cur_msg + 1 < iface->msg_num) { | ||
145 | if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD) | ||
146 | write_MASTER_CTL(iface, | ||
147 | read_MASTER_CTL(iface) | RSTART | MDIR); | ||
148 | else | ||
149 | write_MASTER_CTL(iface, | ||
150 | (read_MASTER_CTL(iface) | RSTART) & ~MDIR); | ||
151 | } | ||
148 | } | 152 | } |
149 | } | 153 | } |
150 | if (twi_int_status & MERR) { | 154 | if (twi_int_status & MERR) { |
@@ -245,12 +249,13 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface, | |||
245 | } | 249 | } |
246 | } | 250 | } |
247 | 251 | ||
248 | if (iface->pmsg[iface->cur_msg].len <= 255) | 252 | if (iface->pmsg[iface->cur_msg].len <= 255) { |
249 | write_MASTER_CTL(iface, | 253 | write_MASTER_CTL(iface, |
250 | (read_MASTER_CTL(iface) & | 254 | (read_MASTER_CTL(iface) & |
251 | (~(0xff << 6))) | | 255 | (~(0xff << 6))) | |
252 | (iface->pmsg[iface->cur_msg].len << 6)); | 256 | (iface->pmsg[iface->cur_msg].len << 6)); |
253 | else { | 257 | iface->manual_stop = 0; |
258 | } else { | ||
254 | write_MASTER_CTL(iface, | 259 | write_MASTER_CTL(iface, |
255 | (read_MASTER_CTL(iface) | | 260 | (read_MASTER_CTL(iface) | |
256 | (0xff << 6))); | 261 | (0xff << 6))); |
@@ -264,8 +269,8 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface, | |||
264 | write_INT_MASK(iface, 0); | 269 | write_INT_MASK(iface, 0); |
265 | write_MASTER_CTL(iface, 0); | 270 | write_MASTER_CTL(iface, 0); |
266 | } | 271 | } |
272 | complete(&iface->complete); | ||
267 | } | 273 | } |
268 | complete(&iface->complete); | ||
269 | } | 274 | } |
270 | 275 | ||
271 | /* Interrupt handler */ | 276 | /* Interrupt handler */ |