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.

Accessing SPI0 from user space using SPIDEV driver in Linux (LogicPD AM1808 Dev Kit)

Other Parts Discussed in Thread: AM1808, ADS1298, DA8XX, OMAP-L138

Hi,

We are using the LogicPD AM1808 Dev Kit for a medical applicaltion.

We will use both SPI on the board to drive an graphical LCD and an ADS1298 ADC from TI also.

We was configuring the BSP (mux.h, mux.c, da850.c, board-da850-evm.c, ...) to enable the  SPI0 chip (We got same help from

TI support and inspiration from the DA830 BSP):

static struct spi_board_info da850_spi_board_info[] = {
    [0] = {
        .modalias = "m25p80",
        .platform_data = &spi_flash_data,
        .mode             = SPI_MODE_0,
        .max_speed_hz     = 1000000,       /* max sample rate at 3V */
        .bus_num         = 1,
        .chip_select     = 0,
    },
    [1] = { // SPI0
        .modalias         = "spidev",
        .mode             = SPI_MODE_0,
        .max_speed_hz     = 1000000,
        .bus_num         = 0,
        .chip_select     = 0,
    },

};

Actually the file /dev/spidev0.0 is created by mdev, but when we launch the spidev_test.c program (/TI Linux Source/Documentation/spi), we get:

spi mode: 0

bits per word: 8

max speed: 1000000 (1000 Khz)

 

and then the program hang up (not responding anyway to CTRL-C etc...) and we don't have any signal on the oscilloscope for SPI0_CLK or SPI0_MOSI

 

Could you please help us on this issue...

  • Any help please...

  • Hello,

    Do you know if this problem is specific to spidev? IOW, if using an in-kernel SPI slave driver for your device causes a similar hang?

    It seems like a similar issue was posted on the DaVinci Linux mailing list:

    http://www.mail-archive.com/davinci-linux-open-source@linux.davincidsp.com/msg18197.html

    The issue was resolved by using the patch here:

    https://patchwork.kernel.org/patch/114924/

    Can you please check if this patch resolves the issue?

    Thanks,

    Sekhar

  • Sekhar,

    In my case, SPI1 is OK when we use it to drive the SPI flash.

    But when I want to use SPIDEV to drive the SPI1, I have the some result as SPI0 (spidev_test hang up)

    Also I want to configure SPI0 to drive the  "m25p80" SPI flash without really and phyisaclly connecting the flash to SPI0, I modify the m25p80.c (function static int read_sr(struct m25p *flash) - line 147)

       
        retval = davinci_cfg_reg(DA850_GPIO6_15); // Disable MII Ethernet on LogicPD, because the RXCLK is connected to SPIOCLK
        if (retval < 0) {
            printk("pin DA850_GPIO6_15 could not be muxed for GPIO functionality\n");
            while(1);
        }
        retval = gpio_request(111, "gpio_test\n");
        if (retval < 0)
        {
            printk("ERROR can not open GPIO DA850_GPIO6_15\n");
            while(1);
        }
        gpio_direction_output(111, 0);  // Here I disable MII Ethernet, I set the RESET pin of the controller to LOW
        while(1)  // My infinite loop to send some data on the SPI0 MOSI, but I get nothing on SP0CLK ans SPI0MOSI
        {
            flash->command[0] = OPCODE_WRSR;
            flash->command[1] = 0;
            spi_write(flash->spi, flash->command, 2);
        }


        ...

     

    And also I modify board-da850-evm.c:

    static struct spi_board_info da850_spi_board_info[] = {
        [0] = {
            .modalias = "
    spidev",
            //.platform_data = &spi_flash_data,
            .mode             = SPI_MODE_0,
            .max_speed_hz     = 30000000,       /* max sample rate at 3V */
            .bus_num         = 1,
            .chip_select     = 0,
        },
        [1] = { // SPI0
            .modalias         = "m25p80",

            .platform_data = &spi_flash_data,
            .mode             = SPI_MODE_0,
            .max_speed_hz     = 30000000,
            .bus_num         = 0,
            .chip_select     = 0,
        },

    };

    But also I get nothing on SP0CLK ans SPI0MOSI.

    Notes:

    1. When I use SPIDEV on SPI0 I get the node /dev/spidev0.0 when the system boot and also /dev/spidev1.0 for SPI1
    2. I m using linux version 03.20.00.12 from davinci git for the LogicPD board

    So please if there are some issue in the spi_davinci driver can you send a patch that add support for SPI0 to the DA850 BSP and configuring it to be used with SPIDEV.

    Thanks.

  • Sekhar,


    Thank you very much for your answer about the patchs, but I had the last up to date patchs, and SPI1 worked.

    Please to better undestand my problem, could  you test that SPI0 is working with SPIDEV using the <spidev_test> program.

    On my side, when I launch <spide_test> on my SPIDEV node (/dev/spidev0.0) the program is hanging up after this message:

     

    spi mode: 0

    bits per word: 8

    max speed: 1000000 (1000 Khz)

    and then the program hang up (not responding anyway to CTRL-C etc...) and we don't have any signal on the oscilloscope for SPI0_CLK or SPI0_MOSI

    If it's working for you, could you please send us a kernel patch to configure our kernel sources like yours.

    Thanks.

  • Hello,

    We tested this with SPI flash on the EVM and see a hang there as well.

    When we configure the driver to polled mode, the test passes. We need to investigate why DMA mode hangs. Note that we can use DMA mode without any issues if we access the SPI flash using the in-kernel driver.

    Thanks,

    Sekhar

    root@arago:~# ./spidev_test -D /dev/spidev1.0 -s 10000000

    spi mode: 0

    bits per word: 8

    max speed: 10000000 Hz (10000 KHz)

     

    FF FF FF FF FF FF

    FF FF FF FF FF FF

    FF FF FF FF FF FF

    FF FF FF FF FF FF

    FF FF FF FF FF FF

    FF FF FF FF FF FF

    FF FF

    root@arago:~# ./spidev_test -D /dev/spidev1.0 -s 1000000

    spi mode: 0

    bits per word: 8

    max speed: 1000000 Hz (1000 KHz)

     

    FF FF FF FF FF FF

    FF FF FF FF FF FF

    FF FF FF FF FF FF

    FF FF FF FF FF FF

    FF FF FF FF FF FF

    FF FF FF FF FF FF

    FF FF

    root@arago:~# ./spidev_test -D /dev/spidev1.0 -s 1000000 -l

    spi mode: 32

    bits per word: 8

    max speed: 1000000 Hz (1000 KHz)

     

    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

    root@arago:~#

  • Please note that the above results were obtained using PSP 03.20.00.12 release with no patches applied (except to modify board-da850-evm.c file to use spidev driver instead of SPI flash driver to access the SPI flash).

    Thanks,

    Sekhar

  • Sekhar,

     

    Thank you for your help, so we will use SPI0 in polling mode  until you found the solution for the issue.

    Please can you tell us how to change the BSP to use SPI in polled mode.


    Thanks

  • Change use_dma member to ZERO in da850_spi1_pdata structure in "arch/arm/mach-davinci/devices-da8xx.c" file.

    Regards, Sudhakar

  • Sekhar and Sudhakar,

     

    Thanks for your help, SPI1 is now working perfectly in polling mode using SPIDEV or using the SPI Flash driver.

    But we need in our application both SPI1 and SPI0, so we configure SPI0 in our BSP to be used like SPI1, but  spidev_test the program always hangs on SPI0.

    Can you please check this issue on SPI0.

    If SPI0 is working for you, so there is a chance that we make some mistakes when we add SPI0 support in the BSP, so can you send us a patch file from your kernel sources to configure SPI0 correctly in our BSP.

    Best regards.

  • We have not tested SPI0 because if we enable SPI0 on the EVM, it clashes with Ethernet and we do not have any devices connected on SPI0. But I can list out few things here which you need to take care when you are adding support for SPI0.

    1. Make sure that the clock structure for SPI0 is populated in arach/arm/mach-davinci/da850.c

    2. Add the pinmuxing details for SPI0 in arch/arm/mach-davinci/da850.c

    3. Add the platform related information for SPI0 in arch/arm/mach-davinci/devices-da8xx.c

    You can check whether the PINMUX and LPSC related changes are properly done by dumping the PINMUX and mdstat registers respectively using a tool called devmem2 from Linux.

    In the meanwhile, send me your patch which enables SPI0. I can review it.

    Regards, Sudhakar

  • Yes we know that ethernet clashes with SPI0,

    we resolved this problem using a simple module which is loaded before testing SPI0.

    This will disable ethernet by putting the ethernet controller in Reset Mode:

    7242.disable-ethernet.zip

    So can you please test SPI0 using spidev_test with our module (to disable ethernet).

    We will send you our patch file ASAP to review how we add support for SPI0 in our BSP.

    Thanks.

  • I tried to test spidev_test.c but hang up on DM365, too.

    So, I tried to test with spidev_fdx.c, it works fine for me.

     

     

  • Hi,

    we still have the same problem regarding SPI0 and SPIDEV, this is how we add support for SPI0 in our BSP to check :

     

    File board-da850-evm.c:

    static struct spi_board_info da850_spi_board_info[] = {
        [0] = {
            .modalias = "spidev",
            //.platform_data  = &spi_flash_data,
            .mode             = SPI_MODE_0,
            .max_speed_hz     = 30000000,       /* max sample rate at 3V */
            .bus_num          = 1,
            .chip_select      = 0,
        },
        [1] = {
            .modalias         = "spidev",
            .mode             = SPI_MODE_0,
            .max_speed_hz     = 3000000,
            .bus_num          = 0,
            .chip_select      = 0,
        },

    };

     

    and in fucntion da850_evm_init

        ret = da8xx_pinmux_setup(da850_spi0_pins);
        if (ret)
            pr_warning("da850_evm_init: spi0 mux setup failed: %d\n",
                    ret);

        da850_init_spi0(BIT(1), da850_spi_board_info,
                ARRAY_SIZE(da850_spi_board_info));

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    File da850.c:

    static struct clk spi0_clk = {
        .name          = "spi0",
        .parent        = &pll0_sysclk2,
        .lpsc          = DA8XX_LPSC0_SPI0,
    };

    static struct clk_lookup da850_clks[] = {

    ...

        CLK("spi_davinci.0",    NULL,        &spi0_clk),
        CLK("spi_davinci.1",    NULL,        &spi1_clk),

    ...
    };


    static const struct mux_config da850_pins[] = {

    ...

        MUX_CFG(DA850, SPI0_CS_0,    4,    4,    15,    1,    false)
        MUX_CFG(DA850, SPI0_CLK,     3,    0,    15,    1,    false)
        MUX_CFG(DA850, SPI0_SOMI,    3,    8,    15,    1,    false)
        MUX_CFG(DA850, SPI0_SIMO,    3,    12,   15,    1,    false)

    ...

    };

     

    const short da850_spi0_pins[] __initdata = {
        DA850_SPI0_CS_0, DA850_SPI0_CLK, DA850_SPI0_SOMI, DA850_SPI0_SIMO,
        -1
    };

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    File devices-da8xxx.c:

    static struct davinci_spi_platform_data da850_spi0_pdata = {
        .version          = SPI_VERSION_2,
        .num_chipselect   = 1,
        .wdelay           = 0,
        .odd_parity       = 0,
        .parity_enable    = 0,
        .wait_enable      = 0,
        .timer_disable    = 0,
        .clk_internal     = 1,
        .cs_hold          = 1,
        .intr_level       = 0,
        .poll_mode        = 1,
        .use_dma          = 1,
        .c2tdelay         = 8,
        .t2cdelay         = 8,
    };

    static struct resource da850_spi0_resources[] = {
        [0] = {
            .start        = 0x01C41000,
            .end          = 0x01C41000 + 0xfff,
            .flags        = IORESOURCE_MEM,
        },
        [1] = {
            .start        = IRQ_DA8XX_SPINT0,
            .end          = IRQ_DA8XX_SPINT0,
            .flags        = IORESOURCE_IRQ,
        },
        [2] = {
            .start        = EDMA_CTLR_CHAN(0, 14),
            .end          = EDMA_CTLR_CHAN(0, 14),
            .flags        = IORESOURCE_DMA,
        },
        [3] = {
            .start        = EDMA_CTLR_CHAN(0, 15),
            .end          = EDMA_CTLR_CHAN(0, 15),
            .flags        = IORESOURCE_DMA,
        },
        [4] = {
            .start        = 1,
            .end          = 1,
            .flags        = IORESOURCE_DMA,
        },
    };

    static struct platform_device da850_spi0_device = {
        .name             = "spi_davinci",
        .id               = 0,
        .resource         = da850_spi0_resources,
        .num_resources    = ARRAY_SIZE(da850_spi0_resources),
        .dev = {
            .platform_data = &da850_spi0_pdata,
        },
    };

    void __init da850_init_spi0(unsigned chipselect_mask,
            struct spi_board_info *info, unsigned len)
    {
        spi_register_board_info(info, len);

        platform_device_register(&da850_spi0_device);
    }

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    File include/mach/mux.h:

    enum davinci_da850_index {

    ...

        DA850_SPI0_CS_0,
        DA850_SPI0_CLK,
        DA850_SPI0_SOMI,
        DA850_SPI0_SIMO,

    ...

    };

  • Hi,

    I was able to get the spidev_test working with SPI0 on DA850 EVM with the modifications what you have provided. In your patch you are configuring SPI0 in DMA mode but I changed it to PIO mode by changing the use_dma variable in da850_spi0_pdata structure to ZERO. Also I am not using the module which you had sent to disable Ethernet. I enabled RMII ethernet option in menuconfig as I was using NFS to boot. So the steps I follow are:

    1. Bring up u-boot with MII ethernet.
    2. Download the uImage.
    3. Connect the ethernet cable to RMII port on the UI daughter card.
    4. Boot the kernel and run spidev_test for spidev0.0.

    Regards, Sudhakar

  • Hi,

    Thank you Sudhakar for your help, now we have <spidev_test> running on both SPI0 and SPI1.

    We also disable MII  using RMII for ethernet.

    We make a small daughter board that we connect to LogicPD dev kit (J28 connector) to monitor SPI0 signals.

    Now when we run <spidev_test> on SPI0,  we get on the screen the same results as you when running <spidev_test> on SPI1.

    But using the oscilloscope we don't get any signal on SPI0_CLK or SPI0_MOSI pins.

     

    FYI, in order to check our board, we allocated SPI0_CLK as a GPIO pin,  we wrote a kernel module that toggle the pin every 1 second, and we have seen the signal on the oscilloscope.

    Thanks.

  • Hi,

    Any update on the DMA hang issue with spidev driver+test app, please?

    I am using the LogicPD OMAP L138 EVM and is experiencing the same problem.

    I applied the necessary changes to mach-davinci/ files and is able to load spidev driver instead of m25p80 flash driver and it is binding to the spidev1.0 device.

    But when i enable use_dma flag in devices_da8xx.c file, the spidev_test application hangs as described in the original post above. Poll mode works fine.

    I introduced some printks in davinci_spi.c controller driver and compared the code flow against spidev driver case and m25p80 flash driver case.

    With the spidev + spidev_test + use_dma case: dma_rx_completion callback is never invoked by the edma driver and code waits forever in

    wait_for_completion_interruptible(
                                    &davinci_spi_dma->dma_rx_completion);

    The mp25p80 flash driver always uses the davinci_spi master driver with either in RX mode or  TX mode, not with both RX and TX  at the same time. But the spidev_test app uses the davinci_spi driver in full duplex mode(Both TX and TX transfers at the same time).

    Ofcourse when the mp25p80 flash driver uses RX only mode, davinci_spi driver creates a temp TX buffer for clocking and the dma PaRAM register setup for this is different from actual TX dma setup.

            if (t->tx_buf) {
                  t->tx_dma = dma_map_single(&spi->dev, (void *)t->tx_buf, count,
                                    DMA_TO_DEVICE);*/
                    if (dma_mapping_error(&spi->dev, t->tx_dma)) {
                            printk("davinci_spi_bufs_dma:L12\n");
                            dev_dbg(sdev, "Unable to DMA map a %d bytes"
                                    " TX buffer\n", count);
                            ret = -ENOMEM;
                            goto out;
                    }
                    printk("davinci_spi_bufs_dma:L13\n");
                  temp_count = count;
            } else {
                    /* We need TX clocking for RX transaction */
                    t->tx_dma = dma_map_single(&spi->dev,
                                    (void *)davinci_spi->tmp_buf, count + 1,
                                    DMA_TO_DEVICE);
                    if (dma_mapping_error(&spi->dev, t->tx_dma)) {
                            printk("davinci_spi_bufs_dma:L15\n");
                            dev_dbg(sdev, "Unable to DMA map a %d bytes"
                                    " TX tmp buffer\n", count);
                            ret = -ENOMEM;
                            goto out;
                    }
                    temp_count = count + 1;
            }

    When I changed the code as below, the spidev DMA mode starts working(though I am loosing one byte of data).

            if (t->tx_buf) {
                  t->tx_dma = dma_map_single(&spi->dev, (void *)t->tx_buf, count+1,
                                    DMA_TO_DEVICE);*/
                    if (dma_mapping_error(&spi->dev, t->tx_dma)) {
                            printk("davinci_spi_bufs_dma:L12\n");
                            dev_dbg(sdev, "Unable to DMA map a %d bytes"
                                    " TX buffer\n", count);
                            ret = -ENOMEM;
                            goto out;
                    }
                    printk("davinci_spi_bufs_dma:L13\n");
                  temp_count = count+1;
            } else {
                    /* We need TX clocking for RX transaction */
                    t->tx_dma = dma_map_single(&spi->dev,
                                    (void *)davinci_spi->tmp_buf, count + 1,
                                    DMA_TO_DEVICE);
                    if (dma_mapping_error(&spi->dev, t->tx_dma)) {
                            printk("davinci_spi_bufs_dma:L15\n");
                            dev_dbg(sdev, "Unable to DMA map a %d bytes"
                                    " TX tmp buffer\n", count);
                            ret = -ENOMEM;
                            goto out;
                    }
                    temp_count = count + 1;
            }

    The spidev_test loopback test gives the follwoing result:

    ./spi_test_app -D /dev/spidev1.0 -l
    spi mode: 32
    bits per word: 8
    max speed: 30000000 Hz (30000 KHz)

    00 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

    As you can see the first and last bytes are wrong. I am sure , though my changes removed the 'Hang issue', they are not perfect.  But hope, this will give you more insight into the issue and probably a fix. Please let me know your comments as DMA is crucial to our application.

     

    Thanks,

    Shameer

     

     

     

  • Hi,

    There is an updated SPI driver available in community which seem to resolve many issues which were present in the old SPI driver. The new SPI driver is available in DaVinci Linux tree at http://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-davinci.git. Currently the DA850/OMAP-L138 specific SPI platform stuff is not present in the kernel but Michael Wiiliamson has submitted the initial version of these patches to the list.

    You can also refer to http://arago-project.org/git/projects/?p=linux-davinci.git;a=shortlog;h=refs/heads/davinci-spi-rewrite for the new SPI driver which has platform support as well but with 2.6.37-rc2 kernel.

    Try testing spidev with this updated driver and post your observation.

    Regards, Sudhakar

  • Hi Sudhakar,

    Finally got sometime to update the kernel and thankfully the issue seems to be fixed. I am not seeing any hang/data loss with spidev+use_dma combination. Thanks for your help.

    Regards,

    Shameer

  • Hi Sudhakar and ,

     

    I have been following the same process, because I can not make a dm365 spi to work in DMA mode. I use spidev_test to test it. I have downloaded the new davinci_spi.c, spi.h and spidev.c files and included them in my kernel (2.6.32). The new device gets registered as /dev/spidev1.0 but when I execute spidev_test, the kernel hangs up!

    I assumme that the new driver is the right one because the link http://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-davinci.git Sudhakhar suggested is not longer active. I downloaded them from:

    http://arago-project.org/git/projects/?p=linux-davinci.git;a=tree;f=drivers/spi;h=a288a12ff147a7f12bc397618d2ad01cf956fbe9;hb=b3a7adfd8ebc7530bb69e6d01b79811ef4775f1c

    which I think is the right place.

    Questions: Is there anything I am doing wrong, I mean are there more files that need to be included apart from this three (davinci_spi.c, spi.h and spidev.c)?

    Any other suggestion why the kernel blocks when I try to access spidev1.0 using spidev_test?

    I have spent a lot of time on this issue and I really appreciatte any help.

    Thanks Jesus

     



  • Hi Jesus,

    The SPI driver you should use is present in:

    http://git.kernel.org/?p=linux/kernel/git/khilman/linux-davinci.git;a=tree;h=e0878cee5ea188240ce32f5801a8f84c31168606;hb=e0878cee5ea188240ce32f5801a8f84c31168606

    OR

    http://arago-project.org/git/projects/?p=linux-davinci.git;a=shortlog;h=refs/heads/03.21.00.03

    The arago link you are using above is from the master branch which contains the old driver. The new SPI driver are present in 03.21.00.03 branch.

    Thanks, Sudhakar

  • Hi Sudahkar,

    I have checked both links, and davinci_spi.c file is different in both of them, and worst of it is that the kernel still hangs up with both files.Ths second link was the one I already used.

    Is there anything else need to be changed apart from davinci_spi.c, spi.h and spidev.c?

    Is there a way of dowloading the whole v37 kernel or a versione with the new driver (I have not found it on the links you sent me)? I suspect that the issue could be related on trying to insert this driver on the v32 kernel version which is the one I have.

     

    May be Shameer could tell me which files he updated in the kernel to make it work...

    Thanks again

    Jesus

     

     

     

  • Hi Jesus,

    I tried two methods:

    First I downloaded the v37 kernel and modified the board-da850-evm.c and related files to add spi device as a platform device, as this functionality was removed from the branch of v37 kernel i got. With this everything was working.

     

    Second, I took the davinci_spi.c, spidev.c and spi_bitbang.c files from v37 and build the  drivers seperately against v33(original psp kernel i got) and loaded the spi_bitbang.ko, davinci_spi.ko and spidev.ko drivers after the linux boot.(Changed the psp kernel config so that spi drivers except spi core driver are not part of linux kernel). This also worked.

    So  you could try by adding spi_bitbang.c to your new setup.

    Also it is a good idea to enable debug prints in davinci_spi.c or add few printk statements in dma tarnsfer path.

    To download the kernel:

    Either you have to setup the git or click on the 'snapshot ' link on the pages provided above by Sudhaker.

    Thanks,

    Shameer

     

     

     

     

  • Hi

    I finally managed to make it work, with your suggestions. I had to add davinci_spi.c, spidev.c and spi_bitbang.c in my v32 kernel from the v37 release that Sudhakar pointed in the second link. I checked it with the oscilloscope and looks ok. Some testing issues with spidev_test (it hangs up) but with spidev_fdx or echo 1234 > /dev/spidev1.0 works fine.

    I tried downloading the whole kernel and compiling it, but I had some problems during compilation, so I decided to path the V32 kernel.

    Thanks for your help, I really appreciate it.

    Jesus

  • Dear Sudhakar,

    we are using L138 EVM and custom daughter card which has LCD interface. We use SPI1 to configure LCD driver. We use SPI1_SCS[2] for chip select. I have made following changes in kernel source. Currently on EVM SPI flash is on SPI1 interface with SPI_SCS[0].

    I am using dvsdk_omapl138-evm_4_01_00_09 and kernel version is linux-2.6.33-rc4-psp03.20.00.14

    -----------------------------------------------------------------------------------------------------------------------

    In file board_arch/arm/mach-davinci/da850.c

    struct davinci_ili9325_info davinci_spi_ili9325_info = {

            .chip_sel = 0x04,               //ToDo: double check this

            .commit_delay = 3,

    };

    static struct spi_board_info da850_spi_board_info[] = {
            [0] = {
                    .modalias = "m25p80",
                    .platform_data = &spi_flash_data,
                    .mode = SPI_MODE_0,
                    .max_speed_hz = 30000000,       /* max sample rate at 3V */
                    .bus_num = 1,
                    .chip_select = 0,
            },
            [1] = {
                    .modalias = DAVINCI_SPI_ILI9325_NAME,
                    .platform_data = &davinci_spi_ili9325_info,
                    .mode = SPI_MODE_0,
                    .irq = 0,
                    .max_speed_hz = 10 * 1000 * 1000 /* max sample rate at 3V */ ,
                    .bus_num = 1,
                    .chip_select = 2,       
            },
    };
    In file arch/arm/mach-davinci/da850.c
    /* SPI1 function */
            MUX_CFG(DA850, SPI1_CS_0,       5,      4,      15,     1,      false)
            MUX_CFG(DA850, SPI1_CS_2,       4,      28,     15,     1,      false)                  
            MUX_CFG(DA850, SPI1_CLK,        5,      8,      15,     1,      false)
            MUX_CFG(DA850, SPI1_SOMI,       5,      16,     15,     1,      false)
            MUX_CFG(DA850, SPI1_SIMO,       5,      20,     15,     1,      false)
    const short da850_spi1_pins[] __initdata = {
            DA850_SPI1_CS_0, DA850_SPI1_CS_2, DA850_SPI1_CLK, DA850_SPI1_SOMI, DA850_SPI1_SIMO,                     
            -1
    };
    In file arch/arm/mach-davinci/devices-da8xx.c
    static struct davinci_spi_platform_data da850_spi1_pdata = {
            .version        = SPI_VERSION_2,
    //      .num_chipselect = 1,
            .num_chipselect = 3,            QUESTION: Is this correct?
            .wdelay         = 0,
            .odd_parity     = 0,
            .parity_enable  = 0,
            .wait_enable    = 0,
            .timer_disable  = 0,
            .clk_internal   = 1,
            .cs_hold        = 1,
            .intr_level     = 0,
            .poll_mode      = 1,
            .use_dma        = 1,
            .c2tdelay       = 8,
            .t2cdelay       = 8,
    };
    In file arch/arm/mach-davinci/include/mach/mux.h
    /* SPI1 function */
            DA850_SPI1_CS_0,
            DA850_SPI1_CS_2,                QUESTION: Is this entry correct? Can we create new entry anywhere in this enum or it has any method to be followed?
            DA850_SPI1_CLK,
            DA850_SPI1_SOMI,
            DA850_SPI1_SIMO,
    In file driver/spi/davinci_spi.h
    //#define SPI_MAX_CHIPSELECT    2
    #define SPI_MAX_CHIPSELECT      3       QUESTION: I s this correct?
    -----------------------------------------------------------------------------------------------------------------------
    I have still not included device specific driver. I am just checking if platform specific details are OKay?
    When I boot I get following error in kernel boot log
    spi_davinci spi_davinci.1: can't setup spi1.2, status -11
    spi_davinci spi_davinci.1: Controller at 0xfef0e000 
    I dont know what am I missing here? Please let me know what i should be doing?
    Regards,
    Dipen patel

  • Hi Shameer,

     

    I am also facing same issue here with spidev on SPI1 chip select 2. 

    I have removed spi_flash entry from board-da850-evm.c and added an entry for spidev with chip select 2 on SPI1.

    As per your suggestion I tried compiling kernel with new davinci_spi.c, spi_bitbang.c and spidev.c but I get errors. I have followed all steps mentioned so far in this thread but no luck. Let me know what can I do.

    Appreciate your response.

    Regards,

    Dipen Patel

    ------------------------------------------------------------------------------------------------------------------------

    drivers/spi/davinci_spi.c: In function 'davinci_spi_chipselect':

    drivers/spi/davinci_spi.c:222: error: 'struct davinci_spi_platform_data' has no member named 'chip_sel'

    drivers/spi/davinci_spi.c:223: error: 'struct davinci_spi_platform_data' has no member named 'chip_sel'

    drivers/spi/davinci_spi.c:223: error: 'SPI_INTERN_CS' undeclared (first use in this function)

    drivers/spi/davinci_spi.c:223: error: (Each undeclared identifier is reported only once

    drivers/spi/davinci_spi.c:223: error: for each function it appears in.)

    drivers/spi/davinci_spi.c:232: error: 'struct davinci_spi_platform_data' has no member named 'chip_sel'

    drivers/spi/davinci_spi.c:234: error: 'struct davinci_spi_platform_data' has no member named 'chip_sel'

    drivers/spi/davinci_spi.c: In function 'davinci_spi_setup_transfer':

    drivers/spi/davinci_spi.c:352: error: dereferencing pointer to incomplete type

    drivers/spi/davinci_spi.c:355: error: dereferencing pointer to incomplete type

    drivers/spi/davinci_spi.c:358: error: dereferencing pointer to incomplete type

    drivers/spi/davinci_spi.c:361: error: dereferencing pointer to incomplete type

    drivers/spi/davinci_spi.c:364: error: dereferencing pointer to incomplete type

    drivers/spi/davinci_spi.c:366: error: dereferencing pointer to incomplete type

    drivers/spi/davinci_spi.c:372: error: dereferencing pointer to incomplete type

    drivers/spi/davinci_spi.c:374: error: dereferencing pointer to incomplete type

    drivers/spi/davinci_spi.c: In function 'davinci_spi_setup':

    drivers/spi/davinci_spi.c:406: error: 'struct davinci_spi_platform_data' has no member named 'chip_sel'

    drivers/spi/davinci_spi.c:407: error: 'struct davinci_spi_platform_data' has no member named 'chip_sel'

    drivers/spi/davinci_spi.c:407: error: 'SPI_INTERN_CS' undeclared (first use in this function)

    drivers/spi/davinci_spi.c: In function 'davinci_spi_bufs':

    drivers/spi/davinci_spi.c:559: error: dereferencing pointer to incomplete type

    drivers/spi/davinci_spi.c:559: error: 'SPI_IO_TYPE_INTR' undeclared (first use in this function)

    drivers/spi/davinci_spi.c:562: error: dereferencing pointer to incomplete type

    drivers/spi/davinci_spi.c:562: error: 'SPI_IO_TYPE_DMA' undeclared (first use in this function)

    drivers/spi/davinci_spi.c:654: error: 'struct davinci_spi_platform_data' has no member named 'cshold_bug'

    drivers/spi/davinci_spi.c:663: error: dereferencing pointer to incomplete type

    drivers/spi/davinci_spi.c:663: error: 'SPI_IO_TYPE_POLL' undeclared (first use in this function)

    drivers/spi/davinci_spi.c:675: error: dereferencing pointer to incomplete type

    drivers/spi/davinci_spi.c: In function 'davinci_spi_probe':

    drivers/spi/davinci_spi.c:886: error: 'struct davinci_spi_platform_data' has no member named 'dma_event_q'

    drivers/spi/davinci_spi.c:893: error: 'struct davinci_spi_platform_data' has no member named 'dma_event_q'

    drivers/spi/davinci_spi.c:913: error: 'struct davinci_spi_platform_data' has no member named 'chip_sel'

    drivers/spi/davinci_spi.c:915: error: 'struct davinci_spi_platform_data' has no member named 'chip_sel'

    drivers/spi/davinci_spi.c:915: error: 'SPI_INTERN_CS' undeclared (first use in this function)

    drivers/spi/davinci_spi.c:916: error: 'struct davinci_spi_platform_data' has no member named 'chip_sel'

    drivers/spi/davinci_spi.c:920: error: 'struct davinci_spi_platform_data' has no member named 'intr_line'

    make[3]: *** [drivers/spi/davinci_spi.o] Error 1

    make[2]: *** [drivers/spi] Error 2

    make[1]: *** [drivers] Error 2

    make[1]: Leaving directory `/opt/ti-dvsdk_omapl138-evm_4_01_00_09/psp/linux-2.6.33-rc4-psp03.20.00.14'

    make: *** [linux_myconfig] Error 2

    ------------------------------------------------------------------------------------------------------------------------

  • Hi,

     

    I've written a driver that uses spi to send and recive in full duplex but am having issus with cache flushing, it appears that the dma_map_single does not hanlde cache flushs corerectly when by dta rates go above 1mbits/s

     

    has anyone seen similar issues?

     

    david

  • Hi Dipen,

    This looks like a header file compatibility issue. Please make sure you are using the correct header file as per the driver versions.

    Places to look:

    Linux-kernel-dir/arch/arm/mach-davinci/include/mach/spi.h

    And check the definition of struct davinci_spi_platform_data.

     

    Regards, Shameer

  • Thanks Shameer,

     

    I will double check header file to confirm.

     

    Currently I have removed flash device by removing its entry from spi_board_info{} structure and instead of that I have kept my SPI device which is on chip select 2. To use chip select 2 I had to change SPI_MAX_CHIPSELECT value from 2 to 3. I have also made changes to PINMUX to enable SPI1_SCS[2].

    Driver gets registered properly  and kernel also boots fine but still I dont see any activity on SPI_CLK and SPI_CHIPSELECT signals.

    Is there anything I need to do extra to enable chip select 2? Any other settings?

     

    Regards,

    Dipen Patel

  • Hi david,

     

    i am using SPI to recieve data from ADC, my driver is not all recieving any thing  from ADC, can you post your driver for me, i can go through that and correct my mistake or i can use it if its compatable to my DM365 DaVinci-PSP-SDK-03.21.00.04 kernel.....if you paste it it will be great help for me..

     

    my mail id is hari@meritup.com or shadaksharikp@gmail.com

    Thanks

    Hari

  • Hi sudhakar/jesus/shameer,

     

    we have been trying to get the SPI using 2.6.37 but yet we are failing to get the CLK signal using leopard board.we have directly taken the kernel patch and then compiled for SPIDEV_test...should we configure for SPIDEV0.0 or SPIDEV1.0??.also if you guyz can list the changes to be made it will be very helpful.we are trying to use SPI1 of the leopard board.Kindly do the needful.

     

    thanks and regards

    Ravi chandran

  • Hi,

    I have followed the thread mail in this forum. Presently i am working on AM1808 experiments kit provided by logic pd and i am a newbie in driver development.

    We made one daughter card on J28 pin, when i am running the spidev_test module i am not able to see any SPIO_CLK or SPIO_MOSI data on oscilloscope.

    That the same you are already convyed, So as per the last line you have allocated one GPIO pin as SPI0_CLK and u have verfied the signal by writing a kernel module.

    this intresting like on port pin we are not getting any value and how we are getting the signal SPI0_CLK on a GPIO.

    If you have that kernel module could you please share me.

    And please let me know any remedy for it.

    Regards

    chandu