Add reset deassertion for Aspeed MDIO. There are 4 MDIO controllers embedded in Aspeed AST2600 SOC and share one reset control register SCU50[3]. So devm_reset_control_get_shared is used in this change.
Signed-off-by: Dylan Hung dylan_hung@aspeedtech.com Cc: stable@vger.kernel.org --- drivers/net/mdio/mdio-aspeed.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/drivers/net/mdio/mdio-aspeed.c b/drivers/net/mdio/mdio-aspeed.c index e2273588c75b..8ac262a12d13 100644 --- a/drivers/net/mdio/mdio-aspeed.c +++ b/drivers/net/mdio/mdio-aspeed.c @@ -3,6 +3,7 @@
#include <linux/bitfield.h> #include <linux/delay.h> +#include <linux/reset.h> #include <linux/iopoll.h> #include <linux/mdio.h> #include <linux/module.h> @@ -37,6 +38,7 @@
struct aspeed_mdio { void __iomem *base; + struct reset_control *reset; };
static int aspeed_mdio_read(struct mii_bus *bus, int addr, int regnum) @@ -120,6 +122,12 @@ static int aspeed_mdio_probe(struct platform_device *pdev) if (IS_ERR(ctx->base)) return PTR_ERR(ctx->base);
+ ctx->reset = devm_reset_control_get_shared(&pdev->dev, NULL); + if (IS_ERR(ctx->reset)) + return PTR_ERR(ctx->reset); + + reset_control_deassert(ctx->reset); + bus->name = DRV_NAME; snprintf(bus->id, MII_BUS_ID_SIZE, "%s%d", pdev->name, pdev->id); bus->parent = &pdev->dev;
Hi Dylan,
On Mo, 2022-03-21 at 15:01 +0800, Dylan Hung wrote:
Add reset deassertion for Aspeed MDIO. There are 4 MDIO controllers embedded in Aspeed AST2600 SOC and share one reset control register SCU50[3]. So devm_reset_control_get_shared is used in this change.
Signed-off-by: Dylan Hung dylan_hung@aspeedtech.com Cc: stable@vger.kernel.org
drivers/net/mdio/mdio-aspeed.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/drivers/net/mdio/mdio-aspeed.c b/drivers/net/mdio/mdio- aspeed.c index e2273588c75b..8ac262a12d13 100644 --- a/drivers/net/mdio/mdio-aspeed.c +++ b/drivers/net/mdio/mdio-aspeed.c @@ -3,6 +3,7 @@ #include <linux/bitfield.h> #include <linux/delay.h> +#include <linux/reset.h> #include <linux/iopoll.h> #include <linux/mdio.h> #include <linux/module.h> @@ -37,6 +38,7 @@ struct aspeed_mdio { void __iomem *base; + struct reset_control *reset; }; static int aspeed_mdio_read(struct mii_bus *bus, int addr, int regnum) @@ -120,6 +122,12 @@ static int aspeed_mdio_probe(struct platform_device *pdev) if (IS_ERR(ctx->base)) return PTR_ERR(ctx->base); + ctx->reset = devm_reset_control_get_shared(&pdev->dev, NULL);
The device tree bindings should have a required reset control property documented before this is added.
+ if (IS_ERR(ctx->reset)) + return PTR_ERR(ctx->reset);
+ reset_control_deassert(ctx->reset);
This is missing a corresponding reset_control_assert() in aspeed_mdio_remove() and in the error path of of_mdiobus_register(). That would allow to assert the reset line again after all MDIO controllers are unbound.
regards Philipp
-----Original Message----- From: Philipp Zabel [mailto:p.zabel@pengutronix.de] Sent: 2022年3月21日 4:15 PM To: Dylan Hung dylan_hung@aspeedtech.com; robh+dt@kernel.org; joel@jms.id.au; andrew@aj.id.au; andrew@lunn.ch; hkallweit1@gmail.com; linux@armlinux.org.uk; davem@davemloft.net; kuba@kernel.org; pabeni@redhat.com; devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-aspeed@lists.ozlabs.org; linux-kernel@vger.kernel.org; netdev@vger.kernel.org Cc: BMC-SW BMC-SW@aspeedtech.com; stable@vger.kernel.org Subject: Re: [PATCH 1/2] net: mdio: add reset deassertion for Aspeed MDIO
Hi Dylan,
On Mo, 2022-03-21 at 15:01 +0800, Dylan Hung wrote:
Add reset deassertion for Aspeed MDIO. There are 4 MDIO controllers embedded in Aspeed AST2600 SOC and share one reset control register SCU50[3]. So devm_reset_control_get_shared is used in this change.
Signed-off-by: Dylan Hung dylan_hung@aspeedtech.com Cc: stable@vger.kernel.org
drivers/net/mdio/mdio-aspeed.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/drivers/net/mdio/mdio-aspeed.c b/drivers/net/mdio/mdio- aspeed.c index e2273588c75b..8ac262a12d13 100644 --- a/drivers/net/mdio/mdio-aspeed.c +++ b/drivers/net/mdio/mdio-aspeed.c @@ -3,6 +3,7 @@
#include <linux/bitfield.h> #include <linux/delay.h> +#include <linux/reset.h> #include <linux/iopoll.h> #include <linux/mdio.h> #include <linux/module.h> @@ -37,6 +38,7 @@
struct aspeed_mdio { void __iomem *base; + struct reset_control *reset; };
static int aspeed_mdio_read(struct mii_bus *bus, int addr, int regnum) @@ -120,6 +122,12 @@ static int aspeed_mdio_probe(struct platform_device *pdev) if (IS_ERR(ctx->base)) return PTR_ERR(ctx->base);
+ ctx->reset = devm_reset_control_get_shared(&pdev->dev, NULL);
The device tree bindings should have a required reset control property documented before this is added.
OK, I will add a commit for the document in V2.
+ if (IS_ERR(ctx->reset)) + return PTR_ERR(ctx->reset);
+ reset_control_deassert(ctx->reset);
This is missing a corresponding reset_control_assert() in aspeed_mdio_remove() and in the error path of of_mdiobus_register(). That would allow to assert the reset line again after all MDIO controllers are unbound.
Thank you for your comment. I will fix it in V2.
regards Philipp
-- Dylan
linux-stable-mirror@lists.linaro.org