Compile kernel with SPI serial port support

Discussion in 'Kernels' started by Whatdoudoo, Jun 22, 2015.

  1. Whatdoudoo

    Whatdoudoo New Member

    Joined:
    Jun 22, 2015
    Messages:
    4
    Likes Received:
    0
    I have an UDOO Quad Rev.D and I would like to activate the serial port SPI2 in the kernel so I can use them from the i.mx6. I chose SPI2 because it is available on the header. I am not sure what I need to add to the kernel files to get it working. I have managed to compile the kernel and get the UARTS working, but I am clueless with the SPI interfaces. Has anyone been able to get a serial port working for the i.mx6? I guess if all else fails, I could bit bang it. Would be nice to get it working without having to bit bang though. Is there a driver for the SPI interface that is needed? Any help would be appreciated. I did find this link on freescale, so I am going to see what I can accomplish while I wait...
    https://community.freescale.com/thread/302612

    Thanks!
     
  2. Andrea Rovai

    Andrea Rovai Well-Known Member

    Joined:
    Oct 27, 2014
    Messages:
    1,703
    Likes Received:
    240
    Hi there Whatdoudoo,
    for the moment regarding this matter the best documentation is indeed the Freescale website.
    I suggest to go for the solution you provided and try if it works.
    Cheers
     
  3. Whatdoudoo

    Whatdoudoo New Member

    Joined:
    Jun 22, 2015
    Messages:
    4
    Likes Received:
    0
    Ok, I will try it this week sometime don't have time today. I already changed the pins in board-mx6qd_seco_UDOO.h. Would the only other file I need to change be the board-mx6_seco_UDOO.c? And I also assume I would use the spidev driver as they did on the freescale link? Thanks!
     
  4. Andrea Rovai

    Andrea Rovai Well-Known Member

    Joined:
    Oct 27, 2014
    Messages:
    1,703
    Likes Received:
    240
    I believe the answer yes, give it a try and let us know.
     
  5. Whatdoudoo

    Whatdoudoo New Member

    Joined:
    Jun 22, 2015
    Messages:
    4
    Likes Received:
    0
    I have tried both ESCPI1 and ESCPI2 with no luck. I finally found a link that said you have to enable the User mode support in the spi device section of the menu config which I have also done.

    Device Drivers --->
    [*] SPI support --->
    <*> Freescale i.MX SPI controllers
    <*> User mode SPI device driver support

    The thing is, I think there is suppose to be an SPIDEV controller in this section to use the spidev drivers. All that is there is the Freescale i.mx SPI Controllers and I haven't found any info on them yet. Speaking of that, I may just be able to add the define for that, have not tried that yet.

    I also found this link in which there was a bug on the raspberrypi which looks like the same problem I am having, so maybe that bug in this kernel as well.
    https://github.com/raspberrypi/linux/issues/296

    Anyway, I have not given up yet just hoping someone might be able to steer me further quicker. Here are my current files. I had no problem enabling all the uarts, but the SPI devices have been a real pain. Anyone see if I'm doing something wrong or something I'm not doing. If these files are right, the problem must be elsewhere.

    ########## board-mx6qd_seco_UDOO.h ##############

    //enabling SPI1, comment out GPIO and uncomment SCLK
    // MX6Q_PAD_DISP0_DAT20__GPIO_5_14, // pin 36
    MX6Q_PAD_DISP0_DAT20__ECSPI1_SCLK,
    //enabling SPI1, comment out GPIO and uncomment MOSI
    // MX6Q_PAD_DISP0_DAT21__GPIO_5_15, // pin 37
    MX6Q_PAD_DISP0_DAT21__ECSPI1_MOSI,
    //enabling SPI1, comment out GPIO and uncomment MISO
    //MX6Q_PAD_DISP0_DAT22__GPIO_5_16, // pin 45
    MX6Q_PAD_DISP0_DAT22__ECSPI1_MISO,
    //enabling SPI1, comment out GPIO and uncomment SP1 SSO
    //MX6Q_PAD_DISP0_DAT23__GPIO_5_17, // pin 46
    MX6Q_PAD_DISP0_DAT23__ECSPI1_SS0,




    ########## board-mx6_seco_UDOO.c ##############

    I added an SPI section.

    /***********************************************************************
    * SPI *
    ***********************************************************************/

    // chip select pin
    static int mx6q_UDOO_spi_SS0[] = {
    MX6Q_PAD_DISP0_DAT23__ECSPI1_SS0,
    };

    // this struct is added in function mx6_seco_UDOO_board_init()
    static const struct spi_imx_master mx6q_UDOO_spi_data2 __initconst = {
    .chipselect = mx6q_UDOO_spi_SS0,
    .num_chipselect = ARRAY_SIZE(mx6q_UDOO_spi_SS0),
    };

    // all spi devices initialization data goes in this array
    static struct spi_board_info imx6_UDOO_spi_any_device[] __initdata = {
    {
    .modalias = "spidev",
    .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
    .bus_num = 0,
    .chip_select = 0,
    .mode = SPI_MODE_0,
    },
    };

    // this is called in function mx6_seco_UDOO_board_init()
    static void spi_device_init(void) {
    imx6q_add_ecspi(0, &mx6q_UDOO_spi_data2);
    spi_register_board_info(imx6_UDOO_spi_any_device, ARRAY_SIZE(imx6_UDOO_spi_any_device));
    }



    In mx6_seco_UDOO_board_init(void) I added

    spi_device_init();
     
  6. Whatdoudoo

    Whatdoudoo New Member

    Joined:
    Jun 22, 2015
    Messages:
    4
    Likes Received:
    0
  7. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    168
    Likes Received:
    47
  8. vpeter

    vpeter Active Member

    Joined:
    Nov 29, 2014
    Messages:
    303
    Likes Received:
    62
  9. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    168
    Likes Received:
    47
    This a DTS file for an other board. There is no chance to have the same addresses or iomux.
     
  10. vpeter

    vpeter Active Member

    Joined:
    Nov 29, 2014
    Messages:
    303
    Likes Received:
    62
    Seems you would like to get final solution already? I'm trying to help you but ......
    You just need to set correct pins (hint: check the schematic).
     
  11. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    168
    Likes Received:
    47
    I've in mind this :

    Code:
    &ecspi2 {
        fsl,spi-num-chipselects = <2>;
        cs-gpios = <0>,<&gpio3 31 0>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_ecspi2_1>;
        status = "okay";
        spidev@0x00 {
            compatible = "spidev";
            spi-max-frequency = <20000000>;
            reg = <0>;
        };
        spidev@0x01 {
            compatible = "spidev";
            spi-max-frequency = <20000000>;
            reg = <1>;
        };
    };
    
    &iomux {
            imx6q-udoo {
                  pinctrl_ecspi2_1: ecspi2grp-1 {
                        fsl,pins = <
                            MX6SL_PAD_ECSPI2_MISO__ECSPI2_MISO 0x100b1
                            MX6SL_PAD_ECSPI2_MOSI__ECSPI2_MOSI 0x100b1
                            MX6SL_PAD_ECSPI2_SCLK__ECSPI2_SCLK 0x100b1
                            MX6SL_PAD_ECSPI2_SS0__ECSPI2_SS0 0x100b1
                            MX6SL_PAD_KEY_ROW3__GPIO3_IO31 0x100b1
                        >;
                  };
           };
    };
    Maybe I can guess the 2 GPIO for the chip select (cs-gpios) but I cannot figure out the rest.
     
  12. patrykk

    patrykk Member

    Joined:
    Dec 10, 2014
    Messages:
    52
    Likes Received:
    9
  13. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    168
    Likes Received:
    47
    I pulled the last commits and compiled the kernel with the new DTS files.
    I do have the spidev1.0 and spidev1.1 devices in /dev now ! I'll try next week to start an SPI communication for test.
     
  14. terraceaudio

    terraceaudio New Member

    Joined:
    May 14, 2014
    Messages:
    5
    Likes Received:
    0
    I'm trying to accomplish the exact same thing. Can you let me know the steps you took for success?

    Cheers!
     
  15. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    168
    Likes Received:
    47
    Just clone the patrykk's repository. Configure and build your kernel.
     

Share This Page