@@ -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);
/*
@@ -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",
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(-)