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.

AM6548: Control GPIO in uboot

Part Number: AM6548

Hi TI,

Sorry to post again.

From former post below, I thought I have no question. But I was wrong!

https://e2e.ti.com/support/processors/f/processors-forum/983550/am6548-read-write-gpio-in-uboot/3635938?tisearch=e2e-sitesearch&keymatch=%25252520user%2525253A445865#3635938

I did the gpio test to flash the LED again.

1. In k3-am654-base-board.dts, I add the test gpio.

gpio_test: gpio_test {
compatible = "gpio-test";
pintest-gpio = <&wkup_gpio0 25 GPIO_ACTIVE_HIGH>;
u-boot,dm-spl;
};

&cbass_wakeup {
wkup_pmx0: pinmux@4301c000 {
compatible = "pinctrl-single";
reg = <0x4301c000 0x118>;
#pinctrl-cells = <1>;
pinctrl-single,register-width = <32>;
pinctrl-single,function-mask = <0xffffffff>;
};

wkup_gpio0: wkup_gpio0@42110000 {
compatible = "ti,am654-gpio", "ti,keystone-gpio";
reg = <0x42110000 0x100>;
gpio-controller;
#gpio-cells = <2>;
ti,ngpio = <56>;
ti,davinci-gpio-unbanked = <0>;
clocks = <&k3_clks 59 0>;
clock-names = "gpio";
u-boot,dm-spl;
};
};

&wkup_pmx0 {
pinctrl-names = "default";
pinctrl-0 = <&gpio_identify_pins>;

gpio_identify_pins: gpio_identify_pins {

pinctrl-single,pins = <
AM65X_WKUP_IOPAD(0x0034, PIN_OUTPUT, 7) /* (T1) MCU_OSPI1_CLK.WKUP_GPIO0_25 LED-ERR*/
>;
u-boot,dm-spl;
};
};

And I add my test function in board_late_init().

int gpio_control_test(void)
{
struct gpio_desc pin_gpio;
int node, pin0Val, ret;


node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "gpio-test");

ret = gpio_request_by_name_nodev(offset_to_ofnode(node), "pintest-gpio", 0, &pin_gpio, GPIOD_IS_OUT);

if (dm_gpio_is_valid(&pin_gpio))
{
pin0Val = dm_gpio_get_value(&pin_gpio);
printf("Eric: gpio_control_test dm_gpio_get_value value=%d [1]\r\n", pin0Val);

dm_gpio_set_dir_flags(&pin_gpio, GPIOD_IS_OUT);
dm_gpio_set_value(&pin_gpio, 1);
mdelay(1000);
pin0Val = dm_gpio_get_value(&pin_gpio);
printf("Eric: gpio_control_test dm_gpio_get_value value=%d [2]\r\n", pin0Val);

dm_gpio_set_value(&pin_gpio, 0);
mdelay(1000);
pin0Val = dm_gpio_get_value(&pin_gpio);
printf("Eric: gpio_control_test dm_gpio_get_value value=%d [3]\r\n", pin0Val);

dm_gpio_set_value(&pin_gpio, 1);
mdelay(1000);
pin0Val = dm_gpio_get_value(&pin_gpio);
printf("Eric: gpio_control_test dm_gpio_get_value value=%d [4] \r\n", pin0Val ? LEDST_ON : LEDST_OFF);
}
else
printf("Eric: gpio_control_test dm_gpio_is_valid error!! \r\n");

return 1;

}

In my program, I want to flash the LED as on, off and on again. And it did work as I want.

However, when I look into my log, I always get the value as 0 from dm_gpio_get_value.

Is there anything I missed?

Thanks.

Eric

  • Hi Eric,

    That is indeed strange where in at the hardware level you are able to toggle and software always reports 0.

    Can you dump registers of wkup_gpio0?

    md 0x42110000 10

    Set GPIO to high and take a dump when LED is On and Set to GPIO to low and take the above dump.

    Best Regards,
    Keerthy

  • Hi 

    I have dump the registers.

    LED_ON:

    => md 0x42110000 10
    42110000: 44832905 00000001 00000000 00000000 .).D............
    42110010: edffffff 12000000 12000000 12000000 ................
    42110020: 00000203 00000000 00000000 00000000 ................
    42110030: 00000000 00000000 ffffffff 00000000 ................
    =>

    LED_OFF:

    => md 0x42110000 10
    42110000: 44832905 00000001 00000000 00000000 .).D............
    42110010: edffffff 10000000 10000000 10000000 ................
    42110020: 00000203 00000000 00000000 00000000 ................
    42110030: 00000000 00000000 ffffffff 00000000 ................
    =>

    Thanks.

    Eric

  • Eric,

    Check this for generic gpio config:  e2e.ti.com/.../948888

    I found the issue is with the pinmux setting. At PAD level keep the config as PIN_INPUT.

    gpio_identify_pins: gpio_identify_pins {

    pinctrl-single,pins = <
    AM65X_WKUP_IOPAD(0x0034, PIN_INPUT, 7) /* (T1) MCU_OSPI1_CLK.WKUP_GPIO0_25 LED-ERR*/
    >;
    u-boot,dm-spl;
    };

    You should see the correct value.

    Thanks for the dumps of registers. Resolve this once you validate.

    Best Regards,
    Keerthy

  • Hi ,

    So, does that mean we need to config the pin as PIN_INPUT if we want to get any gpio value?

    Thanks.

    Eric

  • Eric,

    Yes. Can you confirm that it is working for you? If yes please resolve the issue.

    Best Regards,
    Keerthy