netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arun Ramadoss <arun.ramadoss@microchip.com>
To: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: Woojung Huh <woojung.huh@microchip.com>,
	<UNGLinuxDriver@microchip.com>, Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vladimir Oltean <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	"Russell King" <linux@armlinux.org.uk>
Subject: [RFC Patch net-next 05/10] net: dsa: microchip: add support for common phylink mac link up
Date: Tue, 12 Jul 2022 21:33:03 +0530	[thread overview]
Message-ID: <20220712160308.13253-6-arun.ramadoss@microchip.com> (raw)
In-Reply-To: <20220712160308.13253-1-arun.ramadoss@microchip.com>

This patch add the support for common phylink mac link up for the ksz
series switch. The register address, bit position and values are
configured based on the chip id to the dev->info structure.

Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
---
 drivers/net/dsa/microchip/ksz_common.c   | 30 +++++++++++++++++++----
 drivers/net/dsa/microchip/ksz_common.h   |  4 ---
 drivers/net/dsa/microchip/lan937x.h      |  4 ---
 drivers/net/dsa/microchip/lan937x_main.c | 31 ------------------------
 4 files changed, 25 insertions(+), 44 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 4ef0ee9a245d..0cb711fcf046 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -222,7 +222,6 @@ static const struct ksz_dev_ops lan937x_dev_ops = {
 	.mirror_del = ksz9477_port_mirror_del,
 	.get_caps = lan937x_phylink_get_caps,
 	.phylink_mac_config = lan937x_phylink_mac_config,
-	.phylink_mac_link_up = lan937x_phylink_mac_link_up,
 	.fdb_dump = ksz9477_fdb_dump,
 	.fdb_add = ksz9477_fdb_add,
 	.fdb_del = ksz9477_fdb_del,
@@ -1438,7 +1437,7 @@ void ksz_set_gbit(struct ksz_device *dev, int port, bool gbit)
 	ksz_pwrite8(dev, port, regs[P_XMII_CTRL_1], data8);
 }
 
-void ksz_set_100_10mbit(struct ksz_device *dev, int port, int speed)
+static void ksz_set_100_10mbit(struct ksz_device *dev, int port, int speed)
 {
 	const u8 *bitval = dev->info->bitval;
 	const u16 *regs = dev->info->regs;
@@ -1459,7 +1458,7 @@ void ksz_set_100_10mbit(struct ksz_device *dev, int port, int speed)
 	ksz_pwrite8(dev, port, regs[P_XMII_CTRL_0], data8);
 }
 
-void ksz_set_fullduplex(struct ksz_device *dev, int port, bool val)
+static void ksz_set_fullduplex(struct ksz_device *dev, int port, bool val)
 {
 	const u8 *bitval = dev->info->bitval;
 	const u16 *regs = dev->info->regs;
@@ -1479,7 +1478,7 @@ void ksz_set_fullduplex(struct ksz_device *dev, int port, bool val)
 	ksz_pwrite8(dev, port, regs[P_XMII_CTRL_0], data8);
 }
 
-void ksz_set_tx_pause(struct ksz_device *dev, int port, bool val)
+static void ksz_set_tx_pause(struct ksz_device *dev, int port, bool val)
 {
 	const u32 *masks = dev->info->masks;
 	const u16 *regs = dev->info->regs;
@@ -1495,7 +1494,7 @@ void ksz_set_tx_pause(struct ksz_device *dev, int port, bool val)
 	ksz_pwrite8(dev, port, regs[P_XMII_CTRL_0], data8);
 }
 
-void ksz_set_rx_pause(struct ksz_device *dev, int port, bool val)
+static void ksz_set_rx_pause(struct ksz_device *dev, int port, bool val)
 {
 	const u32 *masks = dev->info->masks;
 	const u16 *regs = dev->info->regs;
@@ -1518,6 +1517,27 @@ static void ksz_phylink_mac_link_up(struct dsa_switch *ds, int port,
 				    int duplex, bool tx_pause, bool rx_pause)
 {
 	struct ksz_device *dev = ds->priv;
+	struct ksz_port *p;
+
+	p = &dev->ports[port];
+
+	/* Internal PHYs */
+	if (dev->info->internal_phy[port])
+		return;
+
+	p->phydev.speed = speed;
+
+	if (speed == SPEED_1000)
+		ksz_set_gbit(dev, port, true);
+
+	if (speed == SPEED_100 || speed == SPEED_10)
+		ksz_set_100_10mbit(dev, port, speed);
+
+	ksz_set_fullduplex(dev, port, duplex);
+
+	ksz_set_tx_pause(dev, port, tx_pause);
+
+	ksz_set_rx_pause(dev, port, rx_pause);
 
 	if (dev->dev_ops->phylink_mac_link_up)
 		dev->dev_ops->phylink_mac_link_up(dev, port, mode, interface,
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 851ee50895a4..db836b376341 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -311,10 +311,6 @@ void ksz_r_mib_stats64(struct ksz_device *dev, int port);
 void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state);
 bool ksz_get_gbit(struct ksz_device *dev, int port);
 void ksz_set_gbit(struct ksz_device *dev, int port, bool gbit);
-void ksz_set_100_10mbit(struct ksz_device *dev, int port, int speed);
-void ksz_set_fullduplex(struct ksz_device *dev, int port, bool val);
-void ksz_set_tx_pause(struct ksz_device *dev, int port, bool val);
-void ksz_set_rx_pause(struct ksz_device *dev, int port, bool val);
 extern const struct ksz_chip_data ksz_switch_chips[];
 
 /* Common register access functions */
diff --git a/drivers/net/dsa/microchip/lan937x.h b/drivers/net/dsa/microchip/lan937x.h
index 72ba9cb2fbc6..0ae553a9b9af 100644
--- a/drivers/net/dsa/microchip/lan937x.h
+++ b/drivers/net/dsa/microchip/lan937x.h
@@ -17,10 +17,6 @@ void lan937x_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val);
 int lan937x_change_mtu(struct ksz_device *dev, int port, int new_mtu);
 void lan937x_phylink_get_caps(struct ksz_device *dev, int port,
 			      struct phylink_config *config);
-void lan937x_phylink_mac_link_up(struct ksz_device *dev, int port,
-				 unsigned int mode, phy_interface_t interface,
-				 struct phy_device *phydev, int speed,
-				 int duplex, bool tx_pause, bool rx_pause);
 void lan937x_phylink_mac_config(struct ksz_device *dev, int port,
 				unsigned int mode,
 				const struct phylink_link_state *state);
diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c
index 67b03ab0ede3..a2e648eacd19 100644
--- a/drivers/net/dsa/microchip/lan937x_main.c
+++ b/drivers/net/dsa/microchip/lan937x_main.c
@@ -345,24 +345,6 @@ static void lan937x_mac_config(struct ksz_device *dev, int port,
 	ksz_pwrite8(dev, port, REG_PORT_XMII_CTRL_1, data8);
 }
 
-static void lan937x_config_interface(struct ksz_device *dev, int port,
-				     int speed, int duplex,
-				     bool tx_pause, bool rx_pause)
-{
-	if (speed == SPEED_1000)
-		ksz_set_gbit(dev, port, true);
-
-	if (speed == SPEED_100 || speed == SPEED_10)
-		ksz_set_100_10mbit(dev, port, speed);
-
-	ksz_set_fullduplex(dev, port, duplex);
-
-	ksz_set_tx_pause(dev, port, tx_pause);
-
-	ksz_set_rx_pause(dev, port, rx_pause);
-
-}
-
 void lan937x_phylink_get_caps(struct ksz_device *dev, int port,
 			      struct phylink_config *config)
 {
@@ -375,19 +357,6 @@ void lan937x_phylink_get_caps(struct ksz_device *dev, int port,
 	}
 }
 
-void lan937x_phylink_mac_link_up(struct ksz_device *dev, int port,
-				 unsigned int mode, phy_interface_t interface,
-				 struct phy_device *phydev, int speed,
-				 int duplex, bool tx_pause, bool rx_pause)
-{
-	/* Internal PHYs */
-	if (dev->info->internal_phy[port])
-		return;
-
-	lan937x_config_interface(dev, port, speed, duplex,
-				 tx_pause, rx_pause);
-}
-
 void lan937x_phylink_mac_config(struct ksz_device *dev, int port,
 				unsigned int mode,
 				const struct phylink_link_state *state)
-- 
2.36.1


  parent reply	other threads:[~2022-07-12 16:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-12 16:02 [RFC Patch net-next 00/10] net: dsa: microchip: add support for phylink mac config and link up Arun Ramadoss
2022-07-12 16:02 ` [RFC Patch net-next 01/10] net: dsa: microchip: lan937x: read rgmii delay from device tree Arun Ramadoss
2022-07-19 10:28   ` Vladimir Oltean
2022-07-19 15:58     ` Arun.Ramadoss
2022-07-12 16:03 ` [RFC Patch net-next 02/10] net: dsa: microchip: add common gigabit set and get function Arun Ramadoss
2022-07-19 10:37   ` Vladimir Oltean
2022-07-12 16:03 ` [RFC Patch net-next 03/10] net: dsa: microchip: add common 100/10Mbps selection function Arun Ramadoss
2022-07-19 10:48   ` Vladimir Oltean
2022-07-19 15:56     ` Arun.Ramadoss
2022-07-12 16:03 ` [RFC Patch net-next 04/10] net: dsa: microchip: add common duplex and flow control function Arun Ramadoss
2022-07-19 10:52   ` Vladimir Oltean
2022-07-19 15:54     ` Arun.Ramadoss
2022-07-12 16:03 ` Arun Ramadoss [this message]
2022-07-12 16:03 ` [RFC Patch net-next 06/10] net: dsa: microchip: lan937x: add support for configuing xMII register Arun Ramadoss
2022-07-19 11:04   ` Vladimir Oltean
2022-07-19 15:55     ` Arun.Ramadoss
2022-07-12 16:03 ` [RFC Patch net-next 07/10] net: dsa: microchip: apply rgmii tx and rx delay in phylink mac config Arun Ramadoss
2022-07-19 10:25   ` Vladimir Oltean
2022-07-20 14:51     ` Arun.Ramadoss
2022-07-20 21:04       ` Vladimir Oltean
2022-07-12 16:03 ` [RFC Patch net-next 08/10] net: dsa: microchip: ksz9477: use common xmii function Arun Ramadoss
2022-07-12 16:03 ` [RFC Patch net-next 09/10] net: dsa: microchip: ksz8795: " Arun Ramadoss
2022-07-12 16:03 ` [RFC Patch net-next 10/10] net: dsa: microchip: add support for phylink mac config Arun Ramadoss

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=20220712160308.13253-6-arun.ramadoss@microchip.com \
    --to=arun.ramadoss@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=vivien.didelot@gmail.com \
    --cc=woojung.huh@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).