Skip to contentSkip to conversation

ftgmac100: Support AST2600 RMII

PATCH Superseded Andrew Jeffery 4 participants 22 messages Sep 22, 2019 – Sep 26, 2019

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover ftgmac100: Support AST2600 RMII

Hello,

This series adds support for ungating RMII RCLK on the AST2600, enabling use of NCSI for the MACs.

The patches have not yet been sent upstream, but I intend to do so once we're through the 5.4 merge window to avoid some of them disappearing into the net-next void.

Please review!

Andrew

Andrew Jeffery (6):
dt-bindings: net: ftgmac100: Document AST2600 compatible
dt-bindings: net: ftgmac100: Describe clock properties
dt-bindings: clock: Add AST2600 RMII RCLK gate definitions
clk: ast2600: Add RMII RCLK gates for all four MACs
net: ftgmac100: Ungate RCLK for RMII on AST2600
ARM: dts: tacoma: Enable 50MHz RMII RCLK for NCSI

 .../devicetree/bindings/net/ftgmac100.txt     |  7 +++
 arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts   |  3 ++
 drivers/clk/clk-ast2600.c                     | 37 +++++++++++++++-
 drivers/net/ethernet/faraday/ftgmac100.c      | 43 ++++++++++++++++---
 include/dt-bindings/clock/ast2600-clock.h     |  5 +++
 5 files changed, 87 insertions(+), 8 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/6 dt-bindings: net: ftgmac100: Document AST2600 compatible

The AST2600 contains an FTGMAC100-compatible MAC, although it no-longer contains an MDIO controller.

---
 Documentation/devicetree/bindings/net/ftgmac100.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/net/ftgmac100.txt +1 -0
index 72e7aaf7242e..04cc0191b7dd 100644
@@ -9,6 +9,7 @@ Required properties:
 
      - "aspeed,ast2400-mac"
      - "aspeed,ast2500-mac"
+     - "aspeed,ast2600-mac"
 
 - reg: Address and length of the register set for the device
 - interrupts: Should contain ethernet controller interrupt
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/6 dt-bindings: net: ftgmac100: Describe clock properties

In reply to Andrew Jeffery

Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is in use.

---
 Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/net/ftgmac100.txt +6 -0
index 04cc0191b7dd..c443b0b84be5 100644
@@ -24,6 +24,12 @@ Optional properties:
 - no-hw-checksum: Used to disable HW checksum support. Here for backward
   compatibility as the driver now should have correct defaults based on
   the SoC.
+- clocks: In accordance with the generic clock bindings. Must describe the MAC
+  IP clock, and optionally an RMII RCLK gate for the AST2600.
+- clock-names:
+
+      - "MACCLK": The MAC IP clock
+      - "RCLK": Clock gate for the RMII RCLK
 
 Example:
 
Signature · 1 line
2.20.1
maintainer
#3 lore raw

Re: [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties

Quoted 14 lines · Andrew Jeffery

Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is in use.

---
 Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/net/ftgmac100.txt +0 -0
index 04cc0191b7dd..c443b0b84be5 100644

Documentation/devicetree/bindings/net/ftgmac100.txt Optional properties: · line 28

Quoted 5 lines
Documentation/devicetree/bindings/net/ftgmac100.txt +2 -0
@@ -24,6 +24,12 @@ Optional properties:
 - no-hw-checksum: Used to disable HW checksum support. Here for backward
   compatibility as the driver now should have correct defaults based on
   the SoC.
+- clocks: In accordance with the generic clock bindings. Must describe the MAC
+  IP clock, and optionally an RMII RCLK gate for the AST2600.

perhaps: "and optionally a RMII clock if RMII or NC-SI is used"

We should implement this for the ast2500 too.

Quoted 10 lines
Documentation/devicetree/bindings/net/ftgmac100.txt +4 -1
+- clock-names:
+
+      - "MACCLK": The MAC IP clock
+      - "RCLK": Clock gate for the RMII RCLK
 
 Example:
 
--

2.20.1

#4 lore raw

Re: [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties

Quoted 23 lines · Joel Stanley
Quoted 14 lines · Andrew Jeffery

Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is in use.

---
 Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/net/ftgmac100.txt +0 -0
index 04cc0191b7dd..c443b0b84be5 100644

Documentation/devicetree/bindings/net/ftgmac100.txt Optional properties: · line 28

Quoted 5 lines
Documentation/devicetree/bindings/net/ftgmac100.txt +2 -0
@@ -24,6 +24,12 @@ Optional properties:
 - no-hw-checksum: Used to disable HW checksum support. Here for backward
   compatibility as the driver now should have correct defaults based on
   the SoC.
+- clocks: In accordance with the generic clock bindings. Must describe the MAC
+  IP clock, and optionally an RMII RCLK gate for the AST2600.

perhaps: "and optionally a RMII clock if RMII or NC-SI is used"

Quoted 1 line

We should implement this for the ast2500 too.

Hmm, I didn't think to check because it has always worked, but I assume that's because u-boot was NCSI enabled and left the clocks ungated.

Will fix in a v2.

Thanks,

Andrew

maintainer
#5 lore raw

Re: [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties

Quoted 27 lines · Andrew Jeffery
Quoted 23 lines · Joel Stanley
Quoted 14 lines · Andrew Jeffery

Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is in use.

---
 Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/net/ftgmac100.txt +0 -0
index 04cc0191b7dd..c443b0b84be5 100644

Documentation/devicetree/bindings/net/ftgmac100.txt Optional properties: · line 28

Quoted 5 lines
Documentation/devicetree/bindings/net/ftgmac100.txt +2 -0
@@ -24,6 +24,12 @@ Optional properties:
 - no-hw-checksum: Used to disable HW checksum support. Here for backward
   compatibility as the driver now should have correct defaults based on
   the SoC.
+- clocks: In accordance with the generic clock bindings. Must describe the MAC
+  IP clock, and optionally an RMII RCLK gate for the AST2600.

perhaps: "and optionally a RMII clock if RMII or NC-SI is used"

Quoted 3 lines
Quoted 1 line

We should implement this for the ast2500 too.

Hmm, I didn't think to check because it has always worked, but I assume that's because u-boot was NCSI enabled and left the clocks ungated.

Yeah spot on. This is something we hit when doing bringup of the ast2500 NCSI, and we "fixed" it by having u-boot enable the clocks.

Quoted 2 lines

Will fix in a v2.

Cheers

Quoted 4 lines

Thanks,

Andrew

#6 lore raw

Re: [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties

In reply to Andrew Jeffery

On 9/22/19, 5:40 AM, "openbmc on behalf of Andrew Jeffery" <[email protected] on behalf of [email protected]> wrote:

Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is in use.

---
Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++ 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt b/Documentation/devicetree/bindings/net/ftgmac100.txt index 04cc0191b7dd..c443b0b84be5 100644
--- a/Documentation/devicetree/bindings/net/ftgmac100.txt
+++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
@@ -24,6 +24,12 @@ Optional properties:
- no-hw-checksum: Used to disable HW checksum support. Here for backward
compatibility as the driver now should have correct defaults based on
the SoC.
This is still used for IPV6 as hw checksum for IPV6 packets is still broken in ast2500

    +- clocks: In accordance with the generic clock bindings. Must describe the MAC
    +  IP clock, and optionally an RMII RCLK gate for the AST2600.
    +- clock-names:
    +
    +      - "MACCLK": The MAC IP clock
    +      - "RCLK": Clock gate for the RMII RCLK
     
     Example:
     
    -- 
    2.20.1
#7 lore raw

Re: [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties

Quoted 21 lines · Vijay Khemka

On 9/22/19, 5:40 AM, "openbmc on behalf of Andrew Jeffery" <[email protected] on behalf of [email protected]> wrote:

Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is in use.

---
Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++ 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt
b/Documentation/devicetree/bindings/net/ftgmac100.txt

    index 04cc0191b7dd..c443b0b84be5 100644
    --- a/Documentation/devicetree/bindings/net/ftgmac100.txt
    +++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
    @@ -24,6 +24,12 @@ Optional properties:
     - no-hw-checksum: Used to disable HW checksum support. Here for 
Quoted 6 lines

backward
compatibility as the driver now should have correct defaults
based on
the SoC.
This is still used for IPV6 as hw checksum for IPV6 packets is still broken in ast2500

I'm not removing it :) I think you've made the same mistake that I've made in the past and interpreted the '-' as a diff marker rather than the bullet marker in the text.

Andrew

#8 lore raw

Re: [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties

On 9/24/19, 9:19 PM, "Andrew Jeffery" <[email protected]> wrote:

On Tue, 24 Sep 2019, at 08:50, Vijay Khemka wrote:
>
>
> On 9/22/19, 5:40 AM, "openbmc on behalf of Andrew Jeffery" > <[email protected] on behalf of > [email protected]> wrote:
>
> Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is
> in use.
>
> Signed-off-by: Andrew Jeffery <[email protected]>
> ---
> Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt
> b/Documentation/devicetree/bindings/net/ftgmac100.txt
> index 04cc0191b7dd..c443b0b84be5 100644
> --- a/Documentation/devicetree/bindings/net/ftgmac100.txt
> +++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
> @@ -24,6 +24,12 @@ Optional properties:
> - no-hw-checksum: Used to disable HW checksum support. Here for
> backward
> compatibility as the driver now should have correct defaults
> based on
> the SoC.
> This is still used for IPV6 as hw checksum for IPV6 packets is still > broken in ast2500

I'm not removing it :) I think you've made the same mistake that I've made in the past and interpreted the '-' as a diff marker rather than the bullet marker in the text.

Ok, got it. Thanks for tips.

Andrew

#9 lore raw

PATCH 3/6 dt-bindings: clock: Add AST2600 RMII RCLK gate definitions

In reply to Andrew Jeffery

The AST2600 has an explicit gate for the RMII RCLK for each of the four MACs.

---
 include/dt-bindings/clock/ast2600-clock.h | 5 +++++
 1 file changed, 5 insertions(+)
include/dt-bindings/clock/ast2600-clock.h +5 -0
index 38074a5f7296..ac567fc84a87 100644
@@ -84,6 +84,11 @@
 #define ASPEED_CLK_MAC34		65
 #define ASPEED_CLK_USBPHY_40M		66
 
+#define ASPEED_CLK_GATE_MAC1RCLK	67
+#define ASPEED_CLK_GATE_MAC2RCLK	68
+#define ASPEED_CLK_GATE_MAC3RCLK	69
+#define ASPEED_CLK_GATE_MAC4RCLK	70
+
 /* Only list resets here that are not part of a gate */
 #define ASPEED_RESET_ADC		55
 #define ASPEED_RESET_JTAG_MASTER2	54
Signature · 1 line
2.20.1
maintainer
#10 lore raw

Re: [PATCH linux dev-5.3 3/6] dt-bindings: clock: Add AST2600 RMII RCLK gate definitions

Quoted 5 lines · Andrew Jeffery

The AST2600 has an explicit gate for the RMII RCLK for each of the four MACs.

Put this in the same patch as the clock driver changes when you respin.

Quoted 9 lines
---
 include/dt-bindings/clock/ast2600-clock.h | 5 +++++
 1 file changed, 5 insertions(+)
include/dt-bindings/clock/ast2600-clock.h +0 -0
index 38074a5f7296..ac567fc84a87 100644

include/dt-bindings/clock/ast2600-clock.h line 90

Quoted 7 lines
include/dt-bindings/clock/ast2600-clock.h +4 -0
@@ -84,6 +84,11 @@
 #define ASPEED_CLK_MAC34               65
 #define ASPEED_CLK_USBPHY_40M          66
 
+#define ASPEED_CLK_GATE_MAC1RCLK       67
+#define ASPEED_CLK_GATE_MAC2RCLK       68
+#define ASPEED_CLK_GATE_MAC3RCLK       69
+#define ASPEED_CLK_GATE_MAC4RCLK       70

Nit: You call them MACnCLK here, but rmmin_clk in is the gate name. Please pick one and use it in both places.

#11 lore raw

Re: [PATCH linux dev-5.3 3/6] dt-bindings: clock: Add AST2600 RMII RCLK gate definitions

Quoted 8 lines · Joel Stanley
Quoted 5 lines · Andrew Jeffery

The AST2600 has an explicit gate for the RMII RCLK for each of the four MACs.

Put this in the same patch as the clock driver changes when you respin.

I initially did what you suggested and checkpatch complained. It's explicitly documented that DT header changes should be separate in the dt-specific submitting-patches documentation.

Quoted 8 lines

include/dt-bindings/clock/ast2600-clock.h line 90

Quoted 5 lines
include/dt-bindings/clock/ast2600-clock.h +4 -0
+#define ASPEED_CLK_GATE_MAC1RCLK       67
+#define ASPEED_CLK_GATE_MAC2RCLK       68
+#define ASPEED_CLK_GATE_MAC3RCLK       69
+#define ASPEED_CLK_GATE_MAC4RCLK       70

Nit: You call them MACnCLK here, but rmmin_clk in is the gate name. Please pick one and use it in both places.

Ack

maintainer
#12 lore raw

Re: [PATCH linux dev-5.3 3/6] dt-bindings: clock: Add AST2600 RMII RCLK gate definitions

Quoted 6 lines · Andrew Jeffery
Quoted 2 lines · Joel Stanley
Quoted 1 line · Andrew Jeffery
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

The AST2600 has an explicit gate for the RMII RCLK for each of the four MACs.

Put this in the same patch as the clock driver changes when you respin.

I initially did what you suggested and checkpatch complained. It's explicitly documented that DT header changes should be separate in the dt-specific submitting-patches documentation.

That's silly. I would ignore that recommendation, but it's your call.

Quoted 11 lines
Quoted 9 lines

include/dt-bindings/clock/ast2600-clock.h line 90

Quoted 6 lines
include/dt-bindings/clock/ast2600-clock.h +4 -0
+#define ASPEED_CLK_GATE_MAC1RCLK       67
+#define ASPEED_CLK_GATE_MAC2RCLK       68
+#define ASPEED_CLK_GATE_MAC3RCLK       69
+#define ASPEED_CLK_GATE_MAC4RCLK       70

Nit: You call them MACnCLK here, but rmmin_clk in is the gate name. Please pick one and use it in both places.

Ack

#13 lore raw

Re: [PATCH linux dev-5.3 3/6] dt-bindings: clock: Add AST2600 RMII RCLK gate definitions

Quoted 10 lines · Joel Stanley
Quoted 9 lines · Andrew Jeffery
Quoted 5 lines · Joel Stanley
Quoted 4 lines · Andrew Jeffery

The AST2600 has an explicit gate for the RMII RCLK for each of the four MACs.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Put this in the same patch as the clock driver changes when you respin.

I initially did what you suggested and checkpatch complained. It's explicitly documented that DT header changes should be separate in the dt-specific submitting-patches documentation.

That's silly.

No arguments here :)

Quoted 1 line

I would ignore that recommendation, but it's your call.

Yeah, was conflicted but given it was all fairly explicitly requested I figured splitting it was likely the path of least resistance.

#14 lore raw

PATCH 4/6 clk: ast2600: Add RMII RCLK gates for all four MACs

In reply to Andrew Jeffery

RCLK is a fixed 50MHz clock derived from HPLL that is described by a single gate for each MAC.

---
 drivers/clk/clk-ast2600.c | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
drivers/clk/clk-ast2600.c +36 -1
index 1c1bb39bb04e..45531495391c 100644
@@ -15,7 +15,7 @@
 
 #include "clk-aspeed.h"
 
-#define ASPEED_G6_NUM_CLKS		67
+#define ASPEED_G6_NUM_CLKS		71
 
 #define ASPEED_G6_SILICON_REV		0x004
 
@@ -40,6 +40,9 @@
 
 #define ASPEED_G6_STRAP1		0x500
 
+#define ASPEED_MAC12_CLK_DLY		0x340
+#define ASPEED_MAC34_CLK_DLY		0x350
+
 /* Globally visible clocks */
 static DEFINE_SPINLOCK(aspeed_g6_clk_lock);
 
@@ -494,6 +497,22 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev)
 		return PTR_ERR(hw);
 	aspeed_g6_clk_data->hws[ASPEED_CLK_MAC12] = hw;
 
+	/* RMII1 50MHz (RCLK) output enable */
+	hw = clk_hw_register_gate(dev, "rmii1_rclk", "hpll", 0,
+			scu_g6_base + ASPEED_MAC12_CLK_DLY, 29, 0,
+			&aspeed_g6_clk_lock);
+	if (IS_ERR(hw))
+		return PTR_ERR(hw);
+	aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC1RCLK] = hw;
+
+	/* RMII2 50MHz (RCLK) output enable */
+	hw = clk_hw_register_gate(dev, "rmii2_rclk", "hpll", 0,
+			scu_g6_base + ASPEED_MAC12_CLK_DLY, 30, 0,
+			&aspeed_g6_clk_lock);
+	if (IS_ERR(hw))
+		return PTR_ERR(hw);
+	aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC2RCLK] = hw;
+
 	/* MAC3/4 AHB bus clock divider */
 	hw = clk_hw_register_divider_table(dev, "mac34", "hpll", 0,
 			scu_g6_base + 0x310, 24, 3, 0,
@@ -503,6 +522,22 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev)
 		return PTR_ERR(hw);
 	aspeed_g6_clk_data->hws[ASPEED_CLK_MAC34] = hw;
 
+	/* RMII3 50MHz (RCLK) output enable */
+	hw = clk_hw_register_gate(dev, "rmii3_rclk", "hpll", 0,
+			scu_g6_base + ASPEED_MAC34_CLK_DLY, 29, 0,
+			&aspeed_g6_clk_lock);
+	if (IS_ERR(hw))
+		return PTR_ERR(hw);
+	aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC3RCLK] = hw;
+
+	/* RMII4 50MHz (RCLK) output enable */
+	hw = clk_hw_register_gate(dev, "rmii4_rclk", "hpll", 0,
+			scu_g6_base + ASPEED_MAC34_CLK_DLY, 30, 0,
+			&aspeed_g6_clk_lock);
+	if (IS_ERR(hw))
+		return PTR_ERR(hw);
+	aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC4RCLK] = hw;
+
 	/* LPC Host (LHCLK) clock divider */
 	hw = clk_hw_register_divider_table(dev, "lhclk", "hpll", 0,
 			scu_g6_base + ASPEED_G6_CLK_SELECTION1, 20, 3, 0,
Signature · 1 line
2.20.1
maintainer
#15 lore raw

Re: [PATCH linux dev-5.3 4/6] clk: ast2600: Add RMII RCLK gates for all four MACs

Quoted 3 lines · Andrew Jeffery

RCLK is a fixed 50MHz clock derived from HPLL that is described by a single gate for each MAC.

This is true for the AST2500 as well (SCU48). For completeness, can we have a patch that enables that?

Quoted 29 lines
---
 drivers/clk/clk-ast2600.c | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
drivers/clk/clk-ast2600.c +4 -1
index 1c1bb39bb04e..45531495391c 100644
@@ -15,7 +15,7 @@
 
 #include "clk-aspeed.h"
 
-#define ASPEED_G6_NUM_CLKS             67
+#define ASPEED_G6_NUM_CLKS             71
 
 #define ASPEED_G6_SILICON_REV          0x004
 
@@ -40,6 +40,9 @@
 
 #define ASPEED_G6_STRAP1               0x500
 
+#define ASPEED_MAC12_CLK_DLY           0x340
+#define ASPEED_MAC34_CLK_DLY           0x350
+
 /* Globally visible clocks */
 static DEFINE_SPINLOCK(aspeed_g6_clk_lock);
 

drivers/clk/clk-ast2600.c static int aspeed_g6_clk_probe(struct platform_device *pdev) · line 503

Quoted 7 lines
drivers/clk/clk-ast2600.c +4 -0
@@ -494,6 +497,22 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev)
                return PTR_ERR(hw);
        aspeed_g6_clk_data->hws[ASPEED_CLK_MAC12] = hw;
 
+       /* RMII1 50MHz (RCLK) output enable */
+       hw = clk_hw_register_gate(dev, "rmii1_rclk", "hpll", 0,
+                       scu_g6_base + ASPEED_MAC12_CLK_DLY, 29, 0,
+                       &aspeed_g6_clk_lock);

We know that this is a 50MHz clock that comes from HPLL. We could describe that in the driver by creating a RCLK and then these four gates hang off of that parent.

This would only be for completeness and correctness, it doesn't bring any added functionality to the system.

Quoted 41 lines
drivers/clk/clk-ast2600.c +28 -1
+       if (IS_ERR(hw))
+               return PTR_ERR(hw);
+       aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC1RCLK] = hw;
+
+       /* RMII2 50MHz (RCLK) output enable */
+       hw = clk_hw_register_gate(dev, "rmii2_rclk", "hpll", 0,
+                       scu_g6_base + ASPEED_MAC12_CLK_DLY, 30, 0,
+                       &aspeed_g6_clk_lock);
+       if (IS_ERR(hw))
+               return PTR_ERR(hw);
+       aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC2RCLK] = hw;
+
        /* MAC3/4 AHB bus clock divider */
        hw = clk_hw_register_divider_table(dev, "mac34", "hpll", 0,
                        scu_g6_base + 0x310, 24, 3, 0,
@@ -503,6 +522,22 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev)
                return PTR_ERR(hw);
        aspeed_g6_clk_data->hws[ASPEED_CLK_MAC34] = hw;
 
+       /* RMII3 50MHz (RCLK) output enable */
+       hw = clk_hw_register_gate(dev, "rmii3_rclk", "hpll", 0,
+                       scu_g6_base + ASPEED_MAC34_CLK_DLY, 29, 0,
+                       &aspeed_g6_clk_lock);
+       if (IS_ERR(hw))
+               return PTR_ERR(hw);
+       aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC3RCLK] = hw;
+
+       /* RMII4 50MHz (RCLK) output enable */
+       hw = clk_hw_register_gate(dev, "rmii4_rclk", "hpll", 0,
+                       scu_g6_base + ASPEED_MAC34_CLK_DLY, 30, 0,
+                       &aspeed_g6_clk_lock);
+       if (IS_ERR(hw))
+               return PTR_ERR(hw);
+       aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC4RCLK] = hw;
+
        /* LPC Host (LHCLK) clock divider */
        hw = clk_hw_register_divider_table(dev, "lhclk", "hpll", 0,
                        scu_g6_base + ASPEED_G6_CLK_SELECTION1, 20, 3, 0,
--

2.20.1

#16 lore raw

PATCH 5/6 net: ftgmac100: Ungate RCLK for RMII on AST2600

In reply to Andrew Jeffery

The 50MHz RMII RCLK has to be enabled before the interface will function.

---
 drivers/net/ethernet/faraday/ftgmac100.c | 43 ++++++++++++++++++++----
 1 file changed, 36 insertions(+), 7 deletions(-)
drivers/net/ethernet/faraday/ftgmac100.c +36 -7
index 9b7af94a40bb..21a58aad1a19 100644
@@ -90,6 +90,9 @@ struct ftgmac100 {
 	struct mii_bus *mii_bus;
 	struct clk *clk;
 
+	/* 2600 RMII clock gate */
+	struct clk *rclk;
+
 	/* Link management */
 	int cur_speed;
 	int cur_duplex;
@@ -1718,11 +1721,27 @@ static void ftgmac100_ncsi_handler(struct ncsi_dev *nd)
 		   nd->link_up ? "up" : "down");
 }
 
-static void ftgmac100_setup_clk(struct ftgmac100 *priv)
+static int ftgmac100_setup_clk(struct ftgmac100 *priv)
 {
-	priv->clk = devm_clk_get(priv->dev, NULL);
-	if (IS_ERR(priv->clk))
-		return;
+	struct clk *clk;
+	bool is_ast2600;
+
+	is_ast2600 = of_device_is_compatible(priv->dev->of_node,
+					     "aspeed,ast2600-mac");
+
+	clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+	priv->clk = clk;
+
+	clk = devm_clk_get_optional(priv->dev, "RCLK");
+	if (!clk && is_ast2600 && priv->use_ncsi) {
+		dev_err(priv->dev, "Cannot ungate RCLK");
+		return -EINVAL;
+	}
+
+	priv->rclk = clk;
+	clk_prepare_enable(priv->rclk);
 
 	clk_prepare_enable(priv->clk);
 
@@ -1732,6 +1751,8 @@ static void ftgmac100_setup_clk(struct ftgmac100 *priv)
 	 */
 	clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
 			FTGMAC_100MHZ);
+
+	return 0;
 }
 
 static int ftgmac100_probe(struct platform_device *pdev)
@@ -1853,8 +1874,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
 			goto err_setup_mdio;
 	}
 
-	if (priv->is_aspeed)
-		ftgmac100_setup_clk(priv);
+	if (priv->is_aspeed) {
+		err = ftgmac100_setup_clk(priv);
+		if (err)
+			goto err_ncsi_dev;
+	}
 
 	/* Default ring sizes */
 	priv->rx_q_entries = priv->new_rx_q_entries = DEF_RX_QUEUE_ENTRIES;
@@ -1886,8 +1910,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
 
 	return 0;
 
-err_ncsi_dev:
 err_register_netdev:
+	if (priv->rclk)
+		clk_disable_unprepare(priv->rclk);
+	clk_disable_unprepare(priv->clk);
+err_ncsi_dev:
 	ftgmac100_destroy_mdio(netdev);
 err_setup_mdio:
 	iounmap(priv->base);
@@ -1909,6 +1936,8 @@ static int ftgmac100_remove(struct platform_device *pdev)
 
 	unregister_netdev(netdev);
 
+	if (priv->rclk)
+		clk_disable_unprepare(priv->rclk);
 	clk_disable_unprepare(priv->clk);
 
 	/* There's a small chance the reset task will have been re-queued,
Signature · 1 line
2.20.1
maintainer Reviewed-by on v1 5/6
#17 lore raw

Re: [PATCH linux dev-5.3 5/6] net: ftgmac100: Ungate RCLK for RMII on AST2600

Quoted 2 lines · Andrew Jeffery

The 50MHz RMII RCLK has to be enabled before the interface will function.

"... when in NCSI or RMII mode"?

Quoted 2 lines
Quoted 98 lines
---
 drivers/net/ethernet/faraday/ftgmac100.c | 43 ++++++++++++++++++++----
 1 file changed, 36 insertions(+), 7 deletions(-)
drivers/net/ethernet/faraday/ftgmac100.c +36 -8
index 9b7af94a40bb..21a58aad1a19 100644
@@ -90,6 +90,9 @@ struct ftgmac100 {
        struct mii_bus *mii_bus;
        struct clk *clk;
 
+       /* 2600 RMII clock gate */
+       struct clk *rclk;
+
        /* Link management */
        int cur_speed;
        int cur_duplex;
@@ -1718,11 +1721,27 @@ static void ftgmac100_ncsi_handler(struct ncsi_dev *nd)
                   nd->link_up ? "up" : "down");
 }
 
-static void ftgmac100_setup_clk(struct ftgmac100 *priv)
+static int ftgmac100_setup_clk(struct ftgmac100 *priv)
 {
-       priv->clk = devm_clk_get(priv->dev, NULL);
-       if (IS_ERR(priv->clk))
-               return;
+       struct clk *clk;
+       bool is_ast2600;
+
+       is_ast2600 = of_device_is_compatible(priv->dev->of_node,
+                                            "aspeed,ast2600-mac");
+
+       clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
+       if (IS_ERR(clk))
+               return PTR_ERR(clk);
+       priv->clk = clk;
+
+       clk = devm_clk_get_optional(priv->dev, "RCLK");
+       if (!clk && is_ast2600 && priv->use_ncsi) {
+               dev_err(priv->dev, "Cannot ungate RCLK");
+               return -EINVAL;
+       }
+
+       priv->rclk = clk;
+       clk_prepare_enable(priv->rclk);
 
        clk_prepare_enable(priv->clk);
 
@@ -1732,6 +1751,8 @@ static void ftgmac100_setup_clk(struct ftgmac100 *priv)
         */
        clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
                        FTGMAC_100MHZ);
+
+       return 0;
 }
 
 static int ftgmac100_probe(struct platform_device *pdev)
@@ -1853,8 +1874,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
                        goto err_setup_mdio;
        }
 
-       if (priv->is_aspeed)
-               ftgmac100_setup_clk(priv);
+       if (priv->is_aspeed) {
+               err = ftgmac100_setup_clk(priv);
+               if (err)
+                       goto err_ncsi_dev;
+       }
 
        /* Default ring sizes */
        priv->rx_q_entries = priv->new_rx_q_entries = DEF_RX_QUEUE_ENTRIES;
@@ -1886,8 +1910,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
 
        return 0;
 
-err_ncsi_dev:
 err_register_netdev:
+       if (priv->rclk)
+               clk_disable_unprepare(priv->rclk);
+       clk_disable_unprepare(priv->clk);
+err_ncsi_dev:
        ftgmac100_destroy_mdio(netdev);
 err_setup_mdio:
        iounmap(priv->base);
@@ -1909,6 +1936,8 @@ static int ftgmac100_remove(struct platform_device *pdev)
 
        unregister_netdev(netdev);
 
+       if (priv->rclk)
+               clk_disable_unprepare(priv->rclk);
        clk_disable_unprepare(priv->clk);
 
        /* There's a small chance the reset task will have been re-queued,
--

2.20.1

#18 lore raw

Re: [PATCH linux dev-5.3 5/6] net: ftgmac100: Ungate RCLK for RMII on AST2600

In reply to Andrew Jeffery
Quoted 26 lines · Andrew Jeffery

The 50MHz RMII RCLK has to be enabled before the interface will function.

---
 drivers/net/ethernet/faraday/ftgmac100.c | 43 ++++++++++++++++++++----
 1 file changed, 36 insertions(+), 7 deletions(-)
drivers/net/ethernet/faraday/ftgmac100.c +3 -1
index 9b7af94a40bb..21a58aad1a19 100644
@@ -90,6 +90,9 @@ struct ftgmac100 {
 	struct mii_bus *mii_bus;
 	struct clk *clk;
 
+	/* 2600 RMII clock gate */
+	struct clk *rclk;
+
 	/* Link management */
 	int cur_speed;
 	int cur_duplex;
@@ -1718,11 +1721,27 @@ static void ftgmac100_ncsi_handler(struct ncsi_dev *nd)
 		   nd->link_up ? "up" : "down");
 }
 
-static void ftgmac100_setup_clk(struct ftgmac100 *priv)

drivers/net/ethernet/faraday/ftgmac100.c static void ftgmac100_ncsi_handler(struct ncsi_dev *nd) · line 1730

Quoted 10 lines
drivers/net/ethernet/faraday/ftgmac100.c +6 -3
+static int ftgmac100_setup_clk(struct ftgmac100 *priv)
 {
-	priv->clk = devm_clk_get(priv->dev, NULL);
-	if (IS_ERR(priv->clk))
-		return;
+	struct clk *clk;
+	bool is_ast2600;
+
+	is_ast2600 = of_device_is_compatible(priv->dev->of_node,
+					     "aspeed,ast2600-mac");

why is ast2600 particular ?

Quoted 62 lines
drivers/net/ethernet/faraday/ftgmac100.c +26 -3
+	clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+	priv->clk = clk;
+
+	clk = devm_clk_get_optional(priv->dev, "RCLK");
+	if (!clk && is_ast2600 && priv->use_ncsi) {
+		dev_err(priv->dev, "Cannot ungate RCLK");
+		return -EINVAL;
+	}
+
+	priv->rclk = clk;
+	clk_prepare_enable(priv->rclk);
 
 	clk_prepare_enable(priv->clk);
 
@@ -1732,6 +1751,8 @@ static void ftgmac100_setup_clk(struct ftgmac100 *priv)
 	 */
 	clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
 			FTGMAC_100MHZ);
+
+	return 0;
 }
 
 static int ftgmac100_probe(struct platform_device *pdev)
@@ -1853,8 +1874,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
 			goto err_setup_mdio;
 	}
 
-	if (priv->is_aspeed)
-		ftgmac100_setup_clk(priv);
+	if (priv->is_aspeed) {
+		err = ftgmac100_setup_clk(priv);
+		if (err)
+			goto err_ncsi_dev;
+	}
 
 	/* Default ring sizes */
 	priv->rx_q_entries = priv->new_rx_q_entries = DEF_RX_QUEUE_ENTRIES;
@@ -1886,8 +1910,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
 
 	return 0;
 
-err_ncsi_dev:
 err_register_netdev:
+	if (priv->rclk)
+		clk_disable_unprepare(priv->rclk);
+	clk_disable_unprepare(priv->clk);
+err_ncsi_dev:
 	ftgmac100_destroy_mdio(netdev);
 err_setup_mdio:
 	iounmap(priv->base);
@@ -1909,6 +1936,8 @@ static int ftgmac100_remove(struct platform_device *pdev)
 
 	unregister_netdev(netdev);
 
+	if (priv->rclk)
+		clk_disable_unprepare(priv->rclk);
 	clk_disable_unprepare(priv->clk);
 
 	/* There's a small chance the reset task will have been re-queued,
#19 lore raw

Re: [PATCH linux dev-5.3 5/6] net: ftgmac100: Ungate RCLK for RMII on AST2600

Quoted 26 lines · Cédric Le Goater
Quoted 25 lines · Andrew Jeffery

The 50MHz RMII RCLK has to be enabled before the interface will function.

---
 drivers/net/ethernet/faraday/ftgmac100.c | 43 ++++++++++++++++++++----
 1 file changed, 36 insertions(+), 7 deletions(-)
drivers/net/ethernet/faraday/ftgmac100.c +3 -0
index 9b7af94a40bb..21a58aad1a19 100644
@@ -90,6 +90,9 @@ struct ftgmac100 {
 	struct mii_bus *mii_bus;
 	struct clk *clk;
 
+	/* 2600 RMII clock gate */
+	struct clk *rclk;
+
 	/* Link management */
 	int cur_speed;
 	int cur_duplex;
@@ -1718,11 +1721,27 @@ static void ftgmac100_ncsi_handler(struct ncsi_dev *nd)
 		   nd->link_up ? "up" : "down");
 }
 
Quoted 13 lines

drivers/net/ethernet/faraday/ftgmac100.c static void ftgmac100_ncsi_handler(struct ncsi_dev *nd) · line 1730

Quoted 11 lines
drivers/net/ethernet/faraday/ftgmac100.c +6 -4
-static void ftgmac100_setup_clk(struct ftgmac100 *priv)
+static int ftgmac100_setup_clk(struct ftgmac100 *priv)
 {
-	priv->clk = devm_clk_get(priv->dev, NULL);
-	if (IS_ERR(priv->clk))
-		return;
+	struct clk *clk;
+	bool is_ast2600;
+
+	is_ast2600 = of_device_is_compatible(priv->dev->of_node,
+					     "aspeed,ast2600-mac");

why is ast2600 particular ?

It isn't, as Joel pointed out. We need this for at least the 2500 as well, but I didn't think to check as u-boot has been leaving the clock ungated.

Quoted 65 lines
Quoted 63 lines
drivers/net/ethernet/faraday/ftgmac100.c +26 -3
+	clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+	priv->clk = clk;
+
+	clk = devm_clk_get_optional(priv->dev, "RCLK");
+	if (!clk && is_ast2600 && priv->use_ncsi) {
+		dev_err(priv->dev, "Cannot ungate RCLK");
+		return -EINVAL;
+	}
+
+	priv->rclk = clk;
+	clk_prepare_enable(priv->rclk);
 
 	clk_prepare_enable(priv->clk);
 
@@ -1732,6 +1751,8 @@ static void ftgmac100_setup_clk(struct ftgmac100 *priv)
 	 */
 	clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
 			FTGMAC_100MHZ);
+
+	return 0;
 }
 
 static int ftgmac100_probe(struct platform_device *pdev)
@@ -1853,8 +1874,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
 			goto err_setup_mdio;
 	}
 
-	if (priv->is_aspeed)
-		ftgmac100_setup_clk(priv);
+	if (priv->is_aspeed) {
+		err = ftgmac100_setup_clk(priv);
+		if (err)
+			goto err_ncsi_dev;
+	}
 
 	/* Default ring sizes */
 	priv->rx_q_entries = priv->new_rx_q_entries = DEF_RX_QUEUE_ENTRIES;
@@ -1886,8 +1910,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
 
 	return 0;
 
-err_ncsi_dev:
 err_register_netdev:
+	if (priv->rclk)
+		clk_disable_unprepare(priv->rclk);
+	clk_disable_unprepare(priv->clk);
+err_ncsi_dev:
 	ftgmac100_destroy_mdio(netdev);
 err_setup_mdio:
 	iounmap(priv->base);
@@ -1909,6 +1936,8 @@ static int ftgmac100_remove(struct platform_device *pdev)
 
 	unregister_netdev(netdev);
 
+	if (priv->rclk)
+		clk_disable_unprepare(priv->rclk);
 	clk_disable_unprepare(priv->clk);
 
 	/* There's a small chance the reset task will have been re-queued,
#20 lore raw

PATCH 6/6 ARM: dts: tacoma: Enable 50MHz RMII RCLK for NCSI

In reply to Andrew Jeffery

Tacoma uses MAC3 for its NCSI-based interface to the outside world.

---
 arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts +3 -0
index 408af001c06c..854b0a532a01 100644
@@ -28,6 +28,9 @@
 	status = "okay";
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_rmii3_default>;
+	clocks = <&syscon ASPEED_CLK_GATE_MAC3CLK>,
+		 <&syscon ASPEED_CLK_GATE_MAC3RCLK>;
+	clock-names = "MACCLK", "RCLK";
 	use-ncsi;
 };
 
Signature · 1 line
2.20.1
maintainer Reviewed-by on v1 6/6
#21 lore raw

Re: [PATCH linux dev-5.3 6/6] ARM: dts: tacoma: Enable 50MHz RMII RCLK for NCSI

Quoted 4 lines · Andrew Jeffery

Tacoma uses MAC3 for its NCSI-based interface to the outside world.

Quoted 21 lines
---
 arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts +3 -1
index 408af001c06c..854b0a532a01 100644
@@ -28,6 +28,9 @@
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_rmii3_default>;
+       clocks = <&syscon ASPEED_CLK_GATE_MAC3CLK>,
+                <&syscon ASPEED_CLK_GATE_MAC3RCLK>;
+       clock-names = "MACCLK", "RCLK";
        use-ncsi;
 };
 
--

2.20.1