diff mbox series

[RFC] bgmac: fix *initial* chip reset to support BCM5358

Message ID 20230207225327.27534-1-zajec5@gmail.com (mailing list archive)
State RFC
Headers show
Series [RFC] bgmac: fix *initial* chip reset to support BCM5358 | expand

Commit Message

Rafał Miłecki Feb. 7, 2023, 10:53 p.m. UTC
While bringing hardware up we should perform a full reset including the
switch bit (BGMAC_BCMA_IOCTL_SW_RESET aka SICF_SWRST). It's what
specification says and what reference driver does.

This seems to be critical for the BCM5358. Without this hardware doesn't
get initialized properly and doesn't seem to transmit or receive any
packets.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
RFC: What do you think about adding that "bool initial" parameter? Is
     that OK? As an alternative I could use something like
     u16 flags;
     BGMAC_FLAGS_INITIAL_RESET
---
 drivers/net/ethernet/broadcom/bgmac.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index 3038386a5afd..4963fdbad31b 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -876,7 +876,7 @@  static void bgmac_miiconfig(struct bgmac *bgmac)
 	}
 }
 
-static void bgmac_chip_reset_idm_config(struct bgmac *bgmac)
+static void bgmac_chip_reset_idm_config(struct bgmac *bgmac, bool initial)
 {
 	u32 iost;
 
@@ -890,20 +890,20 @@  static void bgmac_chip_reset_idm_config(struct bgmac *bgmac)
 
 		if (iost & BGMAC_BCMA_IOST_ATTACHED) {
 			flags = BGMAC_BCMA_IOCTL_SW_CLKEN;
-			if (!bgmac->has_robosw)
+			if (initial || !bgmac->has_robosw)
 				flags |= BGMAC_BCMA_IOCTL_SW_RESET;
 		}
 		bgmac_clk_enable(bgmac, flags);
 	}
 
-	if (iost & BGMAC_BCMA_IOST_ATTACHED && !bgmac->has_robosw)
+	if (iost & BGMAC_BCMA_IOST_ATTACHED && (initial || !bgmac->has_robosw))
 		bgmac_idm_write(bgmac, BCMA_IOCTL,
 				bgmac_idm_read(bgmac, BCMA_IOCTL) &
 				~BGMAC_BCMA_IOCTL_SW_RESET);
 }
 
 /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipreset */
-static void bgmac_chip_reset(struct bgmac *bgmac)
+static void bgmac_chip_reset(struct bgmac *bgmac, bool initial)
 {
 	u32 cmdcfg_sr;
 	int i;
@@ -927,7 +927,7 @@  static void bgmac_chip_reset(struct bgmac *bgmac)
 	}
 
 	if (!(bgmac->feature_flags & BGMAC_FEAT_IDM_MASK))
-		bgmac_chip_reset_idm_config(bgmac);
+		bgmac_chip_reset_idm_config(bgmac, initial);
 
 	/* Request Misc PLL for corerev > 2 */
 	if (bgmac->feature_flags & BGMAC_FEAT_MISC_PLL_REQ) {
@@ -1177,7 +1177,7 @@  static int bgmac_open(struct net_device *net_dev)
 	struct bgmac *bgmac = netdev_priv(net_dev);
 	int err = 0;
 
-	bgmac_chip_reset(bgmac);
+	bgmac_chip_reset(bgmac, false);
 
 	err = bgmac_dma_init(bgmac);
 	if (err)
@@ -1214,7 +1214,7 @@  static int bgmac_stop(struct net_device *net_dev)
 	bgmac_chip_intrs_off(bgmac);
 	free_irq(bgmac->irq, net_dev);
 
-	bgmac_chip_reset(bgmac);
+	bgmac_chip_reset(bgmac, false);
 	bgmac_dma_cleanup(bgmac);
 
 	return 0;
@@ -1515,7 +1515,7 @@  int bgmac_enet_probe(struct bgmac *bgmac)
 			bgmac_idm_write(bgmac, BCMA_OOB_SEL_OUT_A30, 0x86);
 	}
 
-	bgmac_chip_reset(bgmac);
+	bgmac_chip_reset(bgmac, true);
 
 	err = bgmac_dma_alloc(bgmac);
 	if (err) {
@@ -1587,7 +1587,7 @@  int bgmac_enet_suspend(struct bgmac *bgmac)
 	netif_tx_unlock(bgmac->net_dev);
 
 	bgmac_chip_intrs_off(bgmac);
-	bgmac_chip_reset(bgmac);
+	bgmac_chip_reset(bgmac, false);
 	bgmac_dma_cleanup(bgmac);
 
 	return 0;