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.

Linux/AM4376: PRU Ethernet fails with single MAC

Part Number: AM4376

Tool/software: Linux

Hello,

We have a custom hardware design that utilizes the AM4376 processor. We have two Ethernet ports, one that goes to the RMII interface on CPSW and the other that goes to PRUETH1 MII interface. We are unable to get the PRUETH1 interface to work with using the TI processor SDK Linux kernel. The kernel version that we are using is from:

Repo: git.ti.com/.../processor-sdk-linux.git
Version: e29b786ec0983504ed240b333243314fec44d6ef
Branch: processor-sdk-linux-04.03.00

From reading the device tree bindings for the PRUETH driver, it appears that both ethernet-mii0 and ethernet-mii1 are required for this version of the driver. However, our hardware design only uses ethernet-mii1. The console output from the prueth driver shows up twice with appears to mean that the PRUETH driver is deferring initialization because ethernet-mii0 isn't valid. Here is the console output:

[    2.983417] prueth pruss1_eth: pruss MC Mask 0:0:0:0:0:0
[    2.989119] prueth pruss1_eth: could not get ptp tx irq
[    2.994405] prueth pruss1_eth: port 1: using random MAC addr: d6:fa:03:b7:03:cd
[    3.003401] ALSA device list:
[    3.006459]   No soundcards found.
[    3.012618] Freeing unused kernel memory: 1024K
[    3.461984] net eth0: initializing cpsw version 1.15 (0)
[    3.467394] cpsw 4a100000.ethernet: initialized cpsw ale version 1.4
[    3.474219] cpsw 4a100000.ethernet: ALE Table size 1024
[    3.480947] Generic PHY fixed-0:00: attached PHY driver [Generic PHY] (mii_bus:phy_addr=fixed-0:00, irq=-1)
[    3.491718] prueth pruss1_eth: pruss MC Mask 0:0:0:0:0:0
[    3.491897] prueth pruss1_eth: could not get ptp tx irq
[    3.491921] prueth pruss1_eth: port 1: using random MAC addr: 4a:3e:9b:42:57:70

What is required in the device tree bindings for the PRUETH single MAC mode to work correctly? We have used the ti2018.00 tag from git.ti.com/.../ti-linux-kernel.git and were able to get it work correctly.

Here are our PRUETH device tree bindings for the processor-sdk-linux:

pruss1_eth {
        compatible = "ti,am4376-prueth";
        pruss = <&pruss1>;
        firmware-name = "",
                        "ti-pruss/am437x-pru1-prueth-fw.elf";
        sram = <&ocmcram>;
        interrupt-parent = <&pruss1_intc>;

        pinctrl-0 = <&pr1_mii1_pins>;
        pinctrl-names = "default";

        pruss1_emac1: ethernet-mii1 {
                phy-handle = <&pruss1_eth1_phy>;
                phy-mode = "mii";
                interrupts = <21>, <23>;
                interrupt-names = "rx", "tx";
                /* Filled in by bootloader */
                local-mac-address = [00 00 00 00 00 00];
        };
/* NOT USED */
        pruss1_emac0: ethernet-mii0 {
                phy-handle = <&pruss1_eth0_phy>;
                phy-mode = "mii";
                interrupts = <20>, <22>;
                interrupt-names = "rx", "tx";
                /* Filled in by bootloader */
                local-mac-address = [00 00 00 00 00 00];
        };
    };
/* snip */
	    pr1_mii1_pins: pr1_mii1_pins {
        pinctrl-single,pins = <
            0x58  ( PIN_INPUT  | MUX_MODE5 ) /* (E8) gpmc_a6.pr1_mii_mt1_clk */
            0x54  ( PIN_OUTPUT | MUX_MODE5 ) /* (E7) gpmc_a5.pr1_mii1_txd0 */
            0x50  ( PIN_OUTPUT | MUX_MODE5 ) /* (D7) gpmc_a4.pr1_mii1_txd1 */
            0x4c  ( PIN_OUTPUT | MUX_MODE5 ) /* (A4) gpmc_a3.pr1_mii1_txd2 */
            0x48  ( PIN_OUTPUT | MUX_MODE5 ) /* (C6) gpmc_a2.pr1_mii1_txd3 */
            0x6c  ( PIN_INPUT  | MUX_MODE5 ) /* (D8) gpmc_a11.pr1_mii1_rxd0 */
            0x68  ( PIN_INPUT  | MUX_MODE5 ) /* (G8) gpmc_a10.pr1_mii1_rxd1 */
            0x64  ( PIN_INPUT  | MUX_MODE5 ) /* (B4) gpmc_a9.pr1_mii1_rxd2 */
            0x60  ( PIN_INPUT  | MUX_MODE5 ) /* (F7) gpmc_a8.pr1_mii1_rxd3 */
            0x40  ( PIN_OUTPUT | MUX_MODE5 ) /* (C3) gpmc_a0.pr1_mii1_txen */
            0x5c  ( PIN_INPUT  | MUX_MODE5 ) /* (F6) gpmc_a7.pr1_mii_mr1_clk */
            0x44  ( PIN_INPUT  | MUX_MODE5 ) /* (C5) gpmc_a1.pr1_mii1_rxdv */
            0x74  ( PIN_INPUT  | MUX_MODE5 ) /* (B3) gpmc_wpn.pr1_mii1_rxer */
            0x24c ( PIN_INPUT  | MUX_MODE5 ) /* (E24) gpio5_13.pr1_mii1_rxlink */
            0x244 ( PIN_INPUT  | MUX_MODE5 ) /* (F23) gpio5_11.pr1_mii1_crs */
            0x23c ( PIN_INPUT  | MUX_MODE5 ) /* (F24) gpio5_9.pr1_mii1_col */
        >;
    };

    pr1_mdio_pins: pr1_mdio_pins {
        pinctrl-single,pins = <
            0x14c ( PIN_OUTPUT        | MUX_MODE8 ) /* (B17) mdio_clk.pr1_mdio_mdclk */
            0x148 ( PIN_INPUT         | MUX_MODE8 ) /* (A17) mdio_data.pr1_mdio_data */
            0x1ac ( PIN_OUTPUT_PULLUP | MUX_MODE7 ) /* (L24) mcasp0_ahclkx.gpio3[21] */
        >;
    };
/* snip */
&pruss_soc_bus {
    status = "okay";

    pruss1: pruss@54400000 {
        status = "okay";

        pru1_0: pru@54434000 {
            status = "okay";
        };
        pru1_1: pru@54438000 {
            status = "okay";
        };
    };
};

&pruss1_mdio {
    pinctrl-0 = <&pr1_mdio_pins>;
    pinctrl-names = "default";
    status = "okay";

    reset-gpios = <&gpio3 21 GPIO_ACTIVE_LOW>;
    reset-delay-us = <500>;   /* PHY datasheet states 500us min */

    pruss1_eth1_phy: ethernet-phy@1 {
        reg = <0>;
    };

/* DOESN"T EXIST */
    pruss1_eth0_phy: ethernet-phy@0 {
        reg = <1>;
    };
};

  • Hello Ryan,

    Could you expand on what you meant by "We have used the ti2018.00 tag from git.ti.com/.../ti-linux-kernel.git and were able to get it work correctly"?

    Regards,
    Nick
  • Hello Nick,

    Initially we were using the ti-linux-kernel.git repository at ti2018.00 tag. With this version of the kernel, you are able to able to specify PRUETH driver to work in single EMAC mode. We followed the instructions for device tree bind for the PRUETH driver which can be found here: git.ti.com/.../

    The PRUETH1 port was able to work and we were able to send and receive traffic. However, it appeared the driver was unreliable as we were experiencing a lot of rx_over_errors with the driver in the ti2018.00 tag. We discovered that we needed to use the PRUETH driver from the Processor SDK is much more reliable (from testing on the AM437x IDK) as it contains many fixes. We are now experiencing issues with configuring the PRUETH driver in the device tree with a single EMAC mode.

    Thanks,
    -Ryan

  • Hello Ryan,

    Sorry for the delay. ti2018.00 (kernel 4.14) is associated with Processor SDK 5.0, which has not been released yet. I cannot find device tree bindings information from SDK4.3 or earlier talking about enabling single EMAC mode, so it is possible that is functionality that was added to the Linux driver between 4.9 and 4.14.

    Is this something that can be delayed until SDK 5.0 comes out in July?

    Regards,
    Nick
  • Hello Ryan,

    I am marking this resolved, but please reply if there are additional questions.

    Regards,
    Nick
  • Hello Nick,

    Sorry for the delay in response but I was able to get our single PRUETH interface (PRUETH1) working. I accomplished this by adding support for fixed phys to prueth driver in the Processor Linux SDK v4.03. I created a fixed phy on the interface that we were not using (PRUETH0) and the driver was able to initialize properly. Here is the modification to the device tree to support the fixed phy:

    pruss1_emac0: ethernet-mii0 {
        status = "disabled";
        interrupts = <20>, <22>;
        interrupt-names = "rx", "tx";
        /* Filled in by bootloader */
        local-mac-address = [00 00 00 00 00 00];
        phy-mode = "mii";
        fixed-link {
              speed = <100>;
              full-duplex;
        };
    };

    Here is the patch to the 'prueth' driver to add fixed link support:

    From 6da12ee180ef2c69569e98012690a858fee0cff6 Mon Sep 17 00:00:00 2001
    From: Ryan Barnett <ryan.barnett@rockwellcollins.com>
    Date: Thu, 14 Jun 2018 15:14:50 -0500
    Subject: [PATCH 1/1] ti/prueth: add support for fixed-link in prueth driver
    
    Add support for specifying "fixed-link" for the prueth driver. This
    allows the prueth to not be connected to a PHY.
    
    Signed-off-by: Ryan Barnett <ryan.barnett@rockwellcollins.com>
    ---
     drivers/net/ethernet/ti/prueth.c | 13 ++++++++++++-
     1 file changed, 12 insertions(+), 1 deletion(-)
    
    diff --git a/drivers/net/ethernet/ti/prueth.c b/drivers/net/ethernet/ti/prueth.c
    index 23d98f5..dfa28cc 100644
    --- a/drivers/net/ethernet/ti/prueth.c
    +++ b/drivers/net/ethernet/ti/prueth.c
    @@ -3778,7 +3778,18 @@ static int prueth_netdev_init(struct prueth *prueth,
     	ether_addr_copy(emac->mac_addr, ndev->dev_addr);
     
     	emac->phy_node = of_parse_phandle(eth_node, "phy-handle", 0);
    -	if (!emac->phy_node) {
    +	if (of_phy_is_fixed_link(eth_node)) {
    +		/* In the case of a fixed PHY, the DT node associated
    +		 * to the PHY is the Ethernet MAC DT node.
    +		 */
    +		ret = of_phy_register_fixed_link(eth_node);
    +		if (ret) {
    +			if (ret != -EPROBE_DEFER)
    +				dev_err(prueth->dev, "failed to register fixed-link phy: %d\n", ret);
    +			return ret;
    +		}
    +		emac->phy_node = of_node_get(eth_node);
    +	} else if (!emac->phy_node) {
     		dev_err(prueth->dev, "couldn't find phy-handle\n");
     		ret = -ENODEV;
     		goto free;
    -- 
    1.9.1
    
    

    Thanks,
    -Ryan

  • Hello Ryan,

    Thank you for getting back to us with your solution! Please feel free to reply here with follow-up questions or create a new post for any different questions in the future.

    Regards,
    Nick
  • FYI, follow-up from the software team:

    "The customer is tricking the driver to use a dummy PHY. They will still see 2 PRU Etherenet interfaces (ifconfig -a) and both PRUs will be running.

     What we really want is to be able to specify only one port in the DT and driver should be happy with it. It should create only one networking interface and use only 1 PRU. We call this single EMAC mode.

     The support for single EMAC mode went into TI's Linux kernel v4.14.

     I have attached patches for kernel v4.9. After applying this series the customer's board should work without requiring to populate ethernet-mii0 child node."

    Regards, 

    Nick

    ti4.9-prueth-single-emac-v4.tar.gz

  • Additional follow-up: The support for single EMAC mode went into TI's Linux and RT Linux Processor SDK 5.3 release. Single EMAC mode is not available in Linux SDK 5.0 through SDK 5.2.

    Regards,
    Nick