Skip to contentSkip to conversation

Add reset deassertion for Aspeed MDIO

PATCH Superseded Dylan Hung 3 participants 8 messages Mar 21, 2022 – Mar 22, 2022

Subsystems (6)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Dylan Hung

author
#0 lore raw

cover 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(+)
Signature · 1 line
2.25.1
author
#1 lore raw

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.

Cc stable at vger.kernel.org
---
 drivers/net/mdio/mdio-aspeed.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/mdio/mdio-aspeed.c +8 -0
index e2273588c75b..8ac262a12d13 100644
@@ -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;
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 1/2] net: mdio: add reset deassertion for Aspeed MDIO

Hi Dylan,

Quoted 36 lines · Dylan Hung

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.

Cc stable at vger.kernel.org

---
?drivers/net/mdio/mdio-aspeed.c | 8 ++++++++
?1 file changed, 8 insertions(+)

drivers/net/mdio/mdio- renamed from drivers/net/mdio/mdio-aspeed.c +0 -0

aspeed.c
index e2273588c75b..8ac262a12d13 100644

drivers/net/mdio/mdio-aspeed.c +0 -0
@@ -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>

drivers/net/mdio/mdio-aspeed.c +0 -0
@@ -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)

drivers/net/mdio/mdio-aspeed.c +0 -0
@@ -120,6 +122,12 @@ static int aspeed_mdio_probe(struct
 platform_device *pdev)
 ????????if (IS_ERR(ctx->base))
 ????????????????return PTR_ERR(ctx->base);
Quoted 2 lines

?
+???????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.

drivers/net/mdio/mdio-aspeed.c static int aspeed_mdio_probe(struct platform_device *pdev) · line 130

Quoted 5 lines

+???????if (IS_ERR(ctx->reset))
+???????????????return PTR_ERR(ctx->reset);

drivers/net/mdio/mdio-aspeed.c +3 -0
+
+???????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

author
#3 lore raw

RE: [PATCH 1/2] net: mdio: add reset deassertion for Aspeed MDIO

Quoted 51 lines

-----Original Message-----
From: Philipp Zabel [mailto:p.zabel at pengutronix.de]
Sent: 2022?3?21? 4:15 PM
To: Dylan Hung <[email protected]>; robh+dt at kernel.org; joel at jms.id.au; andrew at aj.id.au; andrew at lunn.ch; hkallweit1 at gmail.com; linux at armlinux.org.uk; davem at davemloft.net; kuba at kernel.org; pabeni at redhat.com; devicetree at vger.kernel.org;
linux-arm-kernel at lists.infradead.org; linux-aspeed at lists.ozlabs.org; linux-kernel at vger.kernel.org; netdev at vger.kernel.org
Cc: BMC-SW <[email protected]>; stable at vger.kernel.org
Subject: Re: [PATCH 1/2] net: mdio: add reset deassertion for Aspeed MDIO

Hi Dylan,

Quoted 36 lines · Dylan Hung

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.

Cc stable at vger.kernel.org

---
?drivers/net/mdio/mdio-aspeed.c | 8 ++++++++
?1 file changed, 8 insertions(+)

drivers/net/mdio/mdio- renamed from drivers/net/mdio/mdio-aspeed.c +0 -0

aspeed.c index e2273588c75b..8ac262a12d13 100644

drivers/net/mdio/mdio-aspeed.c +0 -0
@@ -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>

drivers/net/mdio/mdio-aspeed.c +1 -0
@@ -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)

drivers/net/mdio/mdio-aspeed.c +0 -0
@@ -120,6 +122,12 @@ static int aspeed_mdio_probe(struct
 platform_device *pdev)
 ????????if (IS_ERR(ctx->base))
 ????????????????return PTR_ERR(ctx->base);
 
Quoted 5 lines

drivers/net/mdio/mdio-aspeed.c static int aspeed_mdio_probe(struct · line 126

Quoted 1 line
drivers/net/mdio/mdio-aspeed.c +1 -0
+???????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.

Quoted 10 lines

drivers/net/mdio/mdio-aspeed.c static int aspeed_mdio_probe(struct · line 131

Quoted 5 lines
drivers/net/mdio/mdio-aspeed.c +5 -0
+???????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.

Quoted 3 lines

regards
Philipp

--
Dylan

author
#4 lore raw

PATCH 2/2 ARM: dts: aspeed: add reset properties into MDIO nodes

In reply to Dylan Hung

Add reset control properties into MDIO nodes. The 4 MDIO controllers in AST2600 SOC share one reset control bit SCU50[3].

Cc stable at vger.kernel.org
---
 arch/arm/boot/dts/aspeed-g6.dtsi | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/aspeed-g6.dtsi +4 -0
index c32e87fad4dc..ab20ea8d829d 100644
@@ -181,6 +181,7 @@ mdio0: mdio at 1e650000 {
 			status = "disabled";
 			pinctrl-names = "default";
 			pinctrl-0 = <&pinctrl_mdio1_default>;
+			resets = <&syscon ASPEED_RESET_MII>;
 		};
 
 		mdio1: mdio at 1e650008 {
@@ -191,6 +192,7 @@ mdio1: mdio at 1e650008 {
 			status = "disabled";
 			pinctrl-names = "default";
 			pinctrl-0 = <&pinctrl_mdio2_default>;
+			resets = <&syscon ASPEED_RESET_MII>;
 		};
 
 		mdio2: mdio at 1e650010 {
@@ -201,6 +203,7 @@ mdio2: mdio at 1e650010 {
 			status = "disabled";
 			pinctrl-names = "default";
 			pinctrl-0 = <&pinctrl_mdio3_default>;
+			resets = <&syscon ASPEED_RESET_MII>;
 		};
 
 		mdio3: mdio at 1e650018 {
@@ -211,6 +214,7 @@ mdio3: mdio at 1e650018 {
 			status = "disabled";
 			pinctrl-names = "default";
 			pinctrl-0 = <&pinctrl_mdio4_default>;
+			resets = <&syscon ASPEED_RESET_MII>;
 		};
 
 		mac0: ftgmac at 1e660000 {
Signature · 1 line
2.25.1
maintainer
#5 lore raw
In reply to Dylan Hung
Quoted 2 lines · Dylan Hung

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

author
#6 lore raw

Hi Andrew,

Quoted 12 lines

-----Original Message-----
From: Andrew Lunn [mailto:andrew at lunn.ch]
Sent: 2022?3?21? 8:11 PM
To: Dylan Hung <[email protected]>
Cc: robh+dt at kernel.org; joel at jms.id.au; andrew at aj.id.au; hkallweit1 at gmail.com; linux at armlinux.org.uk; davem at davemloft.net; kuba at kernel.org; pabeni at redhat.com; p.zabel at pengutronix.de; devicetree at vger.kernel.org; linux-arm-kernel at lists.infradead.org; linux-aspeed at lists.ozlabs.org; linux-kernel at vger.kernel.org; netdev at vger.kernel.org; BMC-SW <[email protected]>
Subject: Re: [PATCH 0/2] Add reset deassertion for Aspeed MDIO

Quoted 6 lines
Quoted 2 lines · Dylan Hung

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.

Quoted 2 lines

Who asserts the reset in the first place?

The hardware asserts the reset by default.

Quoted 3 lines

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?

Quoted 2 lines

Andrew

--
Dylan

maintainer
#7 lore raw
Quoted 2 lines

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