Skip to content

Commit

Permalink
linux: devicetree: Add support for basic Ethernet switching with DSA
Browse files Browse the repository at this point in the history
  • Loading branch information
CFSworks authored and svenrademakers committed Jul 23, 2024
1 parent 5e1c41c commit 2664384
Show file tree
Hide file tree
Showing 9 changed files with 1,834 additions and 11 deletions.
8 changes: 0 additions & 8 deletions tp2bmc/board/tp2bmc/boot.scr
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ load ${devtype} ${devnum}:${distro_bootpart} ${loadaddr} /boot/turing-pi2.itb
# read hardware version from EEPROM
tpi_info hw_version tpi_hw_version

# Our build of Linux doesn't yet know how to manage the switch, so:
if test "${tpi_hw_version}" = "v2.4.0"; then
env set ethsw_reset_pin PG13
else
env set ethsw_reset_pin PG3
fi
run ethsw_do_reset

setenv fit_boot_args "${loadaddr}#config-${tpi_hw_version:-v2.4.0}"
if env exists boot_unlocked; then
echo "disabling write protection.."
Expand Down
8 changes: 6 additions & 2 deletions tp2bmc/board/tp2bmc/linux_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ CONFIG_IP_MULTIPLE_TABLES=y
CONFIG_INET_IPCOMP=y
CONFIG_INET_UDP_DIAG=y
CONFIG_IPV6_TUNNEL=y
CONFIG_BRIDGE=y
CONFIG_NET_DSA=y
CONFIG_NET_DSA_TAG_RTL4_A=y
CONFIG_NETLINK_DIAG=y
CONFIG_UEVENT_HELPER=y
CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
Expand All @@ -66,6 +69,9 @@ CONFIG_EEPROM_AT24=y
CONFIG_SCSI=y
CONFIG_BLK_DEV_SD=y
CONFIG_NETDEVICES=y
CONFIG_NET_DSA_REALTEK=y
# CONFIG_NET_DSA_REALTEK_MDIO is not set
CONFIG_NET_DSA_REALTEK_RTL8365MB=y
# CONFIG_NET_VENDOR_ALACRITECH is not set
# CONFIG_NET_VENDOR_ALLWINNER is not set
# CONFIG_NET_VENDOR_AMAZON is not set
Expand Down Expand Up @@ -114,7 +120,6 @@ CONFIG_STMMAC_ETH=y
# CONFIG_NET_VENDOR_WANGXUN is not set
# CONFIG_NET_VENDOR_WIZNET is not set
# CONFIG_NET_VENDOR_XILINX is not set
CONFIG_REALTEK_PHY=y
# CONFIG_USB_NET_DRIVERS is not set
# CONFIG_WLAN is not set
CONFIG_INPUT_EVDEV=y
Expand All @@ -128,7 +133,6 @@ CONFIG_SERIAL_8250_NR_UARTS=8
CONFIG_SERIAL_8250_DW=y
CONFIG_I2C=y
CONFIG_I2C_CHARDEV=y
CONFIG_I2C_GPIO=y
CONFIG_I2C_MV64XXX=y
CONFIG_SPI=y
CONFIG_SPI_SUN6I=y
Expand Down
15 changes: 15 additions & 0 deletions tp2bmc/board/tp2bmc/overlay/etc/init.d/S00dsa
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

# Kind of a hack, don't know where else to put this
# Rename `eth0` to `dsa` on boot, so that it is not confused for a usable
# Ethernet interface

case "$1" in
start|"")
exec ip link set eth0 name dsa
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac
11 changes: 11 additions & 0 deletions tp2bmc/board/tp2bmc/overlay/etc/network/interfaces
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# interface file auto-generated by buildroot

auto lo
iface lo inet loopback

auto br0
iface br0 inet dhcp
bridge-ports node1 node2 node3 node4 ge0 ge1
pre-up /etc/network/nfs_check
wait-delay 15
hostname $(hostname)
4 changes: 4 additions & 0 deletions tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.4.dts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@
};
};

&ethernet_switch {
reset-gpios = <&pio 6 13 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
};

&i2c2 {
/*
* The TP2 board design includes a 4-pin fan header (J16) and
Expand Down
4 changes: 4 additions & 0 deletions tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@
};
};

&ethernet_switch {
reset-gpios = <&pio 6 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
};

#ifndef IS_UBOOT
&i2c0 {
status = "okay";
Expand Down
82 changes: 82 additions & 0 deletions tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,88 @@

pagesize = <16>;
};

ethernet_switch: ethernet-switch@5c {
compatible = "realtek,rtl8365mb";
reg = <0x5c>;

ethernet-ports {
#address-cells = <1>;
#size-cells = <0>;

ethernet-port@0 {
reg = <0>;
label = "node1";
phy-handle = <&ethphy0>;
phy-mode = "internal";
};
ethernet-port@1 {
reg = <1>;
label = "node2";
phy-handle = <&ethphy1>;
phy-mode = "internal";
};
ethernet-port@2 {
reg = <2>;
label = "node3";
phy-handle = <&ethphy2>;
phy-mode = "internal";
};
ethernet-port@3 {
reg = <3>;
label = "node4";
phy-handle = <&ethphy3>;
phy-mode = "internal";
};
ethernet-port@4 {
reg = <4>;
label = "cpu";
ethernet = <&emac>;
phy-handle = <&ethphy4>;
phy-mode = "internal";
};
ethernet-port@5 {
reg = <5>;
label = "ge0";
phy-handle = <&ethphy5>;
phy-mode = "internal";
};
ethernet-port@6 {
reg = <6>;
label = "ge1";
phy-handle = <&ethphy6>;
phy-mode = "internal";
};
};

mdio {
compatible = "realtek,smi-mdio";
#address-cells = <1>;
#size-cells = <0>;

ethphy0: ethernet-phy@0 {
reg = <0>;
};
ethphy1: ethernet-phy@1 {
reg = <1>;
};
ethphy2: ethernet-phy@2 {
reg = <2>;
};
ethphy3: ethernet-phy@3 {
reg = <3>;
};
ethphy4: ethernet-phy@4 {
reg = <4>;
};
ethphy5: ethernet-phy@5 {
reg = <5>;
};
ethphy6: ethernet-phy@6 {
reg = <6>;
};
};
};
};

&emac {
Expand Down
2 changes: 1 addition & 1 deletion tp2bmc/package/ifupdown-ng/ifupdown-ng.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
################################################################################

IFUPDOWN_NG_VERSION = 0.12.1
IFUPDOWN_NG_SITE = $(call github,ifupdown-ng,ifupdown-ng,$(IFUPDOWN_NG_VERSION))
IFUPDOWN_NG_SITE = $(call github,ifupdown-ng,ifupdown-ng,ifupdown-ng-$(IFUPDOWN_NG_VERSION))
IFUPDOWN_NG_LICENSE = GPL-2.0+
IFUPDOWN_NG_LICENSE_FILES = COPYING

Expand Down
Loading

0 comments on commit 2664384

Please sign in to comment.