[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221108082330.2086671-2-lukma@denx.de>
Date: Tue, 8 Nov 2022 09:23:22 +0100
From: Lukasz Majewski <lukma@...x.de>
To: Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...il.com>
Cc: Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <olteanv@...il.com>,
"David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
Matthias Schiffer <matthias.schiffer@...tq-group.com>,
Lukasz Majewski <lukma@...x.de>
Subject: [PATCH 1/9] net: dsa: allow switch drivers to override default slave PHY addresses
From: Matthias Schiffer <matthias.schiffer@...tq-group.com>
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@...tq-group.com>
Signed-off-by: Lukasz Majewski <lukma@...x.de>
[Adjustments for newest kernel upstreaming]
---
include/net/dsa.h | 1 +
net/dsa/slave.c | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index ee369670e20e..210b0e215ac9 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -858,6 +858,7 @@ struct dsa_switch_ops {
int (*port_setup)(struct dsa_switch *ds, int port);
void (*port_teardown)(struct dsa_switch *ds, int port);
+ 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 a9fde48cffd4..8bb1e8770846 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -2273,7 +2273,7 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)
struct device_node *port_dn = dp->dn;
struct dsa_switch *ds = dp->ds;
u32 phy_flags = 0;
- int ret;
+ int ret, addr;
dp->pl_config.dev = &slave_dev->dev;
dp->pl_config.type = PHYLINK_NETDEV;
@@ -2299,7 +2299,12 @@ 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, phy_flags);
+ 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, phy_flags);
}
if (ret) {
netdev_err(slave_dev, "failed to connect to PHY: %pe\n",
--
2.37.2
Powered by blists - more mailing lists