linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/4] net: dsa: allow switch drivers to override default slave PHY addresses
@ 2020-03-30 13:53 Matthias Schiffer
  2020-03-30 13:53 ` [PATCH net-next 2/4] net: dsa: mv88e6xxx: account for PHY base address offset in dual chip mode Matthias Schiffer
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Matthias Schiffer @ 2020-03-30 13:53 UTC (permalink / raw)
  To: andrew, vivien.didelot, f.fainelli, davem, kuba
  Cc: netdev, linux-kernel, Matthias Schiffer

Avoid having to define a PHY for every physical port when PHY addresses
are fixed, but port index != PHY address.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---
 include/net/dsa.h |  1 +
 net/dsa/slave.c   | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index aeb411e77b9a..8216f3687799 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -391,6 +391,7 @@ struct dsa_switch_ops {
 
 	int	(*setup)(struct dsa_switch *ds);
 	void	(*teardown)(struct dsa_switch *ds);
+	int	(*get_phy_address)(struct dsa_switch *ds, int port);
 	u32	(*get_phy_flags)(struct dsa_switch *ds, int port);
 
 	/*
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 8ced165a7908..1c78f8cae9e9 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1546,7 +1546,7 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)
 	struct dsa_switch *ds = dp->ds;
 	phy_interface_t mode;
 	u32 phy_flags = 0;
-	int ret;
+	int addr, ret;
 
 	ret = of_get_phy_mode(port_dn, &mode);
 	if (ret)
@@ -1578,7 +1578,13 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)
 		/* We could not connect to a designated PHY or SFP, so try to
 		 * use the switch internal MDIO bus instead
 		 */
-		ret = dsa_slave_phy_connect(slave_dev, dp->index);
+
+		if (ds->ops->get_phy_address)
+			addr = ds->ops->get_phy_address(ds, dp->index);
+		else
+			addr = dp->index;
+
+		ret = dsa_slave_phy_connect(slave_dev, addr);
 		if (ret) {
 			netdev_err(slave_dev,
 				   "failed to connect to port %d: %d\n",
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-04-20  9:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30 13:53 [PATCH net-next 1/4] net: dsa: allow switch drivers to override default slave PHY addresses Matthias Schiffer
2020-03-30 13:53 ` [PATCH net-next 2/4] net: dsa: mv88e6xxx: account for PHY base address offset in dual chip mode Matthias Schiffer
2020-03-31  3:00   ` David Miller
2020-03-30 13:53 ` [PATCH net-next 3/4] net: dsa: mv88e6xxx: implement get_phy_address Matthias Schiffer
2020-03-30 13:53 ` [PATCH net-next 4/4] net: dsa: mv88e6xxx: add support for MV88E6020 switch Matthias Schiffer
2020-03-31  3:04 ` [PATCH net-next 1/4] net: dsa: allow switch drivers to override default slave PHY addresses Florian Fainelli
2020-03-31  9:09   ` (EXT) " Matthias Schiffer
2020-04-20  9:16     ` Matthias Schiffer

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).