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 Module for SK335x

Hi,

I want to write a SPI Device Driver (Kernel Module)  for the SK335x. I want to use SPI0. SPI0 is Multiplexed out in Mode 0 and that is used.

 +

when i look in file " board-am335xevm.c " in arch/arm/mach-omap2 we see that in this struct a spi0 device is initialized !? am i right ?

static struct evm_dev_cfg gen_purp_evm_dev_cfg[] = {
    {am335x_rtc_init, DEV_ON_BASEBOARD, PROFILE_ALL},
    {clkout2_enable, DEV_ON_BASEBOARD, PROFILE_ALL},
    {enable_ecap0,    DEV_ON_DGHTR_BRD, (PROFILE_0 | PROFILE_1 |
                        PROFILE_2 | PROFILE_7) },
    {lcdc_init,    DEV_ON_DGHTR_BRD, (PROFILE_0 | PROFILE_1 |
                        PROFILE_2 | PROFILE_7) },
    {mfd_tscadc_init,    DEV_ON_DGHTR_BRD, (PROFILE_0 | PROFILE_1 |
                        PROFILE_2 | PROFILE_7) },
    {rgmii1_init,    DEV_ON_BASEBOARD, PROFILE_ALL},
    {rgmii2_init,    DEV_ON_DGHTR_BRD, (PROFILE_1 | PROFILE_2 |
                        PROFILE_4 | PROFILE_6) },
    {usb0_init,    DEV_ON_BASEBOARD, PROFILE_ALL},
    {usb1_init,    DEV_ON_BASEBOARD, PROFILE_ALL},
    {evm_nand_init, DEV_ON_DGHTR_BRD,
        (PROFILE_ALL & ~PROFILE_2 & ~PROFILE_3)},
    {i2c1_init,     DEV_ON_DGHTR_BRD, (PROFILE_ALL & ~PROFILE_2)},
    {lis331dlh_init, DEV_ON_DGHTR_BRD, (PROFILE_ALL & ~PROFILE_2)},
    {mcasp1_init,    DEV_ON_DGHTR_BRD, (PROFILE_0 | PROFILE_3 | PROFILE_7)},
    {mmc1_init,    DEV_ON_DGHTR_BRD, PROFILE_2},
    {mmc2_wl12xx_init,    DEV_ON_BASEBOARD, (PROFILE_0 | PROFILE_3 |
                                PROFILE_5)},
    {mmc0_init,    DEV_ON_BASEBOARD, (PROFILE_ALL & ~PROFILE_5)},
    {mmc0_no_cd_init,    DEV_ON_BASEBOARD, PROFILE_5},
    {spi0_init,    DEV_ON_DGHTR_BRD, PROFILE_2},
    {uart1_wl12xx_init,    DEV_ON_BASEBOARD, (PROFILE_0 | PROFILE_3 |
                                PROFILE_5)},
    {wl12xx_init,    DEV_ON_BASEBOARD, (PROFILE_0 | PROFILE_3 | PROFILE_5)},
    {d_can_init,    DEV_ON_DGHTR_BRD, PROFILE_1},
    {matrix_keypad_init, DEV_ON_DGHTR_BRD, PROFILE_0},
    {volume_keys_init,  DEV_ON_DGHTR_BRD, PROFILE_0},
    {uart2_init,    DEV_ON_DGHTR_BRD, PROFILE_3},
    {haptics_init,    DEV_ON_DGHTR_BRD, (PROFILE_4)},
    {NULL, 0, 0},
};

this calls the method:

static void spi0_init(int evm_id, int profile)
{
          setup_pin_mux(spi0_pin_mux);
          spi_register_board_info (am335x_spi0_slave_info, ARRAY_SIZE(am335x_spi0_slave_info));
          return;
}


static struct pinmux_config spi0_pin_mux[] = {
            {"spi0_sclk.spi0_sclk", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL | AM33XX_INPUT_EN},
            {"spi0_d0.spi0_d0", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL | AM33XX_PULL_UP | AM33XX_INPUT_EN},
             {"spi0_d1.spi0_d1", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL| AM33XX_INPUT_EN},
             {"spi0_cs0.spi0_cs0", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL | AM33XX_PULL_UP | AM33XX_INPUT_EN},

             {NULL, 0},

};

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,
},
};



So my Questions are:

1- This initalizes a SPI device  with name "m25p80" .. how can i check in Linux if the device is initialized with this parameters ??

2- The IRQ is set to -1 ... Where is a list ?  or datasheet ? where the IRQs in the Systems are specified ?

3- Is this Device working ? I guess no, because of the -1 IRQ 

4- So could i change the IRQ here and compile the kernel again and so it would work`?


best regards 

aly


  • Hi Aly,

    You are not looking at the correct device config structure. The one you have pasted is for the GP EVM board. The one for the Starter Kit is:

    /* 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},
        {NULL, 0, 0},
    };

    No spi module is initialized inside Starter Kit structure, so you need to add this. Please make sure you don't cause any pinmux conficts with the other modules.

    The "-1" IRQ number should not be a problem. I believe this is an existing IRQ number, although I'm not able to find the exception vectors table with the IRQ enumeration.

    Best regards,
    Miroslav

  • Hi Miro,

    i did this , compliled linux again  , and installed it in targetNFS  , but how can i check if the device is initialized now?

    i don't see "m25p80" in /dev

    what i did is from the root of SDK:

    make clean

    make linux 

    make linux_install

    and restarted my Kit booting from nfs

    console=ttyO0,115200n8 root=/dev/nfs nfsroot=192.168.2.176:/home/user/ti-sdk-am335x-evm-05.06.00.00/targetNFS,nolock rw ip=dhcp

    this is supposed to install the new kernel in targetNFS, right ?

    best regards

    aly

  • Hi,

    You can find m25p8o under /sys/bus/spi/drivers/m25p80.

    But in your case it is not clear you are connected flash device to spi0? If connected you have to check

    is the flash supported in m25p80 by checking m25p80.c driver.

    For testing  spi0 you can use spidev.

    Details of adding spidev support is being discussed.

    http://e2e.ti.com/support/arm/sitara_arm/f/791/p/214756/759067.aspx#759067

    Here you have to add

    1. spidev modalias.

    2. spi0 pin-mux.

    3. spi0 spi_regigister_board_info from spi0_init from evm_sk_dev_cfg[].

    4. enable spidev support in kconfig

        User mode SPI device driver support (SPI_SPIDEV)

    Thanks

    Avinash