ar71xx: merge ag71xx specific patches
[openwrt.git] / target / linux / ar71xx / files / drivers / net / ag71xx / ag71xx_phy.c
index 6fe4d40..547f72e 100644 (file)
@@ -72,8 +72,12 @@ static void ag71xx_phy_link_update(struct ag71xx *ag)
                return;
        }
 
                return;
        }
 
-       ag71xx_wr(ag, AG71XX_REG_FIFO_CFG3,
-                       pdata->is_ar91xx ? 0x780fff : 0x008001ff);
+       if (pdata->is_ar91xx)
+               ag71xx_wr(ag, AG71XX_REG_FIFO_CFG3, 0x00780fff);
+       else if (pdata->is_ar724x)
+               ag71xx_wr(ag, AG71XX_REG_FIFO_CFG3, pdata->fifo_cfg3);
+       else
+               ag71xx_wr(ag, AG71XX_REG_FIFO_CFG3, 0x008001ff);
 
        if (pdata->set_pll)
                pdata->set_pll(ag->speed);
 
        if (pdata->set_pll)
                pdata->set_pll(ag->speed);
@@ -258,10 +262,57 @@ static int ag71xx_phy_connect_multi(struct ag71xx *ag)
        return ret;
 }
 
        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);
 
 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;
+       }
+
+       /* Reset the mdio bus explicitly */
+       mutex_lock(&ag->mii_bus->mdio_lock);
+       ag->mii_bus->reset(ag->mii_bus);
+       mutex_unlock(&ag->mii_bus->mdio_lock);
+
        if (pdata->phy_mask)
                return ag71xx_phy_connect_multi(ag);
 
        if (pdata->phy_mask)
                return ag71xx_phy_connect_multi(ag);
 
This page took 0.025226 seconds and 4 git commands to generate.