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: Read/write GPIO in Uboot

Part Number: AM6548
Other Parts Discussed in Thread: DA8XX

Hi Ti,

I'm using SDK 07_01_00_18 and trying to write some sample code to read/write GPIO in Uboot.

I follow another thread to read the GPIO1_25 or GPIO1_67 on AM65x SR1.0 EVM board, but it always return error message.

The thread is this one: .

According to the thread, I modify k3-am654-base-board.dts by adding the code below:

&main_pmx0 {

.

.

main_gpio1_pins_default: main-gpio1-pins-default {
pinctrl-single,pins = <
//AM65X_IOPAD(0x028c, PIN_INPUT, 7) /* (Y26)GPIO1_67 */
AM65X_IOPAD(0x01E4, PIN_OUTPUT, 7) /* (Y26)GPIO1_25 */
>;
};

};

&main_gpio1 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&main_gpio1_pins_default>;
};

&sdhci0 {
//usb5v-gpios = <&main_gpio1 67 GPIO_ACTIVE_HIGH>;
usb5v-gpios = <&main_gpio1 25 GPIO_ACTIVE_HIGH>;
};

And also modiify k3-am65-main.dtsi:

&cbass_main {

.

.

main_gpio1: main_gpio1@601000 {
compatible = "ti,k2g-gpio", "ti,keystone-gpio";
reg = <0x0 0x601000 0x0 0x100>;
gpio-controller;
#gpio-cells = <2>;
ti,ngpio = <90>;
ti,davinci-gpio-unbanked = <0>;
clocks = <&k3_clks 58 0>;
clock-names = "gpio";
u-boot,dm-spl;
};

Then, I hook my code in am654_sdhci.c, but always get error.

struct gpio_desc desc;
err = gpio_request_by_name(dev, "usb5v-gpios", 0, &desc, GPIOD_IS_OUT);
if(err)
printf("request usb5v-gpios failed !! \n");
ret = dm_gpio_get_value(&desc);
if(err)
printf("get usb5v-gpios value failed !! \n");

Is there anything wrong?

Please help to look into this.

Thanks.

Eric

  • Hi Eric,

    What is the exact error you are getting? Where is it failing?

    Best Regards,
    Keerthy

  • Hi 

    As you can see my log below, I got request usb5v-gpios error.

    Please ignore other errors, because I'm still trying other ways.

    U-Boot SPL 2020.01 (Mar 08 2021 - 17:02:34 +0800)
    SYSFW ABI: 3.1 (firmware rev 0x0014 '20.8.5--v2020.08b (Terrific Lla')
    Eric: dev=memorycontroller@0298e000 num_rates=0 rate = 400000000 ...
    Trying to boot from MMC2
    Eric: dev=a53@0 num_rates=0 rate = 1100000000 ...
    Eric: dev=a53@0 num_rates=1 rate = 1100000000 ...
    Starting ATF on ARM64 core...

    NOTICE: BL31: v2.3():07.01.00.004-1-g52c334fc3-dirty
    NOTICE: BL31: Built : 04:16:36, Nov 26 2020

    U-Boot SPL 2020.01 (Mar 08 2021 - 17:01:16 +0800)
    SYSFW ABI: 3.1 (firmware rev 0x0014 '20.8.5--v2020.08b (Terrific Lla')
    Eric: init_daughtercard_det_gpio
    Eric: identify_pin_detect
    Eric: fdt_node_offset_by_compatible error!!
    Eric: dm_gpio_is_valid error!!
    Detected: AM6-IDKAPPEVM rev E4
    Trying to boot from MMC2
    Eric: am654_sdhci_probe ...
    Eric: request usb5v-gpios failed !!
    Eric: get usb5v-gpios value failed !!


    U-Boot 2020.01 (Mar 08 2021 - 17:01:16 +0800)

    SoC: AM65X SR1.0
    Model: Texas Instruments AM654 Base Board
    Board: AM6-COMPROCEVM rev E4
    DRAM: 4 GiB
    MMC: Eric: am654_sdhci_probe ...
    Eric: am654_sdhci_probe ...
    Eric: request usb5v-gpios failed !!
    Eric: get usb5v-gpios value failed !!
    sdhci@4f80000: 0, sdhci@4fa0000: 1
    Loading Environment from MMC... OK
    In: serial
    Out: serial
    Err: serial

    Thanks.

    Eric

  • Hi 

    I found the cause, the CONFIG_DA8XX_GPIO need to be set.

    Anyway, thanks for your reply.

    Eric

  • Hi ,

    Sorry I have a further question.

    I can control the GPIO as the above description.

    For example, I control the LED gpio to on, off and on again. And the LED did work also.

    However, when I use dm_gpio_get_value to get gpio status, I always got 0.

    Is there any possible reason?

    Thanks.

    Eric

  • Hi Eric,

    You have created a new thread for the above question. So please resolve this & i will be answering on the new thread: https://e2e.ti.com/support/processors/f/processors-forum/986568/am6548-control-gpio-in-uboot

    Best Regards,
    Keerthy