Skip to content

Commit

Permalink
net: dsa: allow switch drivers to specify phy_device::dev_flags
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Florian Fainelli authored and David S. Miller committed Sep 19, 2014
1 parent 487320c commit 6819563
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/net/dsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ struct dsa_switch_driver {
char *(*probe)(struct device *host_dev, int sw_addr);
int (*setup)(struct dsa_switch *ds);
int (*set_addr)(struct dsa_switch *ds, u8 *addr);
u32 (*get_phy_flags)(struct dsa_switch *ds, int port);

/*
* Access to the switch's PHY registers.
Expand Down
9 changes: 8 additions & 1 deletion net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,
struct dsa_chip_data *cd = ds->pd;
struct device_node *phy_dn, *port_dn;
bool phy_is_fixed = false;
u32 phy_flags = 0;
int ret;

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

if (ds->drv->get_phy_flags)
phy_flags = ds->drv->get_phy_flags(ds, p->port);

if (phy_dn)
p->phy = of_phy_connect(slave_dev, phy_dn,
dsa_slave_adjust_link, 0,
dsa_slave_adjust_link, phy_flags,
p->phy_interface);

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

if (p->phy != NULL) {
if (ds->drv->get_phy_flags(ds, port))
p->phy->dev_flags |= ds->drv->get_phy_flags(ds, port);

phy_attach(slave_dev, dev_name(&p->phy->dev),
PHY_INTERFACE_MODE_GMII);

Expand Down

0 comments on commit 6819563

Please sign in to comment.