bcm47xx: fix bgmac support for BCM5358
[openwrt/staging/hauke.git] / target / linux / bcm47xx / patches-5.10 / 170-bgmac-fix-initial-chip-reset-to-support-BCM5358.patch
1 From 327dabbd0111910a7d174b0b812d608d6b67bead Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Mon, 8 Aug 2022 23:05:25 +0200
4 Subject: [PATCH] bgmac: fix *initial* chip reset to support BCM5358
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 While bringing hardware up we should perform a full reset including the
10 switch bit (BGMAC_BCMA_IOCTL_SW_RESET aka SICF_SWRST). It's what
11 specification says and what reference driver does.
12
13 This seems to be critical for the BCM5358. Without this hardware doesn't
14 get initialized properly and doesn't seem to transmit or receive any
15 packets.
16
17 Originally bgmac was calling bgmac_chip_reset() before setting
18 "has_robosw" property which resulted in expected behaviour. That has
19 changed as a side effect of adding platform device support which
20 regressed BCM5358 support.
21
22 Fixes: f6a95a24957a ("net: ethernet: bgmac: Add platform device support")
23 Cc: Jon Mason <jdmason@kudzu.us>
24 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
25 ---
26 drivers/net/ethernet/broadcom/bgmac.c | 8 ++++++--
27 drivers/net/ethernet/broadcom/bgmac.h | 2 ++
28 2 files changed, 8 insertions(+), 2 deletions(-)
29
30 --- a/drivers/net/ethernet/broadcom/bgmac.c
31 +++ b/drivers/net/ethernet/broadcom/bgmac.c
32 @@ -891,13 +891,13 @@ static void bgmac_chip_reset_idm_config(
33
34 if (iost & BGMAC_BCMA_IOST_ATTACHED) {
35 flags = BGMAC_BCMA_IOCTL_SW_CLKEN;
36 - if (!bgmac->has_robosw)
37 + if (bgmac->in_init || !bgmac->has_robosw)
38 flags |= BGMAC_BCMA_IOCTL_SW_RESET;
39 }
40 bgmac_clk_enable(bgmac, flags);
41 }
42
43 - if (iost & BGMAC_BCMA_IOST_ATTACHED && !bgmac->has_robosw)
44 + if (iost & BGMAC_BCMA_IOST_ATTACHED && (bgmac->in_init || !bgmac->has_robosw))
45 bgmac_idm_write(bgmac, BCMA_IOCTL,
46 bgmac_idm_read(bgmac, BCMA_IOCTL) &
47 ~BGMAC_BCMA_IOCTL_SW_RESET);
48 @@ -1502,6 +1502,8 @@ int bgmac_enet_probe(struct bgmac *bgmac
49 struct net_device *net_dev = bgmac->net_dev;
50 int err;
51
52 + bgmac->in_init = true;
53 +
54 bgmac_chip_intrs_off(bgmac);
55
56 net_dev->irq = bgmac->irq;
57 @@ -1562,6 +1564,8 @@ int bgmac_enet_probe(struct bgmac *bgmac
58 bgmac->b53_device = &bgmac_b53_dev;
59 }
60
61 + bgmac->in_init = false;
62 +
63 err = register_netdev(bgmac->net_dev);
64 if (err) {
65 dev_err(bgmac->dev, "Cannot register net device\n");
66 --- a/drivers/net/ethernet/broadcom/bgmac.h
67 +++ b/drivers/net/ethernet/broadcom/bgmac.h
68 @@ -513,6 +513,8 @@ struct bgmac {
69 int irq;
70 u32 int_mask;
71
72 + bool in_init;
73 +
74 /* Current MAC state */
75 int mac_speed;
76 int mac_duplex;