[ "$(rootfs_type)" = "tmpfs" ] && exit 0
+# Some devices make it hard or impossible to acquire a usable ethaddr / MAC address
+# of the device. Some store it in weird places, some ship with only the common
+# Realtek dummy ethaddr, and some are outright broken.
+#
+# For these devices, we generate a random ethaddr in /etc/board.d/02_network,
+# which is stored in /etc/board.json. Here we take this random ethaddr and
+# persist it in the U-Boot environment, so that it survives sysupgrades.
+
case "$(board_name)" in
+hasivo,f1100w-4sx-4xgt|\
+hasivo,f1100w-4sx-4xgt-512mb|\
tplink,tl-st1008f-v2)
env_ethaddr=$(macaddr_canonicalize "$(fw_printenv -n ethaddr 2>/dev/null)")
- # This device ships with a dummy ethaddr because it's an unmanaged switch.
- # If it hasn't been updated to another one yet, do that now.
+ # F1100W-4SX-4XGT and its variants ship with the dummy ethaddr in the u-boot
+ # environment, and the real ethaddr stored in RUNTIME/RUNTIME2 JFFS2 partitions,
+ # which would be annoying to deal with. Also ethaddr isn't printed on the case.
+ #
+ # TL-ST1008F v2 ships with a dummy ethaddr because it's an unmanaged switch.
+ #
+ # We persist the random ethaddr if the currently stored ethaddr is empty or dummy.
if [ -z "$env_ethaddr" ] || [ "$env_ethaddr" = "00:e0:4c:00:00:00" ]; then
json_init
json_load_file "$BOARD_CFG"
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0-or-later
+/dts-v1/;
+
+#include "rtl930x.dtsi"
+
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/leds/common.h>
+
+/ {
+ aliases {
+ led-boot = &led_sys;
+ led-failsafe = &led_sys;
+ led-running = &led_sys;
+ led-upgrade = &led_sys;
+ };
+
+ chosen {
+ stdout-path = "serial0:38400n8";
+ };
+
+ keys {
+ compatible = "gpio-keys";
+
+ button-reset {
+ label = "reset";
+ gpios = <&gpio0 20 GPIO_ACTIVE_HIGH>;
+ linux,code = <KEY_RESTART>;
+ };
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ led_sys: led-0 {
+ gpios = <&gpio0 21 GPIO_ACTIVE_HIGH>;
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_STATUS;
+ };
+ };
+
+ led_set {
+ compatible = "realtek,rtl9300-leds";
+
+ led_set0 = <
+ (RTL93XX_LED_SET_NONE)
+ (RTL93XX_LED_SET_10M | RTL93XX_LED_SET_100M | RTL93XX_LED_SET_1G |
+ RTL93XX_LED_SET_2P5G | RTL93XX_LED_SET_5G |
+ RTL93XX_LED_SET_LINK | RTL93XX_LED_SET_ACT)
+ (RTL93XX_LED_SET_10G | RTL93XX_LED_SET_LINK | RTL93XX_LED_SET_ACT)
+ >;
+ };
+
+ sfp0: sfp-p1 {
+ compatible = "sff,sfp";
+ i2c-bus = <&i2c0>;
+ mod-def0-gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
+ maximum-power-milliwatt = <2000>;
+ #thermal-sensor-cells = <0>;
+ };
+
+ sfp1: sfp-p2 {
+ compatible = "sff,sfp";
+ i2c-bus = <&i2c1>;
+ mod-def0-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
+ maximum-power-milliwatt = <2000>;
+ #thermal-sensor-cells = <0>;
+ };
+
+ sfp2: sfp-p3 {
+ compatible = "sff,sfp";
+ i2c-bus = <&i2c2>;
+ mod-def0-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
+ maximum-power-milliwatt = <2000>;
+ #thermal-sensor-cells = <0>;
+ };
+
+ sfp3: sfp-p4 {
+ compatible = "sff,sfp";
+ i2c-bus = <&i2c3>;
+ mod-def0-gpios = <&gpio0 3 GPIO_ACTIVE_LOW>;
+ maximum-power-milliwatt = <2000>;
+ #thermal-sensor-cells = <0>;
+ };
+};
+
+&i2c_mst1 {
+ status = "okay";
+
+ i2c0: i2c@0 { reg = <0>; };
+ i2c1: i2c@1 { reg = <1>; };
+ i2c2: i2c@2 { reg = <2>; };
+ i2c3: i2c@3 { reg = <3>; };
+};
+
+&spi0 {
+ status = "okay";
+
+ flash@0 {
+ compatible = "jedec,spi-nor";
+ reg = <0>;
+ spi-max-frequency = <10000000>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ /* stock is LOADER */
+ partition@0 {
+ label = "u-boot";
+ reg = <0x0000000 0x00e0000>;
+ read-only;
+ };
+
+ /* stock is BDINFO */
+ partition@e0000 {
+ label = "u-boot-env";
+ reg = <0x00e0000 0x0010000>;
+ };
+
+ /* stock is SYSINFO */
+ partition@f0000 {
+ label = "u-boot-env2";
+ reg = <0x00f0000 0x0010000>;
+ };
+
+ /* stock is CFG JFFS2 */
+ partition@100000 {
+ label = "jffs";
+ reg = <0x0100000 0x0100000>;
+ };
+
+ /* stock is LOG JFFS2 */
+ partition@200000 {
+ label = "jffs2";
+ reg = <0x0200000 0x0100000>;
+ };
+
+ /* stock is RUNTIME and RUNTIME2
+ * RUNTIME is <0x0300000 0x0e80000>
+ * RUNTIME2 is <0x1180000 0x0e80000>
+ */
+ partition@300000 {
+ compatible = "openwrt,uimage", "denx,uimage";
+ label = "firmware";
+ reg = <0x0300000 0x1d00000>;
+ };
+ };
+ };
+};
+
+&mdio_bus0 {
+ PHY_C45(26, 16)
+};
+
+&mdio_bus1 {
+ PHY_C45(27, 0)
+};
+
+&mdio_bus2 {
+ PHY_C45(24, 0)
+};
+
+&mdio_bus3 {
+ PHY_C45(25, 16)
+};
+
+&switch0 {
+ ethernet-ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ /* SFP+ ports, lan1-4 */
+ SWITCH_PORT_SFP(0, 1, 2, 0, 0)
+ SWITCH_PORT_SFP(8, 2, 3, 0, 1)
+ SWITCH_PORT_SFP(16, 3, 4, 0, 2)
+ SWITCH_PORT_SFP(20, 4, 5, 0, 3)
+
+ /* RJ45 ports, lan5-8 */
+ SWITCH_PORT_LED(24, 5, 6, 0, usxgmii)
+ SWITCH_PORT_LED(25, 6, 7, 0, usxgmii)
+ SWITCH_PORT_LED(26, 7, 8, 0, usxgmii)
+ SWITCH_PORT_LED(27, 8, 9, 0, usxgmii)
+
+ /* CPU port */
+ port@28 {
+ ethernet = <ðernet0>;
+ reg = <28>;
+ phy-mode = "internal";
+
+ fixed-link {
+ speed = <1000>;
+ full-duplex;
+ };
+ };
+ };
+};
+
+&thermal_zones {
+ sfp-thermal {
+ polling-delay-passive = <10000>;
+ polling-delay = <10000>;
+ thermal-sensors = <&sfp0>, <&sfp1>, <&sfp2>, <&sfp3>;
+ trips {
+ sfp-crit {
+ temperature = <110000>;
+ hysteresis = <1000>;
+ type = "critical";
+ };
+ };
+ };
+};
+
endef
TARGET_DEVICES += d-link_dgs-1250-28x
+define Device/hasivo_f1100w-4sx-4xgt-common
+ SOC := rtl9303
+ DEVICE_VENDOR := Hasivo
+ DEVICE_MODEL := F1100W-4SX-4XGT
+ DEVICE_ALT0_VENDOR := Hasivo
+ DEVICE_ALT0_MODEL := F1100W-4SX-4XGT-SE
+ DEVICE_ALT1_VENDOR := Hasivo
+ DEVICE_ALT1_MODEL := F1100WP-4SX-4XGT
+ DEVICE_ALT2_VENDOR := Hasivo
+ DEVICE_ALT2_MODEL := F1100WP-4SX-4XGT-SE
+ DEVICE_PACKAGES := kmod-phy-realtek rtl8261n-firmware
+ IMAGE_SIZE := 29696k
+ $(Device/kernel-lzma)
+endef
+
+define Device/hasivo_f1100w-4sx-4xgt
+ $(Device/hasivo_f1100w-4sx-4xgt-common)
+endef
+TARGET_DEVICES += hasivo_f1100w-4sx-4xgt
+
+define Device/hasivo_f1100w-4sx-4xgt-512mb
+ $(Device/hasivo_f1100w-4sx-4xgt-common)
+ DEVICE_VARIANT := 512MB
+ DEVICE_ALT0_VARIANT := 512MB
+ DEVICE_ALT1_VARIANT := 512MB
+ DEVICE_ALT2_VARIANT := 512MB
+endef
+TARGET_DEVICES += hasivo_f1100w-4sx-4xgt-512mb
+
define Device/hasivo_s1100w-8xgt-se
SOC := rtl9303
DEVICE_VENDOR := Hasivo