diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c index a6e50b5113..221e3a7ec1 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c @@ -423,6 +423,47 @@ static struct mtd_part_parser uimage_fonfxc_parser = { .parse_fn = mtdsplit_uimage_parse_fonfxc, }; +/************************************************** + * ubootpad96 + **************************************************/ + +#define ubootpad96_PAD_LEN 96 + +static ssize_t uimage_find_ubootpad96(u_char *buf, size_t len, int *extralen) +{ + if (uimage_verify_default(buf, len, extralen) < 0) + return -EINVAL; + + *extralen = ubootpad96_PAD_LEN; + + return 0; +} + +static int +mtdsplit_uimage_parse_ubootpad96(struct mtd_info *master, + const struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +{ + return __mtdsplit_parse_uimage(master, pparts, data, + uimage_find_ubootpad96); +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) +static const struct of_device_id mtdsplit_uimage_ubootpad96_of_match_table[] = { + { .compatible = "ubootpad96,uimage" }, + {}, +}; +#endif + +static struct mtd_part_parser uimage_ubootpad96_parser = { + .owner = THIS_MODULE, + .name = "ubootpad96-fw", +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) + .of_match_table = mtdsplit_uimage_ubootpad96_of_match_table, +#endif + .parse_fn = mtdsplit_uimage_parse_ubootpad96, +}; + /************************************************** * OKLI (OpenWrt Kernel Loader Image) **************************************************/ @@ -490,6 +531,7 @@ static int __init mtdsplit_uimage_init(void) register_mtd_parser(&uimage_netgear_parser); register_mtd_parser(&uimage_edimax_parser); register_mtd_parser(&uimage_fonfxc_parser); + register_mtd_parser(&uimage_ubootpad96_parser); register_mtd_parser(&uimage_okli_parser); return 0; diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-878-a1.dts b/target/linux/ramips/dts/mt7621_dlink_dir-878-a1.dts new file mode 100755 index 0000000000..b86291cab9 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_dlink_dir-878-a1.dts @@ -0,0 +1,153 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "dlink,dir-878-a1", "mediatek,mt7621-soc"; + model = "D-Link DIR-878 A1"; + + aliases { + led-boot = &led_power_orange; + led-failsafe = &led_power_green; + led-running = &led_power_green; + led-upgrade = &led_net_orange; + label-mac-device = ðernet; + }; + + chosen { + bootargs = "console=ttyS0,57600"; + }; + + leds { + compatible = "gpio-leds"; + + led_power_orange: power_orange { + label = "dir-878-a1:orange:power"; + gpios = <&gpio0 8 GPIO_ACTIVE_LOW>; + }; + + led_power_green: power_green { + label = "dir-878-a1:green:power"; + gpios = <&gpio0 16 GPIO_ACTIVE_LOW>; + }; + + led_net_orange: net_orange { + label = "dir-878-a1:orange:net"; + gpios = <&gpio0 4 GPIO_ACTIVE_LOW>; + }; + + net_green { + label = "dir-878-a1:green:net"; + gpios = <&gpio0 3 GPIO_ACTIVE_LOW>; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio0 15 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio0 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wifi { + label = "wifi"; + gpios = <&gpio0 7 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + m25p,fast-read; + + 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; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x20000>; + read-only; + }; + + partition@60000 { + compatible = "ubootpad96,uimage"; + label = "firmware"; + reg = <0x60000 0xfa0000>; + }; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0000>; + ieee80211-freq-limit = <2400000 2500000>; + + led { + led-active-low; + }; + }; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + + led { + led-active-low; + }; + }; +}; + +ðernet { + mtd-mac-address = <&factory 0xe000>; + mediatek,portmap = "llllw"; +}; + +&state_default { + gpio { + ralink,group = "i2c", "uart3", "jtag", "wdt"; + ralink,function = "gpio"; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index f41457da9d..9a5536750b 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -87,6 +87,11 @@ define Build/netis-tail sed 's/../\\\\x&/g' | xargs echo -ne >> $@ endef +define Build/ubootpad96 + uimage_padhdr -i $@ -o $@.new -l 96 + mv $@.new $@ +endef + define Build/ubnt-erx-factory-image if [ -e $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE) -a "$$(stat -c%s $@)" -lt "$(KERNEL_SIZE)" ]; then \ echo '21001:6' > $(1).compat; \ @@ -220,6 +225,22 @@ define Device/dlink_dir-860l-b1 endef TARGET_DEVICES += dlink_dir-860l-b1 +define Device/dlink_dir-878-a1 + BLOCKSIZE := 64k + IMAGE_SIZE := 16000k + DEVICE_VENDOR := D-Link + IMAGES += factory.bin + DEVICE_MODEL := DIR-878 + DEVICE_VARIANT := A1 + DEVICE_PACKAGES := kmod-mt7615e wpad-basic + KERNEL_INITRAMFS := $$(KERNEL) | ubootpad96 + IMAGE/sysupgrade.bin := append-kernel | append-rootfs | ubootpad96 |\ + pad-rootfs | check-size $$$$(IMAGE_SIZE) | append-metadata + IMAGE/factory.bin := append-kernel | append-rootfs | ubootpad96 |\ + check-size $$$$(IMAGE_SIZE) +endef +TARGET_DEVICES += dlink_dir-878-a1 + define Device/d-team_newifi-d2 IMAGE_SIZE := 32448k DEVICE_VENDOR := Newifi 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 ac73729d1b..f0cc846631 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -29,6 +29,10 @@ gehua,ghl-r-001) dlink,dir-860l-b1) ucidef_set_led_netdev "wan" "wan" "$boardname:green:net" "eth0.2" ;; +dlink,dir-878-a1) + ucidef_set_led_switch "wan-green" "WAN 1Ghz" "$boardname:green:net" "switch0" "0x10" "0x08" + ucidef_set_led_switch "wan-orange" "WAN 10/100Mhz" "$boardname:orange:net" "switch0" "0x10" "0x06" + ;; gnubee,gb-pc1|\ gnubee,gb-pc2) ucidef_set_led_switch "lan1" "lan1" "$boardname:green:lan1" "switch0" "0x01" diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index 58605aca70..e6b1d6a716 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -90,6 +90,7 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:wan:5" "6@eth0" ;; + dlink,dir-878-a1|\ d-team,newifi-d2) ucidef_add_switch "switch0" \ "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan:5" "6@eth0" @@ -181,6 +182,7 @@ ramips_setup_macs() ;; alfa-network,quad-e4g|\ asus,rt-ac57u|\ + dlink,dir-878-a1|\ d-team,newifi-d2|\ d-team,pbr-m1|\ elecom,wrc-1167ghbk2-s|\