Skip to contentSkip to conversation

Add reset deassertion for Aspeed MDIO

PATCH Applied Dylan Hung 2 participants 5 messages Apr 27, 2022 – Apr 28, 2022

Subsystems (5)
lore
Share & tools
lore

Dylan Hung

author
#0 lore raw

v6 cover Add reset deassertion for Aspeed MDIO

Add missing reset deassertion for Aspeed MDIO bus controller. The reset is asserted by the hardware when power-on so the driver only needs to deassert it. To be able to work with the old DT blobs, the reset is optional since it may be deasserted by the bootloader or the previous kernel.

V6:
- fix merge conflict for net-next

V5:
- fix error of dt_binding_check

V4:
- use ASPEED_RESET_MII instead of hardcoding in dt-binding example

V3:
- remove reset property from the required list of the device tree bindings
- remove "Cc: stable at vger.kernel.org" from the commit messages
- add more description in the commit message of the dt-binding

V2:
- add reset property in the device tree bindings
- add reset assertion in the error path and driver remove

Dylan Hung (3):
dt-bindings: net: add reset property for aspeed, ast2600-mdio binding
net: mdio: add reset control for Aspeed MDIO
ARM: dts: aspeed: add reset properties into MDIO nodes

 .../bindings/net/aspeed,ast2600-mdio.yaml         |  6 ++++++
 arch/arm/boot/dts/aspeed-g6.dtsi                  |  4 ++++
 drivers/net/mdio/mdio-aspeed.c                    | 15 ++++++++++++++-
 3 files changed, 24 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v6 1/3 dt-bindings: net: add reset property for aspeed, ast2600-mdio binding

The AST2600 MDIO bus controller has a reset control bit and must be deasserted before manipulating the MDIO controller. By default, the hardware asserts the reset so the driver only need to deassert it.

Regarding to the old DT blobs which don't have reset property in them, the reset deassertion is usually done by the bootloader so the reset property is optional to work with them.

---
 .../devicetree/bindings/net/aspeed,ast2600-mdio.yaml        | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/net/aspeed,ast2600-mdio.yaml +6 -0
index 1c88820cbcdf..f81eda8cb0a5 100644
@@ -20,10 +20,14 @@ allOf:
 properties:
   compatible:
     const: aspeed,ast2600-mdio
+
   reg:
     maxItems: 1
     description: The register range of the MDIO controller instance
 
+  resets:
+    maxItems: 1
+
 required:
   - compatible
   - reg
@@ -34,11 +38,13 @@ unevaluatedProperties: false
 
 examples:
   - |
+    #include <dt-bindings/clock/ast2600-clock.h>
     mdio0: mdio at 1e650000 {
             compatible = "aspeed,ast2600-mdio";
             reg = <0x1e650000 0x8>;
             #address-cells = <1>;
             #size-cells = <0>;
+            resets = <&syscon ASPEED_RESET_MII>;
 
             ethphy0: ethernet-phy at 0 {
                     compatible = "ethernet-phy-ieee802.3-c22";
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH v6 2/3 net: mdio: add reset control for Aspeed MDIO

In reply to Dylan Hung

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.

---
 drivers/net/mdio/mdio-aspeed.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/net/mdio/mdio-aspeed.c +14 -1
index 7aa49827196f..944d005d2bd1 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>
@@ -41,6 +42,7 @@
 
 struct aspeed_mdio {
 	void __iomem *base;
+	struct reset_control *reset;
 };
 
 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)
 	if (IS_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;
 	snprintf(bus->id, MII_BUS_ID_SIZE, "%s%d", pdev->name, pdev->id);
 	bus->parent = &pdev->dev;
@@ -184,6 +192,7 @@ static int aspeed_mdio_probe(struct platform_device *pdev)
 	rc = of_mdiobus_register(bus, pdev->dev.of_node);
 	if (rc) {
 		dev_err(&pdev->dev, "Cannot register MDIO bus!\n");
+		reset_control_assert(ctx->reset);
 		return rc;
 	}
 
@@ -194,7 +203,11 @@ static int aspeed_mdio_probe(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;
 }
Signature · 1 line
2.25.1
author
#3 lore raw

PATCH v6 3/3 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].

---
 arch/arm/boot/dts/aspeed-g6.dtsi | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/aspeed-g6.dtsi +4 -0
index 3d5ce9da42c3..6aa1fd5c9359 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
#4 lore raw
In reply to Dylan Hung
This series was applied to netdev/net-next.git (master) by Paolo Abeni <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by Paolo Abeni <[email protected]>:

Quoted 10 lines · On Wed, 27 Apr 2022 11:54:58 +0800 you wrote:

Add missing reset deassertion for Aspeed MDIO bus controller. The reset is asserted by the hardware when power-on so the driver only needs to deassert it. To be able to work with the old DT blobs, the reset is optional since it may be deasserted by the bootloader or the previous kernel.

V6:
- fix merge conflict for net-next

[...]

Here is the summary with links:
- [net-next,v6,1/3] dt-bindings: net: add reset property for aspeed, ast2600-mdio binding

    https://git.kernel.org/netdev/net-next/c/65e42ad98e22
  - [net-next,v6,2/3] net: mdio: add reset control for Aspeed MDIO
    https://git.kernel.org/netdev/net-next/c/1585362250fe
  - [net-next,v6,3/3] ARM: dts: aspeed: add reset properties into MDIO nodes
    https://git.kernel.org/netdev/net-next/c/a8db203db05c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html