difos/target/linux/realtek/base-files/etc/board.d/02_network
Jacob Potter 735efbfb7c realtek: rtl838x: add Netgear GS110TUP v1 support
The GS110TUP v1 is a managed switch similar to the GS110TPP v1, but with
port 10 as SFP instead of RJ-45 and a total budget of 240 watts. Ports
1-4 support 60-watt 802.3bt PoE and ports 5-8 support 30-watt 802.3at.

The flash layout of the two switches are identical, and the U-Boot
configurations are the same except for having a different magic number,
so installation can be done via the same U-Boot method.

The following command will be needed to enable the port LEDs as per
https://forum.openwrt.org/t/72510/51 :
    fw_setenv bootcmd "rtk network on; boota"

Additionally, port 9 (1000base-T from a separate QSGMII PHY) does not
function without this. Port 10 was not tested as no SFP module was
available.

Signed-off-by: Jacob Potter <jacob@j4cbo.com>
[rebase on merged flash layout]
Signed-off-by: Sander Vanheule <sander@svanheule.net>
2024-01-13 16:45:05 +01:00

115 lines
3 KiB
Text

. /lib/functions.sh
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh
ucidef_set_poe() {
json_select_object poe
json_add_string "budget" "$1"
json_select_array ports
for port in $2; do
if [ -n "$3" -a -n "$(expr "$3" : "\(.\+[[:space:]]\)\{0,1\}$port\([[:space:]].*\|\$\)")" ]; then
continue # skip ports passed via $3
fi
json_add_string "" "$port"
done
json_select ..
json_select ..
}
board=$(board_name)
board_config_update
lan_list=$(ls -1 -v -d /sys/class/net/lan* | xargs -n1 basename | xargs)
lan_list_rev=$(ls -1 -v -d -r /sys/class/net/lan* | xargs -n1 basename | xargs)
ucidef_set_bridge_device switch
ucidef_set_interface_lan "$lan_list"
lan_mac=""
lan_mac_start=""
lan_mac_end=""
label_mac=""
case $board in
hpe,1920-8g|\
hpe,1920-8g-poe-65w|\
hpe,1920-8g-poe-180w|\
hpe,1920-16g|\
hpe,1920-24g)
label_mac=$(mtd_get_mac_binary factory 0x68)
lan_mac=$label_mac
mac_count1=$(hexdump -v -n 4 -s 0x110 -e '4 "%d"' $(find_mtd_part factory) 2>/dev/null)
mac_count2=$(hexdump -v -n 4 -s 0x114 -e '4 "%d"' $(find_mtd_part factory) 2>/dev/null)
lan_mac_start=$(macaddr_add $lan_mac 2)
lan_mac_end=$(macaddr_add $lan_mac $((mac_count2-mac_count1)))
;;
tplink,sg2008p-v1|\
tplink,sg2210p-v3|\
tplink,sg2452p-v4|\
tplink,t1600g-28ts-v3)
label_mac=$(get_mac_label)
lan_mac="$label_mac"
;;
*)
lan_mac=$(mtd_get_mac_ascii u-boot-env2 mac_start)
lan_mac_end=$(mtd_get_mac_ascii u-boot-env2 mac_end)
label_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
[ -z "$lan_mac" ] && lan_mac=$label_mac
;;
esac
ucidef_set_interface_macaddr "lan" $lan_mac
ucidef_set_bridge_mac "$lan_mac"
ucidef_set_network_device_mac eth0 $lan_mac
[ -z "$lan_mac_start" ] && lan_mac_start=$lan_mac
for lan in $lan_list; do
ucidef_set_network_device_mac $lan $lan_mac_start
[ -z "$lan_mac_end" ] || [ "$lan_mac_start" == "$lan_mac_end" ] && lan_mac_start=$(macaddr_setbit_la $lan_mac_start)
lan_mac_start=$(macaddr_add $lan_mac_start 1)
done
[ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
case $board in
d-link,dgs-1210-10mp-f)
ucidef_set_poe 130 "$lan_list" "lan9 lan10"
;;
d-link,dgs-1210-10p)
ucidef_set_poe 65 "$lan_list" "lan9 lan10"
;;
d-link,dgs-1210-28mp-f)
ucidef_set_poe 370 "lan8 lan7 lan6 lan5 lan4 lan3 lan2 lan1 lan16 lan15 lan14 lan13 lan12 lan11 lan10 lan9 lan24 lan23
lan22 lan21 lan20 lan19 lan18 lan17" "lan25 lan26 lan27 lan28"
;;
engenius,ews2910p)
ucidef_set_poe 60 "$lan_list" "lan9 lan10"
;;
hpe,1920-8g-poe-65w)
ucidef_set_poe 65 "$lan_list_rev" "lan9 lan10"
;;
hpe,1920-8g-poe-180w)
ucidef_set_poe 180 "$lan_list_rev" "lan9 lan10"
;;
netgear,gs110tpp-v1)
ucidef_set_poe 130 "$lan_list" "lan9 lan10"
;;
netgear,gs110tup-v1)
ucidef_set_poe 240 "$lan_list" "lan9 lan10"
;;
netgear,gs310tp-v1)
ucidef_set_poe 55 "$lan_list" "lan9 lan10"
;;
zyxel,gs1900-10hp)
ucidef_set_poe 77 "$lan_list" "lan9 lan10"
;;
zyxel,gs1900-8hp-v1|\
zyxel,gs1900-8hp-v2)
ucidef_set_poe 70 "$lan_list"
;;
zyxel,gs1900-24hp-v1|\
zyxel,gs1900-24hp-v2)
ucidef_set_poe 170 "$lan_list" "lan25 lan26"
;;
esac
board_config_flush
exit 0