This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335X MCSPI Problem - PSP_04.06.00.02

Other Parts Discussed in Thread: TLV320AIC26, AM3359, OMAP-L138, ADS7843

Hi,

I am having a problem with the linux mcspi driver for the AM335X product using the PSP_04.06.00.02 branch off of Arago.

Basically, it looks like the spi_write_then_read() calls don't work correctly.  We are able to see (using a scope) proper "read" requests to an AM335X connected to a TLV320AIC26, but the results from the MCSPI driver are not matching the scope.

The code in question is in the aic26_reg_read() method of sound/soc/codecs/tlv320aic26.c, the call

rc = spi_write_then_read(aic26->spi, buffer, 2, buffer, 2);

is failling.  This call, when you walk down into the mcspi driver is running a polled TXONLY transfer of 2 bytes followed by a polled RXONLY transfer of 2 bytes.  We are using the same codec code on other platforms without any issue, so I don't think there is a bug in the codec software.  Observing the SPI data lines, clock, and chip select lines with a scope it appears that the transmit portion is working fine, but the receive portion is not getting the received bytes (which are posted on the MISO data line) correctly.

If I use a "standard" 4 byte transfer (which uses a polled by-directional transfer in the driver) with something like snippet below, the SPI interface works (and our codec interface works), which implies the hardware and the SPI interface setup is OK.

{
u8 buffer[4];
struct spi_message message;
struct spi_transfer x;
spi_message_init(&message);
memset(buffer, 0, 4);
x.len = 4;
x.tx_buf = buffer;
x.rx_buf = buffer;
spi_message_add_tail(&x, &message);
cmd = AIC26_READ_COMMAND_WORD(reg);
buffer[0] = (cmd >> 8) & 0xff;
buffer[1] = cmd & 0xff;
rc = spi_sync(aic26->spi, &message);
value = (buffer[2] << 8) | buffer[3];
}
I suspect that the receive buffer on the MCSPI port is not getting drained / reset properly on TX_ONLY or RX_ONLY transfers, but haven't gotten to the bottom of it...
Anyone seen this before?
-Mike
  • Hi, Mike,

    Have you resolved this SPI receive issue.

    Recently we are using AM3359 SPI to receive data from external device. The SPI port is Rx-Only slave mode. When the external device drives 0x84, what we get from Rx receive register is 0x42, obviously lost the LSB. I'm thinking we meet the same problem you ever encountered. Not sure how you resolve this issue?

    According to the TFM page 4130,the SPI receiver requires extra edge to shift the complete byte into the shift register.(When the third edge occurs, the received data bit is shifted into the shift register. The next data bit of the master is provided to the serial input pin of the slave). This might be the cause of the issue.

    Thanks,

  • Hi,

    For your issue, are you sure you are configuring the SPI mode correctly?  If you have the wrong clock phase (CPH) or clock polarity, you might be on an  edge...

    We still haven't resolved the SPI issue I described in the original post.  For a while I was working around it by always providing both a Tx and Rx buffer on the driver calls, but we ran into another "off-the-shelf" linux spi based driver (for a ads7843) that we have used on the AM-1808 and OMAP-L138 that fails to operate properly with the AM3359 and the mcspi driver provided with the PSP.  It too is trying to do Rx and Tx only style transmissions.  Hacking every driver to sort this out is really not an option for us or our customers.

    I had hoped someone from TI might chime in on this, but not luck yet.  Given the mcspi driver is being widely used (I think) by several other OMAP class devices, I am beginning to suspect there may be a silicon issue or some quirk with this particular peripheral instance that the driver needs to handle.  Perhaps your TRM reference is the root cause?   If time permits I might be able to get back to this, but for now it's an open issue.  I expect a lot of folks will start making noise about this as more custom designs using SPI in different ways move into the validation phase with the AM335x parts if it's something as sinister as what it appears to be.

    -Mike

  • Hi, Mike,

    We configured the clock phase according to TRM. We also tried other clock phase setting, all couldn't work.  Now we are contacting local TI FAE to help on this issue. Meanwhile we are trying to use McASP port to replace the SPI, hope this can work.

    Thanks and Best Regards,

    Peng

     

  • Hi Peng, 

    Did you ever work around this issue?  Anyone advise the issue on the SPI?  I'm a little disappointed that no-one from TI has confirmed or denied this issue....

    -Mike

  • Hi, Mike,

    We eventually worked around this issue by modifying our hardware circuit design to invert the SPI clock input , and configing the AM3359 SPI clock mode to mode 1 instead of mode 3. If the SPI clock mode is 3, then incorrect data is shifted in.

    TI didn't send their own FAE to use, but they send one FAE from their distributor, However we figured out this workround by ourselves.

    Peng,

     

     

  • For what it's worth, we're using the McSPI in slave mode (under Sys/Bios) in mode 3 successfully, so it would seem that whatever problem you've observed is presumably a driver (not hardware) issue (provided your master is playing by the rules, of course).

    Darrin