omap2-mcspi, invalid SPI data received
From: Jonatan Magnusson
Date: Thu Aug 18 2016 - 07:48:06 EST
Hi,
I have this problem that originally started when I tried to use an ENC28J60 device on a Beaglebone (Beaglebone Green Wireless). I noted that while reading one register on the device (EREVID) the value was 0x3C. That register holds the hardware revision and should not be higher than 6 or possibly 7. So I started investigating the code and to make a long story short I ended up writing this silly loop that continuously reads and prints out EREVID:
for(;;) {
printk(KERN_ALERT "REV: 0x%02x\n", nolock_regb_read(priv, EREVID));
}
It reports 0x3C every time so itâs not completely random. If I force the pin to 0V i get 0x00 instead, and 0xFF if I force the pin to 3.3V. That should mean that the hardware config and pinmux is correct, since otherwise it would not change anything if I manipulate the pin.
With this loop active I could investigate what happens with a scope and to my surprise both the sent byte and the received byte are what to be expected: 0x12 and 0x06. But somehow the SPI driver still reads 0x3C instead of 0x06.
Hereâs two screenshots from the scope: https://dl.dropboxusercontent.com/u/176615/erevid.png
The first shows clock and mosi, the second clock and miso.
Iâve tried to track the error and got as far as drivers/spi/spi-omap2-mcspi.c, function omap2_mcspi_txrx_pio. Around line 715, readl_relaxed returns 0x3C.
Any ideas?
Best regards,
Jonatan Magnusson