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

Birger Koblitz mail at birger-koblitz.de
Sun May 26 03:44:59 EDT 2019


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 at gmail.com>
+ * Copyright (C) 2016 Hans Ulli Kroll <ulli.kroll at googlemail.com>
+ * Copyright (C) 2017 James McKenzie <openwrt at 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 at 0 {
+               compatible = "jedec,spi-nor";
+               reg = <0 0>;
+               spi-max-frequency = <10000000>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition at 0 {
+                               label = "u-boot";
+                               reg = <0x0 0x30000>;
+                               read-only;
+                       };
+
+                       partition at 30000 {
+                               label = "u-boot-env";
+                               reg = <0x30000 0x10000>;
+                               read-only;
+                       };
+
+                       factory: partition at 40000 {
+                               label = "factory";
+                               reg = <0x40000 0x10000>;
+                               read-only;
+                       };
+
+                       partition at 50000 {
+                               label = "cimage";
+                               reg = <0x50000 0x20000>;
+                               read-only;
+                       };
+
+                       partition at 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 at 5 {
+               status = "okay";
+               mediatek,fixed-link = <1000 1 1 1>;
+               phy-mode = "rgmii";
+       };
+
+       mdio-bus {
+               status = "okay";
+
+               phy0: ethernet-phy at 0 {
+                       status ="disabled";
+                       reg = <0>;
+                       phy-mode = "rgmii";
+               };
+
+               phy1: ethernet-phy at 1 {
+                       status = "disabled";
+                       reg = <1>;
+                       phy-mode = "rgmii";
+               };
+
+               phy2: ethernet-phy at 2 {
+                       status = "disabled";
+                       reg = <2>;
+                       phy-mode = "rgmii";
+               };
+
+               phy3: ethernet-phy at 3 {
+                       status = "disabled";
+                       reg = <3>;
+                       phy-mode = "rgmii";
+               };
+
+               phy4: ethernet-phy at 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 at 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 at gmail.com>
+ * Copyright (C) 2016 Hans Ulli Kroll <ulli.kroll at googlemail.com>
+ * Copyright (C) 2017 James McKenzie <openwrt at 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 at 0 {
+               compatible = "jedec,spi-nor";
+               reg = <0 0>;
+               spi-max-frequency = <10000000>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition at 0 {
+                               label = "u-boot";
+                               reg = <0x0 0x30000>;
+                               read-only;
+                       };
+
+                       partition at 30000 {
+                               label = "u-boot-env";
+                               reg = <0x30000 0x10000>;
+                               read-only;
+                       };
+
+                       factory: partition at 40000 {
+                               label = "factory";
+                               reg = <0x40000 0x10000>;
+                               read-only;
+                       };
+
+                       partition at 50000 {
+                               label = "cimage";
+                               reg = <0x50000 0x20000>;
+                               read-only;
+                       };
+
+                       partition at 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 at 5 {
+               status = "okay";
+               mediatek,fixed-link = <1000 1 1 1>;
+               phy-mode = "rgmii";
+       };
+
+       mdio-bus {
+               status = "okay";
+
+               phy0: ethernet-phy at 0 {
+                       status ="disabled";
+                       reg = <0>;
+                       phy-mode = "rgmii";
+               };
+
+               phy1: ethernet-phy at 1 {
+                       status = "disabled";
+                       reg = <1>;
+                       phy-mode = "rgmii";
+               };
+
+               phy2: ethernet-phy at 2 {
+                       status = "disabled";
+                       reg = <2>;
+                       phy-mode = "rgmii";
+               };
+
+               phy3: ethernet-phy at 3 {
+                       status = "disabled";
+                       reg = <3>;
+                       phy-mode = "rgmii";
+               };
+
+               phy4: ethernet-phy at 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 at 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



_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list