Embedded_linux [SOLVED]: How to set a pin between boot and module load for an embedded Linux?

Embedded_linux [SOLVED]: How to set a pin between boot and module load for an embedded Linux?

Home Forums Embedded Linux Embedded_linux [SOLVED]: How to set a pin between boot and module load for an embedded Linux?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4355

    Anonymous

    QuestionQuestion

    I am facing an interesting problem. I like to set a pin of my cpu. So far I created a module for controlling the pin. This module is setting the default pin configuration(high). The default pin configuration becomes active when the module is loaded. That is working fine.

    Now I like to enable my default pin configuration right away from the start of boot process. To archive that I wrote a patch for the ATMEL bootloader(at91bootstrap) and the uboot(u-boot-at91). This works fine till the moment the kernel starts. At the kernel start the pins is set to the ATMEL default. They pins are defined in the device tree as gpios.

    I think I have two possibilities:

    1st – patch the /init/main.c at the “right” spot. Where is the right spot?

    2nd – modify the device tree to set the GPIOs to an other default value. How to “re set” an gpio a value?

    #4356

    Anonymous

    Accepted AnswerAnswer

    When you modify the pin in u-boot level; it will be override by the kernel. /init/main.c is worse idea and so I think you should not followed this approach

    In kernel level if you you want to set the GPIO pin, there are two possibilities (apart from your module)

    1) Kernel board file.

    2) Device tree file.

    Suppose if you want to set the SDIO pin as GPIO in i.MX6 board then you need to modify the code like this.

    leds {
       compatible = "gpio-leds";
       pinctrl-names = "default";
       pinctrl-0 = <&pinctrl_gpio_leds>;
    
    red {
           gpios = <&gpio7 0 0>;
           default-state = "on";
    };
    
    MX6QDL_PAD_SD3_DAT5__GPIO7_IO00 0x1b0b0  //set the pin as GPIO
    

    For the default state of the pin please refer the datasheet of your processor. And one pin may have different functionalities.

    And if you want to use the same pin for some other functionalities instead of GPIO then you can choose on of the below configuration.

    MX6QDL_PAD_SD3_DAT5__UART2_RX_DATA  //UART2 RX Data pin
    MX6QDL_PAD_SD3_DAT5__GPIO7_IO00  //As a GPIO pin
    MX6QDL_PAD_SD3_DAT6__UART1_RX_DATA // UART1 RX data
    MX6QDL_PAD_SD3_DAT6__SD3_DATA6 //SDIO pin which is default in this case
    

    Please add more details if you are looking for something more (like pin number and device tree file name).

    Source: http://stackoverflow.com/questions/42483895/how-to-set-a-pin-between-boot-and-module-load-for-an-embedded-linux
    Author: vinod maverick
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.