Commit 15853622 authored by Dylan Hung's avatar Dylan Hung Committed by Paolo Abeni

net: mdio: add reset control for Aspeed MDIO

Add reset assertion/deassertion for Aspeed MDIO.  There are 4 MDIO
controllers embedded in Aspeed AST2600 SOC and share one reset control
register SCU50[3].  To work with old DT blobs which don't have the reset
property, devm_reset_control_get_optional_shared is used in this change.
Signed-off-by: default avatarDylan Hung <dylan_hung@aspeedtech.com>
Reviewed-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarAndrew Jeffery <andrew@aj.id.au>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 65e42ad9
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <linux/bitfield.h> #include <linux/bitfield.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/reset.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/mdio.h> #include <linux/mdio.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -41,6 +42,7 @@ ...@@ -41,6 +42,7 @@
struct aspeed_mdio { struct aspeed_mdio {
void __iomem *base; void __iomem *base;
struct reset_control *reset;
}; };
static int aspeed_mdio_op(struct mii_bus *bus, u8 st, u8 op, u8 phyad, u8 regad, static int aspeed_mdio_op(struct mii_bus *bus, u8 st, u8 op, u8 phyad, u8 regad,
...@@ -174,6 +176,12 @@ static int aspeed_mdio_probe(struct platform_device *pdev) ...@@ -174,6 +176,12 @@ static int aspeed_mdio_probe(struct platform_device *pdev)
if (IS_ERR(ctx->base)) if (IS_ERR(ctx->base))
return PTR_ERR(ctx->base); return PTR_ERR(ctx->base);
ctx->reset = devm_reset_control_get_optional_shared(&pdev->dev, NULL);
if (IS_ERR(ctx->reset))
return PTR_ERR(ctx->reset);
reset_control_deassert(ctx->reset);
bus->name = DRV_NAME; bus->name = DRV_NAME;
snprintf(bus->id, MII_BUS_ID_SIZE, "%s%d", pdev->name, pdev->id); snprintf(bus->id, MII_BUS_ID_SIZE, "%s%d", pdev->name, pdev->id);
bus->parent = &pdev->dev; bus->parent = &pdev->dev;
...@@ -184,6 +192,7 @@ static int aspeed_mdio_probe(struct platform_device *pdev) ...@@ -184,6 +192,7 @@ static int aspeed_mdio_probe(struct platform_device *pdev)
rc = of_mdiobus_register(bus, pdev->dev.of_node); rc = of_mdiobus_register(bus, pdev->dev.of_node);
if (rc) { if (rc) {
dev_err(&pdev->dev, "Cannot register MDIO bus!\n"); dev_err(&pdev->dev, "Cannot register MDIO bus!\n");
reset_control_assert(ctx->reset);
return rc; return rc;
} }
...@@ -194,7 +203,11 @@ static int aspeed_mdio_probe(struct platform_device *pdev) ...@@ -194,7 +203,11 @@ static int aspeed_mdio_probe(struct platform_device *pdev)
static int aspeed_mdio_remove(struct platform_device *pdev) static int aspeed_mdio_remove(struct platform_device *pdev)
{ {
mdiobus_unregister(platform_get_drvdata(pdev)); struct mii_bus *bus = (struct mii_bus *)platform_get_drvdata(pdev);
struct aspeed_mdio *ctx = bus->priv;
reset_control_assert(ctx->reset);
mdiobus_unregister(bus);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment