ramips: add support for TP-Link Archer C5 v4
authorZoltan HERPAI <wigyori@uid0.hu>
Wed, 22 Apr 2020 14:09:45 +0000 (16:09 +0200)
committerZoltan HERPAI <wigyori@uid0.hu>
Wed, 22 Apr 2020 14:11:53 +0000 (16:11 +0200)
Based on work in https://github.com/benwht/openwrt, rebased
for trunk.

Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>
target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts [new file with mode: 0644]
target/linux/ramips/image/mt7620.mk
target/linux/ramips/mt7620/base-files/etc/board.d/01_leds
target/linux/ramips/mt7620/base-files/etc/board.d/02_network

diff --git a/target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts b/target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts
new file mode 100644 (file)
index 0000000..50a2d7d
--- /dev/null
@@ -0,0 +1,228 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include "mt7620a.dtsi"
+
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+       compatible = "tplink,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;
+       };
+
+       chosen {
+               bootargs = "console=ttyS0,115200";
+       };
+
+       gpio-leds {
+               compatible = "gpio-leds";
+
+               led_power: power {
+                       label = "c5-v4:green:power";
+                       gpios = <&gpio2 2 GPIO_ACTIVE_LOW>;
+                       default-state = "keep";
+               };
+
+               wlan2g {
+                       label = "c5-v4:green:wlan2g";
+                       gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
+               };
+
+               wlan5g {
+                       label = "c5-v4:green:wlan5g";
+                       gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy0tpt";
+               };
+
+               wan {
+                       label = "c5-v4:green:wan";
+                       gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
+               };
+
+               wan_orange {
+                       label = "c5-v4:orange:wan";
+                       gpios = <&gpio0 9 GPIO_ACTIVE_LOW>;
+               };
+
+               lan {
+                       label = "c5-v4:green:lan";
+                       gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
+               };
+
+               usb {
+                       label = "c5-v4:green:usb";
+                       gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
+               };
+
+               wps {
+                       label = "c5-v4:green:wps";
+                       gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       gpio-keys-polled {
+               compatible = "gpio-keys-polled";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               poll-interval = <20>; 
+                       
+               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>;
+               };
+       };
+
+       rtkgsw {
+               compatible = "mediatek,rtk-gsw";
+               mediatek,mdio = <&mdio0>;
+               mediatek,reset-pin = <&gpio2 20 GPIO_ACTIVE_HIGH>;
+       };
+};
+
+&gpio2 {
+       status = "okay";
+};
+
+&spi0 {
+       status = "okay";
+
+       flash@0 {
+               compatible = "jedec,spi-nor";
+               reg = <0>;
+               spi-max-frequency = <80000000>;
+               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;
+                       };
+               };
+       };
+};
+
+&pinctrl {
+       state_default: pinctrl0 {
+               gpio {
+                       ralink,group = "i2c", "uartf", "ephy", "rgmii2";
+                       ralink,function = "gpio";
+               };
+       };
+};
+
+&ethernet {
+       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";
+               phy0: ethernet-phy@0 {
+                       reg = <0>;
+                       phy-mode = "rgmii";
+               };
+
+               phy1: ethernet-phy@1 {
+                       reg = <1>;
+                       phy-mode = "rgmii";
+               };
+
+               phy2: ethernet-phy@2 {
+                       reg = <2>;
+                       phy-mode = "rgmii";
+               };
+
+               phy3: ethernet-phy@3 {
+                       reg = <3>;
+                       phy-mode = "rgmii";
+               };
+
+               phy4: ethernet-phy@4 {
+                       reg = <4>;
+                       phy-mode = "rgmii";
+               };
+       };
+};
+
+&ehci {
+       status = "okay";
+};
+
+&ohci {
+       status = "okay";
+};
+
+&wmac {
+       ralink,mtd-eeprom = <&radio 0>;
+       mtd-mac-address = <&rom 0xf100>;
+};
+
+&pcie {
+       status = "okay";
+
+       pcie-bridge {
+               mt76@0,0 {
+                       reg = <0x0000 0 0 0 0>;
+                       device_type = "pci";
+                       mediatek,mtd-eeprom = <&radio 0x8000>;
+                       ieee80211-freq-limit = <5000000 6000000>;
+                       mtd-mac-address = <&rom 0xf100>;
+                       mtd-mac-address-increment = <(-1)>;
+               };
+       };
+}; 
\ No newline at end of file
index 69b9b7d7fd32199c76a81c1c0582ad78650d3b97..b34c53b79c8e5e8d85574f811ef601e460fb187e 100644 (file)
@@ -981,6 +981,19 @@ define Device/tplink_re210-v1
 endef
 TARGET_DEVICES += tplink_re210-v1
 
+define Device/tplink_archer-c5-v4
+  $(Device/tplink-v2)
+  SOC := mt7620a
+  SUPPORTED_DEVICES += tplink,archer-c5-v4
+  DEVICE_MODEL := Archer C5v4
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport kmod-mt76x2 kmod-switch-rtl8367s
+  TPLINK_FLASHLAYOUT := 8Mmtk
+  TPLINK_HWID := 0x04DA857C
+  TPLINK_HWREV := 0x0C000600
+  TPLINK_HWREVADD := 0x04000000
+endef
+TARGET_DEVICES += tplink_archer-c5-v4
+
 define Device/vonets_var11n-300
   SOC := mt7620n
   IMAGE_SIZE := 3776k
index d332e02bbd3ccd8807b3d6e392398ac359140f9a..d93875dc547b6f0bbc1a3e81cfdeb019c90776c5 100755 (executable)
@@ -181,6 +181,12 @@ tplink,archer-c20i)
        ucidef_set_led_switch "lan" "lan" "$boardname:blue:lan" "switch0" "0x1e"
        ucidef_set_led_switch "wan" "wan" "$boardname:blue:wan" "switch0" "0x01"
        ;;
+tplink,c5-v4)
+       set_usb_led "$boardname:green:usb"
+       ucidef_set_led_netdev "lan" "lan" "$boardname:green:lan" "eth0.1"
+       ucidef_set_led_netdev "wan" "wan" "$boardname:green:wan" "eth0.2"
+       ucidef_set_led_netdev "wlan2g" "wlan2g" "$boardname:green:wlan2g" "wlan1"
+       ;;
 tplink,archer-c50-v1)
        ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x1e"
        ucidef_set_led_switch "wan" "wan" "$boardname:green:wan" "switch0" "0x01"
index 8ae50b3df5ad13310e6aa17d8db011de58dfb0bf..3910a7b9b85cc946106e25bccc07cedf3f4b07a3 100755 (executable)
@@ -198,6 +198,10 @@ ramips_setup_interfaces()
                        "0:lan" "1:lan" "2:lan" "3:lan" "6t@eth0"
                ucidef_set_interface_wan "usb0"
                ;;
+       tplink,c5-v4)
+               ucidef_add_switch "switch1" \
+                       "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "5@eth0"
+               ;;
        vonets,var11n-300)
                ucidef_add_switch "switch0" \
                        "0:lan" "4:wan" "6@eth0"