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/AM3358: DTS configuration for GPIO as output

Part Number: AM3358
Other Parts Discussed in Thread: AM4372

Tool/software: Linux

Hi

it seems that the only way i can assign a GPIO as output is by using the pinmux to be compatible with gpio-leds? The question is why?

 

Thanks

  • Hi Mohsen,

    GPIO can be set as output even without using gpio-leds. For example check AM335x StarterKit DTS file and schematics:

    www.ti.com/.../sprr356.pdf

    linux-kernel/arch/arm/boot/dts/am335x-evmsk.dts

    GPIO1_29 pin is used as output, this pin enables WLAN module at WL_EN port.

    wl12xx_gpio: pinmux_wl12xx_gpio {
    pinctrl-single,pins = <
    AM33XX_IOPAD(0x87c, PIN_OUTPUT_PULLUP | MUX_MODE7) /* gpmc_csn0.gpio1_29 */
    >;
    };

    wl12xx_vmmc: fixedregulator2 {
    pinctrl-names = "default";
    pinctrl-0 = <&wl12xx_gpio>;
    compatible = "regulator-fixed";
    regulator-name = "vwl1271";
    regulator-min-microvolt = <1800000>;
    regulator-max-microvolt = <1800000>;
    gpio = <&gpio1 29 0>;
    startup-delay-us = <70000>;
    enable-active-high;
    };


    Regards,
    Pavel
  • Hi Pavel

    thanks for the reply, but that does not help me here. I need a GPIO by itself and not part of another module (like the case you send me which is the wlan12xx) driver. It seems that you have to have it as part of another modules like the LED.

    Thanks

    Mohsen

  • Mohsen,

    You can use GPIO directly. For controlling LEDs and Buttons, the kernel has standard drivers, “leds-gpio” and “gpio_keys”, respectively, that should be used instead of GPIO directly.

    For direct GPIO use example, you can check below DTS files:

    linux-kernel/arch/arm/boot/dts/am335x-icev2-common.dtsi
    linux-kernel/arch/arm/boot/dts/am335x-icev2.dts

    &gpio3 {
    p10 {
    gpio-hog;
    gpios = <10 GPIO_ACTIVE_HIGH>;
    /* ETH1 mux: Low for MII-PRU, high for RMII-CPSW */
    output-high;
    line-name = "MUX_MII_CTL1";
    };
    };

    Another example is in AM437x EVM, where GPIO output pin is used to select between HDMI and LCD:

    linux-kernel/arch/arm/boot/dts/am437x-gp-evm.dts

    &gpio5 {
    pinctrl-names = "default";
    pinctrl-0 = <&display_mux_pins>;
    status = "okay";
    ti,no-reset-on-init;

    p8 {
    /*
    * SelLCDorHDMI selects between display and audio paths:
    * Low: HDMI display with audio via HDMI
    * High: LCD display with analog audio via aic3111 codec
    */
    gpio-hog;
    gpios = <8 GPIO_ACTIVE_HIGH>;
    output-high;
    line-name = "SelLCDorHDMI";
    };
    };

    display_mux_pins: display_mux_pins {
    pinctrl-single,pins = <
    /* GPIO 5_8 to select LCD / HDMI */
    AM4372_IOPAD(0xa38, PIN_OUTPUT_PULLUP | MUX_MODE7)
    >;
    };

    The driver code used is located at:

    linux-kernel/drivers/gpio/

    Regards,
    Pavel