Skip to content

Commit 5a4eb56

Browse files
Linaro1985hauke
authored andcommitted
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 <[email protected]> Link: openwrt/openwrt#16830 Signed-off-by: Hauke Mehrtens <[email protected]>
1 parent 0d651dd commit 5a4eb56

File tree

4 files changed

+331
-6
lines changed

4 files changed

+331
-6
lines changed
Lines changed: 300 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,300 @@
1+
// SPDX-License-Identifier: GPL-2.0-only OR MIT
2+
3+
/dts-v1/;
4+
5+
#include "mt7981.dtsi"
6+
7+
/ {
8+
model = "Keenetic KN-3911";
9+
compatible = "keenetic,kn-3911", "mediatek,mt7981";
10+
11+
aliases {
12+
label-mac-device = &gmac0;
13+
led-boot = &status_led;
14+
led-failsafe = &status_led;
15+
led-running = &status_led;
16+
led-upgrade = &status_led;
17+
serial0 = &uart0;
18+
};
19+
20+
chosen {
21+
stdout-path = "serial0:115200n8";
22+
};
23+
24+
gpio-keys {
25+
compatible = "gpio-keys";
26+
27+
button-fn {
28+
label = "fn";
29+
linux,code = <BTN_0>;
30+
gpios = <&pio 0 GPIO_ACTIVE_LOW>;
31+
};
32+
33+
button-reset {
34+
label = "reset";
35+
linux,code = <KEY_RESTART>;
36+
gpios = <&pio 24 GPIO_ACTIVE_LOW>;
37+
};
38+
39+
button-wps {
40+
label = "wps";
41+
linux,code = <KEY_WPS_BUTTON>;
42+
gpios = <&pio 29 GPIO_ACTIVE_LOW>;
43+
};
44+
};
45+
46+
gpio-leds {
47+
compatible = "gpio-leds";
48+
49+
status_led: led-0 {
50+
color = <LED_COLOR_ID_GREEN>;
51+
function = LED_FUNCTION_STATUS;
52+
gpios = <&pio 11 GPIO_ACTIVE_HIGH>;
53+
};
54+
55+
led-1 {
56+
color = <LED_COLOR_ID_ORANGE>;
57+
function = LED_FUNCTION_WPS;
58+
gpios = <&pio 12 GPIO_ACTIVE_LOW>;
59+
};
60+
};
61+
62+
virtual_flash {
63+
compatible = "mtd-concat";
64+
devices = <&firmware1 &firmware2>;
65+
66+
partitions {
67+
compatible = "fixed-partitions";
68+
#address-cells = <1>;
69+
#size-cells = <1>;
70+
71+
partition@0 {
72+
label = "kernel";
73+
reg = <0x0 0x600000>;
74+
};
75+
76+
partition@400000 {
77+
label = "ubi";
78+
reg = <0x600000 0x0>;
79+
};
80+
};
81+
};
82+
};
83+
84+
&uart0 {
85+
status = "okay";
86+
};
87+
88+
&watchdog {
89+
status = "okay";
90+
};
91+
92+
&eth {
93+
status = "okay";
94+
pinctrl-names = "default";
95+
pinctrl-0 = <&mdio_pins>;
96+
97+
gmac0: mac@0 {
98+
compatible = "mediatek,eth-mac";
99+
reg = <0>;
100+
phy-mode = "2500base-x";
101+
phy-handle = <&phy10>;
102+
label = "lan";
103+
104+
nvmem-cell-names = "mac-address";
105+
nvmem-cells = <&macaddr_factory_4 0>;
106+
};
107+
108+
gmac1: mac@1 {
109+
compatible = "mediatek,eth-mac";
110+
reg = <1>;
111+
phy-mode = "2500base-x";
112+
phy-handle = <&phy11>;
113+
label = "wan";
114+
115+
nvmem-cell-names = "mac-address";
116+
nvmem-cells = <&macaddr_factory_a 0>;
117+
};
118+
};
119+
120+
&mdio_bus {
121+
phy10: ethernet-phy@a {
122+
reg = <0xa>;
123+
interrupt-parent = <&pio>;
124+
interrupts = <38 IRQ_TYPE_EDGE_FALLING>;
125+
reset-gpios = <&pio 22 GPIO_ACTIVE_LOW>;
126+
reset-assert-us = <10000>;
127+
reset-deassert-us = <20000>;
128+
};
129+
130+
phy11: ethernet-phy@b {
131+
reg = <0xb>;
132+
interrupt-parent = <&pio>;
133+
interrupts = <23 IRQ_TYPE_EDGE_FALLING>;
134+
reset-gpios = <&pio 27 GPIO_ACTIVE_LOW>;
135+
reset-assert-us = <10000>;
136+
reset-deassert-us = <20000>;
137+
};
138+
};
139+
140+
&pio {
141+
spi0_flash_pins: spi0-pins {
142+
mux {
143+
function = "spi";
144+
groups = "spi0", "spi0_wp_hold";
145+
};
146+
147+
conf-pu {
148+
pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
149+
drive-strength = <MTK_DRIVE_8mA>;
150+
bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
151+
};
152+
153+
conf-pd {
154+
pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
155+
drive-strength = <MTK_DRIVE_8mA>;
156+
bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
157+
};
158+
};
159+
};
160+
161+
&spi0 {
162+
pinctrl-names = "default";
163+
pinctrl-0 = <&spi0_flash_pins>;
164+
status = "okay";
165+
166+
/* Winbond W25N01GVZEIG (128M) */
167+
spi_nand@0 {
168+
#address-cells = <1>;
169+
#size-cells = <1>;
170+
compatible = "spi-nand";
171+
reg = <0>;
172+
173+
spi-max-frequency = <52000000>;
174+
spi-tx-buswidth = <4>;
175+
spi-rx-buswidth = <4>;
176+
177+
spi-cal-enable;
178+
spi-cal-mode = "read-data";
179+
spi-cal-datalen = <7>;
180+
spi-cal-data = /bits/ 8 <0x53 0x50 0x49 0x4e 0x41 0x4e 0x44>;
181+
spi-cal-addrlen = <5>;
182+
spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>;
183+
184+
mediatek,nmbm;
185+
mediatek,bmt-max-ratio = <1>;
186+
mediatek,bmt-max-reserved-blocks = <64>;
187+
188+
partitions {
189+
compatible = "fixed-partitions";
190+
#address-cells = <1>;
191+
#size-cells = <1>;
192+
193+
/* bl2 */
194+
partition@0 {
195+
label = "preloader";
196+
reg = <0x0 0x80000>;
197+
read-only;
198+
};
199+
200+
/* fip */
201+
partition@80000 {
202+
label = "u-boot";
203+
reg = <0x80000 0x200000>;
204+
read-only;
205+
};
206+
207+
partition@280000 {
208+
label = "u-config";
209+
reg = <0x280000 0x80000>;
210+
read-only;
211+
};
212+
213+
partition@300000 {
214+
label = "rf-eeprom";
215+
reg = <0x300000 0x200000>;
216+
read-only;
217+
218+
nvmem-layout {
219+
compatible = "fixed-layout";
220+
#address-cells = <1>;
221+
#size-cells = <1>;
222+
223+
eeprom_factory_0: eeprom@0 {
224+
reg = <0x0 0x1000>;
225+
};
226+
227+
/* lan mac */
228+
macaddr_factory_4: macaddr@4 {
229+
compatible = "mac-base";
230+
reg = <0x4 0x6>;
231+
#nvmem-cell-cells = <1>;
232+
};
233+
234+
/* wan mac */
235+
macaddr_factory_a: macaddr@a {
236+
compatible = "mac-base";
237+
reg = <0xa 0x6>;
238+
#nvmem-cell-cells = <1>;
239+
};
240+
};
241+
};
242+
243+
firmware1: partition@500000 {
244+
label = "firmware_1";
245+
reg = <0x500000 0x3500000>;
246+
};
247+
248+
partition@3a00000 {
249+
label = "config_1";
250+
reg = <0x3a00000 0x80000>;
251+
read-only;
252+
};
253+
254+
partition@3a80000 {
255+
label = "dump";
256+
reg = <0x3a80000 0x80000>;
257+
read-only;
258+
};
259+
260+
partition@3c00000 {
261+
label = "u-state";
262+
reg = <0x3c00000 0x20000>;
263+
read-only;
264+
};
265+
266+
partition@3e80000 {
267+
label = "u-config_res";
268+
reg = <0x3e80000 0x80000>;
269+
read-only;
270+
};
271+
272+
partition@3f00000 {
273+
label = "rf-eeprom_res";
274+
reg = <0x3f00000 0x200000>;
275+
read-only;
276+
};
277+
278+
firmware2: partition@4100000 {
279+
label = "firmware_2";
280+
reg = <0x4140000 0x3500000>;
281+
};
282+
283+
partition@7600000 {
284+
label = "config_2";
285+
reg = <0x7600000 0x80000>;
286+
read-only;
287+
};
288+
};
289+
};
290+
};
291+
292+
&wifi {
293+
nvmem-cell-names = "eeprom";
294+
nvmem-cells = <&eeprom_factory_0>;
295+
status = "okay";
296+
};
297+
298+
&sgmiisys0 {
299+
/delete-node/ mediatek,pnswap;
300+
};

target/linux/mediatek/filogic/base-files/etc/board.d/02_network

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ mediatek_setup_interfaces()
9090
dlink,aquila-pro-ai-m30-a1)
9191
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" internet
9292
;;
93+
keenetic,kn-3911|\
94+
smartrg,sdg-8622|\
95+
smartrg,sdg-8632|\
96+
smartrg,sdg-8733a|\
97+
yuncore,ax835)
98+
ucidef_set_interfaces_lan_wan lan wan
99+
;;
93100
mediatek,mt7986a-rfb)
94101
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan6" "eth1 wan"
95102
;;
@@ -102,12 +109,6 @@ mediatek_setup_interfaces()
102109
mercusys,mr90x-v1)
103110
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2" eth1
104111
;;
105-
smartrg,sdg-8622|\
106-
smartrg,sdg-8632|\
107-
smartrg,sdg-8733a|\
108-
yuncore,ax835)
109-
ucidef_set_interfaces_lan_wan lan wan
110-
;;
111112
tplink,tl-xdr6086|\
112113
wavlink,wl-wn586x3)
113114
ucidef_set_interfaces_lan_wan "lan1 lan2" eth1

target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ case "$board" in
115115
jdcloud,re-cp-03)
116116
[ "$PHYNBR" = "1" ] && mmc_get_mac_binary factory 0xa > /sys${DEVPATH}/macaddress
117117
;;
118+
keenetic,kn-3911)
119+
[ "$PHYNBR" = "1" ] && \
120+
macaddr_setbit_la "$(mtd_get_mac_binary rf-eeprom 0x4)" > /sys${DEVPATH}/macaddress
121+
;;
118122
mercusys,mr90x-v1|\
119123
tplink,re6000xd)
120124
addr=$(get_mac_binary "/tmp/tp_data/default-mac" 0)

target/linux/mediatek/image/filogic.mk

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,26 @@ define Device/jdcloud_re-cp-03
887887
endef
888888
TARGET_DEVICES += jdcloud_re-cp-03
889889

890+
define Device/keenetic_kn-3911
891+
DEVICE_VENDOR := Keenetic
892+
DEVICE_MODEL := KN-3911
893+
DEVICE_DTS := mt7981b-keenetic-kn-3911
894+
DEVICE_DTS_DIR := ../dts
895+
DEVICE_PACKAGES := kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware kmod-phy-airoha-en8811h
896+
UBINIZE_OPTS := -E 5
897+
BLOCKSIZE := 128k
898+
PAGESIZE := 2048
899+
KERNEL_SIZE := 6144k
900+
IMAGE_SIZE := 108544k
901+
KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | \
902+
append-squashfs4-fakeroot
903+
IMAGES += factory.bin
904+
IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | \
905+
append-ubi | check-size | zyimage -d 0x803911 -v "KN-3911"
906+
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
907+
endef
908+
TARGET_DEVICES += keenetic_kn-3911
909+
890910
define Device/mediatek_mt7981-rfb
891911
DEVICE_VENDOR := MediaTek
892912
DEVICE_MODEL := MT7981 rfb

0 commit comments

Comments
 (0)