From ba018e2a24d85b7eabe0ed5a43d2c0a5ffccac7c Mon Sep 17 00:00:00 2001 From: "wingate.chi" Date: Mon, 9 Dec 2024 03:06:26 +0000 Subject: [PATCH] rampis: add mt7621 sonicfi rap63xc-211g support Signed-off-by: wingate.chi --- package/boot/uboot-envtools/files/ramips | 1 + .../dts/mt7621_sonicfi_rap63xc-211g.dts | 204 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 9 + .../mt7621/base-files/etc/board.d/01_leds | 6 + .../mt7621/base-files/etc/board.d/02_network | 6 + .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 5 + 6 files changed, 231 insertions(+) mode change 100644 => 100755 package/boot/uboot-envtools/files/ramips create mode 100755 target/linux/ramips/dts/mt7621_sonicfi_rap63xc-211g.dts mode change 100644 => 100755 target/linux/ramips/image/mt7621.mk mode change 100644 => 100755 target/linux/ramips/mt7621/base-files/etc/board.d/01_leds mode change 100644 => 100755 target/linux/ramips/mt7621/base-files/etc/board.d/02_network mode change 100644 => 100755 target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips old mode 100644 new mode 100755 index 8c7ce71c49..522bf03254 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -28,6 +28,7 @@ alfa-network,ax1800rm|\ allnet,all0256n-4m|\ allnet,all0256n-8m|\ allnet,all5002|\ +sonicfi,rap63xc-211g|\ yuncore,ax820) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" ;; diff --git a/target/linux/ramips/dts/mt7621_sonicfi_rap63xc-211g.dts b/target/linux/ramips/dts/mt7621_sonicfi_rap63xc-211g.dts new file mode 100755 index 0000000000..149277a825 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_sonicfi_rap63xc-211g.dts @@ -0,0 +1,204 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include +#include + +/ { + compatible = "sonicfi,rap63xc-211g", "mediatek,mt7621-soc"; + model = "sonicfi RAP63XC-211G"; + + aliases { + led-boot = &led_system; + led-failsafe = &led_system; + led-running = &led_system; + led-upgrade = &led_system; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + leds { + compatible = "gpio-leds"; + + /* At least 2 RAP63XC-211G variants are known and cannot be distinguished (same hw rev): + - System LED green GPIO 15; red and blue apparently not connected + - System LED red GPIO 15, WLAN2G LED green GPIO 14, WLAN5G LED blue GPIO 16 + The canonical values taken from a Yuncore datasheet are: + - System LED green GPIO 15, WLAN2G LED blue GPIO 14, WLAN5G LED red GPIO 16 + All 3 colors relate to the same single RGB LED showing up on the front lightpipe. + As a result, all 3 LEDs are defined even if only one may be available, and + the color information is absent as it is not reliable */ + wlan2g { + label = "wlan2g"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0radio"; + }; + + led_system: system { + label = "system"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + + wlan5g { + label = "wlan5g"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1radio"; + }; + + wan { + color = ; + function = LED_FUNCTION_WAN; + gpios = <&switch0 0 GPIO_ACTIVE_LOW>; + }; + + lan { + color = ; + function = LED_FUNCTION_LAN; + gpios = <&switch0 3 GPIO_ACTIVE_LOW>; + }; + }; + + watchdog { + compatible = "linux,wdt-gpio"; + gpios = <&gpio 0 GPIO_ACTIVE_LOW>; + hw_algo = "toggle"; + hw_margin_ms = <200>; + always-running; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <20000000>; + m25p,fast-read; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "Bootloader"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "Config"; + reg = <0x30000 0x10000>; + /* read-only; */ + }; + + /* range 0x40000 to 0x50000 is empty in vendor + * firmware, so we do not use it either + */ + + factory: partition@50000 { + label = "Factory"; + reg = <0x50000 0x40000>; + read-only; + }; + + partition@90000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x90000 0xf50000>; + }; + + partition@fe0000 { + label = "devinfo"; + reg = <0xfe0000 0x10000>; + }; + + partition@ff0000 { + label = "certificates"; + reg = <0xff0000 0x10000>; + }; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + mediatek,disable-radar-background; + }; +}; + +&gmac0 { + nvmem-cells = <&macaddr_factory_4>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <1>; +}; + +&gmac1 { + status = "okay"; + label = "wan"; + phy-handle = <ðphy0>; + + nvmem-cells = <&macaddr_factory_4>; + nvmem-cell-names = "mac-address"; +}; + +&mdio { + ethphy0: ethernet-phy@0 { + reg = <0>; + }; +}; + +&switch0 { + gpio-controller; + #gpio-cells = <2>; + + ports { + port@1 { + status = "okay"; + label = "lan"; + }; + }; +}; + +&state_default { + gpio { + groups = "jtag", "wdt"; + function = "gpio"; + }; +}; + +&factory { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_factory_4: macaddr@4 { + reg = <0x4 0x6>; + }; + + macaddr_factory_e000: macaddr@e000 { + reg = <0xe000 0x6>; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk old mode 100644 new mode 100755 index 8790a2fa50..1a1959bdc4 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -581,6 +581,15 @@ define Device/cudy_x6-v2 endef TARGET_DEVICES += cudy_x6-v2 +define Device/sonicfi_rap63xc-211g + $(Device/dsa-migration) + IMAGE_SIZE := 15808k + DEVICE_VENDOR := sonicfi + DEVICE_MODEL := RAP63XC-211G + DEVICE_PACKAGES := kmod-mt7915-firmware uboot-envtools +endef +TARGET_DEVICES += sonicfi_rap63xc-211g + define Device/dlink_dap-1620-b1 DEVICE_VENDOR := D-Link DEVICE_MODEL := DAP-1620 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 old mode 100644 new mode 100755 index 3ceac60434..84cc404019 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -64,6 +64,12 @@ cudy,wr2100) ucidef_set_led_netdev "lan4" "lan4" "green:lan4" "lan4" ucidef_set_led_netdev "wan" "wan" "green:wan" "wan" ;; +sonicfi,rap63xc-211g) + ucidef_set_led_netdev "wifi2g" "Wifi2G" "wlan2g" "wlan0" "link" + ucidef_set_led_netdev "wifi5g" "Wifi5G" "wlan5g" "wlan1" "link" + ucidef_set_led_netdev "lan" "LAN" "green:lan" "lan" + ucidef_set_led_netdev "wan" "WAN" "green:wan" "wan" + ;; d-team,newifi-d2) ucidef_set_led_netdev "internet" "internet" "amber:internet" "wan" ucidef_set_led_netdev "wlan2g" "WiFi 2.4GHz" "blue:wlan2g" "wlan0" 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 old mode 100644 new mode 100755 index 0f6b7fd526..d3944a47c4 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -91,6 +91,7 @@ ramips_setup_interfaces() uci add_list firewall.@zone[1].network='eth_om' ;; cudy,m1800|\ + sonicfi,rap63xc-211g|\ yuncore,ax820|\ zyxel,nt7101) ucidef_set_interfaces_lan_wan "lan" "wan" @@ -204,6 +205,11 @@ ramips_setup_macs() lan_mac=$wan_mac label_mac=$wan_mac ;; + sonicfi,rap63xc-211g) + wan_mac=$(mtd_get_mac_binary Factory 0x4) + lan_mac=$(macaddr_add "$wan_mac" 1) + label_mac=$wan_mac + ;; dlink,dir-860l-b1) lan_mac=$(mtd_get_mac_ascii factory lanmac) wan_mac=$(mtd_get_mac_ascii factory wanmac) diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac old mode 100644 new mode 100755 index d5bd50fdf7..7ead3274b0 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -33,6 +33,11 @@ case "$board" in [ "$PHYNBR" = "1" ] && \ macaddr_setbit_la "$(macaddr_add $hw_mac_addr 0x100000)" > /sys${DEVPATH}/macaddress ;; + sonicfi,rap63xc-211g) + hw_mac_addr="$(mtd_get_mac_binary Factory 0x4)" + [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress + [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress + ;; dlink,dap-1620-b1|\ dlink,dir-853-a1) lan_mac_addr="$(mtd_get_mac_binary factory 0xe000)" -- 2.17.1