linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Rafał Miłecki" <zajec5@gmail.com>
To: Florian Fainelli <f.fainelli@gmail.com>,
	bcm-kernel-feedback-list@broadcom.com
Cc: "David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, "Rafał Miłecki" <zajec5@gmail.com>,
	"Rafał Miłecki" <rafal@milecki.pl>
Subject: [PATCH RFC] bgmac: fix *initial* chip reset to support BCM5358
Date: Tue,  7 Feb 2023 23:53:27 +0100	[thread overview]
Message-ID: <20230207225327.27534-1-zajec5@gmail.com> (raw)

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 --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;
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

                 reply	other threads:[~2023-02-07 22:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230207225327.27534-1-zajec5@gmail.com \
    --to=zajec5@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rafal@milecki.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).