Skip to content

Commit 6819563

Browse files
ffainellidavem330
authored andcommitted
net: dsa: allow switch drivers to specify phy_device::dev_flags
Some switch drivers (e.g: bcm_sf2) may have to communicate specific workarounds or flags towards the PHY device driver. Allow switches driver to be delegated that task by introducing a get_phy_flags() callback which will do just that. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 487320c commit 6819563

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎include/net/dsa.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ struct dsa_switch_driver {
181181
char *(*probe)(struct device *host_dev, int sw_addr);
182182
int (*setup)(struct dsa_switch *ds);
183183
int (*set_addr)(struct dsa_switch *ds, u8 *addr);
184+
u32 (*get_phy_flags)(struct dsa_switch *ds, int port);
184185

185186
/*
186187
* Access to the switch's PHY registers.

‎net/dsa/slave.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,
371371
struct dsa_chip_data *cd = ds->pd;
372372
struct device_node *phy_dn, *port_dn;
373373
bool phy_is_fixed = false;
374+
u32 phy_flags = 0;
374375
int ret;
375376

376377
port_dn = cd->port_dn[p->port];
@@ -390,9 +391,12 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,
390391
phy_dn = port_dn;
391392
}
392393

394+
if (ds->drv->get_phy_flags)
395+
phy_flags = ds->drv->get_phy_flags(ds, p->port);
396+
393397
if (phy_dn)
394398
p->phy = of_phy_connect(slave_dev, phy_dn,
395-
dsa_slave_adjust_link, 0,
399+
dsa_slave_adjust_link, phy_flags,
396400
p->phy_interface);
397401

398402
if (p->phy && phy_is_fixed)
@@ -480,6 +484,9 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,
480484
netif_carrier_off(slave_dev);
481485

482486
if (p->phy != NULL) {
487+
if (ds->drv->get_phy_flags(ds, port))
488+
p->phy->dev_flags |= ds->drv->get_phy_flags(ds, port);
489+
483490
phy_attach(slave_dev, dev_name(&p->phy->dev),
484491
PHY_INTERFACE_MODE_GMII);
485492

0 commit comments

Comments
 (0)