This fixes Belkin F5D8235 v2 ethernet stuff.
To do it we first need to enable rgmii and then not to configure any
vlans at all. Then there are two ways: enable double tagging on ports
5 and 6 and enable tag removal (as I was doing from the very
beginning) OR we can simply disable vlans and vlan tag removal (as
proposed by Tobias Diedrich). I'm leaving both variants (first one is
commented out) for the sake of reference. Of cause you're free to
remove the commented code.
So:
* add RT305X_ESW_VLAN_CONFIG_EXTSW
* add belkin profile (and remove it from default one)
* remap ports

Tested with r29978.
Adding the patch as attachment also.

Signed-off-by: Roman Yeryomin <[email protected]>

Index: target/linux/ramips/files/arch/mips/ralink/rt305x/mach-f5d8235-v2.c
===================================================================
--- a/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-f5d8235-v2.c       
(revision
29868)
+++ b/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-f5d8235-v2.c       
(working
copy)
@@ -124,15 +124,16 @@

 static void __init f5d8235v2_init(void)
 {
-       rt305x_gpio_init((RT305X_GPIO_MODE_GPIO <<
+       rt305x_gpio_init(((RT305X_GPIO_MODE_GPIO <<
                                        RT305X_GPIO_MODE_UART0_SHIFT) |
                                        RT305X_GPIO_MODE_I2C |
                                        RT305X_GPIO_MODE_SPI |
-                                       RT305X_GPIO_MODE_MDIO);
+                                       RT305X_GPIO_MODE_MDIO) &
+                                       ~RT305X_GPIO_MODE_RGMII);
        rt305x_register_flash(0, &f5d8235v2_flash_data);
        ramips_register_gpio_leds(-1, ARRAY_SIZE(f5d8235v2_leds_gpio),
                                                f5d8235v2_leds_gpio);
-       rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_NONE;
+       rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_EXTSW;
        rt305x_register_ethernet();
        platform_device_register(&f5d8235v2_switch);
        rt305x_register_wifi();
Index: 
target/linux/ramips/files/arch/mips/include/asm/mach-ralink/rt305x_esw_platform.h
===================================================================
--- 
a/target/linux/ramips/files/arch/mips/include/asm/mach-ralink/rt305x_esw_platform.h
 (revision
29868)
+++ 
b/target/linux/ramips/files/arch/mips/include/asm/mach-ralink/rt305x_esw_platform.h
 (working
copy)
@@ -14,6 +14,7 @@
 enum {
        RT305X_ESW_VLAN_CONFIG_NONE = 0,
        RT305X_ESW_VLAN_CONFIG_BYPASS,
+       RT305X_ESW_VLAN_CONFIG_EXTSW,
        RT305X_ESW_VLAN_CONFIG_LLLLW,
        RT305X_ESW_VLAN_CONFIG_WLLLL,
 };
Index: target/linux/ramips/files/drivers/net/ramips_esw.c
===================================================================
--- a/target/linux/ramips/files/drivers/net/ramips_esw.c        (revision 29868)
+++ b/target/linux/ramips/files/drivers/net/ramips_esw.c        (working copy)
@@ -265,14 +265,16 @@
        /* select local register */
        rt305x_mii_write(esw, 0, 31, 0x8000);

-       for (i = 0; i < RT305X_ESW_NUM_VLANS; i++) {
-               rt305x_esw_set_vlan_id(esw, i, 0);
-               rt305x_esw_set_vmsc(esw, i, 0);
+       if (esw->pdata->vlan_config != RT305X_ESW_VLAN_CONFIG_EXTSW) {
+               for (i = 0; i < RT305X_ESW_NUM_VLANS; i++) {
+                       rt305x_esw_set_vlan_id(esw, i, 0);
+                       rt305x_esw_set_vmsc(esw, i, 0);
+               }
+
+               for (i = 0; i < RT305X_ESW_NUM_PORTS; i++)
+                       rt305x_esw_set_pvid(esw, i, 1);
        }

-       for (i = 0; i < RT305X_ESW_NUM_PORTS; i++)
-               rt305x_esw_set_pvid(esw, i, 1);
-
        switch (esw->pdata->vlan_config) {
        case RT305X_ESW_VLAN_CONFIG_NONE:
                break;
@@ -289,6 +291,30 @@
                              RT305X_ESW_REG_POC3);
                break;

+       case RT305X_ESW_VLAN_CONFIG_EXTSW:
+               /* Disable per port vlan id and priority check (EN_VLAN = 0) */
+               rt305x_esw_wr(esw, 0, RT305X_ESW_REG_PFC1);
+               /* Disable VLAN TAG removal and aging */
+               rt305x_esw_wr(esw, 0, RT305X_ESW_REG_POC3);
+
+               /* Enable VLAN on ports 5 and 6*/
+               //rt305x_esw_wr(esw, 0x00605555, 0x14);
+               /* Remove VLAN tag field on all ports */
+               //rt305x_esw_wr(esw, 0x00007f7f, 0x98);
+               /* Insert double tag field port 5 and 6 */
+               //rt305x_esw_wr(esw, 0x00000060, 0xe4);
+
+               /* Disable port 5 auto polling */
+               rt305x_esw_wr(esw, rt305x_esw_rr(esw, RT305X_ESW_REG_FPA2) &
+                                           ~(1 << 29), RT305X_ESW_REG_FPA2);
+               /* Force 1000M full duplex */
+               rt305x_esw_wr(esw, rt305x_esw_rr(esw, RT305X_ESW_REG_FPA2) |
+                                           0x3fff, RT305X_ESW_REG_FPA2);
+               /* rxclk_skew, txclk_skew = 0 */
+               rt305x_esw_wr(esw, rt305x_esw_rr(esw, RT305X_ESW_REG_FPA2) &
+                                           ~(0xf << 20), RT305X_ESW_REG_FPA2);
+               break;
+
        case RT305X_ESW_VLAN_CONFIG_LLLLW:
                rt305x_esw_set_vlan_id(esw, 0, 1);
                rt305x_esw_set_vlan_id(esw, 1, 2);
Index: target/linux/ramips/base-files/etc/uci-defaults/network
===================================================================
--- a/target/linux/ramips/base-files/etc/uci-defaults/network   (revision 29937)
+++ b/target/linux/ramips/base-files/etc/uci-defaults/network   (working copy)
@@ -35,18 +35,24 @@
                ucidef_add_switch_vlan "rtl8366s" "2" "0 5t"
                ;;

-       f5d8235-v2 | \
-       wl-351)
+       f5d8235-v2)
                ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
                ucidef_add_switch "rtl8366rb" "1" "1"
-               ucidef_add_switch_vlan "rtl8366rb" "1" "0 1 2 3 5t"
-               ucidef_add_switch_vlan "rtl8366rb" "2" "4 5t"
+               ucidef_add_switch_vlan "rtl8366rb" "1" "1 2 3 4 5t"
+               ucidef_add_switch_vlan "rtl8366rb" "2" "0 5t"
                ;;

        wcr-150gn)
                ucidef_set_interface_lan_wan "eth0.2" "eth0.1"
                ;;

+       wl-351)
+               ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
+               ucidef_add_switch "rtl8366rb" "1" "1"
+               ucidef_add_switch_vlan "rtl8366rb" "1" "0 1 2 3 5t"
+               ucidef_add_switch_vlan "rtl8366rb" "2" "4 5t"
+               ;;
+
        wli-tx4-ag300n)
                ucidef_set_interface_lan "eth0"
                ;;
@@ -91,7 +97,8 @@
                ;;

        esr-9753 | \
-       nbg-419n)
+       nbg-419n | \
+       wcr-150gn)
                 lan_mac=$(ramips_get_mac_binary factory 4)
                 wan_mac=$(ramips_get_mac_binary factory 40)
                ;;
@@ -106,11 +113,6 @@
                 wan_mac=$(ramips_get_mac_binary factory 46)
                ;;

-       wcr-150gn)
-                lan_mac=$(ramips_get_mac_binary factory 4)
-                wan_mac=$(ramips_get_mac_binary factory 40)
-               ;;
-
        wl341v3)
                lan_mac=$(ramips_get_mac_binary board-nvram 65440)
                wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
Index: target/linux/ramips/rt305x/profiles/belkin.mk
===================================================================
--- a/target/linux/ramips/rt305x/profiles/belkin.mk     (revision 0)
+++ b/target/linux/ramips/rt305x/profiles/belkin.mk     (revision 0)
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/F5D8235V2
+       NAME:=Belkin F5D8235 v2
+       PACKAGES:=\
+               kmod-switch-rtl8366rb kmod-swconfig swconfig \
+               kmod-usb-core kmod-usb-rt305x-dwc_otg \
+               kmod-ledtrig-usbdev
+endef
+
+define Profile/F5D8235V2/Description
+       Package set for Belkin F5D8235 v2
+endef
+
+$(eval $(call Profile,F5D8235V2))
+
Index: target/linux/ramips/image/Makefile
===================================================================
--- a/target/linux/ramips/image/Makefile        (revision 29978)
+++ b/target/linux/ramips/image/Makefile        (working copy)
@@ -321,7 +321,6 @@
        $(call Image/Build/Profile/PWH2004,$(1))
        $(call Image/Build/Profile/WHRG300N,$(1))
        $(call Image/Build/Profile/WCR150GN,$(1))
-       $(call Image/Build/Profile/F5D8235V2,$(1))
        $(call Image/Build/Profile/HW5503G,$(1))
        $(call Image/Build/Profile/MOFI35003GN,$(1))
        $(call Image/Build/Profile/W502U,$(1))
Index: target/linux/ramips/files/arch/mips/ralink/rt305x/mach-f5d8235-v2.c
===================================================================
--- a/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-f5d8235-v2.c	(revision 29868)
+++ b/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-f5d8235-v2.c	(working copy)
@@ -124,15 +124,16 @@
 
 static void __init f5d8235v2_init(void)
 {
-	rt305x_gpio_init((RT305X_GPIO_MODE_GPIO <<
+	rt305x_gpio_init(((RT305X_GPIO_MODE_GPIO <<
 					RT305X_GPIO_MODE_UART0_SHIFT) |
 					RT305X_GPIO_MODE_I2C |
 					RT305X_GPIO_MODE_SPI |
-					RT305X_GPIO_MODE_MDIO);
+					RT305X_GPIO_MODE_MDIO) &
+					~RT305X_GPIO_MODE_RGMII);
 	rt305x_register_flash(0, &f5d8235v2_flash_data);
 	ramips_register_gpio_leds(-1, ARRAY_SIZE(f5d8235v2_leds_gpio),
 						f5d8235v2_leds_gpio);
-	rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_NONE;
+	rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_EXTSW;
 	rt305x_register_ethernet();
 	platform_device_register(&f5d8235v2_switch);
 	rt305x_register_wifi();
Index: target/linux/ramips/files/arch/mips/include/asm/mach-ralink/rt305x_esw_platform.h
===================================================================
--- a/target/linux/ramips/files/arch/mips/include/asm/mach-ralink/rt305x_esw_platform.h	(revision 29868)
+++ b/target/linux/ramips/files/arch/mips/include/asm/mach-ralink/rt305x_esw_platform.h	(working copy)
@@ -14,6 +14,7 @@
 enum {
 	RT305X_ESW_VLAN_CONFIG_NONE = 0,
 	RT305X_ESW_VLAN_CONFIG_BYPASS,
+	RT305X_ESW_VLAN_CONFIG_EXTSW,
 	RT305X_ESW_VLAN_CONFIG_LLLLW,
 	RT305X_ESW_VLAN_CONFIG_WLLLL,
 };
Index: target/linux/ramips/files/drivers/net/ramips_esw.c
===================================================================
--- a/target/linux/ramips/files/drivers/net/ramips_esw.c	(revision 29868)
+++ b/target/linux/ramips/files/drivers/net/ramips_esw.c	(working copy)
@@ -265,14 +265,16 @@
 	/* select local register */
 	rt305x_mii_write(esw, 0, 31, 0x8000);
 
-	for (i = 0; i < RT305X_ESW_NUM_VLANS; i++) {
-		rt305x_esw_set_vlan_id(esw, i, 0);
-		rt305x_esw_set_vmsc(esw, i, 0);
+	if (esw->pdata->vlan_config != RT305X_ESW_VLAN_CONFIG_EXTSW) {
+		for (i = 0; i < RT305X_ESW_NUM_VLANS; i++) {
+			rt305x_esw_set_vlan_id(esw, i, 0);
+			rt305x_esw_set_vmsc(esw, i, 0);
+		}
+
+		for (i = 0; i < RT305X_ESW_NUM_PORTS; i++)
+			rt305x_esw_set_pvid(esw, i, 1);
 	}
 
-	for (i = 0; i < RT305X_ESW_NUM_PORTS; i++)
-		rt305x_esw_set_pvid(esw, i, 1);
-
 	switch (esw->pdata->vlan_config) {
 	case RT305X_ESW_VLAN_CONFIG_NONE:
 		break;
@@ -289,6 +291,30 @@
 			      RT305X_ESW_REG_POC3);
 		break;
 
+	case RT305X_ESW_VLAN_CONFIG_EXTSW:
+		/* Disable per port vlan id and priority check (EN_VLAN = 0) */
+		rt305x_esw_wr(esw, 0, RT305X_ESW_REG_PFC1);
+		/* Disable VLAN TAG removal and aging */
+		rt305x_esw_wr(esw, 0, RT305X_ESW_REG_POC3);
+
+		/* Enable VLAN on ports 5 and 6*/
+		//rt305x_esw_wr(esw, 0x00605555, 0x14);
+		/* Remove VLAN tag field on all ports */
+		//rt305x_esw_wr(esw, 0x00007f7f, 0x98);
+		/* Insert double tag field port 5 and 6 */
+		//rt305x_esw_wr(esw, 0x00000060, 0xe4);
+
+		/* Disable port 5 auto polling */
+		rt305x_esw_wr(esw, rt305x_esw_rr(esw, RT305X_ESW_REG_FPA2) &
+					    ~(1 << 29), RT305X_ESW_REG_FPA2);
+		/* Force 1000M full duplex */
+		rt305x_esw_wr(esw, rt305x_esw_rr(esw, RT305X_ESW_REG_FPA2) |
+					    0x3fff, RT305X_ESW_REG_FPA2);
+		/* rxclk_skew, txclk_skew = 0 */
+		rt305x_esw_wr(esw, rt305x_esw_rr(esw, RT305X_ESW_REG_FPA2) &
+					    ~(0xf << 20), RT305X_ESW_REG_FPA2);
+		break;
+
 	case RT305X_ESW_VLAN_CONFIG_LLLLW:
 		rt305x_esw_set_vlan_id(esw, 0, 1);
 		rt305x_esw_set_vlan_id(esw, 1, 2);
Index: target/linux/ramips/base-files/etc/uci-defaults/network
===================================================================
--- a/target/linux/ramips/base-files/etc/uci-defaults/network	(revision 29937)
+++ b/target/linux/ramips/base-files/etc/uci-defaults/network	(working copy)
@@ -35,18 +35,24 @@
 		ucidef_add_switch_vlan "rtl8366s" "2" "0 5t"
 		;;
 
-	f5d8235-v2 | \
-	wl-351)
+	f5d8235-v2)
 		ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
 		ucidef_add_switch "rtl8366rb" "1" "1"
-		ucidef_add_switch_vlan "rtl8366rb" "1" "0 1 2 3 5t"
-		ucidef_add_switch_vlan "rtl8366rb" "2" "4 5t"
+		ucidef_add_switch_vlan "rtl8366rb" "1" "1 2 3 4 5t"
+		ucidef_add_switch_vlan "rtl8366rb" "2" "0 5t"
 		;;
 
 	wcr-150gn)
 		ucidef_set_interface_lan_wan "eth0.2" "eth0.1"
 		;;
 
+	wl-351)
+		ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
+		ucidef_add_switch "rtl8366rb" "1" "1"
+		ucidef_add_switch_vlan "rtl8366rb" "1" "0 1 2 3 5t"
+		ucidef_add_switch_vlan "rtl8366rb" "2" "4 5t"
+		;;
+
 	wli-tx4-ag300n)
 		ucidef_set_interface_lan "eth0"
 		;;
@@ -91,7 +97,8 @@
 		;;
 
 	esr-9753 | \
-	nbg-419n)
+	nbg-419n | \
+	wcr-150gn)
                 lan_mac=$(ramips_get_mac_binary factory 4)
                 wan_mac=$(ramips_get_mac_binary factory 40)
 		;;
@@ -106,11 +113,6 @@
                 wan_mac=$(ramips_get_mac_binary factory 46)
 		;;
 
-	wcr-150gn)
-                lan_mac=$(ramips_get_mac_binary factory 4)
-                wan_mac=$(ramips_get_mac_binary factory 40)
-		;;
-
 	wl341v3)
 		lan_mac=$(ramips_get_mac_binary board-nvram 65440)
 		wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
Index: target/linux/ramips/rt305x/profiles/belkin.mk
===================================================================
--- a/target/linux/ramips/rt305x/profiles/belkin.mk	(revision 0)
+++ b/target/linux/ramips/rt305x/profiles/belkin.mk	(revision 0)
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/F5D8235V2
+	NAME:=Belkin F5D8235 v2
+	PACKAGES:=\
+		kmod-switch-rtl8366rb kmod-swconfig swconfig \
+		kmod-usb-core kmod-usb-rt305x-dwc_otg \
+		kmod-ledtrig-usbdev
+endef
+
+define Profile/F5D8235V2/Description
+	Package set for Belkin F5D8235 v2
+endef
+
+$(eval $(call Profile,F5D8235V2))
+
Index: target/linux/ramips/image/Makefile
===================================================================
--- a/target/linux/ramips/image/Makefile	(revision 29978)
+++ b/target/linux/ramips/image/Makefile	(working copy)
@@ -321,7 +321,6 @@
 	$(call Image/Build/Profile/PWH2004,$(1))
 	$(call Image/Build/Profile/WHRG300N,$(1))
 	$(call Image/Build/Profile/WCR150GN,$(1))
-	$(call Image/Build/Profile/F5D8235V2,$(1))
 	$(call Image/Build/Profile/HW5503G,$(1))
 	$(call Image/Build/Profile/MOFI35003GN,$(1))
 	$(call Image/Build/Profile/W502U,$(1))
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to