diff mbox series

[OpenWrt-Devel] Support for Edimax EW-7476RPC

Message ID 03add529-c9ba-6cfe-3ce4-9d209239d675@birger-koblitz.de
State Changes Requested
Delegated to: Petr Štetiar
Headers show
Series [OpenWrt-Devel] Support for Edimax EW-7476RPC | expand

Commit Message

Birger Koblitz May 26, 2019, 7:44 a.m. UTC
Hi Cezary,

In addition to the EW-7476RPC, I added support for the EW-7478AC as you 
suggested. I could not test that image, but at least it compiles.

I fixed all of your comments as suggested, however left it at 
mediatek,rtl8211e-reset = "yes"; I believe there are other similar 
devices from Edimax out there with the Realtek chip, and possibly a 
different GPIO line. Then something like mediatek,rtl8211e-reset = <39>; 
could be used.

Birger


Here comes the patch:


    $(Device/Archer)
    DTS := ArcherC2-v1

Comments

Cezary Jackiewicz May 26, 2019, 1:35 p.m. UTC | #1
Dnia 2019-05-26, o godz. 09:44:59
Birger Koblitz <mail@birger-koblitz.de> napisał(a):

Hi,
yes, it works, but see my comments. 
This is almost identical device (EW-7476RPC and EW-7478C, also: RE11, RE11S),
so you can use dtsi to share common code. 

>          wnce2001|\
>          zbt-cpe102|\
>          zorlik,zl5900v2|\
> +       edimax,ew-7476rpc|\
> +       edimax,ew-7478ac|\
>          zte-q7)

Alphabetical order...


> +#include <dt-bindings/gpio/gpio.h>
> +#include <dt-bindings/input/input.h>
> +
> +/ {
> +       compatible = "edimax,ew-7476ac", "ralink,mt7620a-soc";

edimax,ew-7478ac

> +       keys {
> +                compatible = "gpio-keys";
> +
> +                reset_wps {
> +                        label = "reset_wps";
> +                        gpios = <&gpio2 20 GPIO_ACTIVE_LOW>;
> +                        linux,code = <KEY_RESTART>;
> +                };

There is also a switch

		switch_high {
			label = "switch high";
			gpios = <&gpio2 22 GPIO_ACTIVE_LOW>;
			linux,code = <BTN_0>;
			linux,input-type = <EV_SW>;
		};

		switch_off {
			label = "switch off";
			gpios = <&gpio2 23 GPIO_ACTIVE_LOW>;
			linux,code = <BTN_1>;
			linux,input-type = <EV_SW>;
		};


> +       };
> +
> +       leds {
> +               compatible = "gpio-leds";
> +
> +               led_power: power {
> +                       label = "ew-7478ac:green:power";
> +                       gpios = <&gpio2 27 GPIO_ACTIVE_LOW>;
> +               };
> +               internet {
> +                       label = "ew-7478ac:green:internet";
> +                       gpios = <&gpio2 26 GPIO_ACTIVE_LOW>;
> +               };

lan, not internet.

               lan {
                       label = "ew-7478ac:green:lan";
                       gpios = <&gpio2 26 GPIO_ACTIVE_LOW>;
              };

> +               wlan2g {
> +                       label = "ew-7478ac:blue:wlan2g";
> +                       gpios = <&gpio2 30 GPIO_ACTIVE_LOW>;
> +                       linux,default-trigger = "phy1tpt";
> +               };
> +               wlan5g {
> +                       label = "ew-7478ac:blue:wlan5g";
> +                       gpios = <&gpio2 31 GPIO_ACTIVE_LOW>;
> +                       linux,default-trigger = "phy0tpt";
> +               };

And there is more led: 

		wps {
			label = "ew-7478ac:green:wps";
			gpios = <&gpio2 28 GPIO_ACTIVE_LOW>;
		};

		crossband {
			label = "ew-7478ac:green:crossband";
			gpios = <&gpio2 29 GPIO_ACTIVE_LOW>;
		};

> +&ehci {
> +       status = "okay";
> +};
> +
> +&ohci {
> +       status = "okay";
> +};

Drop this. No usb.

> +define Device/edimax_ew-7478ac
> +  DTS := EW-7478AC
> +  DEVICE_TITLE := Edimax EW-7478AC
> +  BLOCKSIZE := 64k

BLOCKSIZE := 4k

See erasesize:

root@OpenWrt:~# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 00030000 00001000 "u-boot"
mtd1: 00010000 00001000 "u-boot-env"
mtd2: 00010000 00001000 "factory"
mtd3: 00020000 00001000 "cimage"
mtd4: 00790000 00001000 "firmware"
mtd5: 00182ef3 00001000 "kernel"
mtd6: 0060d10d 00001000 "rootfs"
mtd7: 0041a000 00001000 "rootfs_data"
Thomas Endt May 26, 2019, 2:34 p.m. UTC | #2
Can you please add the usual hardware and installation info?
For examples see other commits that added support for a specific device.

Thomas

-----Ursprüngliche Nachricht-----
Von: openwrt-devel <openwrt-devel-bounces@lists.openwrt.org> Im Auftrag von Birger Koblitz
Gesendet: Sonntag, 26. Mai 2019 09:45
An: openwrt-devel@lists.openwrt.org
Betreff: [OpenWrt-Devel] [PATCH] Support for Edimax EW-7476RPC

Hi Cezary,

In addition to the EW-7476RPC, I added support for the EW-7478AC as you suggested. I could not test that image, but at least it compiles.

I fixed all of your comments as suggested, however left it at mediatek,rtl8211e-reset = "yes"; I believe there are other similar devices from Edimax out there with the Realtek chip, and possibly a different GPIO line. Then something like mediatek,rtl8211e-reset = <39>; could be used.

Birger


Here comes the patch:


diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds
b/target/linux/ramips/base-files/etc/board.d/01_leds
index b55ca0413e..cc5b305444 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -146,6 +146,10 @@ dir-860l-b1)
  edimax,br-6478ac-v2)
         set_wifi_led "$boardname:blue:wlan"
         ;;
+edimax,ew-7476rpc) \
+edimax,ew-7478ac)
+        ucidef_set_led_netdev "lan" "lan" "$boardname:green:internet" 
"eth0"
+        ;;
  ex2700|\
  wn3000rpv3)
         set_wifi_led "$boardname:green:router"
diff --git a/target/linux/ramips/base-files/etc/board.d/02_network
b/target/linux/ramips/base-files/etc/board.d/02_network
index 2e56678cf5..9c9370411d 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -68,6 +68,8 @@ ramips_setup_interfaces()
         wnce2001|\
         zbt-cpe102|\
         zorlik,zl5900v2|\
+       edimax,ew-7476rpc|\
+       edimax,ew-7478ac|\
         zte-q7)
                 ucidef_add_switch "switch0"
                 ucidef_add_switch_attr "switch0" "enable" "false"
diff --git a/target/linux/ramips/dts/EW-7476RPC.dts
b/target/linux/ramips/dts/EW-7476RPC.dts
new file mode 100644
index 0000000000..382d1e5afc
--- /dev/null
+++ b/target/linux/ramips/dts/EW-7476RPC.dts
@@ -0,0 +1,226 @@
+/*
+ * Device Tree file for the Edimax EW-7476RPC
+ * based on Edimax BR-6478AC V2
+ *
+ * Copyright (C) 2016 Rohan Murch <rohan.murch@gmail.com>
+ * Copyright (C) 2016 Hans Ulli Kroll <ulli.kroll@googlemail.com>
+ * Copyright (C) 2017 James McKenzie <openwrt@madingley.org>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+
+ The following definitions were found in the orignal GPL firmware 
+ source HW_LED_WIRELESS_ABAND_="71"
+ HW_LED_WIRELESS_GBAND_="70"
+ HW_LED_WIRELES_="69"
+ HW_LED_POWER_="67"
+ HW_LED_WPS_="68"
+ HW_LED_LAN_="66"
+ HW_BUTTON_APSWITCH_BUT_1_="62"
+ HW_BUTTON_APSWITCH_BUT_2_="63"
+ HW_BUTTON_RESET_="60"
+
+ The device does not have a reset button (but there are solder pads for
a button), WPS and reset are swapped.
+
+ */
+
+/dts-v1/;
+
+#include "mt7620a.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       compatible = "edimax,ew-7476rpc", "ralink,mt7620a-soc";
+       model = "Edimax EW-7476RPC";
+
+       aliases {
+               led-boot = &led_power;
+               led-failsafe = &led_power;
+               led-running = &led_power;
+               led-upgrade = &led_power;
+       };
+
+       chosen {
+               bootargs = "console=ttyS0,57600";
+       };
+
+
+       keys {
+                compatible = "gpio-keys";
+
+                reset_wps {
+                        label = "reset_wps";
+                        gpios = <&gpio2 20 GPIO_ACTIVE_LOW>;
+                        linux,code = <KEY_RESTART>;
+                };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_power: power {
+                       label = "ew-7476rpc:green:power";
+                       gpios = <&gpio2 27 GPIO_ACTIVE_LOW>;
+               };
+               internet {
+                       label = "ew-7476rpc:green:internet";
+                       gpios = <&gpio2 26 GPIO_ACTIVE_LOW>;
+               };
+               wlan2g {
+                       label = "ew-7476rpc:blue:wlan2g";
+                       gpios = <&gpio2 30 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy1tpt";
+               };
+               wlan5g {
+                       label = "ew-7476rpc:blue:wlan5g";
+                       gpios = <&gpio2 31 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy0tpt";
+               };
+       };
+};
+
+
+&gpio2 {
+       status = "okay";
+};
+
+&spi0 {
+       status = "okay";
+
+       flash@0 {
+               compatible = "jedec,spi-nor";
+               reg = <0 0>;
+               spi-max-frequency = <10000000>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               reg = <0x0 0x30000>;
+                               read-only;
+                       };
+
+                       partition@30000 {
+                               label = "u-boot-env";
+                               reg = <0x30000 0x10000>;
+                               read-only;
+                       };
+
+                       factory: partition@40000 {
+                               label = "factory";
+                               reg = <0x40000 0x10000>;
+                               read-only;
+                       };
+
+                       partition@50000 {
+                               label = "cimage";
+                               reg = <0x50000 0x20000>;
+                               read-only;
+                       };
+
+                       partition@70000 {
+                               compatible = "edimax,uimage";
+                               label = "firmware";
+                               reg = <0x00070000 0x00790000>;
+                       };
+               };
+       };
+};
+
+&pinctrl {
+       state_default: pinctrl0 {
+               gpio {
+            // might need pin 39: ;
+                       ralink,group = "i2c", "uartf", "nd_sd",
"rgmii2", "spi refclk";
+                       ralink,function = "gpio";
+               };
+       };
+};
+
+
+&ethernet {
+
+    status = "okay";
+       mtd-mac-address = <&factory 0x4>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&rgmii1_pins &mdio_pins>;
+       mediatek,portmap = "l";
+    mediatek,mdio-mode = <1>;
+
+       port@5 {
+               status = "okay";
+               mediatek,fixed-link = <1000 1 1 1>;
+               phy-mode = "rgmii";
+       };
+
+       mdio-bus {
+               status = "okay";
+
+               phy0: ethernet-phy@0 {
+                       status ="disabled";
+                       reg = <0>;
+                       phy-mode = "rgmii";
+               };
+
+               phy1: ethernet-phy@1 {
+                       status = "disabled";
+                       reg = <1>;
+                       phy-mode = "rgmii";
+               };
+
+               phy2: ethernet-phy@2 {
+                       status = "disabled";
+                       reg = <2>;
+                       phy-mode = "rgmii";
+               };
+
+               phy3: ethernet-phy@3 {
+                       status = "disabled";
+                       reg = <3>;
+                       phy-mode = "rgmii";
+               };
+
+               phy4: ethernet-phy@4 {
+                       status = "disabled";
+                       reg = <4>;
+                       phy-mode = "rgmii";
+               };
+       };
+};
+
+
+&gsw {
+       mediatek,port5 = "gmac";
+       mediatek,rtl8211e-reset = "yes"; };
+
+
+&wmac {
+       ralink,mtd-eeprom = <&factory 0>; };
+
+&pcie {
+       status = "okay";
+};
+
+&pcie0 {
+       wifi@0,0 {
+               reg = <0x0000 0 0 0 0>;
+               mediatek,mtd-eeprom = <&factory 0x8000>;
+               mediatek,2ghz = <0>;
+       };
+};
+
+&ehci {
+       status = "okay";
+};
+
+&ohci {
+       status = "okay";
+};
diff --git a/target/linux/ramips/dts/EW-7478AC.dts
b/target/linux/ramips/dts/EW-7478AC.dts
new file mode 100644
index 0000000000..5d44823db3
--- /dev/null
+++ b/target/linux/ramips/dts/EW-7478AC.dts
@@ -0,0 +1,226 @@
+/*
+ * Device Tree file for the Edimax EW-7478AC
+ * based on Edimax BR-6478AC V2
+ *
+ * Copyright (C) 2016 Rohan Murch <rohan.murch@gmail.com>
+ * Copyright (C) 2016 Hans Ulli Kroll <ulli.kroll@googlemail.com>
+ * Copyright (C) 2017 James McKenzie <openwrt@madingley.org>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+
+ The following definitions were found in the orignal GPL firmware 
+ source HW_LED_WIRELESS_ABAND_="71"
+ HW_LED_WIRELESS_GBAND_="70"
+ HW_LED_WIRELES_="69"
+ HW_LED_POWER_="67"
+ HW_LED_WPS_="68"
+ HW_LED_LAN_="66"
+ HW_BUTTON_APSWITCH_BUT_1_="62"
+ HW_BUTTON_APSWITCH_BUT_2_="63"
+ HW_BUTTON_RESET_="60"
+
+ The device does not have a reset button (but there are solder pads for
a button), WPS and reset are swapped.
+
+ */
+
+/dts-v1/;
+
+#include "mt7620a.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       compatible = "edimax,ew-7476ac", "ralink,mt7620a-soc";
+       model = "Edimax EW-7478ac";
+
+       aliases {
+               led-boot = &led_power;
+               led-failsafe = &led_power;
+               led-running = &led_power;
+               led-upgrade = &led_power;
+       };
+
+       chosen {
+               bootargs = "console=ttyS0,57600";
+       };
+
+
+       keys {
+                compatible = "gpio-keys";
+
+                reset_wps {
+                        label = "reset_wps";
+                        gpios = <&gpio2 20 GPIO_ACTIVE_LOW>;
+                        linux,code = <KEY_RESTART>;
+                };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_power: power {
+                       label = "ew-7478ac:green:power";
+                       gpios = <&gpio2 27 GPIO_ACTIVE_LOW>;
+               };
+               internet {
+                       label = "ew-7478ac:green:internet";
+                       gpios = <&gpio2 26 GPIO_ACTIVE_LOW>;
+               };
+               wlan2g {
+                       label = "ew-7478ac:blue:wlan2g";
+                       gpios = <&gpio2 30 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy1tpt";
+               };
+               wlan5g {
+                       label = "ew-7478ac:blue:wlan5g";
+                       gpios = <&gpio2 31 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy0tpt";
+               };
+       };
+};
+
+
+&gpio2 {
+       status = "okay";
+};
+
+&spi0 {
+       status = "okay";
+
+       flash@0 {
+               compatible = "jedec,spi-nor";
+               reg = <0 0>;
+               spi-max-frequency = <10000000>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               reg = <0x0 0x30000>;
+                               read-only;
+                       };
+
+                       partition@30000 {
+                               label = "u-boot-env";
+                               reg = <0x30000 0x10000>;
+                               read-only;
+                       };
+
+                       factory: partition@40000 {
+                               label = "factory";
+                               reg = <0x40000 0x10000>;
+                               read-only;
+                       };
+
+                       partition@50000 {
+                               label = "cimage";
+                               reg = <0x50000 0x20000>;
+                               read-only;
+                       };
+
+                       partition@70000 {
+                               compatible = "edimax,uimage";
+                               label = "firmware";
+                               reg = <0x00070000 0x00790000>;
+                       };
+               };
+       };
+};
+
+&pinctrl {
+       state_default: pinctrl0 {
+               gpio {
+            // might need pin 39: ;
+                       ralink,group = "i2c", "uartf", "nd_sd",
"rgmii2", "spi refclk";
+                       ralink,function = "gpio";
+               };
+       };
+};
+
+
+&ethernet {
+
+    status = "okay";
+       mtd-mac-address = <&factory 0x4>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&rgmii1_pins &mdio_pins>;
+       mediatek,portmap = "l";
+    mediatek,mdio-mode = <1>;
+
+       port@5 {
+               status = "okay";
+               mediatek,fixed-link = <1000 1 1 1>;
+               phy-mode = "rgmii";
+       };
+
+       mdio-bus {
+               status = "okay";
+
+               phy0: ethernet-phy@0 {
+                       status ="disabled";
+                       reg = <0>;
+                       phy-mode = "rgmii";
+               };
+
+               phy1: ethernet-phy@1 {
+                       status = "disabled";
+                       reg = <1>;
+                       phy-mode = "rgmii";
+               };
+
+               phy2: ethernet-phy@2 {
+                       status = "disabled";
+                       reg = <2>;
+                       phy-mode = "rgmii";
+               };
+
+               phy3: ethernet-phy@3 {
+                       status = "disabled";
+                       reg = <3>;
+                       phy-mode = "rgmii";
+               };
+
+               phy4: ethernet-phy@4 {
+                       status = "disabled";
+                       reg = <4>;
+                       phy-mode = "rgmii";
+               };
+       };
+};
+
+
+&gsw {
+       mediatek,port5 = "gmac";
+       mediatek,rtl8211e-reset = "yes"; };
+
+
+&wmac {
+       ralink,mtd-eeprom = <&factory 0>; };
+
+&pcie {
+       status = "okay";
+};
+
+&pcie0 {
+       wifi@0,0 {
+               reg = <0x0000 0 0 0 0>;
+               mediatek,mtd-eeprom = <&factory 0x8000>;
+               mediatek,2ghz = <0>;
+       };
+};
+
+&ehci {
+       status = "okay";
+};
+
+&ohci {
+       status = "okay";
+};
diff --git
a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
index 5fc5080aaf..305ce18037 100644
---
a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
+++ 
b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
@@ -84,6 +84,32 @@ static int mt7620_mdio_mode(struct device_node *eth_node)
         return ret;
  }

+void reset_realtek_phy(void){
+#define RALINK_GPIO_DIR        0xB0000600+0x4C #define RALINK_GPIO_DATA       
+0xB0000600+0x48 #define RALINK_RESETPHY_GPIO       (39-24)
+    u32 gpiodir;
+    u32 piodata;
+    u32 reset_pin= RALINK_RESETPHY_GPIO;
+
+    pr_info("gsw: Resetting RTL8211e using gpio 39\n");
+    gpiodir =  le32_to_cpu(*(volatile u32 *)(RALINK_GPIO_DIR));
+    /*set gpio1 to output*/
+    gpiodir |= (1<<reset_pin);
+    *(volatile u32 *)(RALINK_GPIO_DIR) = cpu_to_le32(gpiodir);
+
+    piodata = le32_to_cpu(*(volatile u32 *)(RALINK_GPIO_DATA));
+    /*set to low(0)*/
+    piodata &= ~(1L << reset_pin);
+    *(volatile u32 *)(RALINK_GPIO_DATA) = cpu_to_le32(piodata);
+    /*delay 30ms*/
+    mdelay(30);
+    /*set to high(1)*/
+    piodata |= (1L << reset_pin);
+    *(volatile u32 *)(RALINK_GPIO_DATA) = cpu_to_le32(piodata); }
+
+
  static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode)
  {
         u32 i;
@@ -220,6 +246,7 @@ int mtk_gsw_init(struct fe_priv *priv)
         struct device_node *np = priv->switch_np;
         struct platform_device *pdev = of_find_device_by_node(np);
         struct mt7620_gsw *gsw;
+    const char *rtl8211e_reset = NULL;

         if (!pdev)
                 return -ENODEV;
@@ -231,6 +258,9 @@ int mtk_gsw_init(struct fe_priv *priv)
         priv->soc->swpriv = gsw;

         mt7620_hw_init(gsw, mt7620_mdio_mode(priv->dev->of_node));
+    of_property_read_string(np, "mediatek,rtl8211e-reset",
&rtl8211e_reset);
+    if (rtl8211e_reset && !strcmp(rtl8211e_reset, "yes"))
+        reset_realtek_phy();

         if (gsw->irq) {
                 request_irq(gsw->irq, gsw_interrupt_mt7620, 0, diff --git a/target/linux/ramips/image/mt7620.mk
b/target/linux/ramips/image/mt7620.mk
index cf38aa2cb1..93f4cdd442 100644
--- a/target/linux/ramips/image/mt7620.mk
+++ b/target/linux/ramips/image/mt7620.mk
@@ -617,6 +617,32 @@ define Device/edimax_br-6478ac-v2
  endef
  TARGET_DEVICES += edimax_br-6478ac-v2

+define Device/edimax_ew-7476rpc
+  DTS := EW-7476RPC
+  DEVICE_TITLE := Edimax EW-7476RPC
+  BLOCKSIZE := 64k
+  IMAGE_SIZE := 7616k
+  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \
+        edimax-header -s CSYS -m RN79 -f 0x70000 -S 0x01100000 |
pad-rootfs | \
+        append-metadata | check-size $$$$(IMAGE_SIZE)
+  DEVICE_PACKAGES := kmod-mt76x2 kmod-phy-realtek endef TARGET_DEVICES 
++= edimax_ew-7476rpc
+
+
+define Device/edimax_ew-7478ac
+  DTS := EW-7478AC
+  DEVICE_TITLE := Edimax EW-7478AC
+  BLOCKSIZE := 64k
+  IMAGE_SIZE := 7616k
+  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \
+        edimax-header -s CSYS -m RN70 -f 0x70000 -S 0x01100000 |
pad-rootfs | \
+        append-metadata | check-size $$$$(IMAGE_SIZE)
+  DEVICE_PACKAGES := kmod-mt76x2 kmod-phy-realtek endef TARGET_DEVICES 
++= edimax_ew-7478ac
+
+
  define Device/tplink_c2-v1
    $(Device/Archer)
    DTS := ArcherC2-v1
Cezary Jackiewicz May 26, 2019, 5:28 p.m. UTC | #3
Hi,
typo:

>          ;;
> +edimax,ew-7476rpc) \
> +edimax,ew-7478ac)

edimax,ew-7476rpc| \
edimax,ew-7478ac)

>+        ucidef_set_led_netdev "lan" "lan" "$boardname:green:internet" "eth0"
>+        ;;    

Also working:

ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x20"

(if you rename internet to lan)
Birger Koblitz May 26, 2019, 6:16 p.m. UTC | #4
Hi,

I'll work on all the open points and add the device description. Then I'll submit the next version of the patch.

Birger

On 26 May 2019 19:28:56 CEST, Cezary Jackiewicz <cezary.jackiewicz@gmail.com> wrote:
>Hi,
>typo:
>
>>          ;;
>> +edimax,ew-7476rpc) \
>> +edimax,ew-7478ac)
>
>edimax,ew-7476rpc| \
>edimax,ew-7478ac)
>
>>+        ucidef_set_led_netdev "lan" "lan" "$boardname:green:internet"
>"eth0"
>>+        ;;    
>
>Also working:
>
>ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0"
>"0x20"
>
>(if you rename internet to lan)
>
>-- 
>Pozdrawiam,
> Cezary Jackiewicz
>
>_______________________________________________
>openwrt-devel mailing list
>openwrt-devel@lists.openwrt.org
>https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Birger Koblitz May 26, 2019, 8:16 p.m. UTC | #5
Hi,

On 26.05.19 19:28, Cezary Jackiewicz wrote:
>> +        ucidef_set_led_netdev "lan" "lan" "$boardname:green:internet" "eth0"
>> +        ;;    
> Also working:
>
> ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x20"
>
> (if you rename internet to lan)
>
Are you sure about this? I renamed the internet to lan, but on the
7476rpc the led does not turn on:

+edimax,ew-7476rpc| \
+edimax,ew-7478ac)
+        ucidef_set_led_netdev "lan" "lan" "$boardname:green:lan" 
"switch0" "0x20"
+        ;;

+               lan {
+                       label = "ew-7476rpc:green:lan";
+                       gpios = <&gpio2 26 GPIO_ACTIVE_LOW>;
+               };

I'll also looked into a common .dtsi, but at the moment I'd prefer to
leave it simple and first have a look at the RE11 and RE11S to see what
the differences are.


The following would be the hardware information:

ramips: add Netgear EW-7476RPC

SoC:   MediaTek MT7620a @ 580MHz
RAM:   64M (Winbond W9751G6KB-25)
FLASH: 16MB (Macronix)
WiFi:  SoC-integrated: MediaTek MT76620a bgn
WiFi:  MediaTek MT7612EN nac
GBE:   RTL8211E
BTN:   WPS - RFKILL/RF 50%/RF 100% toggle
LED:    - Wifi 5g (blue)
        - Wifi 2g (blue)
        - Crossband (green)
        - Power (green)
        - WPS (green)
        - LAN (Green)
UART:  UART is present as Pads with throughholes on the PCB. They are
       located next to the switch for the wifi configuration
       3.3V - RX - GND - TX / 57600-8N1
       3.3V is the square pad

Installation
------------
Update the factory image via the web-interfaces (by default:
192.168.9.2/24).
http://192.168.9.2/index.asp

ramips: add Netgear EW-7478AC

SoC:   MediaTek MT7620a @ 580MHz
RAM:   64M (Winbond W9751G6KB-25)
FLASH: 16MB (Macronix)
WiFi:  SoC-integrated: MediaTek MT76620a bgn
WiFi:  MediaTek MT7612EN nac
GBE:   RTL8211E
BTN:   WPS - RFKILL/RF 50%/RF 100% toggle
LED:    - Wifi 5g (blue)
        - Wifi 2g (blue)
        - Crossband (green)
        - Power (green)
        - WPS (green)
        - LAN (Green)
UART:  UART is present as Pads with throughholes on the PCB. They are
       located next to the switch for the wifi configuration
       3.3V - RX - GND - TX / 57600-8N1
       3.3V is the square pad

Installation

------------
Update the factory image via the web-interfaces (by default:
http://edimaxext.setup)

The EW-7478AC is identical to the EW-7476RPC, except instead of 2 internal
antennas it has 2 external ones.

Birger


The complete patch looks like this:

diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds
b/target/linux/ramips/base-files/etc/board.d/01_leds
index b55ca0413e..868a30a06b 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -146,6 +146,10 @@ dir-860l-b1)
 edimax,br-6478ac-v2)
        set_wifi_led "$boardname:blue:wlan"
        ;;
+edimax,ew-7476rpc| \
+edimax,ew-7478ac)
+        ucidef_set_led_netdev "lan" "lan" "$boardname:green:lan" 
"switch0" "0x20"
+        ;;
 ex2700|\
 wn3000rpv3)
        set_wifi_led "$boardname:green:router"
diff --git a/target/linux/ramips/base-files/etc/board.d/02_network
b/target/linux/ramips/base-files/etc/board.d/02_network
index 2e56678cf5..bbdfe9b128 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -50,6 +50,8 @@ ramips_setup_interfaces()
        broadway|\
        dcs-930|\
        dcs-930l-b1|\
+       edimax,ew-7476rpc|\
+       edimax,ew-7478ac|\
        ht-tm02|\
        kimax,u35wf|\
        linkits7688 | \
diff --git a/target/linux/ramips/dts/EW-7476RPC.dts
b/target/linux/ramips/dts/EW-7476RPC.dts
new file mode 100644
index 0000000000..7b1c2832b3
--- /dev/null
+++ b/target/linux/ramips/dts/EW-7476RPC.dts
@@ -0,0 +1,238 @@
+/*
+ * Device Tree file for the Edimax EW-7476RPC
+ * based on Edimax BR-6478AC V2
+ *
+ * Copyright (C) 2016 Rohan Murch <rohan.murch@gmail.com>
+ * Copyright (C) 2016 Hans Ulli Kroll <ulli.kroll@googlemail.com>
+ * Copyright (C) 2017 James McKenzie <openwrt@madingley.org>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+
+ The following definitions were found in the orignal GPL firmware source
+ HW_LED_WIRELESS_ABAND_="71"
+ HW_LED_WIRELESS_GBAND_="70"
+ HW_LED_WIRELES_="69"
+ HW_LED_POWER_="67"
+ HW_LED_WPS_="68"
+ HW_LED_LAN_="66"
+ HW_BUTTON_APSWITCH_BUT_1_="62"
+ HW_BUTTON_APSWITCH_BUT_2_="63"
+ HW_BUTTON_RESET_="60"
+
+ The device does not have a reset button (but there are solder pads for
a button), WPS and reset are swapped.
+
+ */
+
+/dts-v1/;
+
+#include "mt7620a.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       compatible = "edimax,ew-7476rpc", "ralink,mt7620a-soc";
+       model = "Edimax EW-7476RPC";
+
+       aliases {
+               led-boot = &led_power;
+               led-failsafe = &led_power;
+               led-running = &led_power;
+               led-upgrade = &led_power;
+       };
+
+       chosen {
+               bootargs = "console=ttyS0,57600";
+       };
+
+
+       keys {
+                compatible = "gpio-keys";
+
+                reset_wps {
+                        label = "reset_wps";
+                        gpios = <&gpio2 20 GPIO_ACTIVE_LOW>;
+                        linux,code = <KEY_RESTART>;
+                };
+               switch_high {
+                       label = "switch high";
+                       gpios = <&gpio2 22 GPIO_ACTIVE_LOW>;
+                       linux,code = <BTN_0>;
+                       linux,input-type = <EV_SW>;
+               };
+               switch_off {
+                       label = "switch off";
+                       gpios = <&gpio2 23 GPIO_ACTIVE_LOW>;
+                       linux,code = <BTN_1>;
+                       linux,input-type = <EV_SW>;
+               };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_power: power {
+                       label = "ew-7476rpc:green:power";
+                       gpios = <&gpio2 27 GPIO_ACTIVE_LOW>;
+               };
+               lan {
+                       label = "ew-7476rpc:green:lan";
+                       gpios = <&gpio2 26 GPIO_ACTIVE_LOW>;
+               };
+               wlan2g {
+                       label = "ew-7476rpc:blue:wlan2g";
+                       gpios = <&gpio2 30 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy1tpt";
+               };
+               wlan5g {
+                       label = "ew-7476rpc:blue:wlan5g";
+                       gpios = <&gpio2 31 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy0tpt";
+               };
+               wps {
+                       label = "ew-7476rpc:green:wps";
+                       gpios = <&gpio2 28 GPIO_ACTIVE_LOW>;
+               };
+               crossband {
+                       label = "ew-7476rpc:green:crossband";
+                       gpios = <&gpio2 29 GPIO_ACTIVE_LOW>;
+               };
+       };
+};
+
+
+&gpio2 {
+       status = "okay";
+};
+
+&spi0 {
+       status = "okay";
+
+       flash@0 {
+               compatible = "jedec,spi-nor";
+               reg = <0 0>;
+               spi-max-frequency = <10000000>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               reg = <0x0 0x30000>;
+                               read-only;
+                       };
+
+                       partition@30000 {
+                               label = "u-boot-env";
+                               reg = <0x30000 0x10000>;
+                               read-only;
+                       };
+
+                       factory: partition@40000 {
+                               label = "factory";
+                               reg = <0x40000 0x10000>;
+                               read-only;
+                       };
+
+                       partition@50000 {
+                               label = "cimage";
+                               reg = <0x50000 0x20000>;
+                               read-only;
+                       };
+
+                       partition@70000 {
+                               compatible = "edimax,uimage";
+                               label = "firmware";
+                               reg = <0x00070000 0x00790000>;
+                       };
+               };
+       };
+};
+
+&pinctrl {
+       state_default: pinctrl0 {
+               gpio {
+            // might need pin 39: ;
+                       ralink,group = "i2c", "uartf", "nd_sd",
"rgmii2", "spi refclk";
+                       ralink,function = "gpio";
+               };
+       };
+};
+
+
+&ethernet {
+
+    status = "okay";
+       mtd-mac-address = <&factory 0x4>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&rgmii1_pins &mdio_pins>;
+       mediatek,portmap = "l";
+    mediatek,mdio-mode = <1>;
+   
+       port@5 {
+               status = "okay";
+               mediatek,fixed-link = <1000 1 1 1>;
+               phy-mode = "rgmii";
+       };
+
+       mdio-bus {
+               status = "okay";
+
+               phy0: ethernet-phy@0 {
+                       status ="disabled";
+                       reg = <0>;
+                       phy-mode = "rgmii";
+               };
+
+               phy1: ethernet-phy@1 {
+                       status = "disabled";
+                       reg = <1>;
+                       phy-mode = "rgmii";
+               };
+
+               phy2: ethernet-phy@2 {
+                       status = "disabled";
+                       reg = <2>;
+                       phy-mode = "rgmii";
+               };
+
+               phy3: ethernet-phy@3 {
+                       status = "disabled";
+                       reg = <3>;
+                       phy-mode = "rgmii";
+               };
+
+               phy4: ethernet-phy@4 {
+                       status = "disabled";
+                       reg = <4>;
+                       phy-mode = "rgmii";
+               };
+       };
+};
+
+
+&gsw {
+       mediatek,port5 = "gmac";
+       mediatek,rtl8211e-reset = "yes";
+};
+
+
+&wmac {
+       ralink,mtd-eeprom = <&factory 0>;
+};
+
+&pcie {
+       status = "okay";
+};
+
+&pcie0 {
+       wifi@0,0 {
+               reg = <0x0000 0 0 0 0>;
+               mediatek,mtd-eeprom = <&factory 0x8000>;
+               mediatek,2ghz = <0>;
+       };
+};
diff --git a/target/linux/ramips/dts/EW-7478AC.dts
b/target/linux/ramips/dts/EW-7478AC.dts
new file mode 100644
index 0000000000..ac207abf41
--- /dev/null
+++ b/target/linux/ramips/dts/EW-7478AC.dts
@@ -0,0 +1,241 @@
+/*
+ * Device Tree file for the Edimax EW-7478AC
+ * based on Edimax BR-6478AC V2
+ *
+ * Copyright (C) 2016 Rohan Murch <rohan.murch@gmail.com>
+ * Copyright (C) 2016 Hans Ulli Kroll <ulli.kroll@googlemail.com>
+ * Copyright (C) 2017 James McKenzie <openwrt@madingley.org>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+
+ The following definitions were found in the orignal GPL firmware source
+ HW_LED_WIRELESS_ABAND_="71"
+ HW_LED_WIRELESS_GBAND_="70"
+ HW_LED_WIRELES_="69"
+ HW_LED_POWER_="67"
+ HW_LED_WPS_="68"
+ HW_LED_LAN_="66"
+ HW_BUTTON_APSWITCH_BUT_1_="62"
+ HW_BUTTON_APSWITCH_BUT_2_="63"
+ HW_BUTTON_RESET_="60"
+
+ The device does not have a reset button (but there are solder pads for
a button), WPS and reset are swapped.
+
+ */
+
+/dts-v1/;
+
+#include "mt7620a.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       compatible = "edimax,ew-7478ac", "ralink,mt7620a-soc";
+       model = "Edimax EW-7478ac";
+
+       aliases {
+               led-boot = &led_power;
+               led-failsafe = &led_power;
+               led-running = &led_power;
+               led-upgrade = &led_power;
+       };
+
+       chosen {
+               bootargs = "console=ttyS0,57600";
+       };
+
+
+       keys {
+                compatible = "gpio-keys";
+
+                reset_wps {
+                        label = "reset_wps";
+                        gpios = <&gpio2 20 GPIO_ACTIVE_LOW>;
+                        linux,code = <KEY_RESTART>;
+                };
+
+               switch_high {
+                       label = "switch high";
+                       gpios = <&gpio2 22 GPIO_ACTIVE_LOW>;
+                       linux,code = <BTN_0>;
+                       linux,input-type = <EV_SW>;
+               };
+
+               switch_off {
+                       label = "switch off";
+                       gpios = <&gpio2 23 GPIO_ACTIVE_LOW>;
+                       linux,code = <BTN_1>;
+                       linux,input-type = <EV_SW>;
+               };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_power: power {
+                       label = "ew-7478ac:green:power";
+                       gpios = <&gpio2 27 GPIO_ACTIVE_LOW>;
+               };
+               lan {
+                       label = "ew-7478ac:green:lan";
+                       gpios = <&gpio2 26 GPIO_ACTIVE_LOW>;
+               };
+               wlan2g {
+                       label = "ew-7478ac:blue:wlan2g";
+                       gpios = <&gpio2 30 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy1tpt";
+               };
+               wlan5g {
+                       label = "ew-7478ac:blue:wlan5g";
+                       gpios = <&gpio2 31 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy0tpt";
+               };
+               wps {
+                       label = "ew-7478ac:green:wps";
+                       gpios = <&gpio2 28 GPIO_ACTIVE_LOW>;
+               };
+
+               crossband {
+                       label = "ew-7478ac:green:crossband";
+                       gpios = <&gpio2 29 GPIO_ACTIVE_LOW>;
+               };
+       };
+};
+
+
+&gpio2 {
+       status = "okay";
+};
+
+&spi0 {
+       status = "okay";
+
+       flash@0 {
+               compatible = "jedec,spi-nor";
+               reg = <0 0>;
+               spi-max-frequency = <10000000>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               reg = <0x0 0x30000>;
+                               read-only;
+                       };
+
+                       partition@30000 {
+                               label = "u-boot-env";
+                               reg = <0x30000 0x10000>;
+                               read-only;
+                       };
+
+                       factory: partition@40000 {
+                               label = "factory";
+                               reg = <0x40000 0x10000>;
+                               read-only;
+                       };
+
+                       partition@50000 {
+                               label = "cimage";
+                               reg = <0x50000 0x20000>;
+                               read-only;
+                       };
+
+                       partition@70000 {
+                               compatible = "edimax,uimage";
+                               label = "firmware";
+                               reg = <0x00070000 0x00790000>;
+                       };
+               };
+       };
+};
+
+&pinctrl {
+       state_default: pinctrl0 {
+               gpio {
+            // might need pin 39: ;
+                       ralink,group = "i2c", "uartf", "nd_sd",
"rgmii2", "spi refclk";
+                       ralink,function = "gpio";
+               };
+       };
+};
+
+
+&ethernet {
+
+    status = "okay";
+       mtd-mac-address = <&factory 0x4>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&rgmii1_pins &mdio_pins>;
+       mediatek,portmap = "l";
+    mediatek,mdio-mode = <1>;
+   
+       port@5 {
+               status = "okay";
+               mediatek,fixed-link = <1000 1 1 1>;
+               phy-mode = "rgmii";
+       };
+
+       mdio-bus {
+               status = "okay";
+
+               phy0: ethernet-phy@0 {
+                       status ="disabled";
+                       reg = <0>;
+                       phy-mode = "rgmii";
+               };
+
+               phy1: ethernet-phy@1 {
+                       status = "disabled";
+                       reg = <1>;
+                       phy-mode = "rgmii";
+               };
+
+               phy2: ethernet-phy@2 {
+                       status = "disabled";
+                       reg = <2>;
+                       phy-mode = "rgmii";
+               };
+
+               phy3: ethernet-phy@3 {
+                       status = "disabled";
+                       reg = <3>;
+                       phy-mode = "rgmii";
+               };
+
+               phy4: ethernet-phy@4 {
+                       status = "disabled";
+                       reg = <4>;
+                       phy-mode = "rgmii";
+               };
+       };
+};
+
+
+&gsw {
+       mediatek,port5 = "gmac";
+       mediatek,rtl8211e-reset = "yes";
+};
+
+
+&wmac {
+       ralink,mtd-eeprom = <&factory 0>;
+};
+
+&pcie {
+       status = "okay";
+};
+
+&pcie0 {
+       wifi@0,0 {
+               reg = <0x0000 0 0 0 0>;
+               mediatek,mtd-eeprom = <&factory 0x8000>;
+               mediatek,2ghz = <0>;
+       };
+};
diff --git
a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
index 5fc5080aaf..305ce18037 100644
---
a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
+++
b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
@@ -84,6 +84,32 @@ static int mt7620_mdio_mode(struct device_node *eth_node)
        return ret;
 }
 
+void reset_realtek_phy(void){
+#define RALINK_GPIO_DIR        0xB0000600+0x4C
+#define RALINK_GPIO_DATA       0xB0000600+0x48
+#define RALINK_RESETPHY_GPIO       (39-24)
+    u32 gpiodir;
+    u32 piodata;
+    u32 reset_pin= RALINK_RESETPHY_GPIO;
+   
+    pr_info("gsw: Resetting RTL8211e using gpio 39\n");
+    gpiodir =  le32_to_cpu(*(volatile u32 *)(RALINK_GPIO_DIR));
+    /*set gpio1 to output*/
+    gpiodir |= (1<<reset_pin);
+    *(volatile u32 *)(RALINK_GPIO_DIR) = cpu_to_le32(gpiodir);
+
+    piodata = le32_to_cpu(*(volatile u32 *)(RALINK_GPIO_DATA));
+    /*set to low(0)*/
+    piodata &= ~(1L << reset_pin);
+    *(volatile u32 *)(RALINK_GPIO_DATA) = cpu_to_le32(piodata);
+    /*delay 30ms*/
+    mdelay(30);
+    /*set to high(1)*/
+    piodata |= (1L << reset_pin);
+    *(volatile u32 *)(RALINK_GPIO_DATA) = cpu_to_le32(piodata);
+}
+
+
 static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode)
 {
        u32 i;
@@ -220,6 +246,7 @@ int mtk_gsw_init(struct fe_priv *priv)
        struct device_node *np = priv->switch_np;
        struct platform_device *pdev = of_find_device_by_node(np);
        struct mt7620_gsw *gsw;
+    const char *rtl8211e_reset = NULL;
 
        if (!pdev)
                return -ENODEV;
@@ -231,6 +258,9 @@ int mtk_gsw_init(struct fe_priv *priv)
        priv->soc->swpriv = gsw;
 
        mt7620_hw_init(gsw, mt7620_mdio_mode(priv->dev->of_node));
+    of_property_read_string(np, "mediatek,rtl8211e-reset",
&rtl8211e_reset);
+    if (rtl8211e_reset && !strcmp(rtl8211e_reset, "yes"))
+        reset_realtek_phy();
 
        if (gsw->irq) {
                request_irq(gsw->irq, gsw_interrupt_mt7620, 0,
diff --git a/target/linux/ramips/image/mt7620.mk
b/target/linux/ramips/image/mt7620.mk
index cf38aa2cb1..a7b14593c2 100644
--- a/target/linux/ramips/image/mt7620.mk
+++ b/target/linux/ramips/image/mt7620.mk
@@ -617,6 +617,32 @@ define Device/edimax_br-6478ac-v2
 endef
 TARGET_DEVICES += edimax_br-6478ac-v2
 
+define Device/edimax_ew-7476rpc
+  DTS := EW-7476RPC
+  DEVICE_TITLE := Edimax EW-7476RPC
+  BLOCKSIZE := 4k
+  IMAGE_SIZE := 7616k
+  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \
+        edimax-header -s CSYS -m RN79 -f 0x70000 -S 0x01100000 |
pad-rootfs | \
+        append-metadata | check-size $$$$(IMAGE_SIZE)
+  DEVICE_PACKAGES := kmod-mt76x2 kmod-phy-realtek
+endef
+TARGET_DEVICES += edimax_ew-7476rpc
+
+
+define Device/edimax_ew-7478ac
+  DTS := EW-7478AC
+  DEVICE_TITLE := Edimax EW-7478AC
+  BLOCKSIZE := 4k
+  IMAGE_SIZE := 7616k
+  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \
+        edimax-header -s CSYS -m RN70 -f 0x70000 -S 0x01100000 |
pad-rootfs | \
+        append-metadata | check-size $$$$(IMAGE_SIZE)
+  DEVICE_PACKAGES := kmod-mt76x2 kmod-phy-realtek
+endef
+TARGET_DEVICES += edimax_ew-7478ac
+
+
 define Device/tplink_c2-v1
   $(Device/Archer)
   DTS := ArcherC2-v1
Cezary Jackiewicz May 26, 2019, 8:46 p.m. UTC | #6
Dnia 2019-05-26, o godz. 22:16:30
Birger Koblitz <mail@birger-koblitz.de> napisał(a):

> Hi,
> 
> On 26.05.19 19:28, Cezary Jackiewicz wrote:
> >> +        ucidef_set_led_netdev "lan" "lan" "$boardname:green:internet" "eth0"
> >> +        ;;      
> > Also working:
> >
> > ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x20"
> >
> > (if you rename internet to lan)
> >  
> Are you sure about this? I renamed the internet to lan, but on the
> 7476rpc the led does not turn on:

On 7478ac, yes, i'm sure.

root@OpenWrt:~# swconfig dev switch0 show | grep port
	link: port:0 link:down
	link: port:1 link:down
	link: port:2 link:down
	link: port:3 link:down
	link: port:4 link:down
	link: port:5 link:up speed:1000baseT full-duplex 
	link: port:6 link:up speed:1000baseT full-duplex 
	link: port:7 link:down
root@OpenWrt:~# cat /sys/class/leds/ew-7478ac\:green\:lan/trigger 
none [switch0] timer default-on netdev phy0rx phy0tx phy0assoc phy0radio phy0tpt phy1rx phy1tx phy1assoc phy1radio 
root@OpenWrt:~# cat /sys/class/leds/ew-7478ac\:green\:lan/port_mask 
0x20
root@OpenWrt:~# 


> SoC:   MediaTek MT7620a @ 580MHz
> RAM:   64M (Winbond W9751G6KB-25)
> FLASH: 16MB (Macronix)

Are you sure? On your dts:

> +                       partition@70000 {
> +                               compatible = "edimax,uimage";
> +                               label = "firmware";
> +                               reg = <0x00070000 0x00790000>;
> +                       };

This is 8MB

[    1.274276] spi spi0.0: force spi mode3
[    1.282777] m25p80 spi0.0: mx25l6405d (8192 Kbytes)
[    1.292601] 5 fixed-partitions partitions found on MTD device spi0.0
[    1.305262] Creating 5 MTD partitions on "spi0.0":



> Installation
> ------------
> Update the factory image via the web-interfaces (by default:
> 192.168.9.2/24).
> http://192.168.9.2/index.asp

Or push wpa button on power on and send firmware via tftp to 192.168.1.6 
 
> ramips: add Netgear EW-7478AC
> 
> SoC:   MediaTek MT7620a @ 580MHz
> RAM:   64M (Winbond W9751G6KB-25)
> FLASH: 16MB (Macronix)

8MB :) in version sold in Poland.
Birger Koblitz May 26, 2019, 9:05 p.m. UTC | #7
On 26.05.19 22:46, Cezary Jackiewicz wrote:
> Dnia 2019-05-26, o godz. 22:16:30
> Birger Koblitz <mail@birger-koblitz.de> napisał(a):
>
>> Hi,
>>
>> On 26.05.19 19:28, Cezary Jackiewicz wrote:
>>>> +        ucidef_set_led_netdev "lan" "lan" "$boardname:green:internet" "eth0"
>>>> +        ;;      
>>> Also working:
>>>
>>> ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x20"
>>>
>>> (if you rename internet to lan)
>>>  
>> Are you sure about this? I renamed the internet to lan, but on the
>> 7476rpc the led does not turn on:
> On 7478ac, yes, i'm sure.
>
> root@OpenWrt:~# swconfig dev switch0 show | grep port
> 	link: port:0 link:down
> 	link: port:1 link:down
> 	link: port:2 link:down
> 	link: port:3 link:down
> 	link: port:4 link:down
> 	link: port:5 link:up speed:1000baseT full-duplex 
> 	link: port:6 link:up speed:1000baseT full-duplex 
> 	link: port:7 link:down
> root@OpenWrt:~# cat /sys/class/leds/ew-7478ac\:green\:lan/trigger 
> none [switch0] timer default-on netdev phy0rx phy0tx phy0assoc phy0radio phy0tpt phy1rx phy1tx phy1assoc phy1radio 
> root@OpenWrt:~# cat /sys/class/leds/ew-7478ac\:green\:lan/port_mask 
> 0x20
> root@OpenWrt:~# 

I get:

root@OpenWrt:~# ls /sys/class/leds/ew-7476rpc\:green\:lan/
brightness      device          device_name     interval       
link            max_brightness  rx              subsystem      
trigger         tx              uevent

no port_mask


>
>> SoC:   MediaTek MT7620a @ 580MHz
>> RAM:   64M (Winbond W9751G6KB-25)
>> FLASH: 16MB (Macronix)
> Are you sure? On your dts:
>
>> +                       partition@70000 {
>> +                               compatible = "edimax,uimage";
>> +                               label = "firmware";
>> +                               reg = <0x00070000 0x00790000>;
>> +                       };
> This is 8MB

Yes, you are right, according to http://www.acelink.com.tw/EW-7476RPC.html


>
> [    1.274276] spi spi0.0: force spi mode3
> [    1.282777] m25p80 spi0.0: mx25l6405d (8192 Kbytes)
> [    1.292601] 5 fixed-partitions partitions found on MTD device spi0.0
> [    1.305262] Creating 5 MTD partitions on "spi0.0":
>
>
>
>> Installation
>> ------------
>> Update the factory image via the web-interfaces (by default:
>> 192.168.9.2/24).
>> http://192.168.9.2/index.asp
> Or push wpa button on power on and send firmware via tftp to 192.168.1.6 
>  
>> ramips: add Netgear EW-7478AC
>>
>> SoC:   MediaTek MT7620a @ 580MHz
>> RAM:   64M (Winbond W9751G6KB-25)
>> FLASH: 16MB (Macronix)
> 8MB :) in version sold in Poland.
>
>
Unfortunately also in Germany :( . Otherwise I looked into the firmware
of the Edimax RE-11 and there the magic bytes are RN74. Otherwise the
firmware looks identical to the other models.

Birger
Cezary Jackiewicz May 27, 2019, 4:34 a.m. UTC | #8
Dnia 2019-05-26, o godz. 23:05:35
Birger Koblitz <mail@birger-koblitz.de> napisał(a):

> > root@OpenWrt:~# swconfig dev switch0 show | grep port
> > 	link: port:0 link:down
> > 	link: port:1 link:down
> > 	link: port:2 link:down
> > 	link: port:3 link:down
> > 	link: port:4 link:down
> > 	link: port:5 link:up speed:1000baseT full-duplex 
> > 	link: port:6 link:up speed:1000baseT full-duplex 
> > 	link: port:7 link:down
> > root@OpenWrt:~# cat /sys/class/leds/ew-7478ac\:green\:lan/trigger 
> > none [switch0] timer default-on netdev phy0rx phy0tx phy0assoc phy0radio phy0tpt phy1rx phy1tx phy1assoc phy1radio 
> > root@OpenWrt:~# cat /sys/class/leds/ew-7478ac\:green\:lan/port_mask 
> > 0x20
> > root@OpenWrt:~#   
> 
> I get:
> 
> root@OpenWrt:~# ls /sys/class/leds/ew-7476rpc\:green\:lan/
> brightness      device          device_name     interval       
> link            max_brightness  rx              subsystem      
> trigger         tx              uevent
> 
> no port_mask

Set trigger to switch0 first.
diff mbox series

Patch

diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds 
b/target/linux/ramips/base-files/etc/board.d/01_leds
index b55ca0413e..cc5b305444 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -146,6 +146,10 @@  dir-860l-b1)
  edimax,br-6478ac-v2)
         set_wifi_led "$boardname:blue:wlan"
         ;;
+edimax,ew-7476rpc) \
+edimax,ew-7478ac)
+        ucidef_set_led_netdev "lan" "lan" "$boardname:green:internet" 
"eth0"
+        ;;
  ex2700|\
  wn3000rpv3)
         set_wifi_led "$boardname:green:router"
diff --git a/target/linux/ramips/base-files/etc/board.d/02_network 
b/target/linux/ramips/base-files/etc/board.d/02_network
index 2e56678cf5..9c9370411d 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -68,6 +68,8 @@  ramips_setup_interfaces()
         wnce2001|\
         zbt-cpe102|\
         zorlik,zl5900v2|\
+       edimax,ew-7476rpc|\
+       edimax,ew-7478ac|\
         zte-q7)
                 ucidef_add_switch "switch0"
                 ucidef_add_switch_attr "switch0" "enable" "false"
diff --git a/target/linux/ramips/dts/EW-7476RPC.dts 
b/target/linux/ramips/dts/EW-7476RPC.dts
new file mode 100644
index 0000000000..382d1e5afc
--- /dev/null
+++ b/target/linux/ramips/dts/EW-7476RPC.dts
@@ -0,0 +1,226 @@ 
+/*
+ * Device Tree file for the Edimax EW-7476RPC
+ * based on Edimax BR-6478AC V2
+ *
+ * Copyright (C) 2016 Rohan Murch <rohan.murch@gmail.com>
+ * Copyright (C) 2016 Hans Ulli Kroll <ulli.kroll@googlemail.com>
+ * Copyright (C) 2017 James McKenzie <openwrt@madingley.org>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+
+ The following definitions were found in the orignal GPL firmware source
+ HW_LED_WIRELESS_ABAND_="71"
+ HW_LED_WIRELESS_GBAND_="70"
+ HW_LED_WIRELES_="69"
+ HW_LED_POWER_="67"
+ HW_LED_WPS_="68"
+ HW_LED_LAN_="66"
+ HW_BUTTON_APSWITCH_BUT_1_="62"
+ HW_BUTTON_APSWITCH_BUT_2_="63"
+ HW_BUTTON_RESET_="60"
+
+ The device does not have a reset button (but there are solder pads for 
a button), WPS and reset are swapped.
+
+ */
+
+/dts-v1/;
+
+#include "mt7620a.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       compatible = "edimax,ew-7476rpc", "ralink,mt7620a-soc";
+       model = "Edimax EW-7476RPC";
+
+       aliases {
+               led-boot = &led_power;
+               led-failsafe = &led_power;
+               led-running = &led_power;
+               led-upgrade = &led_power;
+       };
+
+       chosen {
+               bootargs = "console=ttyS0,57600";
+       };
+
+
+       keys {
+                compatible = "gpio-keys";
+
+                reset_wps {
+                        label = "reset_wps";
+                        gpios = <&gpio2 20 GPIO_ACTIVE_LOW>;
+                        linux,code = <KEY_RESTART>;
+                };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_power: power {
+                       label = "ew-7476rpc:green:power";
+                       gpios = <&gpio2 27 GPIO_ACTIVE_LOW>;
+               };
+               internet {
+                       label = "ew-7476rpc:green:internet";
+                       gpios = <&gpio2 26 GPIO_ACTIVE_LOW>;
+               };
+               wlan2g {
+                       label = "ew-7476rpc:blue:wlan2g";
+                       gpios = <&gpio2 30 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy1tpt";
+               };
+               wlan5g {
+                       label = "ew-7476rpc:blue:wlan5g";
+                       gpios = <&gpio2 31 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy0tpt";
+               };
+       };
+};
+
+
+&gpio2 {
+       status = "okay";
+};
+
+&spi0 {
+       status = "okay";
+
+       flash@0 {
+               compatible = "jedec,spi-nor";
+               reg = <0 0>;
+               spi-max-frequency = <10000000>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               reg = <0x0 0x30000>;
+                               read-only;
+                       };
+
+                       partition@30000 {
+                               label = "u-boot-env";
+                               reg = <0x30000 0x10000>;
+                               read-only;
+                       };
+
+                       factory: partition@40000 {
+                               label = "factory";
+                               reg = <0x40000 0x10000>;
+                               read-only;
+                       };
+
+                       partition@50000 {
+                               label = "cimage";
+                               reg = <0x50000 0x20000>;
+                               read-only;
+                       };
+
+                       partition@70000 {
+                               compatible = "edimax,uimage";
+                               label = "firmware";
+                               reg = <0x00070000 0x00790000>;
+                       };
+               };
+       };
+};
+
+&pinctrl {
+       state_default: pinctrl0 {
+               gpio {
+            // might need pin 39: ;
+                       ralink,group = "i2c", "uartf", "nd_sd", 
"rgmii2", "spi refclk";
+                       ralink,function = "gpio";
+               };
+       };
+};
+
+
+&ethernet {
+
+    status = "okay";
+       mtd-mac-address = <&factory 0x4>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&rgmii1_pins &mdio_pins>;
+       mediatek,portmap = "l";
+    mediatek,mdio-mode = <1>;
+
+       port@5 {
+               status = "okay";
+               mediatek,fixed-link = <1000 1 1 1>;
+               phy-mode = "rgmii";
+       };
+
+       mdio-bus {
+               status = "okay";
+
+               phy0: ethernet-phy@0 {
+                       status ="disabled";
+                       reg = <0>;
+                       phy-mode = "rgmii";
+               };
+
+               phy1: ethernet-phy@1 {
+                       status = "disabled";
+                       reg = <1>;
+                       phy-mode = "rgmii";
+               };
+
+               phy2: ethernet-phy@2 {
+                       status = "disabled";
+                       reg = <2>;
+                       phy-mode = "rgmii";
+               };
+
+               phy3: ethernet-phy@3 {
+                       status = "disabled";
+                       reg = <3>;
+                       phy-mode = "rgmii";
+               };
+
+               phy4: ethernet-phy@4 {
+                       status = "disabled";
+                       reg = <4>;
+                       phy-mode = "rgmii";
+               };
+       };
+};
+
+
+&gsw {
+       mediatek,port5 = "gmac";
+       mediatek,rtl8211e-reset = "yes";
+};
+
+
+&wmac {
+       ralink,mtd-eeprom = <&factory 0>;
+};
+
+&pcie {
+       status = "okay";
+};
+
+&pcie0 {
+       wifi@0,0 {
+               reg = <0x0000 0 0 0 0>;
+               mediatek,mtd-eeprom = <&factory 0x8000>;
+               mediatek,2ghz = <0>;
+       };
+};
+
+&ehci {
+       status = "okay";
+};
+
+&ohci {
+       status = "okay";
+};
diff --git a/target/linux/ramips/dts/EW-7478AC.dts 
b/target/linux/ramips/dts/EW-7478AC.dts
new file mode 100644
index 0000000000..5d44823db3
--- /dev/null
+++ b/target/linux/ramips/dts/EW-7478AC.dts
@@ -0,0 +1,226 @@ 
+/*
+ * Device Tree file for the Edimax EW-7478AC
+ * based on Edimax BR-6478AC V2
+ *
+ * Copyright (C) 2016 Rohan Murch <rohan.murch@gmail.com>
+ * Copyright (C) 2016 Hans Ulli Kroll <ulli.kroll@googlemail.com>
+ * Copyright (C) 2017 James McKenzie <openwrt@madingley.org>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+
+ The following definitions were found in the orignal GPL firmware source
+ HW_LED_WIRELESS_ABAND_="71"
+ HW_LED_WIRELESS_GBAND_="70"
+ HW_LED_WIRELES_="69"
+ HW_LED_POWER_="67"
+ HW_LED_WPS_="68"
+ HW_LED_LAN_="66"
+ HW_BUTTON_APSWITCH_BUT_1_="62"
+ HW_BUTTON_APSWITCH_BUT_2_="63"
+ HW_BUTTON_RESET_="60"
+
+ The device does not have a reset button (but there are solder pads for 
a button), WPS and reset are swapped.
+
+ */
+
+/dts-v1/;
+
+#include "mt7620a.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       compatible = "edimax,ew-7476ac", "ralink,mt7620a-soc";
+       model = "Edimax EW-7478ac";
+
+       aliases {
+               led-boot = &led_power;
+               led-failsafe = &led_power;
+               led-running = &led_power;
+               led-upgrade = &led_power;
+       };
+
+       chosen {
+               bootargs = "console=ttyS0,57600";
+       };
+
+
+       keys {
+                compatible = "gpio-keys";
+
+                reset_wps {
+                        label = "reset_wps";
+                        gpios = <&gpio2 20 GPIO_ACTIVE_LOW>;
+                        linux,code = <KEY_RESTART>;
+                };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_power: power {
+                       label = "ew-7478ac:green:power";
+                       gpios = <&gpio2 27 GPIO_ACTIVE_LOW>;
+               };
+               internet {
+                       label = "ew-7478ac:green:internet";
+                       gpios = <&gpio2 26 GPIO_ACTIVE_LOW>;
+               };
+               wlan2g {
+                       label = "ew-7478ac:blue:wlan2g";
+                       gpios = <&gpio2 30 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy1tpt";
+               };
+               wlan5g {
+                       label = "ew-7478ac:blue:wlan5g";
+                       gpios = <&gpio2 31 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy0tpt";
+               };
+       };
+};
+
+
+&gpio2 {
+       status = "okay";
+};
+
+&spi0 {
+       status = "okay";
+
+       flash@0 {
+               compatible = "jedec,spi-nor";
+               reg = <0 0>;
+               spi-max-frequency = <10000000>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               reg = <0x0 0x30000>;
+                               read-only;
+                       };
+
+                       partition@30000 {
+                               label = "u-boot-env";
+                               reg = <0x30000 0x10000>;
+                               read-only;
+                       };
+
+                       factory: partition@40000 {
+                               label = "factory";
+                               reg = <0x40000 0x10000>;
+                               read-only;
+                       };
+
+                       partition@50000 {
+                               label = "cimage";
+                               reg = <0x50000 0x20000>;
+                               read-only;
+                       };
+
+                       partition@70000 {
+                               compatible = "edimax,uimage";
+                               label = "firmware";
+                               reg = <0x00070000 0x00790000>;
+                       };
+               };
+       };
+};
+
+&pinctrl {
+       state_default: pinctrl0 {
+               gpio {
+            // might need pin 39: ;
+                       ralink,group = "i2c", "uartf", "nd_sd", 
"rgmii2", "spi refclk";
+                       ralink,function = "gpio";
+               };
+       };
+};
+
+
+&ethernet {
+
+    status = "okay";
+       mtd-mac-address = <&factory 0x4>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&rgmii1_pins &mdio_pins>;
+       mediatek,portmap = "l";
+    mediatek,mdio-mode = <1>;
+
+       port@5 {
+               status = "okay";
+               mediatek,fixed-link = <1000 1 1 1>;
+               phy-mode = "rgmii";
+       };
+
+       mdio-bus {
+               status = "okay";
+
+               phy0: ethernet-phy@0 {
+                       status ="disabled";
+                       reg = <0>;
+                       phy-mode = "rgmii";
+               };
+
+               phy1: ethernet-phy@1 {
+                       status = "disabled";
+                       reg = <1>;
+                       phy-mode = "rgmii";
+               };
+
+               phy2: ethernet-phy@2 {
+                       status = "disabled";
+                       reg = <2>;
+                       phy-mode = "rgmii";
+               };
+
+               phy3: ethernet-phy@3 {
+                       status = "disabled";
+                       reg = <3>;
+                       phy-mode = "rgmii";
+               };
+
+               phy4: ethernet-phy@4 {
+                       status = "disabled";
+                       reg = <4>;
+                       phy-mode = "rgmii";
+               };
+       };
+};
+
+
+&gsw {
+       mediatek,port5 = "gmac";
+       mediatek,rtl8211e-reset = "yes";
+};
+
+
+&wmac {
+       ralink,mtd-eeprom = <&factory 0>;
+};
+
+&pcie {
+       status = "okay";
+};
+
+&pcie0 {
+       wifi@0,0 {
+               reg = <0x0000 0 0 0 0>;
+               mediatek,mtd-eeprom = <&factory 0x8000>;
+               mediatek,2ghz = <0>;
+       };
+};
+
+&ehci {
+       status = "okay";
+};
+
+&ohci {
+       status = "okay";
+};
diff --git 
a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c 
b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
index 5fc5080aaf..305ce18037 100644
--- 
a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
+++ 
b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
@@ -84,6 +84,32 @@  static int mt7620_mdio_mode(struct device_node *eth_node)
         return ret;
  }

+void reset_realtek_phy(void){
+#define RALINK_GPIO_DIR        0xB0000600+0x4C
+#define RALINK_GPIO_DATA       0xB0000600+0x48
+#define RALINK_RESETPHY_GPIO       (39-24)
+    u32 gpiodir;
+    u32 piodata;
+    u32 reset_pin= RALINK_RESETPHY_GPIO;
+
+    pr_info("gsw: Resetting RTL8211e using gpio 39\n");
+    gpiodir =  le32_to_cpu(*(volatile u32 *)(RALINK_GPIO_DIR));
+    /*set gpio1 to output*/
+    gpiodir |= (1<<reset_pin);
+    *(volatile u32 *)(RALINK_GPIO_DIR) = cpu_to_le32(gpiodir);
+
+    piodata = le32_to_cpu(*(volatile u32 *)(RALINK_GPIO_DATA));
+    /*set to low(0)*/
+    piodata &= ~(1L << reset_pin);
+    *(volatile u32 *)(RALINK_GPIO_DATA) = cpu_to_le32(piodata);
+    /*delay 30ms*/
+    mdelay(30);
+    /*set to high(1)*/
+    piodata |= (1L << reset_pin);
+    *(volatile u32 *)(RALINK_GPIO_DATA) = cpu_to_le32(piodata);
+}
+
+
  static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode)
  {
         u32 i;
@@ -220,6 +246,7 @@  int mtk_gsw_init(struct fe_priv *priv)
         struct device_node *np = priv->switch_np;
         struct platform_device *pdev = of_find_device_by_node(np);
         struct mt7620_gsw *gsw;
+    const char *rtl8211e_reset = NULL;

         if (!pdev)
                 return -ENODEV;
@@ -231,6 +258,9 @@  int mtk_gsw_init(struct fe_priv *priv)
         priv->soc->swpriv = gsw;

         mt7620_hw_init(gsw, mt7620_mdio_mode(priv->dev->of_node));
+    of_property_read_string(np, "mediatek,rtl8211e-reset", 
&rtl8211e_reset);
+    if (rtl8211e_reset && !strcmp(rtl8211e_reset, "yes"))
+        reset_realtek_phy();

         if (gsw->irq) {
                 request_irq(gsw->irq, gsw_interrupt_mt7620, 0,
diff --git a/target/linux/ramips/image/mt7620.mk 
b/target/linux/ramips/image/mt7620.mk
index cf38aa2cb1..93f4cdd442 100644
--- a/target/linux/ramips/image/mt7620.mk
+++ b/target/linux/ramips/image/mt7620.mk
@@ -617,6 +617,32 @@  define Device/edimax_br-6478ac-v2
  endef
  TARGET_DEVICES += edimax_br-6478ac-v2

+define Device/edimax_ew-7476rpc
+  DTS := EW-7476RPC
+  DEVICE_TITLE := Edimax EW-7476RPC
+  BLOCKSIZE := 64k
+  IMAGE_SIZE := 7616k
+  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \
+        edimax-header -s CSYS -m RN79 -f 0x70000 -S 0x01100000 | 
pad-rootfs | \
+        append-metadata | check-size $$$$(IMAGE_SIZE)
+  DEVICE_PACKAGES := kmod-mt76x2 kmod-phy-realtek
+endef
+TARGET_DEVICES += edimax_ew-7476rpc
+
+
+define Device/edimax_ew-7478ac
+  DTS := EW-7478AC
+  DEVICE_TITLE := Edimax EW-7478AC
+  BLOCKSIZE := 64k
+  IMAGE_SIZE := 7616k
+  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \
+        edimax-header -s CSYS -m RN70 -f 0x70000 -S 0x01100000 | 
pad-rootfs | \
+        append-metadata | check-size $$$$(IMAGE_SIZE)
+  DEVICE_PACKAGES := kmod-mt76x2 kmod-phy-realtek
+endef
+TARGET_DEVICES += edimax_ew-7478ac
+
+
  define Device/tplink_c2-v1