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.

AM62A7: Controlling the gpio from tiboot3 bootloader

Part Number: AM62A7


Tool/software:

Hi,

SDK: 09.01.00 yocto sdk

EVM: SKAM62 

I am trying to control the certain gpio from tiboot3 bootloader. So, I have gpio which need to be from kept low once board boots. I have made below changes in R5 dst file.

diff --git a/arch/arm/dts/k3-am62a-mcu.dtsi b/arch/arm/dts/k3-am62a-mcu.dtsi
index a3d43bfa9ce..743242cb433 100644
--- a/arch/arm/dts/k3-am62a-mcu.dtsi
+++ b/arch/arm/dts/k3-am62a-mcu.dtsi
@@ -74,4 +74,33 @@
                                sram = <&mcu_ram>;
                };
        };
+
+    mcu_gpio_intr: interrupt-controller@4210000 {
+        compatible = "ti,sci-intr";
+        reg = <0x00 0x04210000 0x00 0x200>;
+        ti,intr-trigger-type = <1>;
+        interrupt-controller;
+        interrupt-parent = <&gic500>;
+        #interrupt-cells = <1>;
+        ti,sci = <&dmsc>;
+        ti,sci-dev-id = <5>;
+        ti,interrupt-ranges = <0 104 4>;
+    };
+
+    mcu_gpio0: gpio@4201000 {
+        compatible = "ti,am64-gpio", "ti,keystone-gpio";
+        reg = <0x00 0x04201000 0x00 0x100>;
+        gpio-controller;
+        #gpio-cells = <2>;
+        interrupt-parent = <&mcu_gpio_intr>;
+        interrupts = <30>, <31>;
+        interrupt-controller;
+        #interrupt-cells = <2>;
+        ti,ngpio = <24>;
+        ti,davinci-gpio-unbanked = <0>;
+        power-domains = <&k3_pds 79 TI_SCI_PD_EXCLUSIVE>;
+        clocks = <&k3_clks 79 0>;
+        clock-names = "gpio";
+        status = "disabled";
+    };
 };
diff --git a/arch/arm/dts/k3-am62a7-r5-sk.dts b/arch/arm/dts/k3-am62a7-r5-sk.dts
index 74df282fae3..74d25f6e06e 100644
--- a/arch/arm/dts/k3-am62a7-r5-sk.dts
+++ b/arch/arm/dts/k3-am62a7-r5-sk.dts
@@ -15,7 +15,6 @@
        aliases {
                remoteproc0 = &sysctrler;
                remoteproc1 = &a53_0;
-               serial0 = &wkup_uart0;
        };

        chosen {
@@ -104,23 +103,25 @@
        status = "okay";
        bootph-pre-ram;

-       wkup_uart0_pins_default: wkup-uart0-pins-default {
-               pinctrl-single,pins = <
-                       AM62X_MCU_IOPAD(0x02c, PIN_INPUT, 0)    /* (C6) WKUP_UART0_CTSn */
-                       AM62X_MCU_IOPAD(0x030, PIN_OUTPUT, 0)   /* (A4) WKUP_UART0_RTSn */
-                       AM62X_MCU_IOPAD(0x024, PIN_INPUT, 0)    /* (B4) WKUP_UART0_RXD */
-                       AM62X_MCU_IOPAD(0x028, PIN_OUTPUT, 0)   /* (C5) WKUP_UART0_TXD */
-               >;
-               bootph-pre-ram;
-       };
+       mcu_gpio0_pins_default: mcu_gpio0_pins_default {
+               pinctrl-single,pins = <
+                   AM62X_MCU_IOPAD(0x050, PIN_OUTPUT, 7)    /* (E13) MCU_GPIO0_20 */
+               >;
+               bootph-pre-ram;
+       };
 };

-/* WKUP UART0 is used for DM firmware logs */
-&wkup_uart0 {
-       pinctrl-names = "default";
-       pinctrl-0 = <&wkup_uart0_pins_default>;
-       status = "okay";
-       bootph-pre-ram;
+&mcu_gpio0 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&mcu_gpio0_pins_default>;
+       E13 {
+           bootph-pre-ram;
+           gpio-hog;
+           gpios = <20 GPIO_ACTIVE_LOW>;
+           output-low;
+           line-name = "E13";
+       };
 };

Above changes have no impact on the gpio pin. Let us know if we have to do any modification in this.

Regards,

Jay

  • Hi Jay,

    I'm not very familiar with U-Boot. Can you try enabling these configs?

    If this doesn't work, you can try directly writing to the MMR registers (and you might have to set the PADCONFIG). Refer to section 12.2.1.4.2 GPIO Function and 14.9.2.1 GPIO Registers in the AM62A TRM: https://www.ti.com/lit/pdf/spruj16

    Best Regards,

    Anshu

  • 1. modify u-boot-2024.04/configs/am62x_lpsk_a53_defconfig
    CONFIG_SPL_GPIO=y
    CONFIG_SPL_BOARD_INIT=y
    CONFIG_SPL_BUILD=y
     
    2. modify u-boot-2024.04/arch/arm/dts/k3-am62-lp-sk.dtsi
    AM62X_IOPAD(0x1A4, PIN_OUTPUT_PULLDOWN, 7) /* (C17) WIFI_EN */
    AM62X_IOPAD(0x1B8, PIN_OUTPUT_PULLDOWN, 7) /* (D13) BT_EN */
    AM62X_IOPAD(0x0C8, PIN_OUTPUT_PULLDOWN, 7) /* (R20) 1V8_EN */
    AM62X_IOPAD(0x0C4, PIN_OUTPUT_PULLDOWN, 7) /* (R19) 3V3_EN */
    AM62X_IOPAD(0x0AC, PIN_OUTPUT_PULLDOWN, 7) /* (H17) WIFI_WAKEUP */
     it  does  not work.
    3.Note:  we need  these Pins   pulldown  immediately from power on.
        How to modify the SPL or U-BOOT project to do this during AM6202 boot phase.
  • Hi Hanson, 

    Thank you for update on the thread. I was just writing to this thread.

    1. modify u-boot-2024.04/configs/am62x_lpsk_a53_defconfig
    CONFIG_SPL_GPIO=y
    CONFIG_SPL_BOARD_INIT=y
    CONFIG_SPL_BUILD=y
     
    2. modify u-boot-2024.04/arch/arm/dts/k3-am62-lp-sk.dtsi
    AM62X_IOPAD(0x1A4, PIN_OUTPUT_PULLDOWN, 7) /* (C17) WIFI_EN */
    AM62X_IOPAD(0x1B8, PIN_OUTPUT_PULLDOWN, 7) /* (D13) BT_EN */
    AM62X_IOPAD(0x0C8, PIN_OUTPUT_PULLDOWN, 7) /* (R20) 1V8_EN */
    AM62X_IOPAD(0x0C4, PIN_OUTPUT_PULLDOWN, 7) /* (R19) 3V3_EN */
    AM62X_IOPAD(0x0AC, PIN_OUTPUT_PULLDOWN, 7) /* (H17) WIFI_WAKEUP */
     it  does  not work.

    So, setting gpio from u-boot device tree did work for you? correct?

    I have seen that it is not working for me as well even after enabling the gpio hog configuration in u-boot. I have tried to write the MMR registers as  has mentioned as shown below but that didn't work for me. I have used PADCONFIG register of GPIO and still not able to change the gpio state. 

    diff --git a/board/ti/am62ax/evm.c b/board/ti/am62ax/evm.c
    index 71fbc9e9c2b..4cfbb4f8b2c 100644
    --- a/board/ti/am62ax/evm.c
    +++ b/board/ti/am62ax/evm.c
    @@ -21,11 +21,37 @@
     #define CTRLMMR_USB1_PHY_CTRL  0x43004018
     #define CORE_VOLTAGE           0x80000000
    
    +#define GPIO_DIR01             0x04201010
    +#define GPIO_OUT_DATA01        0x04201014
    +#define GPIO_CLR_DATA01        0x0420101C
    +#define MCU_PADCONFIG20        0x04084050
    +#define GPIO_20_LOW            0x00001000
    +#define MCU_PADCONFIG20_val    0x00050007
    +
     int board_init(void)
     {
    +    u32 val;
    +
            if (IS_ENABLED(CONFIG_BOARD_HAS_32K_RTC_CRYSTAL))
                    board_rtc_init();
    +
    +    writel(0x00050007, MCU_PADCONFIG20);
    +
    +    /* clear mcu gpio20 */
    +    val = readl(GPIO_CLR_DATA01);
    +    val |= GPIO_20_LOW;
    +    writel(val, GPIO_CLR_DATA01);
    
    +    /* set mcu gpio20 direction as output  */
    +    val = readl(GPIO_DIR01);
    +    val &= ~(GPIO_20_LOW);
    +    writel(val, GPIO_DIR01);
    +
    +    /* set mcu gpio20 value to low */
    +    val = readl(GPIO_OUT_DATA01);
    +    val &= ~(GPIO_20_LOW);
    +    writel(val, GPIO_OUT_DATA01);
    +
            return 0;
     }

    We are using the MCU GPIO (E13) which is open drain pin and have to connect external pull-up on this pin in-order to make pin high and low. So, probably, we won't be able to use pull-down register.

    Is there any other way to make E13 pin (mcu gpio) low as soon as board boots up?

    How to modify the SPL or U-BOOT project to do this during AM6202 boot phase.

    I didn't understand the this statement. Can explain more?

    Regards,

    Jay

  • Hi Jay,

    Anshu is out of office until June 2nd. Please kindly ping this thread if you don't hear a response from him during the first week of June.

    -Daolin

  • Hi, 

    Any update on this thread?

    Regards,

    Jay

  • Hi Jay,

    I just got back so I'll need some time to catch up on threads. I'll try to respond later this week.

    Thanks,

    Anshu

  • Hi Anshu, 

    Thank you for preparing detailed the FAQ on how to control gpio form R5 SPL.

    we are using the AM62A7 processor. 

    I have checked the files "arch/arm/mach-k3/am62ax/clk-data.c" and "arch/arm/mach-k3/am62ax/dev-data.c" for AM62A7 processor's u-boot source.

    In the file "arch/arm/mach-k3/am62ax/clk-data.c", I can't see the mcu_gpio0 interface clock settings which should be "AM62AX_DEV_MCU_GPIO0 (ID = 79)". Could this be the reason that I am not able to control the mcu_gpio0?

    If I have to add this clocks for mcu_gpio0 interface in the file "arch/arm/mach-k3/am62ax/clk-data.c" in the bootloader, How can I add to control the mcu_gpio0 interface?

    Regards,

    Jay

  • Hi Anshu,

    Let us know if you have any update on this.

    Regards,

    Jay