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.

Linux/AM3352: Change gpio logic level at kernel boot

Part Number: AM3352


Tool/software: Linux

I am running kernel version 3.12.10 on AM335x based custom board. I want to set gpio2_28 pin logic level to high as soon as kernel booting starts. This kernel version does not support the gpio hogging. To overcome this I have made gpio pin as led and setting its default state as on.


My questions is. Is there any other way to achieve this?


I was using logic analyzer to see the logic level on the pin. When kernel starts booting the gpio2_28 pin goes low and after few millisecond it goes to high. I want the logic level to be high from the start without any glitches.

  • Hi Ankur,

    I was using logic analyzer to see the logic level on the pin. When kernel starts booting the gpio2_28 pin goes low and after few millisecond it goes to high


    Can you share your dts file? Perhaps you haven't pinmuxed the gpio correctly.

    Also you can have a look at drivers/leds/leds-gpio.c and hardcode the gpio level to active high in gpio_led_set(), which means setting level to 1.

    Best Regards,
    Yordan
  • Hi Yordan,

    I am using device tree derived from AM33xx.dtsi. Any change in the leds-gpio.c is not required because I am able to set the led value from the device tree. I suspect that code in gpio driver (code in file gpio-omap.c) is setting gpio2_28 low.

    Thanks & Regards,
    Ankur
  • Ankur Pawar said:
    When kernel starts booting the gpio2_28 pin goes low and after few millisecond it goes to high.

    1. Have you tried halting at a u-boot prompt and checking the state of the pin?  Are you positive the pin is in the desired state while u-boot is executing?  Perhaps you should be focused on u-boot instead of the kernel.  This would be a quick test to confirm either way.
    2. How are you configuring the gpio2_28 pinmuxing in your dts?
    3. Have you done anything else in the dts to attempt to configure the state of this pin?  Please share snippets (or the whole thing).

  • 1. U-boot
    making GPIO2_28 high to low then high in u-boot function board_late_init()

    if (!gpio_request(GPIO_UART5_CTS, "")) {
    ret = gpio_direction_output(GPIO_UART5_CTS, 0);
    if (ret < 0)
    puts("gpio drirection failed\n");
    ret = gpio_set_value(GPIO_UART5_CTS, 0);
    if (ret < 0)
    puts("gpio set value failed\n");

    puts("start delay\n");
    udelay(90000);
    puts("delay over\n");
    gpio_set_value(GPIO_UART5_CTS, 1);
    if (ret < 0)
    puts("gpio set value failed\n");
    else
    puts("GPIO_UART5_CTS gpio set to 1\n");
    }
    else
    {
    puts("GPIO_UART5_CTS request failed!\n");
    }

    2. In device tree
    gpio_enable_pins: pinmux_gpio_enable_pins {
    pinctrl-single,pins = <
    0xF8 (PIN_INPUT_PULLUP | MUX_MODE7) /* mmc0_dat1.gpio2_28.uart5_cts */
    >;
    };
    gpio2: gpio@481ac000 {
    compatible = "ti,omap4-gpio";
    ti,hwmods = "gpio3";
    clocks = <&l4ls_gclk>, <&gpio2_dbclk>;
    clock-names = "fck", "dbclk";
    gpio-controller;
    #gpio-cells = <2>;
    interrupt-controller;
    #interrupt-cells = <1>;
    reg = <0x481ac000 0x1000>;
    interrupts = <32>;
    };

    gpio2_28enable {
    compatible = "gpio-leds";
    pinctrl-names = "default";
    pinctrl-0 = <&gpio_enable_pins>;

    p28@0 {
    label = "gpio2_28";
    gpios = <&gpio2 28 GPIO_ACTIVE_HIGH>
    default-state = "on";
    };
    };