From df8e6be59a1fbce3f8c6878fe7440a129b1245d6 Mon Sep 17 00:00:00 2001 From: Birger Koblitz Date: Sun, 13 Sep 2020 09:06:13 +0200 Subject: rtl838x: add new architecture This adds support for the RTL838x Architecture. SoCs of this type are used in managed and un-managed Switches and Routers with 8-28 ports. Drivers are provided for SoC initialization, GPIOs, Flash, Ethernet including a DSA switch driver and internal and external PHYs used with these switches. Supported SoCs: RTL8380M RTL8381M RTL8382M The kernel will also boot on the following RTL839x SoCs, however driver support apart from spi-nor is missing: RTL8390 RTL8391 RTL8393 The following PHYs are supported: RTL8214FC (Quad QSGMII multiplexing GMAC and SFP port) RTL8218B internal: internal PHY of the RTL838x chips RTL8318b external (QSGMII 8-port GMAC phy) RTL8382M SerDes for 2 SFP ports Initialization sequences for the PHYs are provided in the form of firmware files. Flash driver supports 3 / 4 byte access DSA switch driver supports VLANs, port isolation, STP and port mirroring. The ALLNET ALL-SG8208M is supported as Proof of Concept: RTL8382M SoC 1 MIPS 4KEc core @ 500MHz 8 Internal PHYs (RTL8218B) 128MB DRAM (Nanya NT5TU128MB) 16MB NOR Flash (MXIC 25L128) 8 GBEthernet ports with one green status LED each (SoC controlled) 1 Power LED (not configurable) 1 SYS LED (configurable) 1 On-Off switch (not configurable) 1 Reset button at the right behind right air-vent (not configurable) 1 Reset button on front panel (configurable) 12V 1A barrel connector 1 serial header with populated standard pin connector and with markings GND TX RX Vcc(3.3V), connection properties: 115200 8N1 To install, upload the sysupgrade image to the OEM webpage. Signed-off-by: Birger Koblitz --- .../linux/rtl838x/base-files/etc/board.d/01_leds | 15 ++++ .../rtl838x/base-files/etc/board.d/02_network | 87 +++++++++++++++++++++ target/linux/rtl838x/base-files/etc/inittab | 3 + .../lib/firmware/rtl838x_phy/rtl838x_8214fc.fw | Bin 0 -> 1676 bytes .../lib/firmware/rtl838x_phy/rtl838x_8218b.fw | Bin 0 -> 1168 bytes .../lib/firmware/rtl838x_phy/rtl838x_8380.fw | Bin 0 -> 1184 bytes .../rtl838x/base-files/lib/upgrade/platform.sh | 19 +++++ 7 files changed, 124 insertions(+) create mode 100755 target/linux/rtl838x/base-files/etc/board.d/01_leds create mode 100755 target/linux/rtl838x/base-files/etc/board.d/02_network create mode 100644 target/linux/rtl838x/base-files/etc/inittab create mode 100644 target/linux/rtl838x/base-files/lib/firmware/rtl838x_phy/rtl838x_8214fc.fw create mode 100644 target/linux/rtl838x/base-files/lib/firmware/rtl838x_phy/rtl838x_8218b.fw create mode 100644 target/linux/rtl838x/base-files/lib/firmware/rtl838x_phy/rtl838x_8380.fw create mode 100644 target/linux/rtl838x/base-files/lib/upgrade/platform.sh (limited to 'target/linux/rtl838x/base-files') diff --git a/target/linux/rtl838x/base-files/etc/board.d/01_leds b/target/linux/rtl838x/base-files/etc/board.d/01_leds new file mode 100755 index 0000000000..7991b832f6 --- /dev/null +++ b/target/linux/rtl838x/base-files/etc/board.d/01_leds @@ -0,0 +1,15 @@ +#!/bin/sh + +. /lib/functions/uci-defaults.sh + +board=$(board_name) +boardname="${board##*,}" + +board_config_update + +case $board in +esac + +board_config_flush + +exit 0 diff --git a/target/linux/rtl838x/base-files/etc/board.d/02_network b/target/linux/rtl838x/base-files/etc/board.d/02_network new file mode 100755 index 0000000000..a79869d8c3 --- /dev/null +++ b/target/linux/rtl838x/base-files/etc/board.d/02_network @@ -0,0 +1,87 @@ +#!/bin/sh + +. /lib/functions.sh +. /lib/functions/uci-defaults.sh +. /lib/functions/system.sh + +rtl838x_setup_switch() +{ + local switchid net portid master device lan_role lan_list + + json_select_object switch + # Find slave ports + for net in $(ls -d /sys/class/net/*); do + switchid=$(cat $net/phys_switch_id 2>/dev/null) + [ -z "$switchid" ] && continue + device=$(basename $net) + portid=$(cat $net/phys_port_name) + lan_role="$lan_role ${portid##p}" + lan_list="$lan_list $device" + json_select_object "switch$((switchid))" + json_add_boolean enable 1 + json_add_boolean reset 0 + json_add_boolean dsa 1 + json_select_array ports + json_add_object + json_add_int num "${portid##p}" + json_add_string role "lan" + json_add_string device "$device" + json_close_object + json_select .. + json_select .. + done + # Add switch master device + for net in $(ls -d /sys/class/net/*/dsa); do + master=$(dirname $net) + device=$(basename $master) + portid=$(cat $master/phys_port_name) + lan_role="$lan_role ${portid##p}" + json_select_object "switch$((switchid))" + json_select_array ports + json_add_object + json_add_int num "${portid##p}" + json_add_string device "$device" + json_add_boolean need_tag 0 + json_add_boolean want_untag 0 + json_add_boolean master 1 + json_close_object + json_select .. + json_select_array roles + json_add_object + json_add_string role "lan" + lan_role=$(echo $lan_role | xargs -n1 | sort -n | xargs) + json_add_string ports "$lan_role" + json_close_object + json_select .. + json_select .. + done + json_select .. + lan_list=$(echo $lan_list | xargs -n1 | sort -V | xargs) + ucidef_set_interface_lan "$lan_list" +} + +rtl838x_setup_macs() +{ + local board="$1" + local lan_mac + local wan_mac + local label_mac + + case $board in + allnet,all-sg8208m) + lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr) + label_mac=$lan_mac + esac + + [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac + [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac + [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac +} + +board_config_update +board=$(board_name) +rtl838x_setup_switch +rtl838x_setup_macs $board +board_config_flush + +exit 0 diff --git a/target/linux/rtl838x/base-files/etc/inittab b/target/linux/rtl838x/base-files/etc/inittab new file mode 100644 index 0000000000..9820e7144b --- /dev/null +++ b/target/linux/rtl838x/base-files/etc/inittab @@ -0,0 +1,3 @@ +::sysinit:/etc/init.d/rcS S boot +::shutdown:/etc/init.d/rcS K shutdown +::askconsole:/usr/libexec/login.sh diff --git a/target/linux/rtl838x/base-files/lib/firmware/rtl838x_phy/rtl838x_8214fc.fw b/target/linux/rtl838x/base-files/lib/firmware/rtl838x_phy/rtl838x_8214fc.fw new file mode 100644 index 0000000000..035c02d804 Binary files /dev/null and b/target/linux/rtl838x/base-files/lib/firmware/rtl838x_phy/rtl838x_8214fc.fw differ diff --git a/target/linux/rtl838x/base-files/lib/firmware/rtl838x_phy/rtl838x_8218b.fw b/target/linux/rtl838x/base-files/lib/firmware/rtl838x_phy/rtl838x_8218b.fw new file mode 100644 index 0000000000..a907849fb9 Binary files /dev/null and b/target/linux/rtl838x/base-files/lib/firmware/rtl838x_phy/rtl838x_8218b.fw differ diff --git a/target/linux/rtl838x/base-files/lib/firmware/rtl838x_phy/rtl838x_8380.fw b/target/linux/rtl838x/base-files/lib/firmware/rtl838x_phy/rtl838x_8380.fw new file mode 100644 index 0000000000..ef84c71753 Binary files /dev/null and b/target/linux/rtl838x/base-files/lib/firmware/rtl838x_phy/rtl838x_8380.fw differ diff --git a/target/linux/rtl838x/base-files/lib/upgrade/platform.sh b/target/linux/rtl838x/base-files/lib/upgrade/platform.sh new file mode 100644 index 0000000000..927aadbe31 --- /dev/null +++ b/target/linux/rtl838x/base-files/lib/upgrade/platform.sh @@ -0,0 +1,19 @@ +PART_NAME=firmware +REQUIRE_IMAGE_METADATA=1 + +RAMFS_COPY_BIN='fw_printenv fw_setenv' +RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' + +platform_check_image() { + return 0 +} + +platform_do_upgrade() { + local board=$(board_name) + + case "$board" in + *) + default_do_upgrade "$1" + ;; + esac +} -- cgit v1.2.3