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.

TI_AM335x_StarterKit_spidev0.0_enable

We are using TI AM335x starter kit for our development activity and trying to “enable” the spidev0.0 driver in linux-3.2.0-psp04.06.00.11 source .So, please give me the steps of information to enable the spidev0.0 driver along with the kernel image.

  • You have to add the following code into your board file.
    arch/arm/mach-omap2/board-am335xevm.c

    /* Module pin mux for SPI flash */
    static struct pinmux_config spi1_pin_mux[] = {
    {"mcasp0_aclkx.spi1_sclk", OMAP_MUX_MODE3 | AM33XX_PULL_ENBL
    | AM33XX_INPUT_EN},
    {"mcasp0_fsx.spi1_d0", OMAP_MUX_MODE3 | AM33XX_PULL_ENBL
    | AM33XX_PULL_UP | AM33XX_INPUT_EN},
    {"mcasp0_axr0.spi1_d1", OMAP_MUX_MODE3 | AM33XX_PULL_ENBL
    | AM33XX_INPUT_EN},
    {"mcasp0_ahclkr.spi1_cs0", OMAP_MUX_MODE3 | AM33XX_PULL_ENBL
    | AM33XX_PULL_UP | AM33XX_INPUT_EN},
    {NULL, 0},
    };

    static struct spi_board_info spidev_board_info[] {
    {
    .modalias = "spidev",
    .max_speed_hz = 1000000,
    .bus_num = 2,
    .chips_select = 0,
    .mode = SPI_MODE_3,
    },
    };

    /* setup spi1 */
    static void spi1_init(int evm_id, int profile)
    {
    setup_pin_mux(spi1_pin_mux);
    spi_register_board_info(spidev_board_info,
    ARRAY_SIZE(spidev_board_info));
    return;
    }

    You have to add the following line in appropriate cfg struture.

    {spi1_init, DEV_ON_DGHTR_BRD, PROFILE_ALL},
  • We are using TI AM335x starter kit and trying to “enable” the spidev0.0 driver in linux-3.2.0-psp04.06.00.11 source.
  • We are using TI AM335x starter kit for our development activity and trying to “enable” the spidev0.0 driver in linux-3.2.0-psp04.06.00.11 source .So, please give me the steps of information to enable the spidev0.0 driver along with the kernel image.
    Please any body in TI help me to solve the issue and help to deliver our product in the field.
  • Hello JVS Electronics Pvt Ltd-India,

    You already have the answer in the first post but I will show you how to enable and check proper work of the spidev in the shortest way.

    If the SPI device is attached to the J11 connector It will appear as /dev/spidev1.0.

    1. Run your favourite kernel configuration tool and enable SPI support for the user space.

       Device Drivers ---> SPI support ---> User mode SPI device driver support

    2. Modify arch/arm/mach-omap2/board-am335xevm.c

    static struct spi_board_info am335x_spi0_slave_info[] = {
    	{
    		.modalias      = "m25p80",
    		.platform_data = &am335x_spi_flash,
    		.irq           = -1,
    		.max_speed_hz  = 24000000,
    		.bus_num       = 1,
    		.chip_select   = 0,
    	},
    };

    to

    static struct spi_board_info am335x_spi0_slave_info[] = {
    	{
    		.modalias = "spidev",
    		.max_speed_hz = 48000000, //48 Mbps
    		.bus_num       = 1,
    		.chip_select   = 0,
    		.mode = SPI_MODE_1,
    	},
    };

    /* EVM - Starter Kit */
    static struct evm_dev_cfg evm_sk_dev_cfg[] = {
    	{am335x_rtc_init, DEV_ON_BASEBOARD, PROFILE_ALL},
    	{mmc1_wl12xx_init,	DEV_ON_BASEBOARD, PROFILE_ALL},
    	{mmc0_init,	DEV_ON_BASEBOARD, PROFILE_ALL},
    	{rgmii1_init,	DEV_ON_BASEBOARD, PROFILE_ALL},
    	{rgmii2_init,	DEV_ON_BASEBOARD, PROFILE_ALL},
    	{lcdc_init,     DEV_ON_BASEBOARD, PROFILE_ALL},
    	{enable_ecap2,     DEV_ON_BASEBOARD, PROFILE_ALL},
    	{mfd_tscadc_init,	DEV_ON_BASEBOARD, PROFILE_ALL},
    	{gpio_keys_init,  DEV_ON_BASEBOARD, PROFILE_ALL},
    	{gpio_led_init,  DEV_ON_BASEBOARD, PROFILE_ALL},
    	{lis331dlh_init, DEV_ON_BASEBOARD, PROFILE_ALL},
    	{mcasp1_init,   DEV_ON_BASEBOARD, PROFILE_ALL},
    	{uart1_wl12xx_init, DEV_ON_BASEBOARD, PROFILE_ALL},
    	{wl12xx_init,       DEV_ON_BASEBOARD, PROFILE_ALL},
    	{gpio_ddr_vtt_enb_init,	DEV_ON_BASEBOARD, PROFILE_ALL},
    	{sgx_init,       DEV_ON_BASEBOARD, PROFILE_ALL},
    	{NULL, 0, 0},
    };

    to



    /* EVM - Starter Kit */ static struct evm_dev_cfg evm_sk_dev_cfg[] = { {am335x_rtc_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {mmc1_wl12xx_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {mmc0_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {rgmii1_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {rgmii2_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {lcdc_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {enable_ecap2, DEV_ON_BASEBOARD, PROFILE_ALL}, {mfd_tscadc_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {gpio_keys_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {gpio_led_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {lis331dlh_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {mcasp1_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {uart1_wl12xx_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {wl12xx_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {gpio_ddr_vtt_enb_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {sgx_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {spi0_init, DEV_ON_BASEBOARD, PROFILE_ALL}, {NULL, 0, 0}, };

    Cross-Compile the spidev_test.c which is located in your kernel source Documentation/spi directory.


    arm-linux-gnueabihf-gcc -o spidev_test spidev_test.c

    Put a wire between MOSI and MISO (J11's pins 3 and 6) and run the compiled spidev_test.

    ./spidev_test -D /dev/spidev1.0

    If all went well the feedback from the execution will be:

    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

    Best regards,

    Kemal

  • It's working ....
    thank you very much for your information