AnsweredAssumed Answered

testing spidev on var-som-mx6

Question asked by Andrea Di Chiara on Oct 27, 2014
Latest reply on Oct 30, 2014 by Andrea Di Chiara

Hi,

I am new to this forum is it the first time I'm testing spi interface on an arm board. I have a VAR-SOM-MX6 custom board and I'm trying to test spi output on J28 connector. In the default kernel image provided by Variscite there isn't any spidev device configured to use that connector but only an ADS7846 spi on bus 2 (as you can see in attached file board_mx6q_var_som.c found in Yocto tree /arm/arch/mach-mx6, here renamed _orig.c to differ it from the one I modified) so I tried to modify board-mx6q_var_som.c to that aim. Following other freescale threads I have enabled "User mode SPI device driver support" on kernel (3.0.35) and I have added an spidev structure configured on bus 1 (as suggested me by Variscite support to use J28 connector) and I registered it using spi_register_board_info function as follows:


static struct spi_board_info mx6_var_som_spidev_device[] __initdata = {
     {
         .modalias = "spidev",
         .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
         .bus_num = 1,
         .chip_select = 0,
     },
};

static void spi_device_init(void)
{
     spi_register_board_info(mx6_var_som_spidev_device,
         ARRAY_SIZE(mx6_var_som_spidev_device));
}


At this point, using a rebuilded kernel I obtain just a /dev/spidev2.0 so I found out that I need to enable ECSPI1 using imx6q_add_ecspi function. Am I wrong? I have added the following code, creating a spi_imx_master structure using GPIO4 [9] as indicated on data sheet for CSPI1_CS0:

    
#define VAR_SOM_ECSPI1_CS0  IMX_GPIO_NR(4, 9)


static int mx6q_var_som_spidev_cs[] = {

    VAR_SOM_ECSPI1_CS0,

};

 

static const struct spi_imx_master mx6q_var_som_spidev_data __initconst = {

    .chipselect     = mx6q_var_som_spidev_cs,

    .num_chipselect = ARRAY_SIZE(mx6q_var_som_spidev_cs),

};

 

imx6q_add_ecspi(1, &mx6q_var_som_spidev_data);

 

With the new kernel I obtain an /dev/spidev1.0 but testing with an oscilloscope on CSPI1_SCLK I can't register any signal. Is it correct? Does it suffice to indicate CSPI1_CS0 pin or have I to configure also CSPI1_SOMI, CSPI1_SIMO and CSPI1_SCLK in any way? Is the first parameter on imx6q_add_ecspi function the bus number? Could anyone tell me there is something wrong (modified board-mx6q_var_som.c is attached) or if there is something necessary that this procedure lacks?


(references http://armbedded.eu/node/318)

I hope someone could help me, thanks in advance

best regards

Andrea

 


Original Attachment has been moved to: board-mx6q_var_som_orig.c.txt.zip

Original Attachment has been moved to: board-mx6q_var_som.c.txt.zip

Outcomes