Using a SPI port on DM365

Using a SPI port on DM365

  • Hi,

     

    I am trying to connect the LeopardBoard DM365 with board using the SPI port. I read of the "User mode SPI device driver support" in make config but I am unsure of how to configure and use it. Could anyone point me in the right direction?

     

    Thanks.

     

    Regards,
    Irwin Liew

  • Please refer to the kernel documentation at

    $DEVDIR/kernel/linux-2.6.32/Documentation/spi

  • Hi Todd,

    Is the SPI initialized on startup or do I have to initialize myself? I can't find the spi0 device in /dev/spi0. If spi0 is not initialize how do you do it?

    Thanks.

    Regards.

    Irwin Liew

  • Hi,

    In order to use Spi0 you need to check the following files:

    LeopardBoardDM365sdkEVAL2011Q2/bootloader/u-boot-2010.12-rc2-psp03.01.01.39/src/board/davinci/dm365leopard/dm365leopard.c and check for Pinmux values

    Also

    LeopardBoardDM365sdkEVAL2011Q2/bootloader/u-boot-2010.12-rc2-psp03.01.01.39/src/include/configs/davinci_dm365leopard.h and check for the SPI base

    Carlos Aguero
    Embedded Software Engineer
    RidgeRun

  • hi,Carlos

    if i want to use Leopardboard J8,GIO22 -GIO25 ,say ,spi0_scs[0],spi0_sclk,spi0_somi,spi0_simo

    as your post above,i must revise dm365leopard.c

    original code

    /* Enable SPI0 ports */

    /* writel(((readl(PINMUX3) & 0x81FFFFFF) | 0x36000000), PINMUX3); */

    /* REG(PINMUX3) |= 0x36000000; */

    /* Enable SPI1 ports */

    writel(((readl(PINMUX3) & 0x7FFFFFFF) | 0x80000000), PINMUX3);

    writel(((readl(PINMUX4) & 0xFFFFFFC0) | 0x00000015), PINMUX4);

    // REG(PINMUX3) |= 0x80000000;

    // REG(PINMUX4) |= 0x00000015;

    revised to

    /* Enable SPI0 ports */

    writel(((readl(PINMUX3) & 0x81FFFFFF) | 0x36000000), PINMUX3);

    REG(PINMUX3) |= 0x36000000;

    /* Enable SPI1 ports */

    writel(((readl(PINMUX3) & 0x7FFFFFFF) | 0x80000000), PINMUX3);

    writel(((readl(PINMUX4) & 0xFFFFFFC0) | 0x00000015), PINMUX4);

    // REG(PINMUX3) |= 0x80000000;

    // REG(PINMUX4) |= 0x00000015;

    and davinci_dm365leopard.h

    #define CONFIG_SYS_SPI_BASE 0x01c66800

    #define CONFIG_SYS_SPI0_BASE 0x01c66000

    #define CONFIG_SYS_SPI1_BASE 0x01c66800

    #define CONFIG_SYS_SPI2_BASE 0x01c67800

    #define CONFIG_SYS_SPI3_BASE 0x01c68000

    #define CONFIG_SYS_SPI4_BASE 0x01c23000

    needn't revise

    Am i right?

  • Hi,

    You need to remove the SPI1 from the code (or comment it)

    /* Enable SPI0 ports */

    /* writel(((readl(PINMUX3) & 0x81FFFFFF) | 0x36000000), PINMUX3); */

    /* REG(PINMUX3) |= 0x36000000; */

    /* Enable SPI1 ports */

    writel(((readl(PINMUX3) & 0x7FFFFFFF) | 0x80000000), PINMUX3);

    writel(((readl(PINMUX4) & 0xFFFFFFC0) | 0x00000015), PINMUX4);

    // REG(PINMUX3) |= 0x80000000;

    // REG(PINMUX4) |= 0x00000015;

    revised to

    /* Enable SPI0 ports */

    writel(((readl(PINMUX3) & 0x81FFFFFF) | 0x36000000), PINMUX3);

    //REG(PINMUX3) |= 0x36000000;

    /* Enable SPI1 ports */

    //writel(((readl(PINMUX3) & 0x7FFFFFFF) | 0x80000000), PINMUX3);

    //writel(((readl(PINMUX4) & 0xFFFFFFC0) | 0x00000015), PINMUX4);

    // REG(PINMUX3) |= 0x80000000;

    // REG(PINMUX4) |= 0x00000015;

    Davinci_dm365leopard.h doesn't need to be changed

    As Todd said, documentation can help a lot, a good guide of the dm365 registers can be found at TI's website:


    http://focus.ti.com/dsp/docs/dspsupporttechdocs.tsp?sectionId=3&tabId=409&viewType=mostuseful&rootFamilyId=44&familyId=1446&docCategoryId=6

    Look for the DM365 ARM subsystem

    Carlos Aguero
    Embedded Software Engineer
    RidgeRun

  • hi,carlos

    why do you revise u-boot code,that is LeopardBoardDM365sdkEVAL2011Q2/bootloader/u-boot-2010.12-rc2-psp03.01.01.39/src/board/davinci/dm365leopard/dm365leopard.c ,and not kernel/linux-2.6.32.17-psp03.01.01.39/arch/arm/mach-davinci/board-dm365-leopard.c

    i think you should revise kernel,not uboot.

    why?any comment?thank u.

  • hi,

    That depends on your needs, SPI at uboot can be used to configure some device (that can be done at kernel too). If you dont initialize pinmux SPI registers at uboot you will need to do it at the board-dm365-leopard.c

    If you want to use SPI at kernel there's documentation about SPI and kernel at:

    $DEVDIR/kernel/linux-2.6.32/Documentation/spi

    Carlos Aguero
    Embedded Software Engineer
    RidgeRun