2022-03-21 16:24:30

by Dylan Hung

[permalink] [raw]
Subject: [PATCH 0/2] Add reset deassertion for Aspeed MDIO

Add missing reset deassertion for Aspeed MDIO. There are 4 MDIOs
embedded in Aspeed AST2600 and share one reset control bit SCU50[3].

Dylan Hung (2):
net: mdio: add reset deassertion for Aspeed MDIO
ARM: dts: aspeed: add reset properties into MDIO nodes

arch/arm/boot/dts/aspeed-g6.dtsi | 4 ++++
drivers/net/mdio/mdio-aspeed.c | 8 ++++++++
2 files changed, 12 insertions(+)

--
2.25.1


2022-03-21 18:21:30

by Dylan Hung

[permalink] [raw]
Subject: [PATCH 1/2] net: mdio: add reset deassertion for Aspeed MDIO

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 <[email protected]>
Cc: [email protected]
---
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;
--
2.25.1

2022-03-21 22:28:26

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH 0/2] Add reset deassertion for Aspeed MDIO

On Mon, Mar 21, 2022 at 03:01:29PM +0800, Dylan Hung wrote:
> Add missing reset deassertion for Aspeed MDIO. There are 4 MDIOs
> embedded in Aspeed AST2600 and share one reset control bit SCU50[3].

Is the reset limited to the MDIO bus masters, or are PHYs one the bus
potentially also reset?

Who asserts the reset in the first place? Don't you want the first
MDIO bus to probe to assert and then deassert the reset in order that
all the hardware is reset?

Andrew

2022-03-21 22:42:45

by Philipp Zabel

[permalink] [raw]
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 <[email protected]>
> Cc: [email protected]
> ---
>  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

2022-03-22 12:28:04

by Dylan Hung

[permalink] [raw]
Subject: RE: [PATCH 0/2] Add reset deassertion for Aspeed MDIO

Hi Andrew,

> -----Original Message-----
> From: Andrew Lunn [mailto:[email protected]]
> Sent: 2022?~3??21?? 8:11 PM
> To: Dylan Hung <[email protected]>
> Cc: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; BMC-SW <[email protected]>
> Subject: Re: [PATCH 0/2] Add reset deassertion for Aspeed MDIO
>
> On Mon, Mar 21, 2022 at 03:01:29PM +0800, Dylan Hung wrote:
> > Add missing reset deassertion for Aspeed MDIO. There are 4 MDIOs
> > embedded in Aspeed AST2600 and share one reset control bit SCU50[3].
>
> Is the reset limited to the MDIO bus masters, or are PHYs one the bus
> potentially also reset?

It is limited to the MDIO bus masters.

>
> Who asserts the reset in the first place?

The hardware asserts the reset by default.

> Don't you want the first MDIO bus to
> probe to assert and then deassert the reset in order that all the hardware is
> reset?

Do I still need to add a reset assertion/deassertion if the hardware asserts the reset by default?

>
> Andrew

--
Dylan

2022-03-24 20:48:52

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH 0/2] Add reset deassertion for Aspeed MDIO

> Do I still need to add a reset assertion/deassertion if the hardware
> asserts the reset by default?

One use case would be kexec when one kernel is used to boot another
kernel. But since this is shared by multiple busses, it is probably
not worth the complexity unless that is something you expect you
customers to do, e.g. during kernel development work.

Andrew