[openwrt/openwrt] mediatek/filogic: add Keenetic KN-3911 support
LEDE Commits
lede-commits at lists.infradead.org
Thu Nov 28 13:36:11 PST 2024
hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/5a4eb56a7bc7d1d8028d103d50b0dba2ff7808c4
commit 5a4eb56a7bc7d1d8028d103d50b0dba2ff7808c4
Author: Maxim Anisimov <maxim.anisimov.ua at gmail.com>
AuthorDate: Thu Oct 31 10:30:08 2024 +0300
mediatek/filogic: add Keenetic KN-3911 support
Specification:
- MT7981 CPU using 2.4GHz and 5GHz WiFi (both AX)
- 512MB RAM
- 128MB SPI NAND
- 2 LEDs (green, orange)
- 3 buttons (fn, reset, wps)
- 2 2.5Gbit ethernet ports based on Airoha EN8811H phy
Serial Interface:
- 3 Pins GND, RX, TX
- Settings: 115200, 8N1
Notes:
- The device supports dual boot mode
Flash instruction:
The only way to flash OpenWrt image is to use tftp recovery mode in U-Boot:
1. Configure PC with static IP 192.168.1.2/24 and tftp server.
2. Rename "openwrt-mediatek-filogic-keenetic_kn-3911-squashfs-factory.bin"
to "KN-3911_recovery.bin" and place it in tftp server directory.
3. Connect PC with ethernet port, press the reset button, power up
the device and keep button pressed until status led start blinking.
4. Device will download file from server, write it to flash and reboot.
Signed-off-by: Maxim Anisimov <maxim.anisimov.ua at gmail.com>
Link: https://github.com/openwrt/openwrt/pull/16830
Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
.../mediatek/dts/mt7981b-keenetic-kn-3911.dts | 300 +++++++++++++++++++++
.../filogic/base-files/etc/board.d/02_network | 13 +-
.../etc/hotplug.d/ieee80211/11_fix_wifi_mac | 4 +
target/linux/mediatek/image/filogic.mk | 20 ++
4 files changed, 331 insertions(+), 6 deletions(-)
diff --git a/target/linux/mediatek/dts/mt7981b-keenetic-kn-3911.dts b/target/linux/mediatek/dts/mt7981b-keenetic-kn-3911.dts
new file mode 100644
index 0000000000..8a9bf0f1a9
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7981b-keenetic-kn-3911.dts
@@ -0,0 +1,300 @@
+// SPDX-License-Identifier: GPL-2.0-only OR MIT
+
+/dts-v1/;
+
+#include "mt7981.dtsi"
+
+/ {
+ model = "Keenetic KN-3911";
+ compatible = "keenetic,kn-3911", "mediatek,mt7981";
+
+ aliases {
+ label-mac-device = &gmac0;
+ led-boot = &status_led;
+ led-failsafe = &status_led;
+ led-running = &status_led;
+ led-upgrade = &status_led;
+ serial0 = &uart0;
+ };
+
+ chosen {
+ stdout-path = "serial0:115200n8";
+ };
+
+ gpio-keys {
+ compatible = "gpio-keys";
+
+ button-fn {
+ label = "fn";
+ linux,code = <BTN_0>;
+ gpios = <&pio 0 GPIO_ACTIVE_LOW>;
+ };
+
+ button-reset {
+ label = "reset";
+ linux,code = <KEY_RESTART>;
+ gpios = <&pio 24 GPIO_ACTIVE_LOW>;
+ };
+
+ button-wps {
+ label = "wps";
+ linux,code = <KEY_WPS_BUTTON>;
+ gpios = <&pio 29 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ gpio-leds {
+ compatible = "gpio-leds";
+
+ status_led: led-0 {
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_STATUS;
+ gpios = <&pio 11 GPIO_ACTIVE_HIGH>;
+ };
+
+ led-1 {
+ color = <LED_COLOR_ID_ORANGE>;
+ function = LED_FUNCTION_WPS;
+ gpios = <&pio 12 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ virtual_flash {
+ compatible = "mtd-concat";
+ devices = <&firmware1 &firmware2>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition at 0 {
+ label = "kernel";
+ reg = <0x0 0x600000>;
+ };
+
+ partition at 400000 {
+ label = "ubi";
+ reg = <0x600000 0x0>;
+ };
+ };
+ };
+};
+
+&uart0 {
+ status = "okay";
+};
+
+&watchdog {
+ status = "okay";
+};
+
+ð {
+ status = "okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&mdio_pins>;
+
+ gmac0: mac at 0 {
+ compatible = "mediatek,eth-mac";
+ reg = <0>;
+ phy-mode = "2500base-x";
+ phy-handle = <&phy10>;
+ label = "lan";
+
+ nvmem-cell-names = "mac-address";
+ nvmem-cells = <&macaddr_factory_4 0>;
+ };
+
+ gmac1: mac at 1 {
+ compatible = "mediatek,eth-mac";
+ reg = <1>;
+ phy-mode = "2500base-x";
+ phy-handle = <&phy11>;
+ label = "wan";
+
+ nvmem-cell-names = "mac-address";
+ nvmem-cells = <&macaddr_factory_a 0>;
+ };
+};
+
+&mdio_bus {
+ phy10: ethernet-phy at a {
+ reg = <0xa>;
+ interrupt-parent = <&pio>;
+ interrupts = <38 IRQ_TYPE_EDGE_FALLING>;
+ reset-gpios = <&pio 22 GPIO_ACTIVE_LOW>;
+ reset-assert-us = <10000>;
+ reset-deassert-us = <20000>;
+ };
+
+ phy11: ethernet-phy at b {
+ reg = <0xb>;
+ interrupt-parent = <&pio>;
+ interrupts = <23 IRQ_TYPE_EDGE_FALLING>;
+ reset-gpios = <&pio 27 GPIO_ACTIVE_LOW>;
+ reset-assert-us = <10000>;
+ reset-deassert-us = <20000>;
+ };
+};
+
+&pio {
+ spi0_flash_pins: spi0-pins {
+ mux {
+ function = "spi";
+ groups = "spi0", "spi0_wp_hold";
+ };
+
+ conf-pu {
+ pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
+ drive-strength = <MTK_DRIVE_8mA>;
+ bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
+ };
+
+ conf-pd {
+ pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
+ drive-strength = <MTK_DRIVE_8mA>;
+ bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
+ };
+ };
+};
+
+&spi0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&spi0_flash_pins>;
+ status = "okay";
+
+ /* Winbond W25N01GVZEIG (128M) */
+ spi_nand at 0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "spi-nand";
+ reg = <0>;
+
+ spi-max-frequency = <52000000>;
+ spi-tx-buswidth = <4>;
+ spi-rx-buswidth = <4>;
+
+ spi-cal-enable;
+ spi-cal-mode = "read-data";
+ spi-cal-datalen = <7>;
+ spi-cal-data = /bits/ 8 <0x53 0x50 0x49 0x4e 0x41 0x4e 0x44>;
+ spi-cal-addrlen = <5>;
+ spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>;
+
+ mediatek,nmbm;
+ mediatek,bmt-max-ratio = <1>;
+ mediatek,bmt-max-reserved-blocks = <64>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ /* bl2 */
+ partition at 0 {
+ label = "preloader";
+ reg = <0x0 0x80000>;
+ read-only;
+ };
+
+ /* fip */
+ partition at 80000 {
+ label = "u-boot";
+ reg = <0x80000 0x200000>;
+ read-only;
+ };
+
+ partition at 280000 {
+ label = "u-config";
+ reg = <0x280000 0x80000>;
+ read-only;
+ };
+
+ partition at 300000 {
+ label = "rf-eeprom";
+ reg = <0x300000 0x200000>;
+ read-only;
+
+ nvmem-layout {
+ compatible = "fixed-layout";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ eeprom_factory_0: eeprom at 0 {
+ reg = <0x0 0x1000>;
+ };
+
+ /* lan mac */
+ macaddr_factory_4: macaddr at 4 {
+ compatible = "mac-base";
+ reg = <0x4 0x6>;
+ #nvmem-cell-cells = <1>;
+ };
+
+ /* wan mac */
+ macaddr_factory_a: macaddr at a {
+ compatible = "mac-base";
+ reg = <0xa 0x6>;
+ #nvmem-cell-cells = <1>;
+ };
+ };
+ };
+
+ firmware1: partition at 500000 {
+ label = "firmware_1";
+ reg = <0x500000 0x3500000>;
+ };
+
+ partition at 3a00000 {
+ label = "config_1";
+ reg = <0x3a00000 0x80000>;
+ read-only;
+ };
+
+ partition at 3a80000 {
+ label = "dump";
+ reg = <0x3a80000 0x80000>;
+ read-only;
+ };
+
+ partition at 3c00000 {
+ label = "u-state";
+ reg = <0x3c00000 0x20000>;
+ read-only;
+ };
+
+ partition at 3e80000 {
+ label = "u-config_res";
+ reg = <0x3e80000 0x80000>;
+ read-only;
+ };
+
+ partition at 3f00000 {
+ label = "rf-eeprom_res";
+ reg = <0x3f00000 0x200000>;
+ read-only;
+ };
+
+ firmware2: partition at 4100000 {
+ label = "firmware_2";
+ reg = <0x4140000 0x3500000>;
+ };
+
+ partition at 7600000 {
+ label = "config_2";
+ reg = <0x7600000 0x80000>;
+ read-only;
+ };
+ };
+ };
+};
+
+&wifi {
+ nvmem-cell-names = "eeprom";
+ nvmem-cells = <&eeprom_factory_0>;
+ status = "okay";
+};
+
+&sgmiisys0 {
+ /delete-node/ mediatek,pnswap;
+};
diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
index 1480dbcbc7..953d96d09c 100644
--- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
@@ -90,6 +90,13 @@ mediatek_setup_interfaces()
dlink,aquila-pro-ai-m30-a1)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" internet
;;
+ keenetic,kn-3911|\
+ smartrg,sdg-8622|\
+ smartrg,sdg-8632|\
+ smartrg,sdg-8733a|\
+ yuncore,ax835)
+ ucidef_set_interfaces_lan_wan lan wan
+ ;;
mediatek,mt7986a-rfb)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan6" "eth1 wan"
;;
@@ -102,12 +109,6 @@ mediatek_setup_interfaces()
mercusys,mr90x-v1)
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2" eth1
;;
- smartrg,sdg-8622|\
- smartrg,sdg-8632|\
- smartrg,sdg-8733a|\
- yuncore,ax835)
- ucidef_set_interfaces_lan_wan lan wan
- ;;
tplink,tl-xdr6086|\
wavlink,wl-wn586x3)
ucidef_set_interfaces_lan_wan "lan1 lan2" eth1
diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
index 5e83a167de..a3b7671223 100644
--- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
+++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
@@ -115,6 +115,10 @@ case "$board" in
jdcloud,re-cp-03)
[ "$PHYNBR" = "1" ] && mmc_get_mac_binary factory 0xa > /sys${DEVPATH}/macaddress
;;
+ keenetic,kn-3911)
+ [ "$PHYNBR" = "1" ] && \
+ macaddr_setbit_la "$(mtd_get_mac_binary rf-eeprom 0x4)" > /sys${DEVPATH}/macaddress
+ ;;
mercusys,mr90x-v1|\
tplink,re6000xd)
addr=$(get_mac_binary "/tmp/tp_data/default-mac" 0)
diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk
index 672790f1a7..ddd23f4d64 100644
--- a/target/linux/mediatek/image/filogic.mk
+++ b/target/linux/mediatek/image/filogic.mk
@@ -887,6 +887,26 @@ define Device/jdcloud_re-cp-03
endef
TARGET_DEVICES += jdcloud_re-cp-03
+define Device/keenetic_kn-3911
+ DEVICE_VENDOR := Keenetic
+ DEVICE_MODEL := KN-3911
+ DEVICE_DTS := mt7981b-keenetic-kn-3911
+ DEVICE_DTS_DIR := ../dts
+ DEVICE_PACKAGES := kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware kmod-phy-airoha-en8811h
+ UBINIZE_OPTS := -E 5
+ BLOCKSIZE := 128k
+ PAGESIZE := 2048
+ KERNEL_SIZE := 6144k
+ IMAGE_SIZE := 108544k
+ KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | \
+ append-squashfs4-fakeroot
+ IMAGES += factory.bin
+ IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | \
+ append-ubi | check-size | zyimage -d 0x803911 -v "KN-3911"
+ IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+endef
+TARGET_DEVICES += keenetic_kn-3911
+
define Device/mediatek_mt7981-rfb
DEVICE_VENDOR := MediaTek
DEVICE_MODEL := MT7981 rfb
More information about the lede-commits
mailing list