Completed DT overlay to get 1000/100/10M ETH working on the PB2

The only thing you need to do to get ethernet working on the PB2 is simply add a device tree overlay, other than create a custom ethernet cape obviously. The speedtest only shows 100M because our current RJ45 jack is only a 100M part, but would work at 1000M if I changed that part.

//Adds ethernet capabilities to the PB2 using RGMII2 and MDIO0
/dts-v1/;
/plugin/;

#include <dt-bindings/leds/common.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include "ti/k3-pinctrl.h"

/*
 * Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
*/
&{/chosen} {
        overlays {
                k3-am62-pocketbeagle2-eth-rgmii2.kernel = __TIMESTAMP__;
        };
};

&main_pmx0 {
        mdio0_pins_default: mdio0-default-pins {
                pinctrl-single,pins = <
                        AM62X_IOPAD(0x0160, PIN_OUTPUT, 0) /* (AD24) MDIO0_MDC */
                        AM62X_IOPAD(0x015c, PIN_INPUT, 0) /* (AB22) MDIO0_MDIO */
                >;
        };
        rgmii2_pins_default: rgmii1-default-pins {
                pinctrl-single,pins = <
                        AM62X_IOPAD(0x0184, PIN_INPUT, 0) /* (AE27) RGMII2_RD0 */
                        AM62X_IOPAD(0x0188, PIN_INPUT, 0) /* (AB20) RGMII2_RD1 */
                        AM62X_IOPAD(0x018c, PIN_INPUT, 0) /* (AC21) RGMII2_RD2 */
                        AM62X_IOPAD(0x0190, PIN_INPUT, 0) /* (AE22) RGMII2_RD3 */
                        AM62X_IOPAD(0x0180, PIN_INPUT, 0) /* (AD23) RGMII2_RXC */
                        AM62X_IOPAD(0x017C, PIN_INPUT, 0) /* (AD22) RGMII2_RX_CTL */
                        AM62X_IOPAD(0x016c, PIN_OUTPUT, 0) /* (Y18) RGMII2_TD0 */
                        AM62X_IOPAD(0x0170, PIN_OUTPUT, 0) /* (AA18) RGMII2_TD1 */
                        AM62X_IOPAD(0x0174, PIN_OUTPUT, 0) /* (AD21) RGMII2_TD2 */
                        AM62X_IOPAD(0x0178, PIN_OUTPUT, 0) /* (AC20) RGMII2_TD3 */
                        AM62X_IOPAD(0x0168, PIN_OUTPUT, 0) /* (AE21) RGMII2_TXC */
                        AM62X_IOPAD(0x0164, PIN_OUTPUT, 0) /* (AA19) RGMII2_TX_CTL */
                >;
        };
};

&ecap2 {
        status = "disabled";
};

&cpsw3g {
        pinctrl-names = "default";
        pinctrl-0 = <&rgmii2_pins_default>;
        status = "okay";
};

&cpsw_port2 {
        phy-mode = "rgmii-id";
        phy-handle = <&cpsw3g_phy1>;
        status = "okay";
};


&cpsw3g_mdio {
        #address-cells = <1>;
        #size-cells = <0>;
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&mdio0_pins_default>;

        cpsw3g_phy1: ethernet-phy@3 {
                #address-cells = <1>;
                #size-cells = <0>;
                reg = <3>;//KSZ9131RNXI Address
        };
};
$sudo dmesg | grep -i -E "mdio|cpsw|phy|eth"
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] arch_timer: cp15 timer running at 200.00MHz (phys).
[    2.999714] am65-cpsw-nuss 8000000.ethernet: initializing am65 cpsw nuss version 0x6BA01103, cpsw version 0x6BA81103 Ports: 3 quirks:00000002
[    3.000140] am65-cpsw-nuss 8000000.ethernet: Use random MAC address
[    3.001699] davinci_mdio 8000f00.mdio: Configuring MDIO in manual mode
[    3.038567] davinci_mdio 8000f00.mdio: davinci mdio revision 9.7, bus freq 1000000
[    3.041705] davinci_mdio 8000f00.mdio: phy[3]: device 8000f00.mdio:03, driver Microchip KSZ9131 Gigabit PHY
[    3.042013] am65-cpsw-nuss 8000000.ethernet: initialized cpsw ale version 1.5
[    3.042023] am65-cpsw-nuss 8000000.ethernet: ALE Table size 512, Policers 32
[    3.043828] am65-cpsw-nuss 8000000.ethernet: CPTS ver 0x4e8a010c, freq:500000000, add_val:1 pps:0
[    3.103593] am65-cpsw-nuss 8000000.ethernet: set new flow-id-base 19
[   13.271900] optee: probing for conduit method.
[   13.726872] am65-cpsw-nuss 8000000.ethernet eth0: PHY [8000f00.mdio:03] driver [Microchip KSZ9131 Gigabit PHY] (irq=POLL)
[   13.727351] am65-cpsw-nuss 8000000.ethernet eth0: configuring for phy/rgmii-rxid link mode
[   27.043960] am65-cpsw-nuss 8000000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx

$ip -s link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether REMOVED brd ff:ff:ff:ff:ff:ff
    RX:  bytes packets errors dropped  missed   mcast
    1226995510 1184589      0       0       0       0
    TX:  bytes packets errors dropped carrier collsns
    1133327122 1162848      0       0       0       0
    altname enxREMOVED

$ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.202  netmask 255.255.254.0  broadcast 192.168.3.255
        inet6 fe80::b82d:48ff:fec1:6f54  prefixlen 64  scopeid 0x20<link>
        ether REMOVED  txqueuelen 1000  (Ethernet)
        RX packets 1184590  bytes 1226995570 (1.1 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1162850  bytes 1133327782 (1.0 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

$speedtest
   Speedtest by Ookla
Idle Latency:     3.43 ms   (jitter: 0.77ms, low: 2.53ms, high: 4.04ms)
    Download:    94.21 Mbps (data used: 42.5 MB)
                 16.02 ms   (jitter: 0.85ms, low: 9.34ms, high: 22.96ms)
      Upload:    92.61 Mbps (data used: 41.8 MB)
                  8.26 ms   (jitter: 1.22ms, low: 5.69ms, high: 10.31ms)
 Packet Loss:     0.0%
1 Like