ramips: add work-in-progress support for D-Link DIR-X1860
authorFelix Fietkau <nbd@nbd.name>
Tue, 12 Jan 2021 13:20:05 +0000 (14:20 +0100)
committerFelix Fietkau <nbd@nbd.name>
Fri, 19 Apr 2024 16:02:49 +0000 (18:02 +0200)
Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/boot/uboot-envtools/files/ramips
target/linux/ramips/dts/mt7621_dlink_dir-x1860.dts [new file with mode: 0644]
target/linux/ramips/image/mt7621.mk
target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
target/linux/ramips/mt7621/base-files/etc/board.d/02_network
target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh

index 317121f2beae8371f41537a5e7dc7447f525a857..177555f042102ece310d88ba99c7b97ffa367c5d 100644 (file)
@@ -86,6 +86,9 @@ sim,simax1800t)
        ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
        ubootenv_add_uci_sys_config "/dev/mtd1" "0x40000" "0x40000" "0x20000"
        ;;
+dlink,dir-x1860)
+       ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x2000" "0x20000"
+       ;;
 hootoo,ht-tm05|\
 ravpower,rp-wd03)
        idx="$(find_mtd_index u-boot-env)"
diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-x1860.dts b/target/linux/ramips/dts/mt7621_dlink_dir-x1860.dts
new file mode 100644 (file)
index 0000000..f481c94
--- /dev/null
@@ -0,0 +1,165 @@
+/dts-v1/;
+
+#include "mt7621.dtsi"
+#include <dt-bindings/input/input.h>
+
+/ {
+       compatible = "dlink,dir-x1860", "mediatek,mt7621-soc";
+       model = "DLink DIR-X1860";
+
+       chosen {
+               bootargs-override = "console=ttyS0,115200";
+       };
+
+       aliases {
+               label-mac-device = &gmac0;
+               led-boot = &led_power_orange;
+               led-failsafe = &led_power_white;
+               led-running = &led_power_white;
+               led-upgrade = &led_net_orange;
+       };
+
+       gpio-leds {
+               compatible = "gpio-leds";
+
+               led_power_white: power_white {
+                       label = "white:power";
+                       gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
+               };
+
+               led_net_orange: net_orange {
+                       label = "orange:net";
+                       gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
+               };
+
+               led_power_orange: power_orange {
+                       label = "orange:power";
+                       gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
+               };
+
+               led_net_white {
+                       label = "white:net";
+                       gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       keys {
+               compatible = "gpio-keys";
+
+               reset {
+                       label = "reset";
+                       gpios = <&gpio 6 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RESTART>;
+               };
+
+               wps {
+                       label = "wps";
+                       linux,code = <KEY_WPS_BUTTON>;
+                       gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
+               };
+       };
+};
+
+&mdio {
+       phy4: ethernet-phy@4 {
+               reg = <4>;
+       };
+};
+
+&gmac1 {
+       status = "okay";
+       phy-handle = <&phy4>;
+};
+
+&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";
+               };
+       };
+};
+
+&nand {
+       status = "okay";
+
+       partitions {
+               compatible = "fixed-partitions";
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               partition@0 {
+                       label = "u-boot";
+                       reg = <0x00000 0x80000>;
+                       read-only;
+               };
+
+               partition@80000 {
+                       label = "u-boot-env";
+                       reg = <0x80000 0x80000>;
+               };
+
+               factory: partition@100000 {
+                       label = "factory";
+                       reg = <0x100000 0x80000>;
+               };
+
+               partition@180000 {
+                       label = "kernel";
+                       reg = <0x180000 0x400000>;
+               };
+
+               partition@580000 {
+                       label = "ubi";
+                       reg = <0x580000 0x2b00000>;
+               };
+
+               partition@2c80000 {
+                       label = "firmware2";
+                       reg = <0x2c80000 0x2b00000>;
+               };
+
+               partition@5780000 {
+                       label = "Devdata";
+                       reg = <0x5780000 0x800000>;
+               };
+
+               partition@5f80000 {
+                       label = "User_data";
+                       reg = <0x5f80000 0x2000000>;
+               };
+       };
+};
+
+&state_default {
+       gpio {
+               groups = "i2c", "uart3", "jtag", "wdt";
+               function = "gpio";
+       };
+};
+
+&pcie {
+       status = "okay";
+};
+
+&pcie1 {
+       mt76@0,0 {
+               reg = <0x0000 0 0 0 0>;
+               mediatek,mtd-eeprom = <&factory 0x0000>;
+       };
+};
index 10e78576140f10f3090018b77b589ed25d81a40e..41dc85d8b3110a8166bca52b02a9252ea82157c3 100644 (file)
@@ -9,6 +9,23 @@ DEFAULT_SOC := mt7621
 
 DEVICE_VARS += ELECOM_HWNAME LINKSYS_HWNAME DLINK_HWID
 
+RELOCATE_LOADADDR = 0x81000000
+
+define Build/uImage-relocate
+       mkimage \
+               -A $(LINUX_KARCH) \
+               -O linux \
+               -T kernel \
+               -C $(word 1,$(1)) \
+               -a $(RELOCATE_LOADADDR) \
+               -e $(RELOCATE_LOADADDR) \
+               -n '$(if $(UIMAGE_NAME),$(UIMAGE_NAME),$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION))' \
+               $(if $(UIMAGE_MAGIC),-M $(UIMAGE_MAGIC)) \
+               $(wordlist 2,$(words $(1)),$(1)) \
+               -d $@ $@.new
+       mv $@.new $@
+endef
+
 define Build/append-dlink-covr-metadata
        echo -ne '{"supported_devices": "$(1)", "firmware": "' > $@metadata.tmp
        $(MKHASH) md5 "$@" | head -c32 >> $@metadata.tmp
@@ -881,6 +898,24 @@ define Device/dlink_dir-882-r1
 endef
 TARGET_DEVICES += dlink_dir-882-r1
 
+define Device/dlink_dir-x1860
+  $(Device/dsa-migration)
+  DEVICE_VENDOR := D-Link
+  DEVICE_MODEL := DIR-X1860
+  DEVICE_PACKAGES += kmod-mt7915e uboot-envtools
+  BLOCKSIZE := 128k
+  PAGESIZE := 2048
+  KERNEL_SIZE := 4096k
+  UBINIZE_OPTS := -E 5
+  KERNEL := kernel-bin | append-dtb | relocate-kernel | lzma | uImage-relocate lzma
+  IMAGES += factory.bin
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+  IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
+       check-size
+  IMAGE_SIZE := 40960k
+endef
+TARGET_DEVICES += dlink_dir-x1860
+
 define Device/dlink_dra-1360-a1
   $(Device/dlink_dxx-1xx0-x1)
   DEVICE_MODEL := DRA-1360
index 6848bebd0010cc1869c13c45227144bb5bffa68b..2ced73edfa231a690061d2d5abbe6db24b5cf21c 100644 (file)
@@ -116,6 +116,10 @@ dlink,dir-882-a1|\
 dlink,dir-882-r1)
        ucidef_set_led_netdev "wan" "wan" "green:net" "wan"
        ;;
+dlink,dir-x1860)
+       ucidef_set_led_netdev "lan" "LAN Link" "orange:net" "eth0"
+       ucidef_set_led_netdev "wan" "WAN Link" "white:net" "eth1"
+       ;;
 gnubee,gb-pc2)
        ucidef_set_led_netdev "ethyellow" "ethyellow" "orange:ethyellow" "ethyellow" "link tx rx"
        ;;
index d932313cf1686da4066d6ff9f1bb695cb21774b2..bdd0d0d4db0a1ed0317d8460212b2eaf8c2b0768 100644 (file)
@@ -102,6 +102,9 @@ ramips_setup_interfaces()
        dlink,covr-x1860-a1)
                ucidef_set_interfaces_lan_wan "ethernet" "internet"
                ;;
+       dlink,dir-x1860)
+               ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "eth1"
+               ;;
        gnubee,gb-pc1)
                ucidef_set_interface_lan "ethblack ethblue"
                ;;
@@ -232,6 +235,11 @@ ramips_setup_macs()
                lan_mac=$(mtd_get_mac_ascii factory lanmac)
                wan_mac=$(mtd_get_mac_ascii factory wanmac)
                ;;
+       dlink,dir-x1860)
+               lan_mac=$(mtd_get_mac_ascii u-boot-env lanmac)
+               label_mac=$lan_mac
+               wan_mac=$(macaddr_add "$lan_mac" 1)
+               ;;
        edimax,ra21s|\
        edimax,rg21s)
                lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
index 93fbc470ad58e02187c79b82c5e1aae81d46e5f2..5e26f37b65b2987d2b146a4b110645eb08aae9d1 100755 (executable)
@@ -77,6 +77,7 @@ platform_do_upgrade() {
        dlink,dir-3060-a1|\
        dlink,dir-853-a3|\
        etisalat,s3|\
+       dlink,dir-x1860|\
        h3c,tx1800-plus|\
        h3c,tx1801-plus|\
        h3c,tx1806|\