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.

MCSDK SPI driver manual

Other Parts Discussed in Thread: OMAPL138, DA8XX

Hi,

I've got custom board based on OMAPl138 running Linux from MCSDK.

I found spi driver in Drivers folder, but can't find any user guide on it, exept this one

http://processors.wiki.ti.com/index.php/MCSDK_User_Guide_for_OMAPL138

Is there any manual which describes how can I use this driver to configurate things plugged to SPI or any example of SPI driver usage?

Thanks.

  • Hi,

    In Linux perspective,

    You can use SPI driver documentation from "linux-source/Documentation/spi"

    If you want to understand the SPI low level init,

    http://processors.wiki.ti.com/index.php/StarterWare_SPI

    Refer this

    http://processors.wiki.ti.com/index.php/Linux_Core_SPI_User%27s_Guide

  • thanks for such fast answer!

    Will search for answer in this documents

  • One more question.

    Firstly I try to кгт SPI driver on LCDK.

    I set CONFIG_SPI=y in .config and modalias = "spidev" in board-da850-evm.c. as it says in documentation/spi/spidev

    But I can't see any /dev/spidev, when I run new kernel.

  • Hi,

    I set CONFIG_SPI=y in .config and modalias = "spidev" in board-da850-evm.c. as it says in documentation/spi/spidev

    How did you configured SPI in linux kernel?

    Whether using "menconfig" or diretcly editing the .config file?

    Use always for kernel configuration,

    make menuconfig ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi-

  • Hi,

    Today I configured SPI with menuconfig. (Choose everything in Device Driver->SPI support.)

    Loaded kernel to LCDK and couldn't see spidev in /dev.

  • Hi,

    Loaded kernel to LCDK and couldn't see spidev in /dev.

    Can you please ensure that you have enabled "User mode SPI device driver support"  (CONFIG_SPIDEV) support in menuconfig for SPIdev support,

    SPIdev support is for accessing the SPI from user space.

    If still you could not see then it could problem of udev population,

    So Try to create node manually and do your experiments,

    Also, the node should be something like /dev/spidevX.Y,

    where X is the bus no and Y is the chip select

    e.g. /dev/spidev0.1

    Q1) Do you have any SPI device on your board ?

    If yes,

    Q2) Have you provide your SPI platform data in your board file located at "arch/arm/mach-davicni/board-<your board>.c ?

    Say e.g.  board-omapl138_lcdk.c

    Something like this

    static struct flash_platform_data da850evm_spiflash_data = {
        .name        = "m25p80",
        .parts        = da850evm_spiflash_part,
        .nr_parts    = ARRAY_SIZE(da850evm_spiflash_part),
        .type        = "m25p64",
    };

    static struct davinci_spi_config da850evm_spiflash_cfg = {
        .io_type    = SPI_IO_TYPE_DMA,
        .c2tdelay    = 8,
        .t2cdelay    = 8,
    };

    static struct spi_board_info da850evm_spi_info[] = {
        {
            .modalias        = "m25p80",
            .platform_data        = &da850evm_spiflash_data,
            .controller_data    = &da850evm_spiflash_cfg,
            .mode            = SPI_MODE_0,
            .max_speed_hz        = 30000000,
            .bus_num        = 1,
            .chip_select        = 0,
        },
    };

    https://www.kernel.org/doc/Documentation/spi/spidev

  • I have choosed every menu item in SPI support section.

    I manually made spidev1.0 (mknod spidev1.0 p).

    There are structures struct flash_platform_data, struct davinci_spi_config, spi_board_info.

    Then I made testfile:

    int main( int argc, char *argv[] ){
        int i = 0;   
        i = open("/dev/spidev1.0", O_RDWR);
        printf("Device opened %d\n", i);   
        close(i);
        printf("Device closed\n");
    }


    And it displayed

    Device opened 3
    Device closed


    As variable i=3, not -1 then I get access to the driver? Tommorow will try to write something to SPI.

    Thank you very much!

  • Hi,

    I think that you no need to create "spidev" node manually,

    I forgot to mention that you have to add spi entry at your device board file located at "arch/arm/mach-davinci/board-<your board name>.c"

    Please refer the following link and let us know the results.

    http://communistcode.co.uk/blog/blogPost.php?blogPostID=1

  • There are some new questions:

    Firstly I try to understand is there any spi initialization at all.

    Two board files  are used for kernel's LCDK config : board-da850-evm.c and board-omapl138-lcdk.c.

    Spi information (da850evm_spi_info structure) is only in da850 file.

    This stucture is used in da850_evm_init function. I put prink in begining of this function. And I didn't see it after kernel loading. So I understand that there is no any SPI initialization at all and no sense in my manipulation with da850evm_spi_info structure.


    Thanks for the link, but there is no such code in mcsdk. I'll try to download older version of sdk and look for it there.

  • Hi,

    You no need to bother "board-omapl138-lcdk.c" board file because it is dedicated to the OMAPL138 LCDK which is low cost and does not have SPI slave devices.

    If you are configuring the linux source for OMAPL138 LCDK then "board-omapl138-lcdk.c" has been used.

    If you are configuring the linux source for OMAPL138 EVM (which has SPI flash slave device) then "board-da850-evm.c" has been used.

    thats why

    Two board files  are used for kernel's LCDK config : board-da850-evm.c and board-omapl138-lcdk.c.

    Only one board file will get compile when you are configuring for the particular board (OMAPL138LCDK or OMAPL138 EVM)

    This stucture is used in da850_evm_init function. I put prink in begining of this function. And I didn't see it after kernel loading. So I understand that there is no any SPI initialization at all and no sense in my manipulation with da850evm_spi_info structure.

    Can you please attach your board file?

    I'm not using/referring the MCSDK but referring the PSP releases of TI linux SDK for OMAPL138

  • My custom board is very similar to LCDK. So I choosed da850_lcdk_defconfig to configurate the linux source at first time. Both board files (board-omapl138-lcdk.c and board-da850-evm.c) are used with this defconfig. It's for OMAPL138 LCDK, or isn't?

    So I've got da850_lcdk_defconfig in .config file. Then I added SPI support in it using menuconfig. It didn't help. Then I found code for SPI support in board-da850-evm.c. I put printk to see it works or not, made uImage, loaded it to my board and didn't see this printk in log. Then I did the same thing on OMAPL138 LCDK, there was no printk too.

    If there is something wrong with hardware on my board, should I see SPI device on OMAPL138 LCDK where is no SPI devices?

    Can you please attach your board file?

    Yes, I can. But it's just board-da850-evm.c with my prink.

    I'm not using/referring the MCSDK but referring the PSP releases of TI linux SDK for OMAPL138

    I use linux-3.3-psp03.22.00.06.sdk, where unfortunately is no arch/arm/mach-omap2/board-am335xevm.c file or any another file with spiX_init function.

    p.s.

    I've just tried to read/write SPI registers.There are just zeros values and I can't write anything in it.

  • Hi,

    My custom board is very similar to LCDK. So I choosed da850_lcdk_defconfig to configurate the linux source at first time. Both board files (board-omapl138-lcdk.c and board-da850-evm.c


    I m surprised that you are using 2 board files for your compilation (plz check .o file for board files; to check whether the & which board file compiled)

    Have you done SPI pinmux settings ?

    please refer the ti e2e post,

    http://e2e.ti.com/support/dsp/omap_applications_processors/f/42/t/329624.aspx

    Yes, I can. But it's just board-da850-evm.c with my prink.


    I asked your board file to check whether the function (which you put printk) called in init function.

  • 1. Yes, there are 3 board-XXX.o files(board-da850-evm.o,board-da850-sdi.o,board-omapl138-lcdk.o)

    2.

    If you configured SPI properly then sysfs ll get created for testing the SPI. /sys/bus/spi/

    I've got it.

    3.

    ...arch/arm/mach-davinci/include/mach/mux.h...
    ....arch/arm/mach-davinci/da850.c...
    You can take reference code from "board-da850-evm.c" or board-da850-sdi.c which they have already implemented.

    But there is no words about Pinmux and SPI in this files.

    4.

    I asked your board file to check whether the function (which you put printk) called in init function.

    Printk is right above ret = da8xx_register_spi... in da850_evm_init functions in board-da850-evm.c and board-da850-sdi.c

    Are you shure that SPI is working in linux on OMAPL138 EVM from the box?

    Summarize:
    I've got LCDK and clean MCSDK(with linux in psp release). I want to make SPI working on LCDK without any device connected to it (to work with this kernel on my custom board knowing that software is ok).

    I select da850_lcdk_defconfig for making kernel.
    I select SPI support in .config file using menuconfig.
    I change .modalias = "m25p80", .modalias = "spidev" in board-da850-evm.c
    What other steps do I have left? (just pinmux?)

    Thanks

  • Hi,

    But there is no words about Pinmux and SPI in this files.

    It seems the SPI pinmux has to be done in your board file.

    Are you shure that SPI is working in linux on OMAPL138 EVM from the box?

    We able to load u-boot image from SPI flash on OMAPL138 EVM as well OMAPL138 SDI (spectrum digital) board.

    Finally I got your problem,

    From MCSDK, I also could see three *.o board files if I configured to OMAPL138 LCDK,

    So, I would like to suggest to you that Please download appropriate source code for OMAPL38 LCDK which is available from below link.

    From OMAPL138 LCDK  LINUX SDK source , If you configured the linux source code for the OMAPL138 LCDK then the appropriate board file would be "board-omapl138-hawk.c"

    root@titus:~/Titus_Linux_Backup/ti-e2e/OMAPL138_LCDK/ti-sdk-omapl138-lcdk-01.00.00/board-support/linux-3.1.10# cd arch/arm/mach-davinci/
    root@titus:~/Titus_Linux_Backup/ti-e2e/OMAPL138_LCDK/ti-sdk-omapl138-lcdk-01.00.00/board-support/linux-3.1.10/arch/arm/mach-davinci# ls
    aemif.c                board-neuros-osd2.c     clock.o    da850.c~             dma.c             Makefile       sleep.S
    aemif.o                board-omapl138-hawk.c   common.c   da850.o              dma.o             Makefile.boot  sram.c
    board-da830-evm.c      board-omapl138-hawk.c~  common.o   devices.c            gpio.c            mux.c          sram.o
    board-da850-evm.c      board-omapl138-hawk.o   cp_intc.c  devices-da8xx.c      gpio.o            mux.h          time.c
    board-dm355-evm.c      board-sffsdr.c          cp_intc.o  devices-da8xx.o      gpio-tnetv107x.c  mux.o          time.o
    board-dm355-leopard.c  board-tnetv107x-evm.c   cpufreq.c  devices-tnetv107x.c  include           pm.c           tnetv107x.c
    board-dm365-evm.c      built-in.o              cpufreq.o  dm355.c              io.c              psc.c          usb.c
    board-dm644x-evm.c     cdce949.c               cpuidle.c  dm365.c              io.o              psc.o          usb.o
    board-dm646x-evm.c     clock.c                 da830.c    dm644x.c             irq.c             serial.c
    board-mityomapl138.c   clock.h                 da850.c    dm646x.c             Kconfig           serial.o
    root@INFCH05297:~/Titus_Linux_Backup/ti-e2e/OMAPL138_LCDK/ti-sdk-omapl138-lcdk-01.00.00/board-support/linux-3.1.10/arch/arm/mach-davinci# 
    

    http://www.ti.com/tool/linuxsdk-omapl138

    http://software-dl.ti.com/dsps/dsps_public_sw/c6000/web/omapl138_lcdk_sdk/latest/index_FDS.html

    http://processors.wiki.ti.com/index.php/OMAP-L138_LCDK_Linux_Software_Developer%27s_Guide

    So, Use OMAPL138 LCDK SDK and do the pinmux for SPI to avoid confusions.

    You can refer the old e2e post for SPI pinmux which i gave previous post.

    I hope it helps,

    Please create new post for specific problem instead continuing the same thread,

    So others will get benefit who face the same issue.