Skip to content

Commit

Permalink
添加对红米路由器AC2100的支持
Browse files Browse the repository at this point in the history
  • Loading branch information
soikjk committed May 7, 2020
1 parent 37d78d7 commit a2cb0df
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 2 deletions.
3 changes: 3 additions & 0 deletions target/linux/ramips/base-files/etc/board.d/01_leds
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ xiaomi,mir3p)
ucidef_set_led_switch "lan2-amber" "LAN2 (amber)" "$boardname:amber:lan2" "switch0" "0x04" "0x08"
ucidef_set_led_switch "lan3-amber" "LAN3 (amber)" "$boardname:amber:lan3" "switch0" "0x08" "0x08"
;;
xiaomi,rm2100)
ucidef_set_led_netdev "internet" "internet" "$boardname:blue:internet" "eth0.2"
;;
xzwifi,creativebox-v1)
ucidef_set_led_switch "internet" "internet" "$boardname:blue:internet" "switch0" "0x10"
;;
Expand Down
7 changes: 6 additions & 1 deletion target/linux/ramips/base-files/etc/board.d/02_network
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ ramips_setup_interfaces()
ucidef_add_switch "switch0" \
"4:lan:1" "2:lan:2" "0:wan" "6@eth0"
;;
xiaomi,rm2100)
ucidef_add_switch "switch0" \
"2:lan:1" "3:lan:2" "4:lan:3" "0:wan" "6@eth0"
;;
zbtlink,zbt-we1226|\
y1)
ucidef_add_switch "switch0" \
Expand Down Expand Up @@ -689,7 +693,8 @@ ramips_setup_macs()
;;
xiaomi,mir3g|\
xiaomi,mir3p|\
xiaomi,mir4)
xiaomi,mir4|\
xiaomi,rm2100)
lan_mac=$(mtd_get_mac_binary Factory 0xe006)
;;
zyxel,keenetic-start)
Expand Down
3 changes: 2 additions & 1 deletion target/linux/ramips/base-files/lib/upgrade/platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ platform_do_upgrade() {
ubnt-erx-sfp|\
xiaomi,mir3g|\
xiaomi,mir3p|\
xiaomi,mir4)
xiaomi,mir4|\
xiaomi,rm2100)
nand_do_upgrade "$1"
;;
tplink,c50-v4)
Expand Down
185 changes: 185 additions & 0 deletions target/linux/ramips/dts/MIRM2100.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;

#include "mt7621.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/ {
compatible = "xiaomi,rm2100", "mediatek,mt7621-soc";
model = "Xiaomi RedMi Router AC2100";

aliases {
led-boot = &system_status_amber;
led-failsafe = &system_status_amber;
led-running = &system_status_blue;
led-upgrade = &system_status_blue;
};

memory@0 {
device_type = "memory";
reg = <0x0 0x8000000>;
};

chosen {
bootargs = "console=ttyS0,115200n8";
};

leds {
compatible = "gpio-leds";

system_status_amber: status_amber {
label = "rm2100:amber:status";
gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
};

system_status_blue: status_blue {
label = "rm2100:blue:status";
gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
};

internet_amber {
label = "rm2100:amber:internet";
gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
};

internet_blue {
label = "rm2100:blue:internet";
gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
};
};

button {
compatible = "gpio-keys-polled";
poll-interval = <20>;

reset {
label = "reset";
gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
};
};

&nand {
status = "okay";

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

partition@0 {
label = "Bootloader";
reg = <0x0 0x80000>;
read-only;
};

partition@80000 {
label = "Config";
reg = <0x80000 0x40000>;
};

partition@c0000 {
label = "Bdata";
reg = <0xc0000 0x40000>;
read-only;
};

factory: partition@100000 {
label = "Factory";
reg = <0x100000 0x40000>;
read-only;
};

partition@140000 {
label = "crash";
reg = <0x140000 0x40000>;
};

partition@180000 {
label = "crash_syslog";
reg = <0x180000 0x40000>;
};

partition@1c0000 {
label = "reserved0";
reg = <0x1c0000 0x40000>;
read-only;
};

/* uboot expects to find kernels at 0x200000 & 0x600000
* referred to as system 1 & system 2 respectively.
* a kernel is considered suitable for handing control over
* if its linux magic number exists & uImage CRC are correct.
* If either of those conditions fail, a matching sys'n'_fail flag
* is set in uboot env & a restart performed in the hope that the
* alternate kernel is okay.
* if neither kernel checksums ok and both are marked failed, system 2
* is booted anyway.
*
* Note uboot's tftp flash install writes the transferred
* image to both kernel partitions.
*/

partition@200000 {
label = "kernel_stock";
reg = <0x200000 0x400000>;
};

partition@600000 {
label = "kernel";
reg = <0x600000 0x400000>;
};

/* ubi partition is the result of squashing
* next consecutive stock partitions:
* - rootfs0 (rootfs partition for stock kernel0),
* - rootfs1 (rootfs partition for stock failsafe kernel1),
* - overlay (used as ubi overlay in stock fw)
* resulting 117,5MiB space for packages.
*/

partition@a00000 {
label = "ubi";
reg = <0xa00000 0x7580000>;
};
};
};

&pcie {
status = "okay";
};

&pcie0 {
wifi@0,0 {
compatible = "mediatek,mt76";
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&factory 0x8000>;
ieee80211-freq-limit = <5000000 6000000>;
};
};

&pcie1 {
wifi@0,0 {
compatible = "mediatek,mt76";
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&factory 0x0000>;
ieee80211-freq-limit = <2400000 2500000>;
};
};

&ethernet {
mtd-mac-address = <&factory 0xe000>;
mediatek,portmap = "wllll";
};

&pinctrl {
state_default: pinctrl0 {
gpio {
ralink,group = "jtag", "uart2", "uart3", "wdt";
ralink,function = "gpio";
};
};
};
17 changes: 17 additions & 0 deletions target/linux/ramips/image/mt7621.mk
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,23 @@ define Device/xiaomi_mir4
endef
TARGET_DEVICES += xiaomi_mir4

define Device/xiaomi_rm2100
DTS := MIRM2100
BLOCKSIZE := 128k
PAGESIZE := 2048
KERNEL_SIZE := 4096k
IMAGE_SIZE := 32768k
UBINIZE_OPTS := -E 5
BOARD_NAME := rm2100
IMAGES += kernel1.bin rootfs0.bin
IMAGE/kernel1.bin := append-kernel
IMAGE/rootfs0.bin := append-ubi | check-size $$$$(IMAGE_SIZE)
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
DEVICE_TITLE := Xiaomi RedMi Router AC2100
DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e wpad-basic uboot-envtools
endef
TARGET_DEVICES += xiaomi_rm2100

define Device/mt7621
DTS := MT7621
BLOCKSIZE := 64k
Expand Down

0 comments on commit a2cb0df

Please sign in to comment.