diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2009-12-08 10:29:27 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2009-12-08 10:29:27 +0000 |
commit | 18867965f79a4dc13db50cdc529c102373da64a8 (patch) | |
tree | 1d3d6f37ea72c8c2eac475a7536614f4f5cfba10 /target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c | |
parent | 0e79007faf77c93d1ac7c3eba19c09df025e9528 (diff) | |
download | upstream-18867965f79a4dc13db50cdc529c102373da64a8.tar.gz upstream-18867965f79a4dc13db50cdc529c102373da64a8.tar.bz2 upstream-18867965f79a4dc13db50cdc529c102373da64a8.zip |
ar71xx: add support for external mii_bus
SVN-Revision: 18692
Diffstat (limited to 'target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c')
-rw-r--r-- | target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c index 176eddaaff..0db0a4bf78 100644 --- a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c +++ b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c @@ -262,10 +262,52 @@ static int ag71xx_phy_connect_multi(struct ag71xx *ag) return ret; } +static int dev_is_class(struct device *dev, void *class) +{ + if (dev->class != NULL && !strcmp(dev->class->name, class)) + return 1; + + return 0; +} + +static struct device *dev_find_class(struct device *parent, char *class) +{ + if (dev_is_class(parent, class)) { + get_device(parent); + return parent; + } + + return device_find_child(parent, class, dev_is_class); +} + +static struct mii_bus *dev_to_mii_bus(struct device *dev) +{ + struct device *d; + + d = dev_find_class(dev, "mdio_bus"); + if (d != NULL) { + struct mii_bus *bus; + + bus = to_mii_bus(d); + put_device(d); + + return bus; + } + + return NULL; +} + int ag71xx_phy_connect(struct ag71xx *ag) { struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag); + ag->mii_bus = dev_to_mii_bus(pdata->mii_bus_dev); + if (ag->mii_bus == NULL) { + printk(KERN_ERR "%s: unable to find MII bus on device '%s'\n", + ag->dev->name, dev_name(pdata->mii_bus_dev)); + return -ENODEV; + } + if (pdata->phy_mask) return ag71xx_phy_connect_multi(ag); |