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.

TDA4VM: [TDA4] toggle gpio reset to ethernet phy when u-boot boot

Part Number: TDA4VM

Hi, Expert 

I need to toggle a gpio pin to an ethernet phy chip reset when u-boot boots.

this reset pin is low active, and I hope this toggle pin keep low about 2 sec after power on.

Thanks E2E give me some information, but these do not work for me

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/937659/am4378-ethernet-initialization

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1114738/processor-sdk-am335x-am335x-using-two-gpio-to-reset-two-different-ethernet-phy/4132350?tisearch=e2e-quicksearch&keymatch=reset-gpios#4132350

https://patchwork.kernel.org/project/linux-omap/patch/daa29a99-0a17-d316-57eb-3e6162938d8d@ti.com/

The toggle pin is GPIO0_30 (AF21)

so I try to modify device tree in u-boot

I set gpio0_30 reset active low after power on

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
&davinci_mdio {
status = "okay";
reset-gpios = <&main_gpio0 30 GPIO_ACTIVE_LOW>;
reset-delay-us = <2000000>;
initially-in-reset = <1>;
phy0: ethernet-phy@0 {
reg = <0>;
max-speed = <100>;
};
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
main_gpio0: gpio@600000 {
compatible = "ti,j721e-gpio", "ti,keystone-gpio";
reg = <0x0 0x00600000 0x0 0x100>;
gpio-controller;
#gpio-cells = <2>;
interrupt-parent = <&main_gpio_intr>;
interrupts = <256>, <257>, <258>, <259>,
<260>, <261>, <262>, <263>;
interrupt-controller;
#interrupt-cells = <2>;
ti,ngpio = <128>;
ti,davinci-gpio-unbanked = <0>;
power-domains = <&k3_pds 105 TI_SCI_PD_EXCLUSIVE>;
clocks = <&k3_clks 105 0>;
clock-names = "gpio";
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Do I miss something?

I think it should be work ....

Thanks very much

Gibbs

  • Hi Gibbs,

    I believe the E2E that you are referring davinci_mdio node is from the kernel & not U-Boot.

    The U-boot code for mdio is under: drivers/net/ti/cpsw_mdio.c & this does not have any code to handle or parse the reset-gpios properties that you have added:

    reset-gpios = <&main_gpio0 30 GPIO_ACTIVE_LOW>;
    reset-delay-us = <2000000>;

    So you see no difference even after adding that.

    Recommend you to go through:

    drivers/net/sun8i_emac.c & parse the properties & make use of them to set gpio as per need.

    Closing this.

    - Keerthy

  • Thanks Keerthy.

    ok ~ let's me check one thing again!

    because I real find device tree configure in u-boot source code, the path as below :

    ti-processor-sdk-linux-j7-evm-08_02_00_03\board-support\u-boot-2021.01+gitAUTOINC+44a87e3ab8-g44a87e3ab8\arch\arm\dts\ k3-j721e-common-proc-board.dts

    ti-processor-sdk-linux-j7-evm-08_02_00_03\board-support\u-boot-2021.01+gitAUTOINC+44a87e3ab8-g44a87e3ab8\arch\arm\dts\ k3-j721e.dtsi

    ...etc

    I modify some device tree properties about eMMC in u-boot source, and it works.

    Do you mean these device tree code is useless?

    I feel a little bit confuse, and I need to double check your meaning again.

    Thanks very much

    Gibbs

  • I modify some device tree properties about eMMC in u-boot source, and it works.

    Can you share that DT code? I see this when i search for reset-gpio under drivers:

    drivers/i2c/acpi_i2c.c:                 acpi_dp_add_gpio(dsd, "reset-gpios", path,
    drivers/i2c/acpi_i2c.c: gpio_request_by_name(dev, "reset-gpios", 0, &priv->reset_gpio,
    drivers/i2c/muxes/pca954x.c:            err = gpio_request_by_name(dev, "reset-gpios", 0,
    drivers/misc/ihs_fpga.c:        ret = gpio_request_by_name(dev, "reset-gpios", 0, &priv->reset_gpio,
    drivers/mmc/meson_gx_mmc.c:     ret = gpio_request_by_name(dev, "reset-gpios", 0, &reset, GPIOD_IS_OUT);
    drivers/mmc/rockchip_dw_mmc.c:  ret = gpio_request_by_name(dev, "reset-gpios", 0, &reset, GPIOD_IS_OUT);
    drivers/net/dwc_eth_qos.c:      ret = gpio_request_by_name(dev, "phy-reset-gpios", 0,
    drivers/net/dwc_eth_qos.c:              /* search "reset-gpios" in phy node */
    drivers/net/dwc_eth_qos.c:                                               "reset-gpios", 0,
    drivers/net/fec_mxc.c:  ret = gpio_request_by_name(dev, "phy-reset-gpios", 0,
    drivers/net/mtk_eth.c:                  gpio_request_by_name(dev, "reset-gpios", 0,
    drivers/net/mvneta.c:   gpio_request_by_name(dev, "phy-reset-gpios", 0,
    drivers/net/mvpp2.c:    gpio_request_by_name(dev, "phy-reset-gpios", 0,
    drivers/net/pic32_eth.c:        gpio_request_by_name_nodev(dev_ofnode(dev), "reset-gpios", 0,
    drivers/net/ravb.c:             gpio_request_by_name_nodev(phandle_args.node, "reset-gpios", 0,
    drivers/net/ravb.c:             gpio_request_by_name(dev, "reset-gpios", 0, &eth->reset_gpio,
    drivers/net/sh_eth.c:           gpio_request_by_name_nodev(phandle_args.node, "reset-gpios", 0,
    drivers/net/sh_eth.c:           gpio_request_by_name(udev, "reset-gpios", 0, &priv->reset_gpio,
    drivers/pci/pci-aardvark.c:     gpio_request_by_name(dev, "reset-gpios", 0, &pcie->reset_gpio,
    drivers/sysinfo/gazerbeam.c:    gpio_num = gpio_request_list_by_name(dev, "reset-gpios",
    drivers/sysinfo/gazerbeam.c:            debug("%s: Error getting GPIO list 'reset-gpios' (err = %d)\n",
    drivers/video/bridge/video-bridge-uclass.c:     ret = gpio_request_by_name(dev, "reset-gpios", 0, &uc_priv->reset,
    drivers/video/bridge/video-bridge-uclass.c:             debug("%s: Could not decode reset-gpios (%d)\n", __func__, ret);
    drivers/video/orisetech_otm8009a.c:     ret = gpio_request_by_name(dev, "reset-gpios", 0, &priv->reset,
    drivers/video/raydium-rm68200.c:        ret = gpio_request_by_name(dev, "reset-gpios", 0, &priv->reset,

    Typically the above drivers parse the reset-gpios property & toggle them as per need.
    Can you confirm on your side when you say eMMC works? What is the DT diff & changes you did?

    - Keerthy

  • HI, Keerthy

    I'm not sure gpio toggle works in device tree, because I am finding the answer.

    about gpio toggle, modiify device tree is not the only solutions, modify source code is also fine.

    I may try to find the way.

    For example,  my experence in u-boot *.dts, information sharing with you:

    Our customer board only support low speed SD boot, 

    SD boot divide two stage, u-boot boot and Linux boot.

    SD u-boot boot base on low speed 3.3V, and linux boot base on high speed 1.8v

    so you need to disable 1.8v , and keep low speed boot

    changes as below.

    SD card linux boot with "low speed" , 3.3v driven, 

    It's work, so it should be some function works in u-boot device tree.

    Gibbs

  • Hi Gibbs,

    drivers/video/raydium-rm68200.c

    In U-boot file. function: rm68200_panel_ofdata_to_platdata

            ret = gpio_request_by_name(dev, "reset-gpios", 0, &priv->reset,
                                       GPIOD_IS_OUT);
            if (ret) {
                    dev_err(dev, "Warning: cannot get reset GPIO\n");
                    if (ret != -ENOENT)
                            return ret;
            }

    Add some code like above in the driver where you want to control gpio.
    You get the gpio handle in priv->reset

    Then you can use something like below:

            /* reset panel */
            dm_gpio_set_value(&priv->reset, true);
            mdelay(1);
            dm_gpio_set_value(&priv->reset, false);
            mdelay(10);

    to toggle.

    You also need to make sure that pinmux is set properly for GPIO output mode like below example.

            sw10_button_pins_default: sw10-button-pins-default {
                    pinctrl-single,pins = <
                            J721E_IOPAD(0x0, PIN_INPUT, 7) /* (AC18) EXTINTn.GPIO0_0 */
                    >;
            };

    in the file: arch/arm/dts/k3-j721e-common-proc-board.dts

    - Keerthy

  • Hi, Keerthy

    Thanks

    I also found this thread which you replied for someone 4 month ago,

    it should be useful

    additional information here:

    e2e.ti.com/.../tda4vm-q1-how-to-control-gpio-on-tda4-uboot