Skip to content

Commit

Permalink
ramips: improve ac2100/dir882 support (coolsnowwolf#5136)
Browse files Browse the repository at this point in the history
  • Loading branch information
aiamadeus committed Jul 19, 2020
1 parent fb7752d commit 1e8536f
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 70 deletions.
40 changes: 40 additions & 0 deletions target/linux/ramips/dts/mt7621_dlink_dir-867-a1.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;

#include "mt7621_dlink_dir-8xx-a1.dtsi"

/ {
compatible = "dlink,dir-867-a1", "mediatek,mt7621-soc";
model = "D-Link DIR-867 A1";

aliases {
led-boot = &led_power_orange;
led-failsafe = &led_power_green;
led-running = &led_power_green;
led-upgrade = &led_net_orange;
};

leds {
compatible = "gpio-leds";

led_power_orange: power_orange {
label = "dir-867-a1:orange:power";
gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
};

led_power_green: power_green {
label = "dir-867-a1:green:power";
gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
};

led_net_orange: net_orange {
label = "dir-867-a1:orange:net";
gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
};

net_green {
label = "dir-867-a1:green:net";
gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
};
};
};
16 changes: 10 additions & 6 deletions target/linux/ramips/dts/mt7621_dlink_dir-878-a1.dts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;

#include "mt7621_dlink_dir.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include "mt7621_dlink_dir-8xx-a1.dtsi"

/ {
compatible = "dlink,dlink-dir878-a1", "mediatek,mt7621-soc";
model = "D-Link DIR878 A1";
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;
};

leds {
compatible = "gpio-leds";
Expand Down
29 changes: 20 additions & 9 deletions target/linux/ramips/dts/mt7621_dlink_dir-882-a1.dts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;

#include "mt7621_dlink_dir.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include "mt7621_dlink_dir-8xx-a1.dtsi"

/ {
compatible = "dlink,dlink-dir882-a1", "mediatek,mt7621-soc";
model = "D-Link DIR882 A1";
compatible = "dlink,dir-882-a1", "mediatek,mt7621-soc";
model = "D-Link DIR-882 A1";

aliases {
led-boot = &led_power_orange;
led-failsafe = &led_power_green;
led-running = &led_power_green;
led-upgrade = &led_net_orange;
};

leds {
compatible = "gpio-leds";
Expand All @@ -33,10 +37,17 @@
gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
};

usb {
label = "dir-882-a1:green:usb";
usb2 {
label = "dir-882-a1:green:usb2";
gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
trigger-sources = <&ehci_port2>;
linux,default-trigger = "usbport";
};

usb3 {
label = "dir-882-a1:green:usb3";
gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
trigger-sources = <&xhci_ehci_port1>, <&ehci_port2>;
trigger-sources = <&xhci_ehci_port1>;
linux,default-trigger = "usbport";
};
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;

#include "mt7621.dtsi"

Expand All @@ -8,10 +7,6 @@

/ {
aliases {
led-boot = &led_power_orange;
led-failsafe = &led_power_orange;
led-running = &led_power_green;
led-upgrade = &led_power_green;
label-mac-device = &gmac0;
};

Expand Down Expand Up @@ -48,7 +43,7 @@
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <10000000>;
spi-max-frequency = <50000000>;

partitions {
compatible = "fixed-partitions";
Expand Down
12 changes: 8 additions & 4 deletions target/linux/ramips/dts/mt7621_motorola_mr2600.dts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;

#include "mt7621_dlink_dir.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include "mt7621_dlink_dir-8xx-a1.dtsi"

/ {
compatible = "motorola,motorola-mr2600", "mediatek,mt7621-soc";
model = "Motorola MR2600";

aliases {
led-boot = &led_power_orange;
led-failsafe = &led_power_green;
led-running = &led_power_green;
led-upgrade = &led_net_orange;
};

leds {
compatible = "gpio-leds";

Expand Down
27 changes: 9 additions & 18 deletions target/linux/ramips/dts/mt7621_xiaomi_mir3g.dts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
led-failsafe = &led_status_red;
led-running = &led_status_blue;
led-upgrade = &led_status_yellow;
label-mac-device = &gmac0;
label-mac-device = &ethernet;
};

chosen {
Expand Down Expand Up @@ -190,28 +190,19 @@
};
};

&gmac0 {
&ethernet {
compatible = "mediatek,ralink-mt7621-eth";
mediatek,switch = <&gsw>;
mtd-mac-address = <&factory 0xe006>;
};

&switch0 {
ports {
port@1 {
status = "okay";
label = "wan";
mtd-mac-address = <&factory 0xe000>;
};

port@2 {
status = "okay";
label = "lan2";
};
/delete-property/ compatible;
phy-mode = "rgmii";
};

port@3 {
status = "okay";
label = "lan1";
};
};
&gsw {
compatible = "mediatek,ralink-mt7621-gsw";
};

&state_default {
Expand Down
2 changes: 0 additions & 2 deletions target/linux/ramips/dts/mt7621_xiaomi_router-ac2100.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <dt-bindings/input/input.h>

/ {

chosen {
bootargs = "console=ttyS0,115200n8";
};
Expand All @@ -33,7 +32,6 @@
partition@0 {
label = "Bootloader";
reg = <0x0 0x80000>;
read-only;
};

partition@80000 {
Expand Down
48 changes: 26 additions & 22 deletions target/linux/ramips/image/mt7621.mk
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ define Device/buffalo_wsr-600dhp
endef
TARGET_DEVICES += buffalo_wsr-600dhp

define Device/dlink_dir-8xx-a1
IMAGE_SIZE := 16000k
DEVICE_VENDOR := D-Link
DEVICE_PACKAGES := kmod-mt7615d luci-app-mtwifi uboot-envtools
endef

define Device/dlink_dir-860l-b1
$(Device/seama)
BLOCKSIZE := 64k
Expand All @@ -228,22 +234,25 @@ define Device/dlink_dir-860l-b1
endef
TARGET_DEVICES += dlink_dir-860l-b1

define Device/dlink_dir-867-a1
$(Device/dlink_dir-8xx-a1)
DEVICE_MODEL := DIR-867
DEVICE_VARIANT := A1
endef
TARGET_DEVICES += dlink_dir-867-a1

define Device/dlink_dir-878-a1
IMAGE_SIZE := 16064k
DEVICE_VENDOR := D-Link
$(Device/dlink_dir-8xx-a1)
DEVICE_MODEL := DIR-878
DEVICE_VARIANT := A1
DEVICE_PACKAGES := kmod-mt7615d luci-app-mtwifi uboot-envtools
endef
TARGET_DEVICES += dlink_dir-878-a1

define Device/dlink_dir-882-a1
IMAGE_SIZE := 16064k
DEVICE_VENDOR := D-Link
$(Device/dlink_dir-8xx-a1)
DEVICE_MODEL := DIR-882
DEVICE_VARIANT := A1
DEVICE_PACKAGES := kmod-mt7615d kmod-usb3 kmod-usb-ledtrig-usbport \
luci-app-mtwifi uboot-envtools
DEVICE_PACKAGES += kmod-usb3 kmod-usb-ledtrig-usbport
endef
TARGET_DEVICES += dlink_dir-882-a1

Expand Down Expand Up @@ -1032,36 +1041,31 @@ define Device/xiaomi_mir4
endef
TARGET_DEVICES += xiaomi_mir4

define Device/xiaomi_mi-router-ac2100
define Device/xiaomi-ac2100
$(Device/uimage-lzma-loader)
BLOCKSIZE := 128k
PAGESIZE := 2048
KERNEL_SIZE := 4096k
IMAGE_SIZE := 120320k
UBINIZE_OPTS := -E 5
IMAGES += kernel1.bin rootfs0.bin
IMAGES += kernel1.bin rootfs0.bin factory.bin
IMAGE/kernel1.bin := append-kernel
IMAGE/rootfs0.bin := append-ubi | check-size
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | check-size
DEVICE_VENDOR := Xiaomi
DEVICE_MODEL := Mi Router AC2100
DEVICE_PACKAGES := kmod-mt7603e kmod-mt7615d luci-app-mtwifi uboot-envtools
endef

define Device/xiaomi_mi-router-ac2100
$(Device/xiaomi-ac2100)
DEVICE_MODEL := Mi Router AC2100
endef
TARGET_DEVICES += xiaomi_mi-router-ac2100

define Device/xiaomi_redmi-router-ac2100
BLOCKSIZE := 128k
PAGESIZE := 2048
KERNEL_SIZE := 4096k
IMAGE_SIZE := 120320k
UBINIZE_OPTS := -E 5
IMAGES += kernel1.bin rootfs0.bin factory.bin
IMAGE/kernel1.bin := append-kernel
IMAGE/rootfs0.bin := append-ubi | check-size
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | check-size $$$$(IMAGE_SIZE)
DEVICE_VENDOR := Xiaomi
$(Device/xiaomi-ac2100)
DEVICE_MODEL := Redmi Router AC2100
DEVICE_PACKAGES := kmod-mt7603e kmod-mt7615d luci-app-mtwifi uboot-envtools
endef
TARGET_DEVICES += xiaomi_redmi-router-ac2100

Expand Down
10 changes: 8 additions & 2 deletions target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ d-team,pbr-m1)
dlink,dir-860l-b1)
ucidef_set_led_netdev "wan" "wan" "$boardname:green:net" "wan"
;;
dlink,dir-867-a1|\
dlink,dir-878-a1|\
dlink,dir-882-a1|\
motorola,mr2600)
Expand Down Expand Up @@ -84,15 +85,20 @@ tplink,re650-v1)
ucidef_set_led_netdev "eth_act" "LAN act" "$boardname:green:eth_act" "lan" "tx rx"
ucidef_set_led_netdev "eth_link" "LAN link" "$boardname:green:eth_link" "lan" "link"
;;
xzwifi,creativebox-v1)
ucidef_set_led_netdev "internet" "internet" "$boardname:blue:internet" "wan"
xiaomi,mir3g)
ucidef_set_led_switch "wan-amber" "WAN (amber)" "$boardname:amber:wan" "switch0" "0x02" "0x08"
ucidef_set_led_switch "lan1-amber" "LAN1 (amber)" "$boardname:amber:lan1" "switch0" "0x08" "0x08"
ucidef_set_led_switch "lan2-amber" "LAN2 (amber)" "$boardname:amber:lan2" "switch0" "0x04" "0x08"
;;
xiaomi,mi-router-ac2100)
ucidef_set_led_switch "wan" "wan" "$boardname:blue:wan" "switch0" "0x1"
;;
xiaomi,redmi-router-ac2100)
ucidef_set_led_switch "wan" "wan" "$boardname:white:wan" "switch0" "0x1"
;;
xzwifi,creativebox-v1)
ucidef_set_led_netdev "internet" "internet" "$boardname:blue:internet" "wan"
;;
youhua,wr1200js)
ucidef_set_led_netdev "internet" "INTERNET" "$boardname:green:wan" "wan"
;;
Expand Down
11 changes: 10 additions & 1 deletion target/linux/ramips/mt7621/base-files/etc/board.d/02_network
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ramips_setup_interfaces()
ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan"
;;
netgear,r6850|\
dlink,dir-867-a1|\
dlink,dir-878-a1|\
dlink,dir-882-a1|\
motorola,mr2600)
Expand All @@ -70,11 +71,15 @@ ramips_setup_interfaces()
ubnt,edgerouter-x-sfp)
ucidef_set_interface_lan_wan "eth1 eth2 eth3 eth4 eth5" "eth0"
;;
xiaomi,mir3g)
ucidef_add_switch "switch0" \
"2:lan:2" "3:lan:1" "1:wan" "6t@eth0"
;;
xiaomi,mi-router-ac2100|\
xiaomi,redmi-router-ac2100)
ucidef_add_switch "switch0" \
"0:wan" "2:lan:1" "3:lan:2" "4:lan:3" "6@eth0"
ucidef_set_interface_lan "eth0.1 ra0 rai0 apcli0 apclii0"
ucidef_set_interface_lan "eth0.2 ra0 rai0 apcli0 apclii0"
;;
*)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
Expand Down Expand Up @@ -139,6 +144,10 @@ ramips_setup_macs()
wan_mac=$label_mac
lan_mac=$(macaddr_add $label_mac 1)
;;
phicomm,k2p)
wan_mac=$(mtd_get_mac_binary factory 0xe006)
;;
xiaomi,mir3g|\
xiaomi,mi-router-ac2100|\
xiaomi,redmi-router-ac2100)
lan_mac=$(cat /sys/class/net/eth0/address)
Expand Down

0 comments on commit 1e8536f

Please sign in to comment.