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.

SPI driver with two devices sharing the same CS

Other Parts Discussed in Thread: AM1808

I'm developing on a AM1808 based board (w sdk 5.03.02.00).

I modified the board configration file in this way in order to use the same CS with two devices:

static struct spi_board_info da850_k5_spi_info[] = {

    [0] = {

        .modalias       = "ili934", /* spidev */

        .mode           = SPI_MODE_0,

        .max_speed_hz       = 5000000,

        .bus_num        = 1,

        .chip_select        = 2,

    },

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

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

    [3] = {

        .modalias       = "hx8238", 

        .mode           = SPI_MODE_0,

        .max_speed_hz       = 5000000,

        .bus_num        = 1,

        .chip_select        = 2,

    }

}

the kernel start correctly but I have the following message: spi_davinci spi_davinci.1: chipselect 2 already in use

So I suppose that this is not the way to do it. Does anyone have some idea?

Thanks in advance.

  • In SPI master slave configuration it is not advisable to connect the same chipselect to 2 different slaves which is why you are seeing the warning. What are trying to achieve with this configuration? do you want to send the same data to 2 different slaves?

  • I have two SPI slaves and I have only one hardware CS available in my board. I tought to insert a mux driven by an I/O pin to connect the CS pin one at a time to the slaves. Now I don't know how to set the kernel to work in this way.I have to link two drivers with the same CS and I have to able to choose the slaves by the I/O pin. I am not skilled enough in Linux to do that. However I don't know if this is the right solution to solve this problem.

    Thak you all in advance

  • Domnico,

    Since you have only one CS, you should configure the kernel to have only one instance of the driver and in the application code select the suitable SPI protocol to the appropriate slave based on the whether the controlling IO pin to the MUX is driven high or low.

    Regards,

    Rahul

  • Rahul,

    I want to use two SPI slaves, an AD Converter and an LCD controller with the same SPI CS. I can switch the CS by a mux through an I/O pin. Now I suppose to link this two drivers in kernel in the board configuration file as in the first post. Anyway I have thinking to modify the hardware and recover another CS.

    Thank you

    Domenico