Erratic MPC8248 CPM2 I2C behaviour
[Resent to the new i2c mailing list, [email protected] is deprecated]
Hi everybody,
I've been struggling with a weird CPM2 I2C behaviour for the past few days without much success.
Some background first. The platform is an MPC8248 (HiP7 Rev 14, Mask 1.0 1K50M) system with an I2C bus on which two peripherals are connected. Back to the ppc architecture days, Heiko Schocher's i2c-mpc8260 out of tree driver worked like a charm.
After switching to the powerpc architecture and Jochen Friedrich's driver, I've experienced erratic transfer timeouts. Quite frequent at first (2.6.26), the problems disappeared on the road to 2.6.27 and have now resurfaced.
As the problem never occured with a ppc kernel I'm pretty sure we can rule out hardware issues. Bad hardware initialisation (either in U-Boot or in the Linux kernel) is possible but in my opinion very unlikely, as timeouts occur about once every 5 boots at most.
I've added debugging messages to the i2c-cpm driver to track down the issue. Here's a sample successful I2C transaction (1 byte write followed by 1 byte read) with comments inlined:
-----------------------------------------------------------------------------
Quoted 4 lines
R: 0 T: 0
Parsing write message (addr0x90len 1)
R: 0 T: 1
Parsing read message (addr0x91len 1)
The two messages making up the transaction are parsed. The driver fills a TX buffer descriptor for the first one, and a TX and an RX buffer descriptor for the second one.
Quoted 1 line
IRQ 0 - 00 00 00 00 00 00 00 00
No I2C IRQ occured so far, more on this later.
Quoted 8 lines
rbase
0x01e0tbase0x01c0rfcr0x30tfcr0x30mrblr0x0201rstate0x00000000rptr0x00000000rbptr0x01e0rcount0x0000rtmp0x00000000tstate0x00000000tptr0x00000000tbptr0x01c0tcount0x0000ttmp0x00000000i2mod0x00, i2add0xfei2brg0x03i2com0x01i2cer0x00i2cmr0x00rx 0 sc0x9000tx 0 sc0x9400
rx 1 sc0x7da4tx 1 sc0xac00
rx 2 sc0xefeftx 2 sc0x743b
rx 3 sc0xf264tx 3 sc0x10e6
I2C controller registers and buffer descriptors state dump.
Quoted 1 line
Waiting on message 0.
The driver waits with wait_event_interruptible_timeout() for the end of the first message.
Quoted 1 line
IRQ 2 - 02 01 00 00 00 00 00 00
Two I2C interrupts occured, one for each message.
Quoted 14 lines
rbase
0x01e0tbase0x01c0rfcr0x30tfcr0x30mrblr0x0201rstate0x30000000rptr0x03905001rbptr0x01e8rcount0x0200rtmp0x00000000tstate0x30000000tptr0x03920002tbptr0x01c0tcount0x0000ttmp0x91000000i2mod0x01, i2add0xfei2brg0x03i2com0x01i2cer0x00i2cmr0x13rx 0 sc0x1800tx 0 sc0x1400
rx 1 sc0x7da4tx 1 sc0x2c00
rx 2 sc0xefeftx 2 sc0x743b
rx 3 sc0xf264tx 3 sc0x10e6
Message 0 completed.
tx sc0x1400
Waiting on message 1.
IRQ 2 - 02 01 00 00 00 00 00 00
rbase0x01e0tbase0x01c0rfcr0x30tfcr0x30mrblr0x0201rstate0x30000000rptr0x03905001rbptr0x01e8rcount0x0200rtmp0x00000000
Quoted 8 lines
tstate
0x30000000tptr0x03920002tbptr0x01c0tcount0x0000ttmp0x91000000i2mod0x01, i2add0xfei2brg0x03i2com0x01i2cer0x00i2cmr0x13rx 0 sc0x1800tx 0 sc0x1400
rx 1 sc0x7da4tx 1 sc0x2c00
rx 2 sc0xefeftx 2 sc0x743b
rx 3 sc0xf264tx 3 sc0x10e6
Message 1 completed.
tx sc0x2c00, rx sc0x1800
Both message have been successfully transmitted.
-----------------------------------------------------------------------------
I've rebooted the system, and the same transaction failed:
-----------------------------------------------------------------------------
Quoted 16 lines
R: 0 T: 0
Parsing write message (addr0x90len 1)
R: 0 T: 1
Parsing read message (addr0x91len 1)
IRQ 0 - 00 00 00 00 00 00 00 00
rbase0x01e0tbase0x01c0rfcr0x30tfcr0x30mrblr0x0201rstate0x00000000rptr0x00000000rbptr0x01e0rcount0x0000rtmp0x00000000tstate0x00000000tptr0x00000000tbptr0x01c0tcount0x0000ttmp0x00000000i2mod0x00, i2add0xfei2brg0x03i2com0x01i2cer0x00i2cmr0x00rx 0 sc0x9000tx 0 sc0x9400
rx 1 sc0x7da4tx 1 sc0xac00
rx 2 sc0xeeeftx 2 sc0x74bb
rx 3 sc0x7264tx 3 sc0x50e6
Waiting on message 0.
IRQ 0 - 00 00 00 00 00 00 00 00
rbase0x01e0tbase0x01c0rfcr0x30tfcr0x30mrblr0x0201
Quoted 8 lines
rstate
0x00000000rptr0x00000000rbptr0x01e0rcount0x0000rtmp0x00000000tstate0x30e00000tptr0x03914002tbptr0x01c0tcount0x0001ttmp0x90010000i2mod0x01, i2add0xfei2brg0x03i2com0x01i2cer0x00i2cmr0x13rx 0 sc0x9000tx 0 sc0x9400
rx 1 sc0x7da4tx 1 sc0xac00
rx 2 sc0xeeeftx 2 sc0x74bb
rx 3 sc0x7264tx 3 sc0x50e6
Message 0 timed out
Transmission timeout after one second. The first TX buffer descriptor status hasn't been modified by the CPM. The CPM state dump shows that processing of the first TX buffer has started, but the CPM stopped after the first byte (tcount is equal to 0x0001 and ttmp contains the 2 bytes to be transmitted). I assume the first byte has been written by the CPM to the I2C controller's register. Processing then stopped for an unknown reason.
Quoted 1 line
cpm_i2c_force_close()
-----------------------------------------------------------------------------
While trying to debug the issue I've added a dev_dbg() in the I2C interrupt handler. With that function being called by the interrupt handler I haven't been able to reproduce the problem. I thus removed the dev_dbg() call and replaced that with an interrupt counter and a table storing the first 8 interrupts events, and printed all those information outside the interrupt handler after wait_for_event_interruptible.
Timing issues come to mind, but what I've found really puzzling is that the above log shows that the interrupt handler hasn't been called at all (confirmed by /proc/interrupts). Why would a call to dev_dbg() in a function that is never called modify execution timings ? This might just be a coincidence.
Has anyone run into the same kind of problem with the CPM2 I2C controller ? All help will really be appreciated.
Best regards,
Signature · 9 lines
Laurent Pinchart CSE Semaphore Belgium Chaussee de Bruxelles, 732A B-1410 Waterloo Belgium T +32 (2) 387 42 59 F +32 (2) 387 42 75