From: Russell King <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Heiner Kallweit <hkallweit1@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org,
Nicolas Ferre <nicolas.ferre@microchip.com>
Subject: [CFT 6/8] net: macb: use resolved link config in mac_link_up()
Date: Mon, 17 Feb 2020 17:24:21 +0000 [thread overview]
Message-ID: <E1j3k85-00072l-RK@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20200217172242.GZ25745@shell.armlinux.org.uk>
Convert the macb ethernet driver to use the finalised link
parameters in mac_link_up() rather than the parameters in mac_config().
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/cadence/macb.h | 1 -
drivers/net/ethernet/cadence/macb_main.c | 46 ++++++++++++++----------
2 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index dbf7070fcdba..e99608f27d23 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -1199,7 +1199,6 @@ struct macb {
unsigned int dma_burst_length;
phy_interface_t phy_interface;
- int speed;
/* AT91RM9200 transmit */
struct sk_buff *skb; /* holds skb until xmit interrupt completes */
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 92e0c1035db8..1332523d7dcb 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -572,20 +572,7 @@ static void macb_mac_config(struct phylink_config *config, unsigned int mode,
old_ctrl = ctrl = macb_or_gem_readl(bp, NCFGR);
/* Clear all the bits we might set later */
- ctrl &= ~(GEM_BIT(GBE) | MACB_BIT(SPD) | MACB_BIT(FD) | MACB_BIT(PAE) |
- GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL));
-
- if (state->speed == SPEED_1000)
- ctrl |= GEM_BIT(GBE);
- else if (state->speed == SPEED_100)
- ctrl |= MACB_BIT(SPD);
-
- if (state->duplex)
- ctrl |= MACB_BIT(FD);
-
- /* We do not support MLO_PAUSE_RX yet */
- if (state->pause & MLO_PAUSE_TX)
- ctrl |= MACB_BIT(PAE);
+ ctrl &= ~(GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL));
if (state->interface == PHY_INTERFACE_MODE_SGMII)
ctrl |= GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL);
@@ -594,8 +581,6 @@ static void macb_mac_config(struct phylink_config *config, unsigned int mode,
if (old_ctrl ^ ctrl)
macb_or_gem_writel(bp, NCFGR, ctrl);
- bp->speed = state->speed;
-
spin_unlock_irqrestore(&bp->lock, flags);
}
@@ -628,9 +613,34 @@ static void macb_mac_link_up(struct phylink_config *config,
struct net_device *ndev = to_net_dev(config->dev);
struct macb *bp = netdev_priv(ndev);
struct macb_queue *queue;
+ unsigned long flags;
unsigned int q;
+ u32 ctrl;
+
+ spin_lock_irqsave(&bp->lock, flags);
+
+ ctrl = macb_or_gem_readl(bp, NCFGR);
- macb_set_tx_clk(bp->tx_clk, bp->speed, ndev);
+ /* Clear all the bits we might set later */
+ ctrl &= ~(GEM_BIT(GBE) | MACB_BIT(SPD) | MACB_BIT(FD) | MACB_BIT(PAE));
+
+ if (speed == SPEED_1000)
+ ctrl |= GEM_BIT(GBE);
+ else if (speed == SPEED_100)
+ ctrl |= MACB_BIT(SPD);
+
+ if (duplex == DUPLEX_FULL)
+ ctrl |= MACB_BIT(FD);
+
+ /* We do not support rx_pause yet */
+ if (tx_pause)
+ ctrl |= MACB_BIT(PAE);
+
+ macb_or_gem_writel(bp, NCFGR, ctrl);
+
+ spin_unlock_irqrestore(&bp->lock, flags);
+
+ macb_set_tx_clk(bp->tx_clk, speed, ndev);
/* Initialize rings & buffers as clearing MACB_BIT(TE) in link down
* cleared the pipeline and control registers.
@@ -4424,8 +4434,6 @@ static int macb_probe(struct platform_device *pdev)
else
bp->phy_interface = interface;
- bp->speed = SPEED_UNKNOWN;
-
/* IP specific init */
err = init(pdev);
if (err)
--
2.20.1
next prev parent reply other threads:[~2020-02-17 17:25 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-17 17:22 [CFT 0/8] rework phylink interface for split MAC/PCS support Russell King - ARM Linux admin
2020-02-17 17:23 ` [CFT 1/8] net: phylink: propagate resolved link config via mac_link_up() Russell King
2020-02-17 18:03 ` Matthew Wilcox
2020-02-17 18:48 ` Russell King - ARM Linux admin
2020-02-17 21:54 ` Florian Fainelli
2020-02-18 1:53 ` Russell King - ARM Linux admin
2020-02-17 17:23 ` [CFT 2/8] net: dsa: " Russell King
2020-02-17 17:24 ` [CFT 3/8] net: mv88e6xxx: use resolved link config in mac_link_up() Russell King
2020-02-17 17:24 ` [CFT 4/8] net: axienet: " Russell King
2020-02-20 10:29 ` Russell King - ARM Linux admin
2020-02-24 12:24 ` Andre Przywara
2020-02-24 13:01 ` Russell King - ARM Linux admin
2020-02-17 17:24 ` [CFT 5/8] net: dpaa2-mac: " Russell King
2020-02-18 10:34 ` Russell King - ARM Linux admin
2020-02-18 10:42 ` Ioana Ciornei
2020-02-20 10:20 ` Russell King - ARM Linux admin
2020-02-17 17:24 ` Russell King [this message]
2020-02-19 14:30 ` [CFT 6/8] net: macb: " Alexandre Belloni
2020-02-20 10:18 ` Russell King - ARM Linux admin
2020-02-20 12:38 ` Andrew Lunn
2020-02-20 12:44 ` Russell King - ARM Linux admin
2020-02-21 20:25 ` Russell King - ARM Linux admin
2020-02-24 13:15 ` Russell King - ARM Linux admin
2020-02-24 14:37 ` Alexandre Belloni
2020-02-17 17:24 ` [CFT 7/8] net: mvneta: " Russell King
2020-02-17 17:24 ` [CFT 8/8] net: mvpp2: " Russell King
2020-02-17 17:33 ` [CFT 0/8] rework phylink interface for split MAC/PCS support Andrew Lunn
2020-02-17 18:51 ` Russell King - ARM Linux admin
2020-02-18 10:29 ` Russell King - ARM Linux admin
2020-06-21 14:33 ` Russell King - ARM Linux admin
2020-06-21 19:37 ` Vladimir Oltean
2020-06-21 20:02 ` Russell King - ARM Linux admin
2020-06-21 21:17 ` Florian Fainelli
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=E1j3k85-00072l-RK@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
/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).