net: mvmdio: allow up to three clocks to be specified for orion-mdio
Allow up to three clocks to be specified and enabled for the orion-mdio interface, which are required for this interface to be accessible on Armada 8k platforms. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
6d6a331f44
commit
96cb434238
@ -53,7 +53,7 @@
|
|||||||
struct orion_mdio_dev {
|
struct orion_mdio_dev {
|
||||||
struct mutex lock;
|
struct mutex lock;
|
||||||
void __iomem *regs;
|
void __iomem *regs;
|
||||||
struct clk *clk;
|
struct clk *clk[3];
|
||||||
/*
|
/*
|
||||||
* If we have access to the error interrupt pin (which is
|
* If we have access to the error interrupt pin (which is
|
||||||
* somewhat misnamed as it not only reflects internal errors
|
* somewhat misnamed as it not only reflects internal errors
|
||||||
@ -187,7 +187,7 @@ static int orion_mdio_probe(struct platform_device *pdev)
|
|||||||
struct resource *r;
|
struct resource *r;
|
||||||
struct mii_bus *bus;
|
struct mii_bus *bus;
|
||||||
struct orion_mdio_dev *dev;
|
struct orion_mdio_dev *dev;
|
||||||
int ret;
|
int i, ret;
|
||||||
|
|
||||||
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
@ -216,9 +216,12 @@ static int orion_mdio_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
init_waitqueue_head(&dev->smi_busy_wait);
|
init_waitqueue_head(&dev->smi_busy_wait);
|
||||||
|
|
||||||
dev->clk = devm_clk_get(&pdev->dev, NULL);
|
for (i = 0; i < ARRAY_SIZE(dev->clk); i++) {
|
||||||
if (!IS_ERR(dev->clk))
|
dev->clk[i] = of_clk_get(pdev->dev.of_node, i);
|
||||||
clk_prepare_enable(dev->clk);
|
if (IS_ERR(dev->clk[i]))
|
||||||
|
break;
|
||||||
|
clk_prepare_enable(dev->clk[i]);
|
||||||
|
}
|
||||||
|
|
||||||
dev->err_interrupt = platform_get_irq(pdev, 0);
|
dev->err_interrupt = platform_get_irq(pdev, 0);
|
||||||
if (dev->err_interrupt > 0 &&
|
if (dev->err_interrupt > 0 &&
|
||||||
@ -259,8 +262,14 @@ static int orion_mdio_probe(struct platform_device *pdev)
|
|||||||
out_mdio:
|
out_mdio:
|
||||||
if (dev->err_interrupt > 0)
|
if (dev->err_interrupt > 0)
|
||||||
writel(0, dev->regs + MVMDIO_ERR_INT_MASK);
|
writel(0, dev->regs + MVMDIO_ERR_INT_MASK);
|
||||||
if (!IS_ERR(dev->clk))
|
|
||||||
clk_disable_unprepare(dev->clk);
|
for (i = 0; i < ARRAY_SIZE(dev->clk); i++) {
|
||||||
|
if (IS_ERR(dev->clk[i]))
|
||||||
|
break;
|
||||||
|
clk_disable_unprepare(dev->clk[i]);
|
||||||
|
clk_put(dev->clk[i]);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,12 +277,18 @@ static int orion_mdio_remove(struct platform_device *pdev)
|
|||||||
{
|
{
|
||||||
struct mii_bus *bus = platform_get_drvdata(pdev);
|
struct mii_bus *bus = platform_get_drvdata(pdev);
|
||||||
struct orion_mdio_dev *dev = bus->priv;
|
struct orion_mdio_dev *dev = bus->priv;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (dev->err_interrupt > 0)
|
if (dev->err_interrupt > 0)
|
||||||
writel(0, dev->regs + MVMDIO_ERR_INT_MASK);
|
writel(0, dev->regs + MVMDIO_ERR_INT_MASK);
|
||||||
mdiobus_unregister(bus);
|
mdiobus_unregister(bus);
|
||||||
if (!IS_ERR(dev->clk))
|
|
||||||
clk_disable_unprepare(dev->clk);
|
for (i = 0; i < ARRAY_SIZE(dev->clk); i++) {
|
||||||
|
if (IS_ERR(dev->clk[i]))
|
||||||
|
break;
|
||||||
|
clk_disable_unprepare(dev->clk[i]);
|
||||||
|
clk_put(dev->clk[i]);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user