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.

AM3517 SPI pin muxing details

Other Parts Discussed in Thread: AM3517

Hi All,

I am working on AM3517 custom board. I want to configure the SPI interface 1 and 2. For the same i did the follwoing chnages in the uboot and kernel. But i didn't see any pulses from MCSPI1_SIMO and MCSPI2_SIMO signals when i execute the following command from console

echo "SPI TEST" >/dev/spidev1.0  

echo "ASHOK" >/dev/spidev2.0

Can any one verify my changes below and let me know if i missed any thing.?

Changes made in uboot

board/adlink/sm3517/sm3517.h

        MUX_VAL(CP(MCSPI1_CLK),         (IEN  | PTU | DIS | M0)) /*MCSPI1_CLK */\
        MUX_VAL(CP(MCSPI1_SIMO),        (IEN  | PTU | DIS | M0)) /*MCSPI1_SIMO */\
        MUX_VAL(CP(MCSPI1_SOMI),        (IEN  | PTU | EN  | M0)) /*MCSPI1_SOMI*/\
        MUX_VAL(CP(MCSPI1_CS0),         (IEN  | PTU | EN  | M0)) /*MCSPI1_CS0 */\
        MUX_VAL(CP(MCSPI1_CS1),         (IEN  | PTD | EN  | M4)) /*GPIO_175*/\
        MUX_VAL(CP(MCSPI1_CS2),         (IEN  | PTU | DIS | M4)) /*GPIO_176*/\
                                                         /* - LAN_INTR*/\
        MUX_VAL(CP(MCSPI1_CS3),         (IEN  | PTD | EN  | M0)) \
        \
        MUX_VAL(CP(MCSPI2_CLK),         (IEN  | PTU | DIS | M0)) /*MCSPI2_CLK*/\
        MUX_VAL(CP(MCSPI2_SIMO),        (IEN  | PTU | DIS | M0)) /*MCSPI2_SIMO*/\
        MUX_VAL(CP(MCSPI2_SOMI),        (IEN  | PTU | EN  | M0)) /*MCSPI2_SOMI*/\
        MUX_VAL(CP(MCSPI2_CS0),         (IEN  | PTU | EN  | M0)) /*MCSPI2_CS0*/\
        MUX_VAL(CP(MCSPI2_CS1),         (IEN  | PTU | EN  | M0)) /*MCSPI2_CS1*/\

Below is the PIN used for SPI interface as per my schematic

SPI

SPI interface           -    AM3517 Pin names
SPI1_CS0_3V         -    GPIO_174/MMC2_DAT7/MCSPI1_CS0    
SPI1_CLK_3V        -    GPIO_171/MMC2_DAT4/MCSPI1_CLK        
SPI1_SOMI_3V        -    GPIO_173/MMC2_DAT6/MCSPI1_SOMI
SPI1_SIMO_3V        -    GPIO_172/MMC2_DAT5/MCSPI1_SIMO

SPI0

SPI interface           -    AM3517 Pin names
SPI2_CLK_3V        -     GPIO_178/HSUSB2_DATA7/HSUSB2_TLL_DATA7/MCSPI2_CLK
SPI2_SOMI_3V        -    GPIO_180/HSUSB2_DATA5/HSUSB2_TLL_DATA5/GPT10_PWM_EVT/MCSPI2_SOMI    
SPI2_SIMO_3V        -    GPIO_179/HSUSB2_DATA4/HSUSB2_TLL_DATA4/GPT9_PWM_EVT/MCSPI2_SIMO
SPI2_CS0_3V        -    GPIO_181/HSUSB2_DATA6/HSUSB2_TLL_DATA6/GPT11_PWM_EVT/MCSPI2_CS0
SPI2_CS1_3V        -    GPIO_182/MM_FSUSB_TXEN_N/HSUSB2_DATA3/HSUSB2_TLL_DATA3/GPT8_PWM_EVT/MCSPI2_CS1

Code changes in the Kernel

1. .config file

CONFIG_SPI=y
CONFIG_SPI_DEBUG=y
CONFIG_SPI_MASTER=y
CONFIG_SPI_OMAP24XX=y
CONFIG_SPI_SPIDEV=y

2. Board file  (arch/arm/mach-omap2/board-am3517evm.c)

static struct spi_board_info tcw_spi_board_info[] = {
        {
                .modalias       = "spidev",
                .max_speed_hz   = 48000000, //48 Mbps
                .bus_num        = 1,
                .chip_select    = 0,
                .mode = SPI_MODE_1 | SPI_CS_HIGH,
        },
        {
                .modalias       = "spidev",
                .max_speed_hz   = 48000000, //48 Mbps
                .bus_num        = 2,
                .chip_select    = 0,
/*                .mode = SPI_MODE_3, */
                .mode = SPI_MODE_1 | SPI_CS_HIGH,
        },

};

static void __init am3517_evm_init(void)
{

................

................

        spi_register_board_info(tcw_spi_board_info,
                       ARRAY_SIZE(tcw_spi_board_info));

}

  • Hi Ashok,

    Can you verify the pinmuxing from user space? Do the following:

    mount -t debugfs none /sys/kernel/debug/

    Then "cat" the files corresponding to the pins you are using inside /sys/kernel/debug/omap_mux/.

    Best regards,
    Miroslav

  • Hi Miroslav,

    Thanks for your response. Please find the details below. Please let me know if anything wrong in the muxing. I am not even getting the SPI cock output. 

    Mux Details

    cat /sys/kernel/debug/omap_mux/mcspi1_clk
    name: mcspi1_clk.mcspi1_clk (0x480021c8/0x198 = 0x0118), b ab3, t NA
    mode: OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0
    signals: mcspi1_clk | NA | NA | NA | NA | NA | NA | safe_mode

    root@am3517-evm:~# cat /sys/kernel/debug/omap_mux/mcspi1_somi
    name: mcspi1_somi.mcspi1_somi (0x480021cc/0x19c = 0x0118), b aa4, t NA
    mode: OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0
    signals: mcspi1_somi | NA | NA | NA | NA | NA | NA | safe_mode


    root@am3517-evm:~# cat /sys/kernel/debug/omap_mux/mcspi1_simo
    name: mcspi1_simo.mcspi1_simo (0x480021ca/0x19a = 0x0000), b ab4, t NA
    mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
    signals: mcspi1_simo | NA | NA | NA | NA | NA | NA | safe_mode


    root@am3517-evm:~# cat /sys/kernel/debug/omap_mux/mcspi2_clk
    name: mcspi2_clk.mcspi2_clk (0x480021d6/0x1a6 = 0x0118), b aa3, t NA
    mode: OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0
    signals: mcspi2_clk | NA | NA | NA | NA | NA | NA | safe_mode

    root@am3517-evm:~# cat /sys/kernel/debug/omap_mux/mcspi2_somi
    name: mcspi2_somi.mcspi2_somi (0x480021da/0x1aa = 0x0118), b y3, t NA
    mode: OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0
    signals: mcspi2_somi | NA | NA | NA | NA | NA | NA | safe_mode

    root@am3517-evm:~# cat /sys/kernel/debug/omap_mux/mcspi2_simo
    name: mcspi2_simo.mcspi2_simo (0x480021d8/0x1a8 = 0x0000), b y2, t NA
    mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
    signals: mcspi2_simo | NA | NA | NA | NA | NA | NA | safe_mode

    root@am3517-evm:~# cat /sys/kernel/debug/omap_mux/mcspi2_c    
    mcspi2_clk  mcspi2_cs0  mcspi2_cs1  

    root@am3517-evm:~# cat /sys/kernel/debug/omap_mux/mcspi2_c
    mcspi2_clk  mcspi2_cs0  mcspi2_cs1  

    root@am3517-evm:~# cat /sys/kernel/debug/omap_mux/mcspi2_cs0
    name: mcspi2_cs0.mcspi2_cs0 (0x480021dc/0x1ac = 0x0000), b y4, t NA
    mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
    signals: mcspi2_cs0 | NA | NA | NA | NA | NA | NA | safe_mode

    root@am3517-evm:~# cat /sys/kernel/debug/omap_mux/mcspi2_cs1
    name: mcspi2_cs1.mcspi2_cs1 (0x480021de/0x1ae = 0x0000), b v3, t NA
    mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
    signals: mcspi2_cs1 | NA | NA | NA | NA | NA | NA | safe_mode

     

  • Ashok, please attach a log file of the boot process to check if there are any spi related error messages.

    Also, please check both the SOMI and SIMO pins of the SPI interface for any output when trying to send data. Looking at the TRM, by default the SOMI pin is configured for transmission.

    Best regards,
    Miroslav

  • hi Miroslav,

    I attached the console log and dmesg logs for your reference. I don't see any pulses from the SPI data lines.

    Please let me know where the SPI controller will get configured. It will be appreciated if you point out the driver file details  

    Thanks,

    P.Ashok

    6204.AM3517_console_log.txt

  • Ashok,

    The mcspi driver is located inside <kernel_dir>/drivers/spi/spi-omap2-mcspi.c.

    There is something odd about your spi_clk pinmuxing. In U-Boot it seems like you set the pull to disabled:

    ASHOK palaniswamy said:
    MUX_VAL(CP(MCSPI1_CLK),         (IEN  | PTU | DIS | M0)) /*MCSPI1_CLK */\

    , but later in user space it is shown as enabled:

    ASHOK palaniswamy said:
    name: mcspi1_clk.mcspi1_clk (0x480021c8/0x198 = 0x0118), b ab3, t NA
    mode: OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0

    Can you please try to do the pinmuxing in kernel (in the board config file), not in U-Boot, using the omap_mux_init_signal() function (located inside <kernel_dir>/arch/arm/mach-omap2/mux.c).

    Another approach to testing the SPI communication is to use the spidev_test application. The source code is located inside <kernel_dir>/Documentation/spi/spidev_test.c. Just cross compile it, copy it on the target system, short the SOMI and SIMO pins of the SPI interface you wish to test and then run the application:

    spitest -D /dev/spidevX

    Best regards,
    Miroslav

  • ASHOK palaniswamy said:

    echo "SPI TEST" >/dev/spidev1.0  

    echo "ASHOK" >/dev/spidev2.0

    The spidev driver doesn't support a redirection from echo.  You should use the spi test utils mentioned in a previous post or write your own app to test the spi.  The MCSPI allows you to configure the pins as either MISO or MOSI, so check that the kernel settings are what you require.  If you write your own app, the steps are something like:

    long data = 12

    spimsg.tx_buf = &data;

    spifd = open(spidev1.0)

    ioctl(spifd, SPI_IOC_MESSAGE(1), spimsg)

    close(spifd)


    There should be a clock even if the MISO/MOSI don't toggle.  Having the clock means that part of the spidev driver was configured properly.

  • Hi Miroslav,

    Thanks for your input. I used the spidev_test tool and shorted the pins SOMI and SIMO of the SPI 0 and 1 interface.

    When i run the test i got few data's. Please let me know how to validate the SPI interface using this tool. I attached the spidev test log message for your reference. Please let me know if anything wrong in this logs.

    Thanks,

    P.Ashok

    5488.SPI_dev_test_log.txt
    root@am3517-evm:/# ./spi -D /dev/spidev1.0 
    [   99.492401] ASHOK DEBUG: spi->mode: 0 spi->master->mode_bits: 7 
    [   99.498840] ASHOK :  function: omap2_mcspi_setup  Line :801 
    [   99.504760] ASHOK :  function: omap2_mcspi_request_dma  Line :767 
    [   99.511322] ASHOK :  function: omap2_mcspi_setup_transfer  Line :667 
    [   99.518127] spidev spi1.0: setup: speed 48000000, sample leading edge, clk normal
    [   99.526000] spidev spi1.0: setup mode 0, 8 bits/w, 48000000 Hz max --> 0
    [   99.533050] spidev spi1.0: spi mode 00
    [   99.539367] ASHOK DEBUG: spi->mode: 0 spi->master->mode_bits: 7 
    [   99.545989] ASHOK :  function: omap2_mcspi_setup  Line :801 
    [   99.551940] ASHOK :  function: omap2_mcspi_setup_transfer  Line :667 
    [   99.558715] spidev spi1.0: setup: speed 48000000, sample leading edge, clk normal
    [   99.566619] spidev spi1.0: setup mode 0, 8 bits/w, 48000000 Hz max --> 0
    [   99.573669] spidev spi1.0: 8 bits per word
    [   99.578643] ASHOK DEBUG: spi->mode: 0 spi->master->mode_bits: 7 
    [   99.584991] ASHOK :  function: omap2_mcspi_setup  Line :801 
    [   99.590942] ASHOK :  function: omap2_mcspi_setup_transfer  Line :667 
    [   99.597717] spidev spi1.0: setup: speed 375000, sample leading edge, clk normal
    [   99.605407] spidev spi1.0: setup mode 0, 8 bits/w, 500000 Hz max --> 0
    [   99.612304] spidev spi1.0: 500000 Hz (max)
    spi mode: 0[   99.619567] ASHOK :omap2_mcspi_transfer 1030 
    [   99.624847] ASHOK : Prepare for Transfer 1038 
    [   99.629516] ASHOK : call queue_work 
    
    bits per word:[   99.633392] ASHOK :omap2_mcspi_work 884 
     8
    max speed: 5[   99.639129] ASHOK :  function: omap2_mcspi_setup_transfer  Line :667 
    00000 Hz (500 KH[   99.647064] spidev spi1.0: setup: speed 375000, sample leading edge, clk normal
    z)
    [   99.656127] ASHOK :omap2_mcspi_work t->len 38 
    [   99.661102] ASHOK :omap2_mcspi_work Calling omap2_mcspi_txrx_pio  
    [   99.668518] ASHOK :omap2_mcspi_work Restore defaults if they were overriden  
    [   99.675994] ASHOK :  function: omap2_mcspi_setup_transfer  Line :667 
    [   99.682800] spidev spi1.0: setup: speed 375000, sample leading edge, clk normal
    [   99.690460] ASHOK :omap2_mcspi_work omap2_mcspi_set_enable 
    [   99.696350] ASHOK :omap2_mcspi_work omap2_mcspi_disable_clocks 
    
    80 80 80 80 80 80 
    40 00 00 00 00 95 
    80 80 80 80 80 80 
    80 80 80 80 80 80 
    80 80 80 80 80 80 
    90 A9 A0 88 A2 A9 
    80 09 
    root@am3517-evm:/# 
    root@am3517-evm:/# 
    root@am3517-evm:/# 
    root@am3517-evm:/# 
    root@am3517-evm:/# 
    root@am3517-evm:/# ./spi -D /dev/spidev2.0 
    [  118.491394] ASHOK DEBUG: spi->mode: 0 spi->master->mode_bits: 7 
    [  118.497802] ASHOK :  function: omap2_mcspi_setup  Line :801 
    [  118.503753] ASHOK :  function: omap2_mcspi_setup_transfer  Line :667 
    [  118.510559] spidev spi2.0: setup: speed 48000000, sample leading edge, clk normal
    [  118.518432] spidev spi2.0: setup mode 0, 8 bits/w, 48000000 Hz max --> 0
    [  118.525482] spidev spi2.0: spi mode 00
    [  118.530517] ASHOK DEBUG: spi->mode: 0 spi->master->mode_bits: 7 
    [  118.536895] ASHOK :  function: omap2_mcspi_setup  Line :801 
    [  118.542846] ASHOK :  function: omap2_mcspi_setup_transfer  Line :667 
    [  118.549621] spidev spi2.0: setup: speed 48000000, sample leading edge, clk normal
    [  118.557495] spidev spi2.0: setup mode 0, 8 bits/w, 48000000 Hz max --> 0
    [  118.564544] spidev spi2.0: 8 bits per word
    [  118.571166] ASHOK DEBUG: spi->mode: 0 spi->master->mode_bits: 7 
    [  118.577758] ASHOK :  function: omap2_mcspi_setup  Line :801 
    [  118.583740] ASHOK :  function: omap2_mcspi_setup_transfer  Line :667 
    [  118.590484] spidev spi2.0: setup: speed 375000, sample leading edge, clk normal
    [  118.598175] spidev spi2.0: setup mode 0, 8 bits/w, 500000 Hz max --> 0
    [  118.605041] spidev spi2.0: 500000 Hz (max)
    spi mode: 0[  118.610656] ASHOK :omap2_mcspi_transfer 1030 
    [  118.615936] ASHOK : Prepare for Transfer 1038 
    [  118.620605] ASHOK : call queue_work 
    
    bits per word:[  118.624481] ASHOK :omap2_mcspi_work 884 
     8
    max speed: 5[  118.629943] ASHOK :  function: omap2_mcspi_setup_transfer  Line :667 
    00000 Hz (500 KH[  118.638122] spidev spi2.0: setup: speed 375000, sample leading edge, clk normal
    z)
    [  118.647186] ASHOK :omap2_mcspi_work t->len 38 
    [  118.652160] ASHOK :omap2_mcspi_work Calling omap2_mcspi_txrx_pio  
    [  118.659576] ASHOK :omap2_mcspi_work Restore defaults if they were overriden  
    [  118.667083] ASHOK :  function: omap2_mcspi_setup_transfer  Line :667 
    [  118.674102] spidev spi2.0: setup: speed 375000, sample leading edge, clk normal
    [  118.681793] ASHOK :omap2_mcspi_work omap2_mcspi_set_enable 
    [  118.687683] ASHOK :omap2_mcspi_work omap2_mcspi_disable_clocks 
    
    FF FF FF FF FF FF 
    40 00 00 00 00 95 
    FF FF FF FF FF FF 
    FF FF FF FF FF FF 
    FF FF FF FF FF FF 
    DE AD BE EF BA AD 
    F0 0D
    

  • Ashok,

    The output you get is absolutely correct. The spidev_test tool should transfer the following byte sequence:

        uint8_t tx[] = {
            0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
            0x40, 0x00, 0x00, 0x00, 0x00, 0x95,
            0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
            0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
            0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
            0xDE, 0xAD, 0xBE, 0xEF, 0xBA, 0xAD,
            0xF0, 0x0D,

    and this is exactly what you get. This is how you validate your SPI interface.

    Best regards,
    Miroslav

  • Hi Miroslav,

    Thanks for the details.   But i am not sure why i didn't get any pulses from SPI_CLK, SPI_SOMI, SPI_SIMO when i verify with scope

    Thanks,

    P.Ashok