]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/6.6.26/net-bcmasp-bring-up-unimac-after-phy-link-up.patch
Linux 6.6.26
[thirdparty/kernel/stable-queue.git] / releases / 6.6.26 / net-bcmasp-bring-up-unimac-after-phy-link-up.patch
CommitLineData
ffc1c2fe
SL
1From 23be5ac6454727213901eecd3fca822ff01bb453 Mon Sep 17 00:00:00 2001
2From: Sasha Levin <sashal@kernel.org>
3Date: Mon, 25 Mar 2024 12:30:24 -0700
4Subject: net: bcmasp: Bring up unimac after PHY link up
5
6From: Justin Chen <justin.chen@broadcom.com>
7
8[ Upstream commit dfd222e2aef68818320a57b13a1c52a44c22bc80 ]
9
10The unimac requires the PHY RX clk during reset or it may be put
11into a bad state. Bring up the unimac after link up to ensure the
12PHY RX clk exists.
13
14Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")
15Signed-off-by: Justin Chen <justin.chen@broadcom.com>
16Signed-off-by: Paolo Abeni <pabeni@redhat.com>
17Signed-off-by: Sasha Levin <sashal@kernel.org>
18---
19 .../net/ethernet/broadcom/asp2/bcmasp_intf.c | 28 +++++++++++++------
20 1 file changed, 19 insertions(+), 9 deletions(-)
21
22diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
23index 9cae5a3090000..b3d04f49f77e9 100644
24--- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
25+++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
26@@ -391,7 +391,9 @@ static void umac_reset(struct bcmasp_intf *intf)
27 umac_wl(intf, 0x0, UMC_CMD);
28 umac_wl(intf, UMC_CMD_SW_RESET, UMC_CMD);
29 usleep_range(10, 100);
30- umac_wl(intf, 0x0, UMC_CMD);
31+ /* We hold the umac in reset and bring it out of
32+ * reset when phy link is up.
33+ */
34 }
35
36 static void umac_set_hw_addr(struct bcmasp_intf *intf,
37@@ -411,6 +413,8 @@ static void umac_enable_set(struct bcmasp_intf *intf, u32 mask,
38 u32 reg;
39
40 reg = umac_rl(intf, UMC_CMD);
41+ if (reg & UMC_CMD_SW_RESET)
42+ return;
43 if (enable)
44 reg |= mask;
45 else
46@@ -429,7 +433,6 @@ static void umac_init(struct bcmasp_intf *intf)
47 umac_wl(intf, 0x800, UMC_FRM_LEN);
48 umac_wl(intf, 0xffff, UMC_PAUSE_CNTRL);
49 umac_wl(intf, 0x800, UMC_RX_MAX_PKT_SZ);
50- umac_enable_set(intf, UMC_CMD_PROMISC, 1);
51 }
52
53 static int bcmasp_tx_poll(struct napi_struct *napi, int budget)
54@@ -656,6 +659,12 @@ static void bcmasp_adj_link(struct net_device *dev)
55 UMC_CMD_HD_EN | UMC_CMD_RX_PAUSE_IGNORE |
56 UMC_CMD_TX_PAUSE_IGNORE);
57 reg |= cmd_bits;
58+ if (reg & UMC_CMD_SW_RESET) {
59+ reg &= ~UMC_CMD_SW_RESET;
60+ umac_wl(intf, reg, UMC_CMD);
61+ udelay(2);
62+ reg |= UMC_CMD_TX_EN | UMC_CMD_RX_EN | UMC_CMD_PROMISC;
63+ }
64 umac_wl(intf, reg, UMC_CMD);
65
66 intf->eee.eee_active = phy_init_eee(phydev, 0) >= 0;
67@@ -1061,9 +1070,6 @@ static int bcmasp_netif_init(struct net_device *dev, bool phy_connect)
68
69 umac_init(intf);
70
71- /* Disable the UniMAC RX/TX */
72- umac_enable_set(intf, (UMC_CMD_RX_EN | UMC_CMD_TX_EN), 0);
73-
74 umac_set_hw_addr(intf, dev->dev_addr);
75
76 intf->old_duplex = -1;
77@@ -1083,9 +1089,6 @@ static int bcmasp_netif_init(struct net_device *dev, bool phy_connect)
78
79 bcmasp_enable_rx(intf, 1);
80
81- /* Turn on UniMAC TX/RX */
82- umac_enable_set(intf, (UMC_CMD_RX_EN | UMC_CMD_TX_EN), 1);
83-
84 intf->crc_fwd = !!(umac_rl(intf, UMC_CMD) & UMC_CMD_CRC_FWD);
85
86 bcmasp_netif_start(dev);
87@@ -1321,7 +1324,14 @@ static void bcmasp_suspend_to_wol(struct bcmasp_intf *intf)
88 if (intf->wolopts & WAKE_FILTER)
89 bcmasp_netfilt_suspend(intf);
90
91- /* UniMAC receive needs to be turned on */
92+ /* Bring UniMAC out of reset if needed and enable RX */
93+ reg = umac_rl(intf, UMC_CMD);
94+ if (reg & UMC_CMD_SW_RESET)
95+ reg &= ~UMC_CMD_SW_RESET;
96+
97+ reg |= UMC_CMD_RX_EN | UMC_CMD_PROMISC;
98+ umac_wl(intf, reg, UMC_CMD);
99+
100 umac_enable_set(intf, UMC_CMD_RX_EN, 1);
101
102 if (intf->parent->wol_irq > 0) {
103--
1042.43.0
105