Files
openwrt-R7800-nss/target/linux/realtek/base-files/etc/board.d/02_network
Luiz Angelo Daros de Luca 23ac1ad951 realtek: d-link: add support for dgs-1210-28p-f
General hardware info:
----------------------

D-Link DGS-1210-28P rev. F1 is a switch with 24 ethernet ports and 4
combo ports, all ports Gbit capable. It is based on a RTL8382 SoC
@500MHz, DRAM 128MB and 32MB flash. 24 ethernet ports are 802.3af/at PoE
capable with a total PoE power budget of 193W.

Power over Ethernet:
--------------------

The PSE hardware consists of three BCM59121 PSE chips, serving 8 ports
each. They are controlled by a Nuvoton MCU.  In order to enable PoE, the
realtek-poe package is required. It is installed by default, but
currently it requires the manual editing of /etc/config/poe. Keep in
mind that the port number assignment does not match on this switch,
alway 8 ports are in reversed order: 8-1, 16-9 and 24-17.

LEDs and Buttons:
-----------------

On stock firmware, the mode button is supposed to switch the LED
indicators of all port LEDs between Link Activity and PoE status. The
currently selected mode is visualized using the respective LEDs. PoE Max
indicates that the maximum PoE budget has been reached.  Since there is
currently no support for this behavior, these LEDs and the mode button
can be used independently.

Serial connection:
------------------
The UART for the SoC (115200 8N1) is available via unpopulated standard
0.1" pin header marked J6. Pin1 is marked with arrow and square.

Pin 1: Vcc 3.3V
Pin 2: Tx
Pin 3: Rx
Pin 4: Gnd

OEM installation from Web Interface:
------------------------------------

    1. Make sure you are booting using OEM in image 2 slot. If not,
       switch to
        image2 using the menus
        System > Firmware Information > Boot from image2
        Tools > reboot
    2. Upload image in vendor firmware via Tools > Backup / Upgrade
        Firmware > image1
    3. Toggle startup image via System > Firmware Information > Boot
       from
        image1
    4. Tools > reboot

Other installation methods not tested, but since the device shares the
board with the DGS-1210-28, the following should work:

Boot initramfs image from U-Boot:
---------------------------------

    1. Press Escape key during `Hit Esc key to stop autoboot` prompt
    2. Press CTRL+C keys to get into real U-Boot prompt
    3. Init network with `rtk network on` command
    4. Load image with `tftpboot 0x8f000000
        openwrt-rtl838x-generic-d-link_dgs-1210-28p-f-initramfs-kernel.bin`
        command
    5. Boot the image with `bootm` command

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/15938
Signed-off-by: Sander Vanheule <sander@svanheule.net>
2024-09-24 20:59:50 +02:00

131 lines
3.8 KiB
Plaintext

. /lib/functions.sh
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh
_filter_port_list_ordered() {
local ports="$1"
local excluded="$2"
local sort_opts="$3"
echo $ports $excluded | xargs -n1 basename | sort -V $sort_opts | uniq -u | xargs
}
filter_port_list() {
_filter_port_list_ordered "$1" "$2"
}
filter_port_list_reverse() {
_filter_port_list_ordered "$1" "$2" "-r"
}
board=$(board_name)
board_config_update
lan_list=$(ls -1 -v -d /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|\
hpe,1920-48g|\
hpe,1920-48g-poe)
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 "$(filter_port_list "$lan_list" "lan9 lan10")"
;;
d-link,dgs-1210-10p)
ucidef_set_poe 65 "$(filter_port_list "$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"
;;
d-link,dgs-1210-28p-f)
ucidef_set_poe 193 "lan8 lan7 lan6 lan5 lan4 lan3 lan2 lan1 lan16 lan15 lan14 lan13 lan12 lan11 lan10 lan9 lan24 lan23
lan22 lan21 lan20 lan19 lan18 lan17"
;;
engenius,ews2910p)
ucidef_set_poe 60 "$(filter_port_list "$lan_list" "lan9 lan10")"
;;
hpe,1920-8g-poe-65w)
ucidef_set_poe 65 "$(filter_port_list_reverse "$lan_list" "lan9 lan10")"
;;
hpe,1920-8g-poe-180w)
ucidef_set_poe 180 "$(filter_port_list_reverse "$lan_list" "lan9 lan10")"
;;
hpe,1920-48g-poe)
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 lan32 lan31 lan30 lan29 lan28 lan27 lan26 lan25 lan40 lan39 lan38 lan37
lan36 lan35 lan34 lan33 lan48 lan47 lan46 lan45 lan44 lan43 lan42 lan41"
;;
netgear,gs110tpp-v1)
ucidef_set_poe 130 "$(filter_port_list "$lan_list" "lan9 lan10")"
;;
netgear,gs110tup-v1)
ucidef_set_poe 240 "$(filter_port_list "$lan_list" "lan9 lan10")"
;;
netgear,gs310tp-v1)
ucidef_set_poe 55 "$(filter_port_list "$lan_list" "lan9 lan10")"
;;
zyxel,gs1900-10hp)
ucidef_set_poe 77 "$(filter_port_list "$lan_list" "lan9 lan10")"
;;
zyxel,gs1900-8hp-v1|\
zyxel,gs1900-8hp-v2)
ucidef_set_poe 70 "$lan_list"
;;
zyxel,gs1900-24ep)
ucidef_set_poe 130 "lan1 lan2 lan3 lan4 lan5 lan6 lan7 lan8 lan9 lan10 lan11 lan12"
;;
zyxel,gs1900-24hp-v1|\
zyxel,gs1900-24hp-v2)
ucidef_set_poe 170 "$(filter_port_list "$lan_list" "lan25 lan26")"
;;
esac
board_config_flush
exit 0