Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ramips: add support for C-Life XG1 [WIFI6] #10057

Merged
merged 1 commit into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package/boot/uboot-envtools/files/ramips
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ ravpower,rp-wd03)
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "0x4000" "0x1000" "0x1000"
;;
c-life,xg1|\
jcg,q20)
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
;;
Expand Down
160 changes: 160 additions & 0 deletions target/linux/ramips/dts/mt7621_c-life_xg1.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

#include "mt7621.dtsi"

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

/ {
compatible = "c-life,xg1", "mediatek,mt7621-soc";
model = "C-Life XG1";

aliases {
led-boot = &led_status_red;
led-failsafe = &led_status_red;
led-running = &led_status_blue;
led-upgrade = &led_status_blue;
label-mac-device = &gmac0;
};

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

leds {
compatible = "gpio-leds";

led_status_red: status_red {
label = "red:status";
gpios = <&gpio 14 GPIO_ACTIVE_HIGH>;
};

led_status_blue: status_blue {
label = "blue:status";
gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
};
};

keys {
compatible = "gpio-keys";

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

wps {
label = "wps";
gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WPS_BUTTON>;
};
};
};

&nand {
status = "okay";

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

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

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 = "kernel";
reg = <0x200000 0x400000>;
};

partition@600000 {
label = "ubi";
reg = <0x600000 0x7980000>;
};
};
};

&pcie {
status = "okay";
};

&pcie1 {
wifi@0,0 {
compatible = "mediatek,mt76";
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&factory 0x0>;
};
};

&gmac0 {
mtd-mac-address = <&factory 0x04>;
};

&gmac1 {
mtd-mac-address = <&factory 0x0a>;
phy-mode = "rgmii";
status = "okay";

fixed-link {
speed = <1000>;
full-duplex;
pause;
};
};

&gsw {
mediatek,portmap = "llllw";
status = "okay";
};

&hnat {
mtketh-wan = "eth1";
mtketh-ppd = "eth0";
mtketh-lan = "eth0";
mtketh-max-gmac = <2>;
/delete-property/ mtkdsa-wan-port;
};

&switch0 {
status = "disabled";
};

&state_default {
gpio {
groups = "jtag", "wdt";
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 @@ -380,6 +380,23 @@ define Device/buffalo_wsr-600dhp
endef
TARGET_DEVICES += buffalo_wsr-600dhp

define Device/c-life_xg1
$(Device/dsa-migration)
BLOCKSIZE := 128k
PAGESIZE := 2048
UBINIZE_OPTS := -E 5
KERNEL_SIZE := 4096k
IMAGE_SIZE := 91136k
IMAGES += factory.bin
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
check-size
DEVICE_VENDOR := C-Life
DEVICE_MODEL := XG1
DEVICE_PACKAGES := kmod-mt7915e uboot-envtools kmod-usb3
endef
TARGET_DEVICES += c-life_xg1

define Device/cudy_wr1300
$(Device/dsa-migration)
IMAGE_SIZE := 15872k
Expand Down
9 changes: 9 additions & 0 deletions target/linux/ramips/mt7621/base-files/etc/board.d/02_network
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ ramips_setup_interfaces()
ucidef_add_switch "switch0" \
"1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4" "0:wan" "6@eth0"
;;
c-life,xg1)
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "0:wan" "6u@eth0" "5u@eth1"
;;
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"
Expand Down Expand Up @@ -143,6 +147,11 @@ ramips_setup_macs()
wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
lan_mac=$wan_mac
;;
c-life,xg1)
base_mac=$(cat /sys/class/net/eth0/address)
lan_mac=$(macaddr_add "$base_mac" -1)
wan_mac=$(macaddr_add "$lan_mac" -1)
;;
d-team,newifi-d2)
lan_mac=$(cat /sys/class/net/eth0/address)
wan_mac=$(mtd_get_mac_binary factory 0xe006)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ PHYNBR=${DEVPATH##*/phy}
board=$(board_name)

case "$board" in
c-life,xg1)
if [ "$PHYNBR" = "1" ]; then
base_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
macaddr_setbit_la "$base_mac" > /sys${DEVPATH}/macaddress
fi
;;
dlink,dir-853-a3)
[ "$PHYNBR" = "0" ] && \
macaddr_setbit_la "$(mtd_get_mac_binary factory 0xe000)" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ platform_do_upgrade() {
asus,rt-ac85p|\
beeline,smartbox-giga|\
beeline,smartbox-turbo-plus|\
c-life,xg1|\
dlink,dir-1960-a1|\
dlink,dir-2640-a1|\
dlink,dir-2660-a1|\
Expand Down