2009-02-09 18:10:18 bug in i2c-bfin-twi.c?
Frank Shew (UNITED STATES)
Message: 69152
We have a custom BF537 board with an I2C RTC (MAX DS3231) running uclinux 2007R1 for some time. Recently during migration to 2008R1.5-RC3 we losted access to the RTC. The RTC driver calls 'i2c_transfer()' which in turns calls 'bfin_twi_master_xfer()' in i2c-bfin-twi.c.
Compared with 2007R1, it looks like the 2008R1.5 version of i2c-bin-twi.c has a new mode 'TWI_I2C-MODE_REPEAT' which corresponds to the Repeat Start Condition described in the HRM. However, according to the HRM, at XMIT or RECV interrupt and when the data count is 0, not only is the RESTART bit supposed to be set, but MDIR must also be set if the next operation is a receive sequence, and cleared if not. Currently there is no code that looks at the I2C_M_RD bit in the flag from the next cur_msg and set/clear the MDIR flag accordingly at the same time that the RSTART bit is set. Instead, MDIR is set or cleared (by OR'ing with 0?) after the RESTART bit has been cleared during handling of MCOMP interrupt.
It appears that this is causing our failure with reading the RTC, as a quick patch to set/clear MDIR when RESTART is set seem to solve our problem.
Frank
QuoteReplyEditDelete
2009-02-09 20:44:29 Re: bug in i2c-bfin-twi.c?
Yi Li (CHINA)
Message: 69159
Frank,
Could you post or attach the patch here? So we can have a test.
Thanks,
-Yi
QuoteReplyEditDelete
2009-02-10 22:41:03 Re: bug in i2c-bfin-twi.c?
Frank Shew (UNITED STATES)
Message: 69230
Hi Yi,
Here's the patch to apply to i2c_bfin_twi.c (2008r1.5-rc3). I've tried xfer sequences of Write-Read-Write-Read, W-R-R, and W-W-R and they seem to work.
Its a little messy handling the RCVSERV interupt, as the HRM seems to suggest that RSTART and MDIR should be set as early as possible (I.E., on the 1st recv interrupt), so the kludge I have does this at every RECVSERV interrupt.
Frank
twi.patch
QuoteReplyEditDelete
2009-02-13 03:00:19 Re: bug in i2c-bfin-twi.c?
Yi Li (CHINA)
Message: 69377
Franks,
Thanks. The patch/bug is being tracked at:
blackfin.uclinux.org/gf/project/uclinux-dist/tracker/?action=TrackerItemEdit&tracker_item_id=4901
-Yi