2012.02.11. 23:06 keltezéssel, Roman Yeryomin írta:
> On 11 February 2012 19:12, Gabor Juhos <juh...@openwrt.org> wrote:
>> 2012.02.01. 3:19 keltezéssel, Roman Yeryomin írta:
>>> 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 <ro...@advem.lv>
>>>
>>> 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);
>>
>> This change makes no sense. RT305X_GPIO_MODE_RGMII is defined as BIT(9), and
>> that bit is not present in the original value.
> 
> right, it's not present, but default value in the chip is 1, also it
> doesn't work without this

Well, if it is working with this change, it must work without it as well,
becasue the argument of the rt305x_gpio_init() call is the same in both cases:

RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT = 0x7 << 2 = 0x0000001c
RT305X_GPIO_MODE_I2C = BIT(0) = 0x00000001
RT305X_GPIO_MODE_SPI = BIT(1) = 0x00000002
RT305X_GPIO_MODE_MDIO = BIT(7) = 0x00000080

0x0000001c | 0x00000001 | 0x00000002 | 0x00000080 = 0x0000009f

~RT305X_GPIO_MODE_RGMII = ~BIT(9) = 0xfffffdff

0x0000009f & 0xfffffdff = 0x0000009f

>>>       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,
>>
>> The RT305X_ESW_VLAN_CONFIG_BYPASS mode has been introduced in order to handle
>> the external switch case. Adding yet another mode for the same thing seems
>> superfluous.
> 
> BYPASS doesn't work for me, it works _only_ if I don't touch vlan
> config at all (see below) AND do one out of two things (one of those
> is commented) under CONFIG_EXTSW

It means that the BYPASS mode is broken probably. However, I still don't want to
have two different options for the same thing. I believe that both of the BYPASS
and EXTSW options can be avoided.

Can you try the attached patches please? Along with the patches, you still have
to override the FPA2 register value in the board setup.

<...>

>>> +             /* 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);
>>
>> You can override the FPA2 register value via platform data.
> 
> maybe I overlooked it, could you point out where to look?

See the 'wl351_init' function in
'target/linux/ramips/files/arch/mips/ralink/rt305x/mach-wl351.c'.

> 
>>> +             break;
>>> +
>>>       case RT305X_ESW_VLAN_CONFIG_LLLLW:
>>>               rt305x_esw_set_vlan_id(esw, 0, 1);
>>>               rt305x_esw_set_vlan_id(esw, 1, 2);
>>
>> The rest of the patch is applied, but please don't mix unrelated changes 
>> into a
>> single patch next time.
>>
> 
> Well the rest actually is related because this was the patch to get
> Belkin board finally working without dirty hacks.
> Or you mean in the sense of files?

I meant this part:

> @@ -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)

Regards,
Gabor
>From 5c5e03f75239984b9ac58eb70e045cb3ba6af661 Mon Sep 17 00:00:00 2001
From: Gabor Juhos <juh...@openwrt.org>
Date: Tue, 14 Feb 2012 09:03:42 +0100
Subject: [PATCH 1/5] ramips: ramips_esw: move VLAN initialization into a separate function

---
 target/linux/ramips/files/drivers/net/ramips_esw.c |   22 +++++++++++++------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/target/linux/ramips/files/drivers/net/ramips_esw.c b/target/linux/ramips/files/drivers/net/ramips_esw.c
index a2fa579..d430b93 100644
--- a/target/linux/ramips/files/drivers/net/ramips_esw.c
+++ b/target/linux/ramips/files/drivers/net/ramips_esw.c
@@ -197,6 +197,20 @@ rt305x_esw_set_vmsc(struct rt305x_esw *esw, unsigned vlan, unsigned msc)
 }
 
 static void
+rt305x_esw_init_vlans(struct rt305x_esw *esw)
+{
+	int i;
+
+	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);
+}
+
+static void
 rt305x_esw_hw_init(struct rt305x_esw *esw)
 {
 	int i;
@@ -265,13 +279,7 @@ rt305x_esw_hw_init(struct rt305x_esw *esw)
 	/* 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);
-	}
-
-	for (i = 0; i < RT305X_ESW_NUM_PORTS; i++)
-		rt305x_esw_set_pvid(esw, i, 1);
+	rt305x_esw_init_vlans(esw);
 
 	switch (esw->pdata->vlan_config) {
 	case RT305X_ESW_VLAN_CONFIG_NONE:
-- 
1.7.2.1

>From 954a1e831a7df7a14c4ddfbf34fa04271c6b1466 Mon Sep 17 00:00:00 2001
From: Gabor Juhos <juh...@openwrt.org>
Date: Tue, 14 Feb 2012 09:23:04 +0100
Subject: [PATCH 2/5] ramips: ramips_esw: setup per-port VLAN ID checking in init_vlans

Based on a pach by Roman Yeryomin <leroi.li...@gmail.com>
---
 target/linux/ramips/files/drivers/net/ramips_esw.c |   24 +++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/target/linux/ramips/files/drivers/net/ramips_esw.c b/target/linux/ramips/files/drivers/net/ramips_esw.c
index d430b93..6804026 100644
--- a/target/linux/ramips/files/drivers/net/ramips_esw.c
+++ b/target/linux/ramips/files/drivers/net/ramips_esw.c
@@ -25,6 +25,12 @@
 #define RT305X_ESW_REG_P3LED	0xb0
 #define RT305X_ESW_REG_P4LED	0xb4
 
+#define RT305X_ESW_PFC1_PRIO_S(_p)	((_p) * 2)
+#define RT305X_ESW_PFC1_PRIO_M(_p)	(0x3 << RT305X_ESW_PFC1_PRIO_S((_p)))
+#define RT305X_ESW_PFC1_PRIO(_p, _x)	((_x) << RT305X_ESW_PFC1_PRIO_S((_p)))
+#define RT305X_ESW_PFC1_EN_VLAN_S	16
+#define RT305X_ESW_PFC1_EN_VLAN(_m)	((_m) << RT305X_ESW_PFC1_EN_VLAN_S)
+
 #define RT305X_ESW_PCR0_WT_NWAY_DATA_S	16
 #define RT305X_ESW_PCR0_WT_PHY_CMD	BIT(13)
 #define RT305X_ESW_PCR0_CPU_PHY_REG_S	8
@@ -201,6 +207,17 @@ rt305x_esw_init_vlans(struct rt305x_esw *esw)
 {
 	int i;
 
+	/* Set per-port default priority to 1 */
+	for (i = 0; i < RT305X_ESW_NUM_PORTS; i++)
+		rt305x_esw_rmw(esw, RT305X_ESW_REG_PFC1,
+			       RT305X_ESW_PFC1_PRIO_M(i),
+			       RT305X_ESW_PFC1_PRIO(i, 1));
+
+	/* Enable VLAN ID and priority check on the CPU port */
+	rt305x_esw_rmw(esw, RT305X_ESW_REG_PFC1,
+		       RT305X_ESW_PFC1_EN_VLAN(RT305X_ESW_PORTS_CPU),
+		       RT305X_ESW_PFC1_EN_VLAN(RT305X_ESW_PORTS_CPU));
+
 	for (i = 0; i < RT305X_ESW_NUM_VLANS; i++) {
 		rt305x_esw_set_vlan_id(esw, i, 0);
 		rt305x_esw_set_vmsc(esw, i, 0);
@@ -218,7 +235,12 @@ rt305x_esw_hw_init(struct rt305x_esw *esw)
 	/* vodoo from original driver */
 	rt305x_esw_wr(esw, 0xC8A07850, RT305X_ESW_REG_FCT0);
 	rt305x_esw_wr(esw, 0x00000000, RT305X_ESW_REG_SGC2);
-	rt305x_esw_wr(esw, 0x00405555, RT305X_ESW_REG_PFC1);
+
+	/*
+	 * Disable VLAN ID and priority check on all ports,
+	 * and set default priority to 0 on all ports
+	 */
+	rt305x_esw_wr(esw, 0x0, RT305X_ESW_REG_PFC1);
 
 	/* Enable Back Pressure, and Flow Control */
 	rt305x_esw_wr(esw,
-- 
1.7.2.1

>From 66d68c83f6258dd8248276d0e1aa83842615520d Mon Sep 17 00:00:00 2001
From: Gabor Juhos <juh...@openwrt.org>
Date: Tue, 14 Feb 2012 09:26:51 +0100
Subject: [PATCH 3/5] ramips: ramips_esw: enable aging an VLAN tag removal in init_vlans

Based on a pach by Roman Yeryomin <leroi.li...@gmail.com>
---
 target/linux/ramips/files/drivers/net/ramips_esw.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/target/linux/ramips/files/drivers/net/ramips_esw.c b/target/linux/ramips/files/drivers/net/ramips_esw.c
index 6804026..c615564 100644
--- a/target/linux/ramips/files/drivers/net/ramips_esw.c
+++ b/target/linux/ramips/files/drivers/net/ramips_esw.c
@@ -218,6 +218,12 @@ rt305x_esw_init_vlans(struct rt305x_esw *esw)
 		       RT305X_ESW_PFC1_EN_VLAN(RT305X_ESW_PORTS_CPU),
 		       RT305X_ESW_PFC1_EN_VLAN(RT305X_ESW_PORTS_CPU));
 
+	/* Enable Aging, and VLAN TAG removal */
+	rt305x_esw_wr(esw,
+		      ((RT305X_ESW_PORTS_ALL << RT305X_ESW_POC3_ENAGING_S) |
+		       (RT305X_ESW_PORTS_NOCPU << RT305X_ESW_POC3_UNTAG_EN_S)),
+		      RT305X_ESW_REG_POC3);
+
 	for (i = 0; i < RT305X_ESW_NUM_VLANS; i++) {
 		rt305x_esw_set_vlan_id(esw, i, 0);
 		rt305x_esw_set_vmsc(esw, i, 0);
@@ -248,11 +254,8 @@ rt305x_esw_hw_init(struct rt305x_esw *esw)
 		       (RT305X_ESW_PORTS_ALL << RT305X_ESW_POC1_EN_FC_S)),
 		      RT305X_ESW_REG_POC1);
 
-	/* Enable Aging, and VLAN TAG removal */
-	rt305x_esw_wr(esw,
-		      ((RT305X_ESW_PORTS_ALL << RT305X_ESW_POC3_ENAGING_S) |
-		       (RT305X_ESW_PORTS_NOCPU << RT305X_ESW_POC3_UNTAG_EN_S)),
-		      RT305X_ESW_REG_POC3);
+	/* Disable Aging and VLAN TAG removal */
+	rt305x_esw_wr(esw, 0, RT305X_ESW_REG_POC3);
 
 	rt305x_esw_wr(esw, esw->pdata->reg_initval_fct2, RT305X_ESW_REG_FCT2);
 	rt305x_esw_wr(esw, 0x0008a301, RT305X_ESW_REG_SGC);
-- 
1.7.2.1

>From 14d4ff42b7750227d486c1210856db958c58da80 Mon Sep 17 00:00:00 2001
From: Gabor Juhos <juh...@openwrt.org>
Date: Tue, 14 Feb 2012 09:30:05 +0100
Subject: [PATCH 4/5] ramips: ramips_esw: call vlan_init only if it is required by the actual board

---
 target/linux/ramips/files/drivers/net/ramips_esw.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/linux/ramips/files/drivers/net/ramips_esw.c b/target/linux/ramips/files/drivers/net/ramips_esw.c
index c615564..4e6e38d 100644
--- a/target/linux/ramips/files/drivers/net/ramips_esw.c
+++ b/target/linux/ramips/files/drivers/net/ramips_esw.c
@@ -304,8 +304,6 @@ rt305x_esw_hw_init(struct rt305x_esw *esw)
 	/* select local register */
 	rt305x_mii_write(esw, 0, 31, 0x8000);
 
-	rt305x_esw_init_vlans(esw);
-
 	switch (esw->pdata->vlan_config) {
 	case RT305X_ESW_VLAN_CONFIG_NONE:
 		break;
@@ -323,6 +321,7 @@ rt305x_esw_hw_init(struct rt305x_esw *esw)
 		break;
 
 	case RT305X_ESW_VLAN_CONFIG_LLLLW:
+		rt305x_esw_init_vlans(esw);
 		rt305x_esw_set_vlan_id(esw, 0, 1);
 		rt305x_esw_set_vlan_id(esw, 1, 2);
 		rt305x_esw_set_pvid(esw, RT305X_ESW_PORT4, 2);
@@ -336,6 +335,7 @@ rt305x_esw_hw_init(struct rt305x_esw *esw)
 		break;
 
 	case RT305X_ESW_VLAN_CONFIG_WLLLL:
+		rt305x_esw_init_vlans(esw);
 		rt305x_esw_set_vlan_id(esw, 0, 1);
 		rt305x_esw_set_vlan_id(esw, 1, 2);
 		rt305x_esw_set_pvid(esw, RT305X_ESW_PORT0, 2);
-- 
1.7.2.1

>From b5ca8aba99ffb5f7b0b444c78cbe9bc29d6a09d8 Mon Sep 17 00:00:00 2001
From: Gabor Juhos <juh...@openwrt.org>
Date: Tue, 14 Feb 2012 09:35:22 +0100
Subject: [PATCH 5/5] ramips: nuke RT305X_ESW_VLAN_CONFIG_BYPASS

---
 .../include/asm/mach-ralink/rt305x_esw_platform.h  |    1 -
 .../files/arch/mips/ralink/rt305x/mach-wl351.c     |    1 -
 target/linux/ramips/files/drivers/net/ramips_esw.c |   12 ------------
 3 files changed, 0 insertions(+), 14 deletions(-)

diff --git a/target/linux/ramips/files/arch/mips/include/asm/mach-ralink/rt305x_esw_platform.h b/target/linux/ramips/files/arch/mips/include/asm/mach-ralink/rt305x_esw_platform.h
index 9634322..2098c5c 100644
--- a/target/linux/ramips/files/arch/mips/include/asm/mach-ralink/rt305x_esw_platform.h
+++ b/target/linux/ramips/files/arch/mips/include/asm/mach-ralink/rt305x_esw_platform.h
@@ -13,7 +13,6 @@
 
 enum {
 	RT305X_ESW_VLAN_CONFIG_NONE = 0,
-	RT305X_ESW_VLAN_CONFIG_BYPASS,
 	RT305X_ESW_VLAN_CONFIG_LLLLW,
 	RT305X_ESW_VLAN_CONFIG_WLLLL,
 };
diff --git a/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-wl351.c b/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-wl351.c
index 8d37f8f..140e232 100644
--- a/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-wl351.c
+++ b/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-wl351.c
@@ -135,7 +135,6 @@ static void __init wl351_init(void)
 				     ARRAY_SIZE(wl351_gpio_buttons),
 				     wl351_gpio_buttons);
 	// external rtl8366rb
-	rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_BYPASS;
 	rt305x_esw_data.reg_initval_fct2 = 0x0002500c;
 	rt305x_esw_data.reg_initval_fpa2 = 0x1f003fff;
 	rt305x_register_ethernet();
diff --git a/target/linux/ramips/files/drivers/net/ramips_esw.c b/target/linux/ramips/files/drivers/net/ramips_esw.c
index 4e6e38d..cf90c1b 100644
--- a/target/linux/ramips/files/drivers/net/ramips_esw.c
+++ b/target/linux/ramips/files/drivers/net/ramips_esw.c
@@ -308,18 +308,6 @@ rt305x_esw_hw_init(struct rt305x_esw *esw)
 	case RT305X_ESW_VLAN_CONFIG_NONE:
 		break;
 
-	case RT305X_ESW_VLAN_CONFIG_BYPASS:
-		/* Pass all vlan tags to all ports */
-		for (i = 0; i < RT305X_ESW_NUM_VLANS; i++) {
-			rt305x_esw_set_vlan_id(esw, i, i+1);
-			rt305x_esw_set_vmsc(esw, i, RT305X_ESW_PORTS_ALL);
-		}
-		/* Disable VLAN TAG removal, keep aging on. */
-		rt305x_esw_wr(esw,
-			      RT305X_ESW_PORTS_ALL << RT305X_ESW_POC3_ENAGING_S,
-			      RT305X_ESW_REG_POC3);
-		break;
-
 	case RT305X_ESW_VLAN_CONFIG_LLLLW:
 		rt305x_esw_init_vlans(esw);
 		rt305x_esw_set_vlan_id(esw, 0, 1);
-- 
1.7.2.1

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

Reply via email to