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.

SPI query for multi-channel usage

Other Parts Discussed in Thread: AM3352

Hi

I am using SDk 7 and AM3352. I am facing an issue with MCSPI driver. We only use the second SPI master( from TRM we understand AM335x provides 2 master's and 2 chip selects per each master ).

use case: In addition to the spidev driver utilizing the SPI node Spidev2.1( initialized via linux device tree ), we also have our own custom driver which makes use of SPI 2.0. i.e. SPI master 2 and chip select 0.

As far as I understood, the McSPI driver is configured as a single channel master. Following is the sequence and what works and what does not:

1) Verify spidev nodes correctly initialized at bootup. Use an application to read/write on the spidev2.1 node. Everything works fine as seen from the scope( both MISO/MOSI lines indicate data ).

2) Load our custom driver ( after which driver creates a new device object for master 2 and chip select 0 ). Also verified the MCSPI_CH0CONF was again being written for new node as base address of SPI controller is different for chip select 0 and 1. ( In case this helps, base address being used for master 2  and chip select 0 and 1 are:  4196008192 and 4196008212 respectively ( in decimal ) ).

3) Here the custom driver works correctly and we can verifiy that MISO/MOSI lines do transmit/receive data. Next we unload the custom driver.

4) Use an application to utilize spidev2.1 to read/write data. This does not work. We can only transmit data( MOSI has data) but not receive data ( MISO remains in default state ). We verified that on unloading the custom driver and utilizing our application the chip select 1 base address was utilized to re-configure MCSPI_CH0CONF. All read/write now seems to be happening on master 2 and  chip select 1.

As far as I can understand, the above should work as we use only one channel at a time and re-configure the channel when we switch between various chip selects.

Please do let me know your thoughts and if I am doing something which is fundamentally flawed. I have never worked on SPI earlier.

Regards

Manbir

  • HiSome more information.
    Also to add, I am using PIO mode. I also read the value of register MCSPI_CH0CONF just before transmission and reception. In all the cases, the value was 1442765( i.e. 0x1603CD ). So this indicates the following( from TRM ):
    1 - CPHA3h - CLKD8h - WL etc
    Among the interesting stuff, it indicates TRM = 0, data line 0 = tx, data line 1 = rx.
    The above register value does not change for any of the 4 steps I mentioned in the previous post. The only thing which changes is the base address ( depending on which chip select I wish to write to for the second SPI node).
    As of now I am not sure if I am missing a step or trying to achieve what AM335x was never intended to.
    Do share your thoughts. Thanks in advance for your inputs.Thanks and Regards
    Manbir Singh Jhawer
  • Hi Manbir,

    I will forward this to the SW team. Please post which Linux SDK you are using.

  • Hi Manbir,
    If you use only one channel at a time, it shouldn't be a problem.
    Can you provide a dump of the following registers:
    1. Load your custom driver & see the values of:
    conf_mcasp0_ahclkr - 0x44E1099C
    conf_mcasp0_axr0 - 0x44E10998
    Or whichever conf registers of whichever pins your spi1_d0 & spi1_d1 are muxed.
    see if any data is being written in:
    MCSPI_TX0
    MCSPI_RX0
    MCSPI_TX1
    MCSPI_RX1
    2. Unload your custom driver, utilize spidev2.1 & check the values of:
    conf_mcasp0_ahclkr - 0x44E1099C
    conf_mcasp0_axr0 - 0x44E10998
    and again see if any data is being written in:
    MCSPI_TX0
    MCSPI_RX0
    MCSPI_TX1
    MCSPI_RX1

    What happens if you utilize spidev2 cs0 & spidev2 cs1, instead of spidev & your custom driver? Do you experience the same problems?

    Best Regards,
    Yordan