Cudy WR1300 v4 is a MT7621 based dual-band router.

Hardware:
- SoC: MediaTek MT7621
- RAM: 128 MiB
- Flash: 16 MiB SPI NOR
- WiFi 2.4 GHz: MediaTek MT7603E
- WiFi 5 GHz: MediaTek MT7663E
- Ethernet: 5x 10/100/1000 Mbps
- Buttons: Reset, WPS
- LEDs: System, Internet, WAN, LAN1-4, WiFi 2.4 GHz, WiFi 5 GHz

The v4 hardware differs from v3 in GPIO assignments for LEDs and
buttons. WiFi LEDs are connected to MT7621 GPIO5/GPIO6 and require
the uart3 pin group to be muxed as GPIO.

Tested on retail Cudy WR1300 v4:
- sysupgrade image boots
- WAN and LAN1-4
- 2.4 GHz and 5 GHz WiFi
- Reset and WPS button events
- System, Internet, WAN, LAN1-4 and WiFi LEDs

Refactor the existing WR1300 v1/v2/v3 DTS files into a shared
mt7621_cudy_wr1300.dtsi with per-variant conditionals, and add
WR1300 v4 on top of that common structure.

Signed-off-by: Jan Brudna <[email protected]>
---

Changes since v1:
- Refactor the WR1300 v1/v2/v3 DTS files into a shared
  mt7621_cudy_wr1300.dtsi with per-variant conditionals,
  following review feedback.
- Add WR1300 v4 on top of the new common structure.

 .../ramips/dts/mt7621_cudy_wr1300-v1.dts      | 229 +---------
 .../ramips/dts/mt7621_cudy_wr1300-v2.dts      |  28 +-
 .../ramips/dts/mt7621_cudy_wr1300-v2v3.dtsi   | 189 --------
 .../ramips/dts/mt7621_cudy_wr1300-v3.dts      |  33 +-
 .../ramips/dts/mt7621_cudy_wr1300-v4.dts      |   4 +
 .../linux/ramips/dts/mt7621_cudy_wr1300.dtsi  | 404 ++++++++++++++++++
 target/linux/ramips/image/mt7621.mk           |  12 +
 .../mt7621/base-files/etc/board.d/01_leds     |   9 +
 8 files changed, 435 insertions(+), 473 deletions(-)
 delete mode 100644 target/linux/ramips/dts/mt7621_cudy_wr1300-v2v3.dtsi
 create mode 100644 target/linux/ramips/dts/mt7621_cudy_wr1300-v4.dts
 create mode 100644 target/linux/ramips/dts/mt7621_cudy_wr1300.dtsi

diff --git a/target/linux/ramips/dts/mt7621_cudy_wr1300-v1.dts 
b/target/linux/ramips/dts/mt7621_cudy_wr1300-v1.dts
index af04e033a1..3b8cfb4be5 100644
--- a/target/linux/ramips/dts/mt7621_cudy_wr1300-v1.dts
+++ b/target/linux/ramips/dts/mt7621_cudy_wr1300-v1.dts
@@ -1,229 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 
-#include "mt7621.dtsi"
-
-#include <dt-bindings/input/input.h>
-#include <dt-bindings/leds/common.h>
-#include <dt-bindings/gpio/gpio.h>
-
-/ {
-       compatible = "cudy,wr1300-v1", "mediatek,mt7621-soc";
-       model = "Cudy WR1300 v1";
-
-       aliases {
-               led-boot = &led_sys;
-               led-failsafe = &led_sys;
-               led-running = &led_sys;
-               led-upgrade = &led_sys;
-               label-mac-device = &gmac0;
-       };
-
-       chosen {
-               bootargs = "console=ttyS0,115200";
-       };
-
-       keys {
-               compatible = "gpio-keys";
-
-               reset {
-                       label = "reset";
-                       gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
-                       linux,code = <KEY_RESTART>;
-               };
-
-               wps {
-                       label = "wps";
-                       gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
-                       linux,code = <KEY_WPS_BUTTON>;
-               };
-       };
-
-       leds {
-               compatible = "gpio-leds";
-
-               led_sys: sys {
-                       label = "green:sys";
-                       gpios = <&gpio 15 GPIO_ACTIVE_HIGH>;
-               };
-
-               usb {
-                       function = LED_FUNCTION_USB;
-                       color = <LED_COLOR_ID_GREEN>;
-                       gpios = <&gpio 14 GPIO_ACTIVE_HIGH>;
-                       trigger-sources = <&xhci_ehci_port1>, <&ehci_port2>;
-                       linux,default-trigger = "usbport";
-               };
-
-               wps {
-                       function = LED_FUNCTION_WPS;
-                       color = <LED_COLOR_ID_GREEN>;
-                       gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
-               };
-       };
-};
-
-&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>;
-
-                       partition@0 {
-                               label = "u-boot";
-                               reg = <0x0 0x30000>;
-                               read-only;
-                       };
-
-                       partition@30000 {
-                               label = "u-boot-env";
-                               reg = <0x30000 0x10000>;
-                               read-only;
-                       };
-
-                       partition@40000 {
-                               label = "factory";
-                               reg = <0x40000 0x10000>;
-                               read-only;
-
-                               nvmem-layout {
-                                       compatible = "fixed-layout";
-                                       #address-cells = <1>;
-                                       #size-cells = <1>;
-
-                                       eeprom_factory_0: eeprom@0 {
-                                               reg = <0x0 0x400>;
-                                       };
-
-                                       eeprom_factory_8000: eeprom@8000 {
-                                               reg = <0x8000 0x200>;
-                                       };
-                               };
-                       };
-
-                       partition@50000 {
-                               compatible = "denx,uimage";
-                               label = "firmware";
-                               reg = <0x50000 0xf80000>;
-                       };
-
-                       partition@fd0000 {
-                               label = "debug";
-                               reg = <0xfd0000 0x10000>;
-                               read-only;
-                       };
-
-                       partition@fe0000 {
-                               label = "backup";
-                               reg = <0xfe0000 0x10000>;
-                               read-only;
-                       };
-
-                       partition@ff0000 {
-                               label = "bdinfo";
-                               reg = <0xff0000 0x10000>;
-                               read-only;
-
-                               nvmem-layout {
-                                       compatible = "fixed-layout";
-                                       #address-cells = <1>;
-                                       #size-cells = <1>;
-
-                                       macaddr_bdinfo_de00: macaddr@de00 {
-                                               compatible = "mac-base";
-                                               reg = <0xde00 0x6>;
-                                               #nvmem-cell-cells = <1>;
-                                       };
-                               };
-                       };
-               };
-       };
-};
-
-&pcie {
-       status = "okay";
-};
-
-&pcie0 {
-       wifi@0,0 {
-               compatible = "mediatek,mt76";
-               reg = <0x0000 0 0 0 0>;
-               nvmem-cells = <&eeprom_factory_0>, <&macaddr_bdinfo_de00 0>;
-               nvmem-cell-names = "eeprom", "mac-address";
-               ieee80211-freq-limit = <2400000 2500000>;
-
-               led {
-                       led-active-low;
-               };
-       };
-};
-
-&pcie1 {
-       wifi@0,0 {
-               compatible = "mediatek,mt76";
-               reg = <0x0000 0 0 0 0>;
-               nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_de00 2>;
-               nvmem-cell-names = "eeprom", "mac-address";
-               ieee80211-freq-limit = <5000000 6000000>;
-
-               led {
-                       led-sources = <2>;
-                       led-active-low;
-               };
-       };
-};
-
-&gmac0 {
-       nvmem-cells = <&macaddr_bdinfo_de00 0>;
-       nvmem-cell-names = "mac-address";
-};
-
-&gmac1 {
-       status = "okay";
-       label = "wan";
-       phy-handle = <&ethphy4>;
-
-       nvmem-cells = <&macaddr_bdinfo_de00 1>;
-       nvmem-cell-names = "mac-address";
-};
-
-&ethphy4 {
-       /delete-property/ interrupts;
-};
-
-&switch0 {
-       ports {
-               port@0 {
-                       status = "okay";
-                       label = "lan4";
-               };
-
-               port@1 {
-                       status = "okay";
-                       label = "lan3";
-               };
-
-               port@2 {
-                       status = "okay";
-                       label = "lan2";
-               };
-
-               port@3 {
-                       status = "okay";
-                       label = "lan1";
-               };
-       };
-};
-
-&state_default {
-       gpio {
-               groups = "wdt", "i2c", "jtag";
-               function = "gpio";
-       };
-};
+#define WR1300_V1
+#include "mt7621_cudy_wr1300.dtsi"
diff --git a/target/linux/ramips/dts/mt7621_cudy_wr1300-v2.dts 
b/target/linux/ramips/dts/mt7621_cudy_wr1300-v2.dts
index a33279e596..5e3f712f9b 100644
--- a/target/linux/ramips/dts/mt7621_cudy_wr1300-v2.dts
+++ b/target/linux/ramips/dts/mt7621_cudy_wr1300-v2.dts
@@ -1,28 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 
-#include "mt7621_cudy_wr1300-v2v3.dtsi"
-
-/ {
-       compatible = "cudy,wr1300-v2", "mediatek,mt7621-soc";
-       model = "Cudy WR1300 v2";
-};
-
-&pcie1 {
-       wifi@0,0 {
-               compatible = "mediatek,mt76";
-               reg = <0x0000 0 0 0 0>;
-               nvmem-cells = <&eeprom_factory_0>, <&macaddr_bdinfo_de00 0>;
-               nvmem-cell-names = "eeprom", "mac-address";
-               ieee80211-freq-limit = <2400000 2500000>;
-       };
-};
-
-&pcie0 {
-       wifi@0,0 {
-               compatible = "mediatek,mt76";
-               reg = <0x0000 0 0 0 0>;
-               nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_de00 2>;
-               nvmem-cell-names = "eeprom", "mac-address";
-               ieee80211-freq-limit = <5000000 6000000>;
-       };
-};
+#define WR1300_V2
+#include "mt7621_cudy_wr1300.dtsi"
diff --git a/target/linux/ramips/dts/mt7621_cudy_wr1300-v2v3.dtsi 
b/target/linux/ramips/dts/mt7621_cudy_wr1300-v2v3.dtsi
deleted file mode 100644
index da62648bc9..0000000000
--- a/target/linux/ramips/dts/mt7621_cudy_wr1300-v2v3.dtsi
+++ /dev/null
@@ -1,189 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
-
-#include "mt7621.dtsi"
-
-#include <dt-bindings/input/input.h>
-#include <dt-bindings/leds/common.h>
-#include <dt-bindings/gpio/gpio.h>
-
-/ {
-       aliases {
-               led-boot = &led_sys;
-               led-failsafe = &led_sys;
-               led-running = &led_sys;
-               led-upgrade = &led_sys;
-               label-mac-device = &gmac0;
-       };
-
-       chosen {
-               bootargs = "console=ttyS0,115200";
-       };
-
-       keys {
-               compatible = "gpio-keys";
-
-               reset {
-                       label = "reset";
-                       gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
-                       linux,code = <KEY_RESTART>;
-               };
-
-               wps {
-                       label = "wps";
-                       gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
-                       linux,code = <KEY_WPS_BUTTON>;
-               };
-       };
-
-       leds {
-               compatible = "gpio-leds";
-
-               led_sys: sys {
-                       label = "green:sys";
-                       gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
-               };
-
-               wps {
-                       function = LED_FUNCTION_WPS;
-                       color = <LED_COLOR_ID_GREEN>;
-                       gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
-               };
-       };
-};
-
-&spi0 {
-       status = "okay";
-
-       flash@0 {
-               compatible = "jedec,spi-nor";
-               reg = <0>;
-               spi-max-frequency = <40000000>;
-
-               partitions {
-                       compatible = "fixed-partitions";
-                       #address-cells = <1>;
-                       #size-cells = <1>;
-
-                       partition@0 {
-                               label = "u-boot";
-                               reg = <0x0 0x30000>;
-                               read-only;
-                       };
-
-                       partition@30000 {
-                               label = "u-boot-env";
-                               reg = <0x30000 0x10000>;
-                               read-only;
-                       };
-
-                       partition@40000 {
-                               label = "factory";
-                               reg = <0x40000 0x10000>;
-                               read-only;
-
-                               nvmem-layout {
-                                       compatible = "fixed-layout";
-                                       #address-cells = <1>;
-                                       #size-cells = <1>;
-
-                                       eeprom_factory_0: eeprom@0 {
-                                               reg = <0x0 0x400>;
-                                       };
-
-                                       eeprom_factory_8000: eeprom@8000 {
-                                               reg = <0x8000 0x4da8>;
-                                       };
-                               };
-                       };
-
-                       partition@50000 {
-                               compatible = "denx,uimage";
-                               label = "firmware";
-                               reg = <0x50000 0xf80000>;
-                       };
-
-                       partition@fd0000 {
-                               label = "debug";
-                               reg = <0xfd0000 0x10000>;
-                               read-only;
-                       };
-
-                       partition@fe0000 {
-                               label = "backup";
-                               reg = <0xfe0000 0x10000>;
-                               read-only;
-                       };
-
-                       partition@ff0000 {
-                               label = "bdinfo";
-                               reg = <0xff0000 0x10000>;
-                               read-only;
-
-                               nvmem-layout {
-                                       compatible = "fixed-layout";
-                                       #address-cells = <1>;
-                                       #size-cells = <1>;
-
-                                       macaddr_bdinfo_de00: macaddr@de00 {
-                                               compatible = "mac-base";
-                                               reg = <0xde00 0x6>;
-                                               #nvmem-cell-cells = <1>;
-                                       };
-                               };
-                       };
-               };
-       };
-};
-
-&pcie {
-       status = "okay";
-};
-
-&gmac0 {
-       nvmem-cells = <&macaddr_bdinfo_de00 0>;
-       nvmem-cell-names = "mac-address";
-};
-
-&gmac1 {
-       status = "okay";
-       label = "wan";
-       phy-handle = <&ethphy4>;
-
-       nvmem-cells = <&macaddr_bdinfo_de00 1>;
-       nvmem-cell-names = "mac-address";
-};
-
-&ethphy4 {
-       /delete-property/ interrupts;
-};
-
-&switch0 {
-       ports {
-               port@0 {
-                       status = "okay";
-                       label = "lan4";
-               };
-
-               port@1 {
-                       status = "okay";
-                       label = "lan3";
-               };
-
-               port@2 {
-                       status = "okay";
-                       label = "lan2";
-               };
-
-               port@3 {
-                       status = "okay";
-                       label = "lan1";
-               };
-       };
-};
-
-&state_default {
-       gpio {
-               groups = "wdt", "i2c", "jtag";
-               function = "gpio";
-       };
-};
diff --git a/target/linux/ramips/dts/mt7621_cudy_wr1300-v3.dts 
b/target/linux/ramips/dts/mt7621_cudy_wr1300-v3.dts
index cb75703a0a..36665e9944 100644
--- a/target/linux/ramips/dts/mt7621_cudy_wr1300-v3.dts
+++ b/target/linux/ramips/dts/mt7621_cudy_wr1300-v3.dts
@@ -1,33 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 
-#include "mt7621_cudy_wr1300-v2v3.dtsi"
-
-/ {
-       compatible = "cudy,wr1300-v3", "mediatek,mt7621-soc";
-       model = "Cudy WR1300 v3";
-};
-
-&pcie0 {
-       wifi@0,0 {
-               compatible = "mediatek,mt76";
-               reg = <0x0000 0 0 0 0>;
-               nvmem-cells = <&eeprom_factory_0>, <&macaddr_bdinfo_de00 0>;
-               nvmem-cell-names = "eeprom", "mac-address";
-               ieee80211-freq-limit = <2400000 2500000>;
-
-               led {
-                       led-sources = <0>;
-                       led-active-low;
-               };
-       };
-};
-
-&pcie1 {
-       wifi@0,0 {
-               compatible = "mediatek,mt76";
-               reg = <0x0000 0 0 0 0>;
-               nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_de00 2>;
-               nvmem-cell-names = "eeprom", "mac-address";
-               ieee80211-freq-limit = <5000000 6000000>;
-       };
-};
+#define WR1300_V3
+#include "mt7621_cudy_wr1300.dtsi"
diff --git a/target/linux/ramips/dts/mt7621_cudy_wr1300-v4.dts 
b/target/linux/ramips/dts/mt7621_cudy_wr1300-v4.dts
new file mode 100644
index 0000000000..b9444db2d1
--- /dev/null
+++ b/target/linux/ramips/dts/mt7621_cudy_wr1300-v4.dts
@@ -0,0 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#define WR1300_V4
+#include "mt7621_cudy_wr1300.dtsi"
diff --git a/target/linux/ramips/dts/mt7621_cudy_wr1300.dtsi 
b/target/linux/ramips/dts/mt7621_cudy_wr1300.dtsi
new file mode 100644
index 0000000000..8faf5e2981
--- /dev/null
+++ b/target/linux/ramips/dts/mt7621_cudy_wr1300.dtsi
@@ -0,0 +1,404 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "mt7621.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
+
+#if defined(WR1300_V1)
+#define WR1300_SPI_MAX_FREQUENCY       10000000
+#define WR1300_EEPROM_8000_SIZE                0x200
+#elif defined(WR1300_V2) || defined(WR1300_V3) || defined(WR1300_V4)
+#define WR1300_SPI_MAX_FREQUENCY       40000000
+#define WR1300_EEPROM_8000_SIZE                0x4da8
+#else
+#error "Unknown Cudy WR1300 hardware revision"
+#endif
+
+/ {
+#if defined(WR1300_V1)
+       compatible = "cudy,wr1300-v1", "mediatek,mt7621-soc";
+       model = "Cudy WR1300 v1";
+#elif defined(WR1300_V2)
+       compatible = "cudy,wr1300-v2", "mediatek,mt7621-soc";
+       model = "Cudy WR1300 v2";
+#elif defined(WR1300_V3)
+       compatible = "cudy,wr1300-v3", "mediatek,mt7621-soc";
+       model = "Cudy WR1300 v3";
+#elif defined(WR1300_V4)
+       compatible = "cudy,wr1300-v4", "mediatek,mt7621-soc";
+       model = "Cudy WR1300 v4";
+#endif
+
+       aliases {
+               led-boot = &led_sys;
+               led-failsafe = &led_sys;
+               led-running = &led_sys;
+               led-upgrade = &led_sys;
+               label-mac-device = &gmac0;
+       };
+
+       chosen {
+               bootargs = "console=ttyS0,115200";
+       };
+
+       keys {
+               compatible = "gpio-keys";
+
+#if defined(WR1300_V4)
+               wps {
+                       label = "wps";
+                       gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_WPS_BUTTON>;
+               };
+
+               reset {
+                       label = "reset";
+                       gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RESTART>;
+               };
+#elif defined(WR1300_V1)
+               reset {
+                       label = "reset";
+                       gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RESTART>;
+               };
+
+               wps {
+                       label = "wps";
+                       gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_WPS_BUTTON>;
+               };
+#else
+               reset {
+                       label = "reset";
+                       gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RESTART>;
+               };
+
+               wps {
+                       label = "wps";
+                       gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_WPS_BUTTON>;
+               };
+#endif
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+#if defined(WR1300_V4)
+               led_sys: sys {
+                       label = "green:sys";
+                       gpios = <&gpio 18 GPIO_ACTIVE_HIGH>;
+               };
+
+               internet {
+                       label = "green:internet";
+                       gpios = <&gpio 9 GPIO_ACTIVE_HIGH>;
+               };
+
+               lan4 {
+                       label = "green:lan4";
+                       gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
+               };
+
+               lan3 {
+                       label = "green:lan3";
+                       gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
+               };
+
+               lan2 {
+                       label = "green:lan2";
+                       gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
+               };
+
+               lan1 {
+                       label = "green:lan1";
+                       gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
+               };
+
+               wan {
+                       label = "green:wan";
+                       gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
+               };
+
+               wlan2g {
+                       label = "green:wlan2g";
+                       gpios = <&gpio 6 GPIO_ACTIVE_LOW>;
+               };
+
+               wlan5g {
+                       label = "green:wlan5g";
+                       gpios = <&gpio 5 GPIO_ACTIVE_HIGH>;
+               };
+#elif defined(WR1300_V1)
+               led_sys: sys {
+                       label = "green:sys";
+                       gpios = <&gpio 15 GPIO_ACTIVE_HIGH>;
+               };
+
+               usb {
+                       function = LED_FUNCTION_USB;
+                       color = <LED_COLOR_ID_GREEN>;
+                       gpios = <&gpio 14 GPIO_ACTIVE_HIGH>;
+                       trigger-sources = <&xhci_ehci_port1>, <&ehci_port2>;
+                       linux,default-trigger = "usbport";
+               };
+
+               wps {
+                       function = LED_FUNCTION_WPS;
+                       color = <LED_COLOR_ID_GREEN>;
+                       gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
+               };
+#else
+               led_sys: sys {
+                       label = "green:sys";
+                       gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
+               };
+
+               wps {
+                       function = LED_FUNCTION_WPS;
+                       color = <LED_COLOR_ID_GREEN>;
+                       gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
+               };
+#endif
+       };
+};
+
+&spi0 {
+       status = "okay";
+
+       flash@0 {
+               compatible = "jedec,spi-nor";
+               reg = <0>;
+               spi-max-frequency = <WR1300_SPI_MAX_FREQUENCY>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               reg = <0x0 0x30000>;
+                               read-only;
+                       };
+
+                       partition@30000 {
+                               label = "u-boot-env";
+                               reg = <0x30000 0x10000>;
+                               read-only;
+                       };
+
+                       partition@40000 {
+                               label = "factory";
+                               reg = <0x40000 0x10000>;
+                               read-only;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       eeprom_factory_0: eeprom@0 {
+                                               reg = <0x0 0x400>;
+                                       };
+
+                                       eeprom_factory_8000: eeprom@8000 {
+                                               reg = <0x8000 
WR1300_EEPROM_8000_SIZE>;
+                                       };
+                               };
+                       };
+
+                       partition@50000 {
+                               compatible = "denx,uimage";
+                               label = "firmware";
+                               reg = <0x50000 0xf80000>;
+                       };
+
+                       partition@fd0000 {
+                               label = "debug";
+                               reg = <0xfd0000 0x10000>;
+                               read-only;
+                       };
+
+                       partition@fe0000 {
+                               label = "backup";
+                               reg = <0xfe0000 0x10000>;
+                               read-only;
+                       };
+
+                       partition@ff0000 {
+                               label = "bdinfo";
+                               reg = <0xff0000 0x10000>;
+                               read-only;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       macaddr_bdinfo_de00: macaddr@de00 {
+                                               compatible = "mac-base";
+                                               reg = <0xde00 0x6>;
+                                               #nvmem-cell-cells = <1>;
+                                       };
+                               };
+                       };
+               };
+       };
+};
+
+&pcie {
+       status = "okay";
+};
+
+#if defined(WR1300_V1)
+&pcie0 {
+       wifi@0,0 {
+               compatible = "mediatek,mt76";
+               reg = <0x0000 0 0 0 0>;
+               nvmem-cells = <&eeprom_factory_0>, <&macaddr_bdinfo_de00 0>;
+               nvmem-cell-names = "eeprom", "mac-address";
+               ieee80211-freq-limit = <2400000 2500000>;
+
+               led {
+                       led-active-low;
+               };
+       };
+};
+
+&pcie1 {
+       wifi@0,0 {
+               compatible = "mediatek,mt76";
+               reg = <0x0000 0 0 0 0>;
+               nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_de00 2>;
+               nvmem-cell-names = "eeprom", "mac-address";
+               ieee80211-freq-limit = <5000000 6000000>;
+
+               led {
+                       led-sources = <2>;
+                       led-active-low;
+               };
+       };
+};
+#elif defined(WR1300_V2)
+&pcie1 {
+       wifi@0,0 {
+               compatible = "mediatek,mt76";
+               reg = <0x0000 0 0 0 0>;
+               nvmem-cells = <&eeprom_factory_0>, <&macaddr_bdinfo_de00 0>;
+               nvmem-cell-names = "eeprom", "mac-address";
+               ieee80211-freq-limit = <2400000 2500000>;
+       };
+};
+
+&pcie0 {
+       wifi@0,0 {
+               compatible = "mediatek,mt76";
+               reg = <0x0000 0 0 0 0>;
+               nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_de00 2>;
+               nvmem-cell-names = "eeprom", "mac-address";
+               ieee80211-freq-limit = <5000000 6000000>;
+       };
+};
+#elif defined(WR1300_V3)
+&pcie0 {
+       wifi@0,0 {
+               compatible = "mediatek,mt76";
+               reg = <0x0000 0 0 0 0>;
+               nvmem-cells = <&eeprom_factory_0>, <&macaddr_bdinfo_de00 0>;
+               nvmem-cell-names = "eeprom", "mac-address";
+               ieee80211-freq-limit = <2400000 2500000>;
+
+               led {
+                       led-sources = <0>;
+                       led-active-low;
+               };
+       };
+};
+
+&pcie1 {
+       wifi@0,0 {
+               compatible = "mediatek,mt76";
+               reg = <0x0000 0 0 0 0>;
+               nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_de00 2>;
+               nvmem-cell-names = "eeprom", "mac-address";
+               ieee80211-freq-limit = <5000000 6000000>;
+       };
+};
+#elif defined(WR1300_V4)
+&pcie0 {
+       wifi@0,0 {
+               compatible = "mediatek,mt76";
+               reg = <0x0000 0 0 0 0>;
+               nvmem-cells = <&eeprom_factory_0>, <&macaddr_bdinfo_de00 0>;
+               nvmem-cell-names = "eeprom", "mac-address";
+               ieee80211-freq-limit = <2400000 2500000>;
+       };
+};
+
+&pcie1 {
+       wifi@0,0 {
+               compatible = "mediatek,mt76";
+               reg = <0x0000 0 0 0 0>;
+               nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_de00 2>;
+               nvmem-cell-names = "eeprom", "mac-address";
+               ieee80211-freq-limit = <5000000 6000000>;
+       };
+};
+#endif
+
+&gmac0 {
+       nvmem-cells = <&macaddr_bdinfo_de00 0>;
+       nvmem-cell-names = "mac-address";
+};
+
+&gmac1 {
+       status = "okay";
+       label = "wan";
+       phy-handle = <&ethphy4>;
+       nvmem-cells = <&macaddr_bdinfo_de00 1>;
+       nvmem-cell-names = "mac-address";
+};
+
+&ethphy4 {
+       /delete-property/ interrupts;
+};
+
+&switch0 {
+       ports {
+               port@0 {
+                       status = "okay";
+                       label = "lan4";
+               };
+
+               port@1 {
+                       status = "okay";
+                       label = "lan3";
+               };
+
+               port@2 {
+                       status = "okay";
+                       label = "lan2";
+               };
+
+               port@3 {
+                       status = "okay";
+                       label = "lan1";
+               };
+       };
+};
+
+&state_default {
+       gpio {
+#if defined(WR1300_V4)
+               groups = "wdt", "i2c", "jtag", "uart3";
+#else
+               groups = "wdt", "i2c", "jtag";
+#endif
+               function = "gpio";
+       };
+};
diff --git a/target/linux/ramips/image/mt7621.mk 
b/target/linux/ramips/image/mt7621.mk
index cd595e72c4..76e2d6b43a 100644
--- a/target/linux/ramips/image/mt7621.mk
+++ b/target/linux/ramips/image/mt7621.mk
@@ -821,6 +821,18 @@ define Device/cudy_wr1300-v3
 endef
 TARGET_DEVICES += cudy_wr1300-v3
 
+define Device/cudy_wr1300-v4
+  $(Device/dsa-migration)
+  IMAGE_SIZE := 15872k
+  DEVICE_VENDOR := Cudy
+  DEVICE_MODEL := WR1300
+  DEVICE_VARIANT := v4
+  DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7663-firmware-ap \
+       -uboot-envtools
+  SUPPORTED_DEVICES += cudy,wr1300 R30
+endef
+TARGET_DEVICES += cudy_wr1300-v4
+
 define Device/cudy_wr2100
   $(Device/dsa-migration)
   DEVICE_VENDOR := Cudy
diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds 
b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
index eb4de3e03d..efede4b59e 100644
--- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
@@ -7,6 +7,15 @@ board=$(board_name)
 board_config_update
 
 case $board in
+cudy,wr1300-v4)
+       ucidef_set_led_netdev "wan" "WAN" "green:wan" "wan" "link tx rx"
+       ucidef_set_led_netdev "lan1" "LAN1" "green:lan1" "lan1" "link tx rx"
+       ucidef_set_led_netdev "lan2" "LAN2" "green:lan2" "lan2" "link tx rx"
+       ucidef_set_led_netdev "lan3" "LAN3" "green:lan3" "lan3" "link tx rx"
+       ucidef_set_led_netdev "lan4" "LAN4" "green:lan4" "lan4" "link tx rx"
+       ucidef_set_led_wlan "wlan2g" "WiFi 2.4GHz" "green:wlan2g" "phy0tpt"
+       ucidef_set_led_wlan "wlan5g" "WiFi 5GHz" "green:wlan5g" "phy1tpt"
+       ;;
 alfa-network,ax1800rm)
        ucidef_set_led_netdev "lan1" "lan1" "green:lan1" "lan1"
        ucidef_set_led_netdev "lan2" "lan2" "green:lan2" "lan2"
-- 
2.34.1


_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to