[openwrt/openwrt] ramips: mt7620: Add support for D-Link DWR-961 A1

LEDE Commits lede-commits at lists.infradead.org
Wed Mar 16 07:06:07 PDT 2022


mans0n pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/be89c9eec4c28123b61ed020ad5b8b02905e73af

commit be89c9eec4c28123b61ed020ad5b8b02905e73af
Author: Pawel Dembicki <paweldembicki at gmail.com>
AuthorDate: Fri Feb 18 00:23:45 2022 +0100

    ramips: mt7620: Add support for D-Link DWR-961 A1
    
    The DWR-961 A1 Wireless Router is based on the MT7620A SoC.
    It's a merge of two Amit boards: DWR-960 with ethernet part
    of Lava LR-25G001.
    
    ROMID it's taken from Telenor branded version and it works with tested
    device. Images from D-Link site for this router are from DWR-953 and it
    have ROMID DLK6E2424001. I don't know if it's mistake on web-site
    or if it's will require different image.
    
    Specification:
    
    - MediaTek MT7620A (580 Mhz)
    - 128 MB of RAM
    - 16 MB of FLASH
    - 1x 802.11bgn radio
    - 1x 802.11ac radio (MT7612 mpcie card)
    - 5x 10/100/1000 Mbps Ethernet: 4xLAN and 1xWAN (QCA8337)
    - 2x internal, non-detachable antennas (Wifi 2.4G)
    - 3x external, detachable antennas (2x LTE, 1x Wifi 5G)
    - 1x LTE modem cat 6
    - UART (J5) header on PCB (57600 8n1)
    - 13x LED, 2x button
    - JBOOT bootloader
    
    Installation:
    Apply factory image via http web-gui or JBOOT recovery page
    
    How to revert to OEM firmware:
    - push the reset button and turn on the power. Wait until LED start
      blinking (~10sec.)
    - upload original factory image via JBOOT http (IP: 192.168.123.254)
    
    Signed-off-by: Pawel Dembicki <paweldembicki at gmail.com>
---
 target/linux/ramips/dts/mt7620a_dlink_dwr-960.dts  | 174 +--------------------
 .../linux/ramips/dts/mt7620a_dlink_dwr-961-a1.dts  |  62 ++++++++
 ...link_dwr-960.dts => mt7620a_dlink_dwr-96x.dtsi} |  96 +++++-------
 target/linux/ramips/image/mt7620.mk                |  15 ++
 .../ramips/mt7620/base-files/etc/board.d/01_leds   |   4 +
 .../mt7620/base-files/etc/board.d/02_network       |   8 +
 .../mt7620/base-files/etc/board.d/03_gpio_switches |   3 +-
 .../etc/hotplug.d/firmware/10-rt2x00-eeprom        |   1 +
 8 files changed, 131 insertions(+), 232 deletions(-)

diff --git a/target/linux/ramips/dts/mt7620a_dlink_dwr-960.dts b/target/linux/ramips/dts/mt7620a_dlink_dwr-960.dts
index 77b94a1190..3de9533edc 100644
--- a/target/linux/ramips/dts/mt7620a_dlink_dwr-960.dts
+++ b/target/linux/ramips/dts/mt7620a_dlink_dwr-960.dts
@@ -1,93 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 
-#include "mt7620a.dtsi"
-
-#include <dt-bindings/input/input.h>
-#include <dt-bindings/gpio/gpio.h>
-#include <dt-bindings/mtd/partitions/uimage.h>
+#include "mt7620a_dlink_dwr-96x.dtsi"
 
 / {
 	compatible = "dlink,dwr-960", "ralink,mt7620a-soc";
 	model = "D-Link DWR-960";
-
-	aliases {
-		led-boot = &led_status;
-		led-failsafe = &led_status;
-		led-running = &led_status;
-		led-upgrade = &led_status;
-	};
-
-	keys {
-		compatible = "gpio-keys";
-
-		reset {
-			label = "reset";
-			gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
-			linux,code = <KEY_RESTART>;
-		};
-
-		wps {
-			label = "wps";
-			gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
-			linux,code = <KEY_WPS_BUTTON>;
-		};
-	};
-
-	leds {
-		compatible = "gpio-leds";
-
-		led_status: status {
-			label = "green:status";
-			gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
-		};
-
-		wan {
-			label = "green:wan";
-			gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
-		};
-
-		lan {
-			label = "green:lan";
-			gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
-		};
-
-		sms {
-			label = "green:sms";
-			gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
-		};
-
-		signal_green {
-			label = "green:signal";
-			gpios = <&gpio2 0 GPIO_ACTIVE_HIGH>;
-		};
-
-		signal_red {
-			label = "red:signal";
-			gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>;
-		};
-
-		4g {
-			label = "green:4g";
-			gpios = <&gpio2 2 GPIO_ACTIVE_LOW>;
-		};
-
-		3g {
-			label = "green:3g";
-			gpios = <&gpio2 3 GPIO_ACTIVE_LOW>;
-		};
-
-		wlan5g {
-			label = "green:wlan5g";
-			gpios = <&gpio2 4 GPIO_ACTIVE_LOW>;
-			linux,default-trigger = "phy0tpt";
-		};
-
-		wlan2g {
-			label = "green:wlan2g";
-			gpios = <&gpio3 0 GPIO_ACTIVE_LOW>;
-			linux,default-trigger = "phy1tpt";
-		};
-	};
 };
 
 &ethernet {
@@ -112,91 +29,6 @@
 	};
 };
 
-&gpio1 {
-	status = "okay";
-};
-
-&gpio2 {
-	status = "okay";
-};
-
-&gpio3 {
-	status = "okay";
-};
-
-&spi0 {
-	status = "okay";
-
-	flash at 0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <50000000>;
-
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition at 0 {
-				label = "jboot";
-				reg = <0x0 0x10000>;
-				read-only;
-			};
-
-			partition at 10000 {
-				compatible = "openwrt,uimage", "denx,uimage";
-				openwrt,ih-magic = <IH_MAGIC_OKLI>;
-				openwrt,offset = <0x10000>;
-				label = "firmware";
-				reg = <0x10000 0xfe0000>;
-			};
-
-			config: partition at ff0000 {
-				label = "config";
-				reg = <0xff0000 0x10000>;
-				read-only;
-			};
-		};
-	};
-};
-
-&ehci {
-	status = "okay";
-};
-
-&ohci {
-	status = "okay";
-};
-
-&pcie {
-	status = "okay";
-};
-
-&pcie0 {
-	wifi at 0,0 {
-		compatible = "mediatek,mt76";
-		reg = <0x0000 0 0 0 0>;
-		ieee80211-freq-limit = <5000000 6000000>;
-		mediatek,mtd-eeprom = <&config 0xe08e>;
-		nvmem-cells = <&macaddr_config_e50e>;
-		nvmem-cell-names = "mac-address";
-		mac-address-increment = <2>;
-	};
-};
-
-&state_default {
-	default {
-		groups = "i2c", "wled", "spi refclk", "uartf", "ephy";
-		function = "gpio";
-	};
-};
-
-&config {
-	compatible = "nvmem-cells";
-	#address-cells = <1>;
-	#size-cells = <1>;
-
-	macaddr_config_e50e: macaddr at e50e {
-		reg = <0xe50e 0x6>;
-	};
+&wifi {
+	mediatek,mtd-eeprom = <&config 0xe08e>;
 };
diff --git a/target/linux/ramips/dts/mt7620a_dlink_dwr-961-a1.dts b/target/linux/ramips/dts/mt7620a_dlink_dwr-961-a1.dts
new file mode 100644
index 0000000000..7eae666668
--- /dev/null
+++ b/target/linux/ramips/dts/mt7620a_dlink_dwr-961-a1.dts
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * D-Link DWR-961 A1 Board Description
+ * Copyright 2022 Pawel Dembicki <paweldembicki at gmail.com>
+ */
+#include "mt7620a_dlink_dwr-96x.dtsi"
+
+/ {
+	compatible = "dlink,dwr-961-a1", "ralink,mt7620a-soc";
+	model = "D-Link DWR-961 A1";
+
+	leds {
+		hidden-1 { /* hidden next to wlan5g led */
+			label = "green:hidden-1";
+			gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
+		};
+
+		hidden-2 { /* hidden next to sms led*/
+			label = "green:hidden-2";
+			gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
+		};
+	};
+};
+
+&ethernet {
+	pinctrl-names = "default";
+	pinctrl-0 = <&rgmii1_pins &mdio_pins>;
+
+	port at 5 {
+		status = "okay";
+		phy-mode = "rgmii";
+		mediatek,fixed-link = <1000 1 1 1>;
+	};
+
+	mdio-bus {
+		status = "okay";
+
+		ethernet-phy at 0 {
+			reg = <0>;
+			phy-mode = "rgmii";
+			qca,ar8327-initvals = <
+				0x04 0x87300000 /* PORT0 PAD MODE CTRL */
+				0x0c 0x00000000 /* PORT6 PAD MODE CTRL */
+				0x7c 0x0000007e /* PORT0_STATUS */
+				0x80 0x00001200 /* PORT1_STATUS */
+				0x84 0x00001200 /* PORT2_STATUS */
+				0x88 0x00001200 /* PORT3_STATUS */
+				0x8c 0x00001200 /* PORT4_STATUS */
+				0x90 0x00001200 /* PORT5_STATUS */
+				0x94 0x00000000 /* PORT6_STATUS */
+			>;
+		};
+	};
+};
+
+&gsw {
+	mediatek,ephy-base = /bits/ 8 <8>;
+};
+
+&wifi {
+	mediatek,mtd-eeprom = <&config 0xe29e>;
+};
diff --git a/target/linux/ramips/dts/mt7620a_dlink_dwr-960.dts b/target/linux/ramips/dts/mt7620a_dlink_dwr-96x.dtsi
similarity index 79%
copy from target/linux/ramips/dts/mt7620a_dlink_dwr-960.dts
copy to target/linux/ramips/dts/mt7620a_dlink_dwr-96x.dtsi
index 77b94a1190..a5fd705eba 100644
--- a/target/linux/ramips/dts/mt7620a_dlink_dwr-960.dts
+++ b/target/linux/ramips/dts/mt7620a_dlink_dwr-96x.dtsi
@@ -1,15 +1,15 @@
-// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
-
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * D-Link DWR-96x Common Board Description
+ * Copyright 2022 Pawel Dembicki <paweldembicki at gmail.com>
+ */
 #include "mt7620a.dtsi"
 
-#include <dt-bindings/input/input.h>
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
 #include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
-	compatible = "dlink,dwr-960", "ralink,mt7620a-soc";
-	model = "D-Link DWR-960";
-
 	aliases {
 		led-boot = &led_status;
 		led-failsafe = &led_status;
@@ -31,6 +31,7 @@
 			gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
 			linux,code = <KEY_WPS_BUTTON>;
 		};
+
 	};
 
 	leds {
@@ -90,26 +91,8 @@
 	};
 };
 
-&ethernet {
-	pinctrl-names = "default";
-	pinctrl-0 = <&rgmii2_pins &mdio_pins>;
-
-	mediatek,portmap = "wllll";
-
-	port at 5 {
-		status = "okay";
-		phy-mode = "rgmii-txid";
-		phy-handle = <&phy7>;
-	};
-
-	mdio-bus {
-		status = "okay";
-
-		phy7: ethernet-phy at 7 {
-			reg = <7>;
-			phy-mode = "rgmii-id";
-		};
-	};
+&ehci {
+	status = "okay";
 };
 
 &gpio1 {
@@ -124,6 +107,25 @@
 	status = "okay";
 };
 
+&ohci {
+	status = "okay";
+};
+
+&pcie {
+	status = "okay";
+};
+
+&pcie0 {
+	wifi: wifi at 0,0 {
+		compatible = "mediatek,mt76";
+		reg = <0x0000 0 0 0 0>;
+		ieee80211-freq-limit = <5000000 6000000>;
+		nvmem-cells = <&macaddr_config_e50e>;
+		nvmem-cell-names = "mac-address";
+		mac-address-increment = <(2)>;
+	};
+};
+
 &spi0 {
 	status = "okay";
 
@@ -152,51 +154,25 @@
 			};
 
 			config: partition at ff0000 {
+				compatible = "nvmem-cells";
+				#address-cells = <1>;
+				#size-cells = <1>;
+
 				label = "config";
 				reg = <0xff0000 0x10000>;
 				read-only;
+
+				macaddr_config_e50e: macaddr at e50e {
+					reg = <0xe50e 0x6>;
+				};
 			};
 		};
 	};
 };
 
-&ehci {
-	status = "okay";
-};
-
-&ohci {
-	status = "okay";
-};
-
-&pcie {
-	status = "okay";
-};
-
-&pcie0 {
-	wifi at 0,0 {
-		compatible = "mediatek,mt76";
-		reg = <0x0000 0 0 0 0>;
-		ieee80211-freq-limit = <5000000 6000000>;
-		mediatek,mtd-eeprom = <&config 0xe08e>;
-		nvmem-cells = <&macaddr_config_e50e>;
-		nvmem-cell-names = "mac-address";
-		mac-address-increment = <2>;
-	};
-};
-
 &state_default {
 	default {
 		groups = "i2c", "wled", "spi refclk", "uartf", "ephy";
 		function = "gpio";
 	};
 };
-
-&config {
-	compatible = "nvmem-cells";
-	#address-cells = <1>;
-	#size-cells = <1>;
-
-	macaddr_config_e50e: macaddr at e50e {
-		reg = <0xe50e 0x6>;
-	};
-};
diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk
index 5efb4e5e17..49d25b947f 100644
--- a/target/linux/ramips/image/mt7620.mk
+++ b/target/linux/ramips/image/mt7620.mk
@@ -314,6 +314,21 @@ define Device/dlink_dwr-960
 endef
 TARGET_DEVICES += dlink_dwr-960
 
+define Device/dlink_dwr-961-a1
+  $(Device/amit_jboot)
+  SOC := mt7620a
+  IMAGE_SIZE := 16256k
+  DEVICE_VENDOR := D-Link
+  DEVICE_MODEL := DWR-961
+  DEVICE_VARIANT := A1
+  DLINK_ROM_ID := DLK6E3813001
+  DLINK_FAMILY_MEMBER := 0x6E38
+  DLINK_FIRMWARE_SIZE := 0xFE0000
+  DEVICE_PACKAGES += kmod-mt76x2 kmod-usb-net-qmi-wwan kmod-usb-serial-option \
+	uqmi
+endef
+TARGET_DEVICES += dlink_dwr-961-a1
+
 define Device/domywifi_dm202
   SOC := mt7620a
   IMAGE_SIZE := 16064k
diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds
index 1f53930311..5f105bd834 100644
--- a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds
@@ -81,6 +81,10 @@ dlink,dwr-960)
 	ucidef_set_led_switch "lan" "lan" "green:lan" "switch0" "0x2e"
 	ucidef_set_led_switch "wan" "wan" "green:wan" "switch0" "0x01"
 	;;
+dlink,dwr-961-a1)
+	ucidef_set_led_switch "lan" "lan" "green:lan" "switch0" "0x3c"
+	ucidef_set_led_switch "wan" "wan" "green:wan" "switch0" "0x02"
+	;;
 domywifi,dm202|\
 domywifi,dm203|\
 domywifi,dw22d)
diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
index 47bd02f3d1..3ed72fa3ab 100644
--- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
@@ -130,6 +130,13 @@ ramips_setup_interfaces()
 		ucidef_add_switch "switch0" \
 			"1:lan" "2:lan" "3:lan" "5:lan" "0:wan" "6 at eth0"
 		;;
+	dlink,dwr-961-a1)
+		ucidef_add_switch "switch0" \
+			"2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan" "0 at eth0"
+		ucidef_add_switch "switch1" \
+			"5:lan" "6 at eth0"
+		ucidef_add_switch_attr "switch1" "enable" "false"
+		;;
 	edimax,br-6478ac-v2|\
 	lb-link,bl-w1200|\
 	tplink,archer-c2-v1)
@@ -303,6 +310,7 @@ ramips_setup_macs()
 	dlink,dwr-921-c1|\
 	dlink,dwr-922-e2|\
 	dlink,dwr-960|\
+	dlink,dwr-961-a1|\
 	lava,lr-25g001)
 		wan_mac=$(jboot_config_read -m -i $(find_mtd_part "config") -o 0xE000)
 		lan_mac=$(macaddr_add "$wan_mac" 1)
diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/03_gpio_switches b/target/linux/ramips/mt7620/base-files/etc/board.d/03_gpio_switches
index 969e9eba63..81daca4978 100644
--- a/target/linux/ramips/mt7620/base-files/etc/board.d/03_gpio_switches
+++ b/target/linux/ramips/mt7620/base-files/etc/board.d/03_gpio_switches
@@ -10,7 +10,8 @@ dlink,dir-510l)
 	ucidef_add_gpio_switch "usb_enable1" "USB 1A enable" "12" "0"
 	ucidef_add_gpio_switch "usb_enable05" "USB 0.5A enable" "13" "1"
 	;;
-dlink,dwr-960)
+dlink,dwr-960|\
+dlink,dwr-961-a1)
 	ucidef_add_gpio_switch "power_mpcie" "mPCIe power" "0" "1"
 	;;
 head-weblink,hdrm200)
diff --git a/target/linux/ramips/mt7620/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom b/target/linux/ramips/mt7620/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
index 291f89f41d..2d1ac2e872 100644
--- a/target/linux/ramips/mt7620/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
+++ b/target/linux/ramips/mt7620/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
@@ -29,6 +29,7 @@ case "$FIRMWARE" in
 	dlink,dwr-921-c1|\
 	dlink,dwr-922-e2|\
 	dlink,dwr-960|\
+	dlink,dwr-961-a1|\
 	lava,lr-25g001)
 		wan_mac=$(jboot_config_read -m -i $(find_mtd_part "config") -o 0xE000)
 		wifi_mac=$(macaddr_add "$wan_mac" 1)




More information about the lede-commits mailing list