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.

TDA2HG: How do we set a pin value in uboot or kernel?

Part Number: TDA2HG

Hello,

We use TDA2HG device based on VSDK 03 05. We have set pin_mux in u-boot/board/ti/dra7xx/mux_data.h. How do we set a pin value in uboot or kernel?  For instance, we set VIN1A_D22 as a gpio pin, as below,

 {VIN1A_D22, (M14 | PIN_INPUT)}, /* AD2 vin1a_d22.gpio3_26 */

PS: We are not good at BSP part, could you help us to have a look?

Thanks

Terence

  • Hi Terence,

    For uboot:

    You can go through code in this file : board/ti/am335x/board.c

    Check gpio_request() and gpio_direction_output()

    The gpio argument of gpio_request() is derived as follows : GPIO_TO_PIN(bank, bank_gpio)    (32 * (bank - 1) + (bank_gpio))

    So in your case, it should be 

    gpio_request(GPIO_TO_PIN(3,26), "my gpio");

    For setting the GPIO high:

    gpio_direction_output(GPIO_TO_PIN(3,26), 1);

    For setting the GPIO low:

    gpio_direction_output(GPIO_TO_PIN(3,26), 0);

    For kernel:


    Refer to these documents as starting point :    &  

    1. pinmux would be set under "&am33xx_pinmux" field in the respective dts file. e.g: am335x-evm.dts. And pinmux phandle would be used by a device node. Say for example :

    &mmc1 {
    status = "okay";
    vmmc-supply = <&vmmc_reg>;
    bus-width = <4>;
    pinctrl-names = "default";
    pinctrl-0 = <&mmc1_pins>;
    cd-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
    };

    See mmc1_pins, under am335x_pinmux as below:

    mmc1_pins: pinmux_mmc1_pins {
    pinctrl-single,pins = <
    AM33XX_IOPAD(0x960, PIN_INPUT | MUX_MODE7) /* spi0_cs1.gpio0_6 */
    >;
    };

    And go through the code : drivers/mmc/host/omap_hsmmc.c, fubction omap_hsmmc_gpio_init(), specifically associated with "gpio_cd". You would come across devm_gpio APIs e.g. "devm_gpio_request_one" and gpiod_ APIs present in drivers/gpio/gpiolib.c and associate with above document

    2. Second option in kernel is adding gpio-hog, where the GPIO driver itself will configure it to a specific value, if you do not want to change.

  • Hi Dwarakesh,

    Thank you very much !

    Terence