netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/3] net: dsa: b53: BCM58xx devices fixes
@ 2017-04-24 21:27 Florian Fainelli
  2017-04-24 21:27 ` [PATCH net 1/3] net: dsa: b53: Include IMP/CPU port in dumb forwarding mode Florian Fainelli
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Florian Fainelli @ 2017-04-24 21:27 UTC (permalink / raw)
  To: netdev; +Cc: andrew, vivien.didelot, eric, jon.mason, Florian Fainelli

Hi David,

This patch series contains fixes for the 58xx devices (Broadcom Northstar
Plus), which were identified thanks to the help of Eric Anholt.

Florian Fainelli (3):
  net: dsa: b53: Include IMP/CPU port in dumb forwarding mode
  net: dsa: b53: Implement software reset for 58xx devices
  net: dsa: b53: Fix CPU port for 58xx devices

 drivers/net/dsa/b53/b53_common.c | 37 +++++++++++++++++++++++++++++++++++--
 drivers/net/dsa/b53/b53_regs.h   |  5 +++++
 2 files changed, 40 insertions(+), 2 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net 1/3] net: dsa: b53: Include IMP/CPU port in dumb forwarding mode
  2017-04-24 21:27 [PATCH net 0/3] net: dsa: b53: BCM58xx devices fixes Florian Fainelli
@ 2017-04-24 21:27 ` Florian Fainelli
  2017-04-24 21:27 ` [PATCH net 2/3] net: dsa: b53: Implement software reset for 58xx devices Florian Fainelli
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2017-04-24 21:27 UTC (permalink / raw)
  To: netdev; +Cc: andrew, vivien.didelot, eric, jon.mason, Florian Fainelli

Since Broadcom tags are not enabled in b53 (DSA_PROTO_TAG_NONE), we need
to make sure that the IMP/CPU port is included in the forwarding
decision.

Without this change, switching between non-management ports would work,
but not between management ports and non-management ports thus breaking
the default state in which DSA switch are brought up.

Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch")
Reported-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/b53/b53_common.c | 10 ++++++++++
 drivers/net/dsa/b53/b53_regs.h   |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 8cf4801994e8..ca7f3b005a29 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -326,6 +326,7 @@ static void b53_get_vlan_entry(struct b53_device *dev, u16 vid,
 
 static void b53_set_forwarding(struct b53_device *dev, int enable)
 {
+	struct dsa_switch *ds = dev->ds;
 	u8 mgmt;
 
 	b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, &mgmt);
@@ -336,6 +337,15 @@ static void b53_set_forwarding(struct b53_device *dev, int enable)
 		mgmt &= ~SM_SW_FWD_EN;
 
 	b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, mgmt);
+
+	/* Include IMP port in dumb forwarding mode when no tagging protocol is
+	 * set
+	 */
+	if (ds->ops->get_tag_protocol(ds) == DSA_TAG_PROTO_NONE) {
+		b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, &mgmt);
+		mgmt |= B53_MII_DUMB_FWDG_EN;
+		b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, mgmt);
+	}
 }
 
 static void b53_enable_vlan(struct b53_device *dev, bool enable)
diff --git a/drivers/net/dsa/b53/b53_regs.h b/drivers/net/dsa/b53/b53_regs.h
index 9fd24c418fa4..f2a060e7a637 100644
--- a/drivers/net/dsa/b53/b53_regs.h
+++ b/drivers/net/dsa/b53/b53_regs.h
@@ -104,6 +104,10 @@
 #define  B53_UC_FWD_EN			BIT(6)
 #define  B53_MC_FWD_EN			BIT(7)
 
+/* Switch control (8 bit) */
+#define B53_SWITCH_CTRL			0x22
+#define  B53_MII_DUMB_FWDG_EN		BIT(6)
+
 /* (16 bit) */
 #define B53_UC_FLOOD_MASK		0x32
 #define B53_MC_FLOOD_MASK		0x34
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net 2/3] net: dsa: b53: Implement software reset for 58xx devices
  2017-04-24 21:27 [PATCH net 0/3] net: dsa: b53: BCM58xx devices fixes Florian Fainelli
  2017-04-24 21:27 ` [PATCH net 1/3] net: dsa: b53: Include IMP/CPU port in dumb forwarding mode Florian Fainelli
@ 2017-04-24 21:27 ` Florian Fainelli
  2017-04-24 21:27 ` [PATCH net 3/3] net: dsa: b53: Fix CPU port " Florian Fainelli
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2017-04-24 21:27 UTC (permalink / raw)
  To: netdev; +Cc: andrew, vivien.didelot, eric, jon.mason, Florian Fainelli

Implement the correct software reset sequence for 58xx devices by
setting all 3 reset bits and polling for the SW_RST bit to clear itself
without a given timeout. We cannot use is58xx() here because that would
also include the 7445/7278 Starfighter 2 which have their own driver
doing the reset earlier on due to the HW specific integration.

Fixes: 991a36bb4645 ("net: dsa: b53: Add support for BCM585xx/586xx/88312 integrated switch")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/b53/b53_common.c | 25 ++++++++++++++++++++++++-
 drivers/net/dsa/b53/b53_regs.h   |  1 +
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index ca7f3b005a29..b66ee18cbe49 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -608,7 +608,8 @@ static void b53_switch_reset_gpio(struct b53_device *dev)
 
 static int b53_switch_reset(struct b53_device *dev)
 {
-	u8 mgmt;
+	unsigned int timeout = 1000;
+	u8 mgmt, reg;
 
 	b53_switch_reset_gpio(dev);
 
@@ -617,6 +618,28 @@ static int b53_switch_reset(struct b53_device *dev)
 		b53_write8(dev, B53_CTRL_PAGE, B53_SOFTRESET, 0x00);
 	}
 
+	/* This is specific to 58xx devices here, do not use is58xx() which
+	 * covers the larger Starfigther 2 family, including 7445/7278 which
+	 * still use this driver as a library and need to perform the reset
+	 * earlier.
+	 */
+	if (dev->chip_id == BCM58XX_DEVICE_ID) {
+		b53_read8(dev, B53_CTRL_PAGE, B53_SOFTRESET, &reg);
+		reg |= SW_RST | EN_SW_RST | EN_CH_RST;
+		b53_write8(dev, B53_CTRL_PAGE, B53_SOFTRESET, reg);
+
+		do {
+			b53_read8(dev, B53_CTRL_PAGE, B53_SOFTRESET, &reg);
+			if (!(reg & SW_RST))
+				break;
+
+			usleep_range(1000, 2000);
+		} while (timeout-- > 0);
+
+		if (timeout == 0)
+			return -ETIMEDOUT;
+	}
+
 	b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, &mgmt);
 
 	if (!(mgmt & SM_SW_FWD_EN)) {
diff --git a/drivers/net/dsa/b53/b53_regs.h b/drivers/net/dsa/b53/b53_regs.h
index f2a060e7a637..e5c86d44667a 100644
--- a/drivers/net/dsa/b53/b53_regs.h
+++ b/drivers/net/dsa/b53/b53_regs.h
@@ -143,6 +143,7 @@
 /* Software reset register (8 bit) */
 #define B53_SOFTRESET			0x79
 #define   SW_RST			BIT(7)
+#define   EN_CH_RST			BIT(6)
 #define   EN_SW_RST			BIT(4)
 
 /* Fast Aging Control register (8 bit) */
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net 3/3] net: dsa: b53: Fix CPU port for 58xx devices
  2017-04-24 21:27 [PATCH net 0/3] net: dsa: b53: BCM58xx devices fixes Florian Fainelli
  2017-04-24 21:27 ` [PATCH net 1/3] net: dsa: b53: Include IMP/CPU port in dumb forwarding mode Florian Fainelli
  2017-04-24 21:27 ` [PATCH net 2/3] net: dsa: b53: Implement software reset for 58xx devices Florian Fainelli
@ 2017-04-24 21:27 ` Florian Fainelli
  2017-04-24 21:32 ` [PATCH net 0/3] net: dsa: b53: BCM58xx devices fixes Eric Anholt
  2017-04-24 22:29 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2017-04-24 21:27 UTC (permalink / raw)
  To: netdev; +Cc: andrew, vivien.didelot, eric, jon.mason, Florian Fainelli

The 58xx devices (Northstar Plus) do actually have their CPU port wired
at port 8, it was unfortunately set to port 5 (B53_CPU_PORT_25) which is
incorrect, since that is the second possible management port.

Fixes: 991a36bb4645 ("net: dsa: b53: Add support for BCM585xx/586xx/88312 integrated switch")
Reported-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/b53/b53_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index b66ee18cbe49..fa0eece21eef 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1764,7 +1764,7 @@ static const struct b53_chip_data b53_switch_chips[] = {
 		.vlans	= 4096,
 		.enabled_ports = 0x1ff,
 		.arl_entries = 4,
-		.cpu_port = B53_CPU_PORT_25,
+		.cpu_port = B53_CPU_PORT,
 		.vta_regs = B53_VTA_REGS,
 		.duplex_reg = B53_DUPLEX_STAT_GE,
 		.jumbo_pm_reg = B53_JUMBO_PORT_MASK,
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net 0/3] net: dsa: b53: BCM58xx devices fixes
  2017-04-24 21:27 [PATCH net 0/3] net: dsa: b53: BCM58xx devices fixes Florian Fainelli
                   ` (2 preceding siblings ...)
  2017-04-24 21:27 ` [PATCH net 3/3] net: dsa: b53: Fix CPU port " Florian Fainelli
@ 2017-04-24 21:32 ` Eric Anholt
  2017-04-24 22:29 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Eric Anholt @ 2017-04-24 21:32 UTC (permalink / raw)
  To: Florian Fainelli, netdev
  Cc: andrew, vivien.didelot, jon.mason, Florian Fainelli

[-- Attachment #1: Type: text/plain, Size: 349 bytes --]

Florian Fainelli <f.fainelli@gmail.com> writes:

> Hi David,
>
> This patch series contains fixes for the 58xx devices (Broadcom Northstar
> Plus), which were identified thanks to the help of Eric Anholt.

This series is:

Tested-by: Eric Anholt <eric@anholt.net>

Thanks for all your help debugging this, Florian!  I'll send out my DT
changes now.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 0/3] net: dsa: b53: BCM58xx devices fixes
  2017-04-24 21:27 [PATCH net 0/3] net: dsa: b53: BCM58xx devices fixes Florian Fainelli
                   ` (3 preceding siblings ...)
  2017-04-24 21:32 ` [PATCH net 0/3] net: dsa: b53: BCM58xx devices fixes Eric Anholt
@ 2017-04-24 22:29 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-04-24 22:29 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, andrew, vivien.didelot, eric, jon.mason

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Mon, 24 Apr 2017 14:27:20 -0700

> This patch series contains fixes for the 58xx devices (Broadcom Northstar
> Plus), which were identified thanks to the help of Eric Anholt.

Series applied, thanks Florian.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-04-24 22:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-24 21:27 [PATCH net 0/3] net: dsa: b53: BCM58xx devices fixes Florian Fainelli
2017-04-24 21:27 ` [PATCH net 1/3] net: dsa: b53: Include IMP/CPU port in dumb forwarding mode Florian Fainelli
2017-04-24 21:27 ` [PATCH net 2/3] net: dsa: b53: Implement software reset for 58xx devices Florian Fainelli
2017-04-24 21:27 ` [PATCH net 3/3] net: dsa: b53: Fix CPU port " Florian Fainelli
2017-04-24 21:32 ` [PATCH net 0/3] net: dsa: b53: BCM58xx devices fixes Eric Anholt
2017-04-24 22:29 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).