Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12358177 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'mdio-devices'



Andrew Lunn says:

====================
Support MDIO devices

The discussions about changing the way DSA probes switches resulted in
the wish to have switches attached to an MDIO bus to be represented as
an MDIO device. However the current code only supports PHYs on MDIO
busses. This patchset remedies this problem. It consists of a number
of cleanups, abstraction for accessing structure members, and
refactoring, as well as adding the concept of a generic MDIO device
and MDIO driver.

v2:
Added Reviewed-by from Florian
Made phydev_name() an inline function
Added phy_attached_info/phy_attached_print() for information about
the attached phy.
Removed now redundant irq setup from of_mdio.c
Dropped hunks from PHYMII ioctl which prevented access to any address
DSA carrier off before phy setup
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 9e0efaf6 711fdba3
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -131,23 +131,15 @@ static int ep8248e_mdio_probe(struct platform_device *ofdev)
	if (!bus)
		return -ENOMEM;

	bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
	if (bus->irq == NULL) {
		ret = -ENOMEM;
		goto err_free_bus;
	}

	bus->name = "ep8248e-mdio-bitbang";
	bus->parent = &ofdev->dev;
	snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start);

	ret = of_mdiobus_register(bus, ofdev->dev.of_node);
	if (ret)
		goto err_free_irq;
		goto err_free_bus;

	return 0;
err_free_irq:
	kfree(bus->irq);
err_free_bus:
	free_mdio_bitbang(bus);
	return ret;
+0 −3
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ static void __iomem *gpio_regs;
struct gpio_priv {
	int mdc_pin;
	int mdio_pin;
	int mdio_irqs[PHY_MAX_ADDR];
};

#define MDC_PIN(bus)	(((struct gpio_priv *)bus->priv)->mdc_pin)
@@ -245,8 +244,6 @@ static int gpio_mdio_probe(struct platform_device *ofdev)
	snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", *prop);
	new_bus->priv = priv;

	new_bus->irq = priv->mdio_irqs;

	prop = of_get_property(np, "mdc-pin", NULL);
	priv->mdc_pin = *prop;

+3 −14
Original line number Diff line number Diff line
@@ -372,7 +372,7 @@ static int ax_mii_probe(struct net_device *dev)
	ax->phy_dev = phy_dev;

	netdev_info(dev, "PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
		    phy_dev->drv->name, dev_name(&phy_dev->dev), phy_dev->irq);
		    phy_dev->drv->name, phydev_name(phy_dev), phy_dev->irq);

	return 0;
}
@@ -627,7 +627,7 @@ static int ax_mii_init(struct net_device *dev)
	struct platform_device *pdev = to_platform_device(dev->dev.parent);
	struct ei_device *ei_local = netdev_priv(dev);
	struct ax_device *ax = to_ax_dev(dev);
	int err, i;
	int err;

	ax->bb_ctrl.ops = &bb_ops;
	ax->addr_memr = ei_local->mem + AX_MEMR;
@@ -642,23 +642,12 @@ static int ax_mii_init(struct net_device *dev)
	snprintf(ax->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
		pdev->name, pdev->id);

	ax->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
	if (!ax->mii_bus->irq) {
		err = -ENOMEM;
		goto out_free_mdio_bitbang;
	}

	for (i = 0; i < PHY_MAX_ADDR; i++)
		ax->mii_bus->irq[i] = PHY_POLL;

	err = mdiobus_register(ax->mii_bus);
	if (err)
		goto out_free_irq;
		goto out_free_mdio_bitbang;

	return 0;

 out_free_irq:
	kfree(ax->mii_bus->irq);
 out_free_mdio_bitbang:
	free_mdio_bitbang(ax->mii_bus);
 out:
+4 −15
Original line number Diff line number Diff line
@@ -419,7 +419,7 @@ static int mii_probe(struct net_device *dev, int phy_mode)
		return -EINVAL;
	}

	phydev = phy_connect(dev, dev_name(&phydev->dev),
	phydev = phy_connect(dev, phydev_name(phydev),
			     &bfin_mac_adjust_link, phy_mode);

	if (IS_ERR(phydev)) {
@@ -444,9 +444,7 @@ static int mii_probe(struct net_device *dev, int phy_mode)
	lp->old_duplex = -1;
	lp->phydev = phydev;

	pr_info("attached PHY driver [%s] "
	        "(mii_bus:phy_addr=%s, irq=%d, mdc_clk=%dHz(mdc_div=%d)@sclk=%dMHz)\n",
	        phydev->drv->name, dev_name(&phydev->dev), phydev->irq,
	phy_attached_print(phydev, "mdc_clk=%dHz(mdc_div=%d)@sclk=%dMHz)\n",
			   MDC_CLK, mdc_div, sclk / 1000000);

	return 0;
@@ -1840,12 +1838,6 @@ static int bfin_mii_bus_probe(struct platform_device *pdev)

	snprintf(miibus->id, MII_BUS_ID_SIZE, "%s-%x",
		pdev->name, pdev->id);
	miibus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
	if (!miibus->irq)
		goto out_err_irq_alloc;

	for (i = rc; i < PHY_MAX_ADDR; ++i)
		miibus->irq[i] = PHY_POLL;

	rc = clamp(mii_bus_pd->phydev_number, 0, PHY_MAX_ADDR);
	if (rc != mii_bus_pd->phydev_number)
@@ -1864,14 +1856,12 @@ static int bfin_mii_bus_probe(struct platform_device *pdev)
	rc = mdiobus_register(miibus);
	if (rc) {
		dev_err(&pdev->dev, "Cannot register MDIO bus!\n");
		goto out_err_mdiobus_register;
		goto out_err_alloc;
	}

	platform_set_drvdata(pdev, miibus);
	return 0;

out_err_mdiobus_register:
	kfree(miibus->irq);
out_err_irq_alloc:
	mdiobus_free(miibus);
out_err_alloc:
@@ -1887,7 +1877,6 @@ static int bfin_mii_bus_remove(struct platform_device *pdev)
		dev_get_platdata(&pdev->dev);

	mdiobus_unregister(miibus);
	kfree(miibus->irq);
	mdiobus_free(miibus);
	peripheral_free_list(mii_bus_pd->mac_peripherals);

+0 −5
Original line number Diff line number Diff line
@@ -1337,11 +1337,6 @@ static int greth_mdio_init(struct greth_private *greth)
	greth->mdio->write = greth_mdio_write;
	greth->mdio->priv = greth;

	greth->mdio->irq = greth->mdio_irqs;

	for (phy = 0; phy < PHY_MAX_ADDR; phy++)
		greth->mdio->irq[phy] = PHY_POLL;

	ret = mdiobus_register(greth->mdio);
	if (ret) {
		goto error;
Loading