I found the reason why the gpio 2 (wlan2g) didn't work.
It's because of rfkill in keys section:
keys {
compatible = "gpio-keys";
reset {
label = "reset";
gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
rfkill {
label = "rfkill";
gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RFKILL>;
};
};
I haven't noticed that before. It needs to clear out.
Here's working dts file:
# cat ./target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include "mt7620a.dtsi"
#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>
/ {
compatible = "tplink,archer-c5-v4", "ralink,mt7620a-soc";
model = "TP-Link Archer C5 v4";
aliases {
led-boot = &led_power;
led-failsafe = &led_power;
led-running = &led_power;
led-upgrade = &led_power;
label-mac-device = ðernet;
};
chosen {
bootargs = "console=ttyS0,115200";
};
leds {
compatible = "gpio-leds";
led_power: power {
label = "green:power";
gpios = <&gpio2 2 GPIO_ACTIVE_LOW>;
};
wan_orange {
label = "orange:wan";
gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
};
wlan2g {
label = "green:wlan2g";
gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
linux,default-trigger = "phy1tpt";
};
wlan5g {
label = "green:wlan5g";
gpios = <&gpio0 9 GPIO_ACTIVE_LOW>;
linux,default-trigger = "phy0tpt";
};
lan {
label = "green:lan";
gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
};
};
keys {
compatible = "gpio-keys";
reset {
label = "reset";
gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
};
rtl8367s {
compatible = "realtek,rtl8367c";
cpu_port = <7>;
realtek,extif2 = <1 0 1 1 1 1 1 1 2>;
mii-bus = <&mdio0>;
phy-id = <29>;
};
};
&gpio2 {
status = "okay";
};
&spi0 {
status = "okay";
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <60000000>;
m25p,fast-read;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "u-boot";
reg = <0x0 0x20000>;
read-only;
};
partition@20000 {
compatible = "tplink,firmware";
label = "firmware";
reg = <0x20000 0x7a0000>;
};
partition@7c0000 {
label = "config";
reg = <0x7c0000 0x10000>;
read-only;
};
rom: partition@7d0000 {
label = "rom";
reg = <0x7d0000 0x10000>;
read-only;
};
partition@7e0000 {
label = "romfile";
reg = <0x7e0000 0x10000>;
read-only;
};
radio: partition@7f0000 {
label = "radio";
reg = <0x7f0000 0x10000>;
read-only;
};
};
};
};
&state_default {
gpio {
groups = "i2c", "uartf", "ephy", "rgmii2";
function = "gpio";
};
};
ðernet {
pinctrl-names = "default";
mtd-mac-address = <&rom 0xf100>;
pinctrl-0 = <&rgmii1_pins &mdio_pins>;
port@5 {
status = "okay";
mediatek,fixed-link = <1000 1 1 1>;
phy-mode = "rgmii";
};
mdio0: mdio-bus {
status = "okay";
reset-gpios = <&gpio2 20 GPIO_ACTIVE_LOW>;
reset-delay-us = <10000>;
};
};
&ehci {
status = "okay";
};
&ohci {
status = "okay";
};
&wmac {
ralink,mtd-eeprom = <&radio 0x0>;
mtd-mac-address = <&rom 0xf100>;
};
&pcie {
status = "okay";
};
&pcie0 {
wifi@0,0 {
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&radio 0x8000>;
ieee80211-freq-limit = <5000000 6000000>;
mtd-mac-address = <&rom 0xf100>;
mtd-mac-address-increment = <2>;
};
};
So I compiled 22.03.6 as in this post
Then I flashed the firmware, but ethernet and wlan5g won't work, it's happened because modules kmod-mt76x2 kmod-switch-rtl8367b haven't checked for some reasons during selecting target profile, don't know why.
I checked it out by hands in menuconfig. Now all works fine.