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
Delegated to: Netdev Maintainers
Headers show
Series [RFC] bgmac: fix *initial* chip reset to support BCM5358 | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: From:/Signed-off-by: email address mismatch: 'From: "Rafał Miłecki" <zajec5@gmail.com>' != 'Signed-off-by: Rafał Miłecki <rafal@milecki.pl>'
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

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;