netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: b53: Don't assign autonegotiation enabled
@ 2018-09-21 22:30 Florian Fainelli
  0 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2018-09-21 22:30 UTC (permalink / raw)
  To: netdev
  Cc: rmk+kernel, Florian Fainelli, Andrew Lunn, Vivien Didelot,
	David S. Miller, open list

PHYLINK takes care of filing the right information into
state->an_enabled, get rid of the read from the SerDes's BMCR register.

Fixes: 0e01491de646 ("net: dsa: b53: Add SerDes support")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/b53/b53_serdes.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_serdes.c b/drivers/net/dsa/b53/b53_serdes.c
index b45c55e0b8b4..629bf14128a2 100644
--- a/drivers/net/dsa/b53/b53_serdes.c
+++ b/drivers/net/dsa/b53/b53_serdes.c
@@ -100,15 +100,13 @@ int b53_serdes_link_state(struct b53_device *dev, int port,
 			  struct phylink_link_state *state)
 {
 	u8 lane = b53_serdes_map_lane(dev, port);
-	u16 dig, bmcr, bmsr;
+	u16 dig, bmsr;
 
 	if (lane == B53_INVALID_LANE)
 		return 1;
 
 	dig = b53_serdes_read(dev, lane, B53_SERDES_DIGITAL_STATUS,
 			      SERDES_DIGITAL_BLK);
-	bmcr = b53_serdes_read(dev, lane, B53_SERDES_MII_REG(MII_BMCR),
-			       SERDES_MII_BLK);
 	bmsr = b53_serdes_read(dev, lane, B53_SERDES_MII_REG(MII_BMSR),
 			       SERDES_MII_BLK);
 
@@ -129,7 +127,6 @@ int b53_serdes_link_state(struct b53_device *dev, int port,
 	}
 
 	state->duplex = dig & DUPLEX_STATUS ? DUPLEX_FULL : DUPLEX_HALF;
-	state->an_enabled = !!(bmcr & BMCR_ANENABLE);
 	state->an_complete = !!(bmsr & BMSR_ANEGCOMPLETE);
 	state->link = !!(dig & LINK_STATUS);
 	if (dig & PAUSE_RESOLUTION_RX_SIDE)
-- 
2.17.1

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

* [PATCH net-next 0/2] net: dsa: b53: SGMII modes fixes
@ 2018-09-21 23:43 Florian Fainelli
  2018-09-21 23:43 ` [PATCH net-next] net: dsa: b53: Don't assign autonegotiation enabled Florian Fainelli
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Florian Fainelli @ 2018-09-21 23:43 UTC (permalink / raw)
  To: netdev; +Cc: andrew, rmk+kernel, davem, Florian Fainelli

Hi David,

Here are two additional fixes that are required in order for SGMII to
work correctly. This was discovered with using a copper SFP which would
make us use SGMII mode, we would actually leave the HW configured in its
default mode: Fiber.

Florian Fainelli (2):
  net: dsa: b53: Fix B53_SERDES_DIGITAL_CONTROL offset
  net: dsa: b53: Also include SGMII for mac_config and mac_link_state

 drivers/net/dsa/b53/b53_common.c | 10 ++++++----
 drivers/net/dsa/b53/b53_serdes.h |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

-- 
2.17.1

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

* [PATCH net-next] net: dsa: b53: Don't assign autonegotiation enabled
  2018-09-21 23:43 [PATCH net-next 0/2] net: dsa: b53: SGMII modes fixes Florian Fainelli
@ 2018-09-21 23:43 ` Florian Fainelli
  2018-09-21 23:43 ` [PATCH net-next 1/2] net: dsa: b53: Fix B53_SERDES_DIGITAL_CONTROL offset Florian Fainelli
  2018-09-21 23:43 ` [PATCH net-next 2/2] net: dsa: b53: Also include SGMII for mac_config and mac_link_state Florian Fainelli
  2 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2018-09-21 23:43 UTC (permalink / raw)
  To: netdev; +Cc: andrew, rmk+kernel, davem, Florian Fainelli

PHYLINK takes care of filing the right information into
state->an_enabled, get rid of the read from the SerDes's BMCR register.

Fixes: 0e01491de646 ("net: dsa: b53: Add SerDes support")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/b53/b53_serdes.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_serdes.c b/drivers/net/dsa/b53/b53_serdes.c
index b45c55e0b8b4..629bf14128a2 100644
--- a/drivers/net/dsa/b53/b53_serdes.c
+++ b/drivers/net/dsa/b53/b53_serdes.c
@@ -100,15 +100,13 @@ int b53_serdes_link_state(struct b53_device *dev, int port,
 			  struct phylink_link_state *state)
 {
 	u8 lane = b53_serdes_map_lane(dev, port);
-	u16 dig, bmcr, bmsr;
+	u16 dig, bmsr;
 
 	if (lane == B53_INVALID_LANE)
 		return 1;
 
 	dig = b53_serdes_read(dev, lane, B53_SERDES_DIGITAL_STATUS,
 			      SERDES_DIGITAL_BLK);
-	bmcr = b53_serdes_read(dev, lane, B53_SERDES_MII_REG(MII_BMCR),
-			       SERDES_MII_BLK);
 	bmsr = b53_serdes_read(dev, lane, B53_SERDES_MII_REG(MII_BMSR),
 			       SERDES_MII_BLK);
 
@@ -129,7 +127,6 @@ int b53_serdes_link_state(struct b53_device *dev, int port,
 	}
 
 	state->duplex = dig & DUPLEX_STATUS ? DUPLEX_FULL : DUPLEX_HALF;
-	state->an_enabled = !!(bmcr & BMCR_ANENABLE);
 	state->an_complete = !!(bmsr & BMSR_ANEGCOMPLETE);
 	state->link = !!(dig & LINK_STATUS);
 	if (dig & PAUSE_RESOLUTION_RX_SIDE)
-- 
2.17.1

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

* [PATCH net-next 1/2] net: dsa: b53: Fix B53_SERDES_DIGITAL_CONTROL offset
  2018-09-21 23:43 [PATCH net-next 0/2] net: dsa: b53: SGMII modes fixes Florian Fainelli
  2018-09-21 23:43 ` [PATCH net-next] net: dsa: b53: Don't assign autonegotiation enabled Florian Fainelli
@ 2018-09-21 23:43 ` Florian Fainelli
  2018-09-21 23:43 ` [PATCH net-next 2/2] net: dsa: b53: Also include SGMII for mac_config and mac_link_state Florian Fainelli
  2 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2018-09-21 23:43 UTC (permalink / raw)
  To: netdev; +Cc: andrew, rmk+kernel, davem, Florian Fainelli

Maths went wrong, to get 0x20, we need to do 0x1e + (x) * 2, not 0x18,
fix that offset so we access the correct registers. This would make us
not access the correct SerDes Digital control words, status would be
fine and so we would not be correctly flipping between Fiber and SGMII
modes resulting in incorrect status words being pulled into the SerDes
digital status register.

Fixes: 0e01491de646 ("net: dsa: b53: Add SerDes support")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/b53/b53_serdes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/b53/b53_serdes.h b/drivers/net/dsa/b53/b53_serdes.h
index eed7c9357091..3bb4f91aec9e 100644
--- a/drivers/net/dsa/b53/b53_serdes.h
+++ b/drivers/net/dsa/b53/b53_serdes.h
@@ -20,7 +20,7 @@
 #define  SERDES_ID0_REV_LETTER_SHIFT	14
 
 #define B53_SERDES_MII_REG(x)		(0x20 + (x) * 2)
-#define B53_SERDES_DIGITAL_CONTROL(x)	(0x18 + (x) * 2)
+#define B53_SERDES_DIGITAL_CONTROL(x)	(0x1e + (x) * 2)
 #define B53_SERDES_DIGITAL_STATUS	0x28
 
 /* SERDES_DIGITAL_CONTROL1 */
-- 
2.17.1

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

* [PATCH net-next 2/2] net: dsa: b53: Also include SGMII for mac_config and mac_link_state
  2018-09-21 23:43 [PATCH net-next 0/2] net: dsa: b53: SGMII modes fixes Florian Fainelli
  2018-09-21 23:43 ` [PATCH net-next] net: dsa: b53: Don't assign autonegotiation enabled Florian Fainelli
  2018-09-21 23:43 ` [PATCH net-next 1/2] net: dsa: b53: Fix B53_SERDES_DIGITAL_CONTROL offset Florian Fainelli
@ 2018-09-21 23:43 ` Florian Fainelli
  2 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2018-09-21 23:43 UTC (permalink / raw)
  To: netdev; +Cc: andrew, rmk+kernel, davem, Florian Fainelli

In both 802.3z and SGMII modes we need to configure the MAC accordingly
to flip between Fiber and SGMII modes, and we need to read the MAC
status from the SGMII in-band control word.

Fixes: 0e01491de646 ("net: dsa: b53: Add SerDes support")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/b53/b53_common.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index dbf5b86a07fe..700d86dd5e13 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1172,8 +1172,9 @@ int b53_phylink_mac_link_state(struct dsa_switch *ds, int port,
 	struct b53_device *dev = ds->priv;
 	int ret = -EOPNOTSUPP;
 
-	if (phy_interface_mode_is_8023z(state->interface) &&
-	    dev->ops->serdes_link_state)
+	if ((phy_interface_mode_is_8023z(state->interface) ||
+	     state->interface == PHY_INTERFACE_MODE_SGMII) &&
+	     dev->ops->serdes_link_state)
 		ret = dev->ops->serdes_link_state(dev, port, state);
 
 	return ret;
@@ -1195,8 +1196,9 @@ void b53_phylink_mac_config(struct dsa_switch *ds, int port,
 		return;
 	}
 
-	if (phy_interface_mode_is_8023z(state->interface) &&
-	    dev->ops->serdes_config)
+	if ((phy_interface_mode_is_8023z(state->interface) ||
+	     state->interface == PHY_INTERFACE_MODE_SGMII) &&
+	     dev->ops->serdes_config)
 		dev->ops->serdes_config(dev, port, mode, state);
 }
 EXPORT_SYMBOL(b53_phylink_mac_config);
-- 
2.17.1

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

end of thread, other threads:[~2018-09-22  5:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-21 23:43 [PATCH net-next 0/2] net: dsa: b53: SGMII modes fixes Florian Fainelli
2018-09-21 23:43 ` [PATCH net-next] net: dsa: b53: Don't assign autonegotiation enabled Florian Fainelli
2018-09-21 23:43 ` [PATCH net-next 1/2] net: dsa: b53: Fix B53_SERDES_DIGITAL_CONTROL offset Florian Fainelli
2018-09-21 23:43 ` [PATCH net-next 2/2] net: dsa: b53: Also include SGMII for mac_config and mac_link_state Florian Fainelli
  -- strict thread matches above, loose matches on Subject: below --
2018-09-21 22:30 [PATCH net-next] net: dsa: b53: Don't assign autonegotiation enabled Florian Fainelli

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