linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next v3 0/4] net: ftgmac100: Add SoC reset support for RMII mode
@ 2025-07-08  6:55 Jacky Chou
  2025-07-08  6:55 ` [net-next v3 1/4] dt-bindings: net: ftgmac100: Add resets property Jacky Chou
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Jacky Chou @ 2025-07-08  6:55 UTC (permalink / raw)
  To: netdev, devicetree, linux-kernel, linux-clk, linux-arm-kernel,
	linux-aspeed, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
	krzk+dt, conor+dt, joel, andrew, mturquette, sboyd, p.zabel,
	horms, jacob.e.keller, u.kleine-koenig, hkallweit1
  Cc: BMC-SW

This patch series adds support for an optional reset line to the
ftgmac100 ethernet controller, as used on Aspeed SoCs. On these SoCs,
the internal MAC reset is not sufficient to reset the RMII interface.
By providing a SoC-level reset via the device tree "resets" property,
the driver can properly reset both the MAC and RMII logic, ensuring
correct operation in RMII mode.

The series includes:
- Device tree binding update to document the new "resets" property.
- Addition of MAC1 and MAC2 reset definitions for AST2600.
- Device tree changes for AST2600 to use the new reset properties.
- Driver changes to assert/deassert the reset line as needed.

This improves reliability and initialization of the MAC in RMII mode
on Aspeed platforms.

Jacky Chou (4):
  dt-bindings: net: ftgmac100: Add resets property
  dt-bindings: clock: ast2600: Add reset definitions for MAC1 and MAC2
  ARM: dts: aspeed-g6: Add resets property for MAC controllers
  net: ftgmac100: Add optional reset control for RMII mode on Aspeed
    SoCs

 .../bindings/net/faraday,ftgmac100.yaml       | 23 +++++++++++++---
 arch/arm/boot/dts/aspeed/aspeed-g6.dtsi       |  4 +++
 drivers/net/ethernet/faraday/ftgmac100.c      | 26 +++++++++++++++++++
 include/dt-bindings/clock/ast2600-clock.h     |  2 ++
 4 files changed, 52 insertions(+), 3 deletions(-)

---
v3:
  - Fixed allOf in faraday,ftgmac100.yaml.
v2:
  - Added restriction on resets property in faraday,ftgmac100.yaml.
---

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [net-next v3 1/4] dt-bindings: net: ftgmac100: Add resets property
  2025-07-08  6:55 [net-next v3 0/4] net: ftgmac100: Add SoC reset support for RMII mode Jacky Chou
@ 2025-07-08  6:55 ` Jacky Chou
  2025-07-08  7:50   ` Krzysztof Kozlowski
  2025-07-08  6:55 ` [net-next v3 2/4] dt-bindings: clock: ast2600: Add reset definitions for MAC1 and MAC2 Jacky Chou
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Jacky Chou @ 2025-07-08  6:55 UTC (permalink / raw)
  To: netdev, devicetree, linux-kernel, linux-clk, linux-arm-kernel,
	linux-aspeed, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
	krzk+dt, conor+dt, joel, andrew, mturquette, sboyd, p.zabel,
	horms, jacob.e.keller, u.kleine-koenig, hkallweit1
  Cc: BMC-SW

Add optional resets property for Aspeed SoCs to reset the MAC and
RGMII/RMII.

Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
 .../bindings/net/faraday,ftgmac100.yaml       | 23 ++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml b/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml
index 55d6a8379025..a2e7d439074a 100644
--- a/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml
+++ b/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml
@@ -6,9 +6,6 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 
 title: Faraday Technology FTGMAC100 gigabit ethernet controller
 
-allOf:
-  - $ref: ethernet-controller.yaml#
-
 maintainers:
   - Po-Yu Chuang <ratbert@faraday-tech.com>
 
@@ -35,6 +32,11 @@ properties:
       - description: MAC IP clock
       - description: RMII RCLK gate for AST2500/2600
 
+  resets:
+    maxItems: 1
+    description:
+      Optional reset control for the MAC controller
+
   clock-names:
     minItems: 1
     items:
@@ -74,6 +76,21 @@ required:
   - reg
   - interrupts
 
+allOf:
+  - $ref: ethernet-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - aspeed,ast2600-mac
+    then:
+      properties:
+        resets: true
+    else:
+      properties:
+        resets: false
+
 unevaluatedProperties: false
 
 examples:
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [net-next v3 2/4] dt-bindings: clock: ast2600: Add reset definitions for MAC1 and MAC2
  2025-07-08  6:55 [net-next v3 0/4] net: ftgmac100: Add SoC reset support for RMII mode Jacky Chou
  2025-07-08  6:55 ` [net-next v3 1/4] dt-bindings: net: ftgmac100: Add resets property Jacky Chou
@ 2025-07-08  6:55 ` Jacky Chou
  2025-07-08  6:55 ` [net-next v3 3/4] ARM: dts: aspeed-g6: Add resets property for MAC controllers Jacky Chou
  2025-07-08  6:55 ` [net-next v3 4/4] net: ftgmac100: Add optional reset control for RMII mode on Aspeed SoCs Jacky Chou
  3 siblings, 0 replies; 7+ messages in thread
From: Jacky Chou @ 2025-07-08  6:55 UTC (permalink / raw)
  To: netdev, devicetree, linux-kernel, linux-clk, linux-arm-kernel,
	linux-aspeed, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
	krzk+dt, conor+dt, joel, andrew, mturquette, sboyd, p.zabel,
	horms, jacob.e.keller, u.kleine-koenig, hkallweit1
  Cc: BMC-SW, Conor Dooley

Add ASPEED_RESET_MAC1 and ASPEED_RESET_MAC2 reset definitions to
the ast2600-clock binding header. These are required for proper
reset control of the MAC1 and MAC2 ethernet controllers on the
AST2600 SoC.

Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Acked-by: Stephen Boyd <sboyd@kernel.org>
---
 include/dt-bindings/clock/ast2600-clock.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/dt-bindings/clock/ast2600-clock.h b/include/dt-bindings/clock/ast2600-clock.h
index 7ae96c7bd72f..f60fff261130 100644
--- a/include/dt-bindings/clock/ast2600-clock.h
+++ b/include/dt-bindings/clock/ast2600-clock.h
@@ -122,6 +122,8 @@
 #define ASPEED_RESET_PCIE_DEV_OEN	20
 #define ASPEED_RESET_PCIE_RC_O		19
 #define ASPEED_RESET_PCIE_RC_OEN	18
+#define ASPEED_RESET_MAC2		12
+#define ASPEED_RESET_MAC1		11
 #define ASPEED_RESET_PCI_DP		5
 #define ASPEED_RESET_HACE		4
 #define ASPEED_RESET_AHB		1
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [net-next v3 3/4] ARM: dts: aspeed-g6: Add resets property for MAC controllers
  2025-07-08  6:55 [net-next v3 0/4] net: ftgmac100: Add SoC reset support for RMII mode Jacky Chou
  2025-07-08  6:55 ` [net-next v3 1/4] dt-bindings: net: ftgmac100: Add resets property Jacky Chou
  2025-07-08  6:55 ` [net-next v3 2/4] dt-bindings: clock: ast2600: Add reset definitions for MAC1 and MAC2 Jacky Chou
@ 2025-07-08  6:55 ` Jacky Chou
  2025-07-08  6:55 ` [net-next v3 4/4] net: ftgmac100: Add optional reset control for RMII mode on Aspeed SoCs Jacky Chou
  3 siblings, 0 replies; 7+ messages in thread
From: Jacky Chou @ 2025-07-08  6:55 UTC (permalink / raw)
  To: netdev, devicetree, linux-kernel, linux-clk, linux-arm-kernel,
	linux-aspeed, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
	krzk+dt, conor+dt, joel, andrew, mturquette, sboyd, p.zabel,
	horms, jacob.e.keller, u.kleine-koenig, hkallweit1
  Cc: BMC-SW

Add the "resets" property to the MAC nodes in the AST2600 device tree,
using the appropriate ASPEED_RESET_MACx definitions.

Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
 arch/arm/boot/dts/aspeed/aspeed-g6.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/aspeed/aspeed-g6.dtsi b/arch/arm/boot/dts/aspeed/aspeed-g6.dtsi
index 8ed715bd53aa..f9fe89665e49 100644
--- a/arch/arm/boot/dts/aspeed/aspeed-g6.dtsi
+++ b/arch/arm/boot/dts/aspeed/aspeed-g6.dtsi
@@ -236,6 +236,7 @@ mac0: ethernet@1e660000 {
 			reg = <0x1e660000 0x180>;
 			interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>;
+			resets = <&syscon ASPEED_RESET_MAC1>;
 			status = "disabled";
 		};
 
@@ -244,6 +245,7 @@ mac1: ethernet@1e680000 {
 			reg = <0x1e680000 0x180>;
 			interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&syscon ASPEED_CLK_GATE_MAC2CLK>;
+			resets = <&syscon ASPEED_RESET_MAC2>;
 			status = "disabled";
 		};
 
@@ -252,6 +254,7 @@ mac2: ethernet@1e670000 {
 			reg = <0x1e670000 0x180>;
 			interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&syscon ASPEED_CLK_GATE_MAC3CLK>;
+			resets = <&syscon ASPEED_RESET_MAC3>;
 			status = "disabled";
 		};
 
@@ -260,6 +263,7 @@ mac3: ethernet@1e690000 {
 			reg = <0x1e690000 0x180>;
 			interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&syscon ASPEED_CLK_GATE_MAC4CLK>;
+			resets = <&syscon ASPEED_RESET_MAC4>;
 			status = "disabled";
 		};
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [net-next v3 4/4] net: ftgmac100: Add optional reset control for RMII mode on Aspeed SoCs
  2025-07-08  6:55 [net-next v3 0/4] net: ftgmac100: Add SoC reset support for RMII mode Jacky Chou
                   ` (2 preceding siblings ...)
  2025-07-08  6:55 ` [net-next v3 3/4] ARM: dts: aspeed-g6: Add resets property for MAC controllers Jacky Chou
@ 2025-07-08  6:55 ` Jacky Chou
  3 siblings, 0 replies; 7+ messages in thread
From: Jacky Chou @ 2025-07-08  6:55 UTC (permalink / raw)
  To: netdev, devicetree, linux-kernel, linux-clk, linux-arm-kernel,
	linux-aspeed, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
	krzk+dt, conor+dt, joel, andrew, mturquette, sboyd, p.zabel,
	horms, jacob.e.keller, u.kleine-koenig, hkallweit1
  Cc: BMC-SW

On Aspeed SoCs, the internal MAC reset is insufficient to fully reset the
RMII interface; only the SoC-level reset line can properly reset the RMII
logic. This patch adds support for an optional "resets" property in the
device tree, allowing the driver to assert and deassert the SoC reset line
when operating in RMII mode. This ensures the MAC and RMII interface are
correctly reset and initialized.

Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
 drivers/net/ethernet/faraday/ftgmac100.c | 26 ++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index a98d5af3f9e3..05b8e3743a79 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -9,6 +9,7 @@
 #define pr_fmt(fmt)	KBUILD_MODNAME ": " fmt
 
 #include <linux/clk.h>
+#include <linux/reset.h>
 #include <linux/dma-mapping.h>
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
@@ -101,6 +102,8 @@ struct ftgmac100 {
 
 	/* AST2500/AST2600 RMII ref clock gate */
 	struct clk *rclk;
+	/* Aspeed reset control */
+	struct reset_control *rst;
 
 	/* Link management */
 	int cur_speed;
@@ -148,6 +151,23 @@ static int ftgmac100_reset_and_config_mac(struct ftgmac100 *priv)
 {
 	u32 maccr = 0;
 
+	/* Aspeed RMII needs SCU reset to clear status */
+	if (priv->is_aspeed && priv->netdev->phydev->interface == PHY_INTERFACE_MODE_RMII) {
+		int err;
+
+		err = reset_control_assert(priv->rst);
+		if (err) {
+			dev_err(priv->dev, "Failed to reset mac (%d)\n", err);
+			return err;
+		}
+		usleep_range(10000, 20000);
+		err = reset_control_deassert(priv->rst);
+		if (err) {
+			dev_err(priv->dev, "Failed to deassert mac reset (%d)\n", err);
+			return err;
+		}
+	}
+
 	switch (priv->cur_speed) {
 	case SPEED_10:
 	case 0: /* no link */
@@ -1968,6 +1988,12 @@ static int ftgmac100_probe(struct platform_device *pdev)
 
 	}
 
+	priv->rst = devm_reset_control_get_optional_exclusive(priv->dev, NULL);
+	if (IS_ERR(priv->rst)) {
+		err = PTR_ERR(priv->rst);
+		goto err_phy_connect;
+	}
+
 	if (priv->is_aspeed) {
 		err = ftgmac100_setup_clk(priv);
 		if (err)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [net-next v3 1/4] dt-bindings: net: ftgmac100: Add resets property
  2025-07-08  6:55 ` [net-next v3 1/4] dt-bindings: net: ftgmac100: Add resets property Jacky Chou
@ 2025-07-08  7:50   ` Krzysztof Kozlowski
  2025-07-09  5:52     ` 回覆: " Jacky Chou
  0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2025-07-08  7:50 UTC (permalink / raw)
  To: Jacky Chou
  Cc: netdev, devicetree, linux-kernel, linux-clk, linux-arm-kernel,
	linux-aspeed, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
	krzk+dt, conor+dt, joel, andrew, mturquette, sboyd, p.zabel,
	horms, jacob.e.keller, u.kleine-koenig, hkallweit1, BMC-SW

On Tue, Jul 08, 2025 at 02:55:41PM +0800, Jacky Chou wrote:
> Add optional resets property for Aspeed SoCs to reset the MAC and

s/Aspeed SoCs/Aspeed AST2600 SoCs/

> RGMII/RMII.

... because ? It was missing? Incomplete? You changed hardware?

Make the commits useful, explain WHY you are doing, not repeating WHAT
you are doing. What is obvious from the diff. You already got this
feedback with other patches.

> 
> Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> ---
>  .../bindings/net/faraday,ftgmac100.yaml       | 23 ++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml b/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml
> index 55d6a8379025..a2e7d439074a 100644
> --- a/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml
> +++ b/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml
> @@ -6,9 +6,6 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
>  
>  title: Faraday Technology FTGMAC100 gigabit ethernet controller
>  
> -allOf:
> -  - $ref: ethernet-controller.yaml#
> -
>  maintainers:
>    - Po-Yu Chuang <ratbert@faraday-tech.com>
>  
> @@ -35,6 +32,11 @@ properties:
>        - description: MAC IP clock
>        - description: RMII RCLK gate for AST2500/2600
>  
> +  resets:
> +    maxItems: 1
> +    description:
> +      Optional reset control for the MAC controller

Drop description, redundant and obvious form the schema. It cannot be a
reset for anything else than MAC controller, because this is the MAC
controller. It cannot be "non optional" because schema says it is
optional.

Write concise and USEFUL descriptions/commit messages, not just
something to satisfy line/patch count.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 7+ messages in thread

* 回覆: [net-next v3 1/4] dt-bindings: net: ftgmac100: Add resets property
  2025-07-08  7:50   ` Krzysztof Kozlowski
@ 2025-07-09  5:52     ` Jacky Chou
  0 siblings, 0 replies; 7+ messages in thread
From: Jacky Chou @ 2025-07-09  5:52 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-aspeed@lists.ozlabs.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, joel@jms.id.au, andrew@codeconstruct.com.au,
	mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de,
	horms@kernel.org, jacob.e.keller@intel.com,
	u.kleine-koenig@baylibre.com, hkallweit1@gmail.com, BMC-SW

Hi Krzysztof

Thank you for your reply.

> > Add optional resets property for Aspeed SoCs to reset the MAC and
> 
> s/Aspeed SoCs/Aspeed AST2600 SoCs/
> 
> > RGMII/RMII.
> 
> ... because ? It was missing? Incomplete? You changed hardware?
> 
> Make the commits useful, explain WHY you are doing, not repeating WHAT
> you are doing. What is obvious from the diff. You already got this feedback with
> other patches.
> 

Agreed.
Got it. I will add more commit message to describe why we do that and
what we do.

> >
> > Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> > ---
> >  .../bindings/net/faraday,ftgmac100.yaml       | 23
> ++++++++++++++++---
> >  1 file changed, 20 insertions(+), 3 deletions(-)
> >
> > diff --git
> > a/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml
> > b/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml
> > index 55d6a8379025..a2e7d439074a 100644
> > --- a/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml
> > +++ b/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml
> > @@ -6,9 +6,6 @@ $schema:
> http://devicetree.org/meta-schemas/core.yaml#
> >
> >  title: Faraday Technology FTGMAC100 gigabit ethernet controller
> >
> > -allOf:
> > -  - $ref: ethernet-controller.yaml#
> > -
> >  maintainers:
> >    - Po-Yu Chuang <ratbert@faraday-tech.com>
> >
> > @@ -35,6 +32,11 @@ properties:
> >        - description: MAC IP clock
> >        - description: RMII RCLK gate for AST2500/2600
> >
> > +  resets:
> > +    maxItems: 1
> > +    description:
> > +      Optional reset control for the MAC controller
> 
> Drop description, redundant and obvious form the schema. It cannot be a reset
> for anything else than MAC controller, because this is the MAC controller. It
> cannot be "non optional" because schema says it is optional.
> 
> Write concise and USEFUL descriptions/commit messages, not just something
> to satisfy line/patch count.

Agreed.
I will adjust this part to meet schema.

Thanks,
Jacky


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-07-09  5:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-08  6:55 [net-next v3 0/4] net: ftgmac100: Add SoC reset support for RMII mode Jacky Chou
2025-07-08  6:55 ` [net-next v3 1/4] dt-bindings: net: ftgmac100: Add resets property Jacky Chou
2025-07-08  7:50   ` Krzysztof Kozlowski
2025-07-09  5:52     ` 回覆: " Jacky Chou
2025-07-08  6:55 ` [net-next v3 2/4] dt-bindings: clock: ast2600: Add reset definitions for MAC1 and MAC2 Jacky Chou
2025-07-08  6:55 ` [net-next v3 3/4] ARM: dts: aspeed-g6: Add resets property for MAC controllers Jacky Chou
2025-07-08  6:55 ` [net-next v3 4/4] net: ftgmac100: Add optional reset control for RMII mode on Aspeed SoCs Jacky Chou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).