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.

DM385: Trouble with omap2_mcspi driver on linux

Other Parts Discussed in Thread: DM385

I need to write a protocol driver for an SPI chip we are using in our application.

I have followed the instructions in those two guides:

http://www.jumpnowtek.com/?option=com_content&view=article&id=57&Itemid=62

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

After muxing all the pins to their SPI functions in u-boot, and enabling SPI clock from uboot (CM_ALWON_SPI_CLKCTRL = 0x2), and adding the following code to the board file in the kernel:

struct spi_board_info __initdata dm385_spi_slave_info[] = {
{
.modalias = "an41919a",
.irq = -1,
.max_speed_hz = 10 * 1000 * 1000,
.bus_num = 1,
.chip_select = 0,
.mode = SPI_MODE_3 | SPI_CS_HIGH,
},

};

I can see that once omap2_mcspi.ko is loaded, it shows that it configured a new slave device at bus 1, cs 0, with all the above parameters, and once I load my an41919a.ko module, the probe callback function gets called.

But when I try to use an spi_write() command, I get a return value of 0, indicating no error, but no actual signals can be seen on a logic analyzer looking at the SPI wires.

From looking at omap2_mcspi.c code, it seems like the register configurations are different from what the DM385 TRM mentions for the SPI module.

Is the omap2_mcspi.c compatible with DM385? If yes, what else could I be missing? I have tried playing around with the pull down/up settings in the pinmux of the SPI bus without any results.

  • I've done some further debugging regarding the issue.

    It seems that the memory addresses for the SPI registers are configured correctly on kernel startup.

    My device is connected to SPI[1] bus on the board.

    However, when using the correct config (bus_num=2 as opposed to using bus_num=1):

    struct spi_board_info __initdata dm385_spi_slave_info[] = {
    	{
    	.modalias = "an41919a",
    	.irq = -1,
    	.max_speed_hz = 10 * 1000 * 1000,
    	.bus_num = 2,
    	.chip_select = 0,
    	.mode = SPI_MODE_3 | SPI_CS_HIGH,
    	},
    }; 

    the omap2_mcspi_probe() does not complete, and fails with an ENODEV error during the following loop:

    	for (i = 0; i < num_chipselect; i++) {
     r = platform_get_resource(pdev, IORESOURCE_DMA, 0); 		if (r == NULL) {
    				status = -ENODEV;
    				goto err1;
    			}
    		mcspi->dma_channels[i].dma_tx_sync_dev = r->start;
    		mcspi->dma_channels[i].dma_tx_channel = -1;
    		//printk(KERN_INFO"allocated tx channel:%d\n",r->start);
    
     r = platform_get_resource(pdev, IORESOURCE_DMA, 1); 		if (r == NULL) {
    				status = -ENODEV;
    				goto err1;
    			}
    		//printk(KERN_INFO"allocated rx channel:%d\n",r->start);
    		mcspi->dma_channels[i].dma_rx_sync_dev = r->start;
    		mcspi->dma_channels[i].dma_rx_channel = -1;
    	}
    

    Only when using bus_num=1 this function completes successfuly and a new SPI slave is registered without problems.

    Can anyone help me with this?

  • It seems that the version of omap2_mcspi.c that comes with IPNC_RDK 3.5 is problematic and causes DMA allocation errors for spi bus_num > 1

    I have used the following version instead:

    http://ubuntu.wikimedia.org/git/ubuntu-jaunty/drivers/spi/omap2_mcspi.c

    Now I am successfully able to initialize bus 2, and I can see the CS and CLK changing on a logic analyzer whenever I initiate a transfer.

    I am still not able to see any data on the MOSI and MISO channels. 

    I've noticed that the original driver is using D[1] to receive instead of D[0] and changed that in the new driver but that didn't solve the problem.

    After changing the D[1] and D[0] Tx/Rx configurations in the driver for the appropriate CONFIG_MACH_TYPE, I am able to send SPI data on the MOSI line.

  • Hi 

    We are also facing same issue in IPNC RDK 3.5 for DM385:

    McSpi works for "bus_num   = 1" only and creates "/dev/spidev1.1 "

    but it doesn’t creating  spidev2.1 for "bus_num   = 2"

    The link provided above is not available now.

    struct spi_board_info __initdata dm385_spi_slave_info[] = {
        {
            .modalias   = "spidev",
            .irq        = -1,
            .max_speed_hz   = 75000000,
            .bus_num    = 1,
            .chip_select    = 1,
            .mode = SPI_MODE_0,
        },
        {
            .modalias   = "spidev",
            .irq        = -1,
            .max_speed_hz   = 75000000,
            .bus_num    = 2,
            .chip_select    = 1,
            .mode = SPI_MODE_0,
        }
    };
    ==================================

    Error occurs in "for loop" described above.

    Any help will be very much appreciated,

    Thanks in advance

    Kalpesh