From 87f0b29a20370e2d49939b94bb155063b3abbe95 Mon Sep 17 00:00:00 2001 From: lean Date: Tue, 27 Apr 2021 22:58:52 +0800 Subject: [PATCH] ramips: add support for Xiaomi Mi Router CR660x series --- package/boot/uboot-envtools/files/ramips | 3 + .../dts/mt7621_xiaomi_mi-router-cr6606.dts | 187 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 27 +++ .../mt7621/base-files/etc/board.d/01_leds | 3 + .../mt7621/base-files/etc/board.d/02_network | 1 + .../mt7621/base-files/lib/upgrade/platform.sh | 1 + 6 files changed, 222 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_xiaomi_mi-router-cr6606.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index cb2e3da28..0ea78f126 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -51,6 +51,9 @@ xiaomi,mi-router-ac2100|\ xiaomi,redmi-router-ac2100) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x20000" ;; +xiaomi,mi-router-cr6606) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x20000" + ;; esac config_load ubootenv diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-cr6606.dts b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-cr6606.dts new file mode 100644 index 000000000..896c0f6a2 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-cr6606.dts @@ -0,0 +1,187 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "xiaomi,mi-router-cr6606", "mediatek,mt7621-soc"; + model = "Xiaomi Mi Router CR6606"; + + aliases { + led-boot = &led_sys_yellow; + led-failsafe = &led_sys_yellow; + led-running = &led_sys_blue; + led-upgrade = &led_sys_yellow; + label-mac-device = &gmac0; + }; + + chosen { + bootargs = "console=ttyS0,115200n8"; + }; + + leds { + compatible = "gpio-leds"; + + led_sys_yellow: sys_yellow { + label = "yellow:sys"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + }; + + led_sys_blue: sys_blue { + label = "blue:sys"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + }; + + net_yellow { + label = "yellow:net"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + + net_blue { + label = "blue:net"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + }; + + keys: keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 7 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + linux,code = ; + }; + }; +}; + +&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 = "Nvram"; + reg = <0x80000 0x40000>; + read-only; + }; + + partition@c0000 { + label = "Bdata"; + reg = <0xc0000 0x40000>; + read-only; + }; + + factory: partition@100000 { + label = "Factory"; + reg = <0x100000 0x80000>; + read-only; + }; + + partition@180000 { + label = "crash"; + reg = <0x180000 0x40000>; + read-only; + }; + + partition@1c0000 { + label = "crash_log"; + reg = <0x1c0000 0x40000>; + read-only; + }; + + partition@200000 { + label = "firmware"; + compatible = "denx,uimage"; + reg = <0x200000 0x1e00000>; + }; + + partition@2000000 { + label = "firmware1"; + reg = <0x2000000 0x1e00000>; + }; + + partition@3e00000 { + label = "ubi"; + reg = <0x3e00000 0x3200000>; + }; + + partition@7000000 { + label = "obr"; + reg = <0x7000000 0x1000000>; + read-only; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + }; +}; + +&pcie2 { + wifi@0,0 { + reg = <0x0 0 0 0 0>; + }; +}; + +&gmac0 { + mtd-mac-address = <&factory 0x3fff4>; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "lan1"; + }; + + port@1 { + status = "okay"; + label = "lan2"; + }; + + port@2 { + status = "okay"; + label = "lan3"; + }; + + port@4 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0x3fffa>; + }; + }; +}; + +&state_default { + gpio { + groups = "jtag", "uart3", "wdt"; + function = "gpio"; + }; +}; \ No newline at end of file diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index e0f75377f..50a26024f 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -1093,6 +1093,33 @@ define Device/xiaomi_mi-router-ac2100 endef TARGET_DEVICES += xiaomi_mi-router-ac2100 +define Device/xiaomi_mi-router-cr6606 + $(Device/dsa-migration) + $(Device/uimage-lzma-loader) + DEVICE_VENDOR := Xiaomi + DEVICE_MODEL := Mi Router CR6606 + DEVICE_ALT0_VENDOR := Xiaomi + DEVICE_ALT0_MODEL := Mi Router CR6606 + DEVICE_ALT0_VARIANT := China Unicom + DEVICE_ALT1_VENDOR := Xiaomi + DEVICE_ALT1_MODEL := Mi Router CR6608 + DEVICE_ALT1_VARIANT := China Mobile + DEVICE_ALT2_VENDOR := Xiaomi + DEVICE_ALT2_MODEL := Mi Router CR6609 + DEVICE_ALT2_VARIANT := China Telecom + BLOCKSIZE := 128k + PAGESIZE := 2048 + UBINIZE_OPTS := -E 5 + IMAGE_SIZE := 51200k + IMAGES += firmware.bin overlay.bin + IMAGE/firmware.bin := append-kernel | pad-to 128k | append-rootfs | \ + pad-rootfs + IMAGE/overlay.bin := append-ubi | check-size + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + DEVICE_PACKAGES += uboot-envtools kmod-mt7915e +endef +TARGET_DEVICES += xiaomi_mi-router-cr6606 + define Device/xiaomi_redmi-router-ac2100 $(Device/xiaomi-ac2100) DEVICE_MODEL := Redmi Router AC2100 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 9391aad43..f7a64f1c3 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 @@ -94,6 +94,9 @@ xiaomi,mir3g) xiaomi,mi-router-ac2100) ucidef_set_led_switch "wan" "wan" "$boardname:blue:wan" "switch0" "0x1" ;; +xiaomi,mi-router-cr6606) + ucidef_set_led_netdev "internet" "internet" "blue:net" "wan" + ;; xiaomi,redmi-router-ac2100) ucidef_set_led_switch "wan" "wan" "$boardname:white:wan" "switch0" "0x1" ;; 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 5f1e371c1..b8e28e7e4 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_set_interface_lan "eth0.1 ra0 rai0" ;; xiaomi,mi-router-ac2100|\ + xiaomi,mi-router-cr6606|\ xiaomi,redmi-router-ac2100) ucidef_add_switch "switch0" \ "0:wan" "2:lan:1" "3:lan:2" "4:lan:3" "6@eth0" diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index c5abb4afe..71d864ca1 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -59,6 +59,7 @@ platform_do_upgrade() { xiaomi,mir3p|\ xiaomi,mir4|\ xiaomi,mi-router-ac2100|\ + xiaomi,mi-router-cr6606|\ xiaomi,redmi-router-ac2100) nand_do_upgrade "$1" ;;