2019-10-08 11:51:23

by Andrew Jeffery

[permalink] [raw]
Subject: [PATCH 0/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs

Hello,

This series slightly extends the devicetree binding and driver for the
FTGMAC100 to describe an optional RMII RCLK gate in the clocks property.
Currently it's necessary for the kernel to ungate RCLK on the AST2600 in NCSI
configurations as u-boot does not yet support NCSI (which uses the RMII).

Please review!

Andrew

Andrew Jeffery (3):
dt-bindings: net: ftgmac100: Document AST2600 compatible
dt-bindings: net: ftgmac100: Describe clock properties
net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs

.../devicetree/bindings/net/ftgmac100.txt | 7 ++++
drivers/net/ethernet/faraday/ftgmac100.c | 35 +++++++++++++++----
2 files changed, 35 insertions(+), 7 deletions(-)

--
2.20.1


2019-10-08 11:51:25

by Andrew Jeffery

[permalink] [raw]
Subject: [PATCH 1/3] dt-bindings: net: ftgmac100: Document AST2600 compatible

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

Signed-off-by: Andrew Jeffery <[email protected]>
---
Documentation/devicetree/bindings/net/ftgmac100.txt | 1 +
1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt b/Documentation/devicetree/bindings/net/ftgmac100.txt
index 72e7aaf7242e..04cc0191b7dd 100644
--- a/Documentation/devicetree/bindings/net/ftgmac100.txt
+++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
@@ -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
--
2.20.1

2019-10-08 11:51:57

by Andrew Jeffery

[permalink] [raw]
Subject: [PATCH 2/3] dt-bindings: net: ftgmac100: Describe clock properties

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

2019-10-08 11:54:18

by Andrew Jeffery

[permalink] [raw]
Subject: [PATCH 3/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs

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

Signed-off-by: Andrew Jeffery <[email protected]>
---
drivers/net/ethernet/faraday/ftgmac100.c | 35 +++++++++++++++++++-----
1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 9b7af94a40bb..9ff791fb0449 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -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,12 +1721,14 @@ 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;

+ clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+ priv->clk = clk;
clk_prepare_enable(priv->clk);

/* Aspeed specifies a 100MHz clock is required for up to
@@ -1732,6 +1737,14 @@ static void ftgmac100_setup_clk(struct ftgmac100 *priv)
*/
clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
FTGMAC_100MHZ);
+
+ /* RCLK is for RMII, typically used for NCSI. Optional because its not
+ * necessary if it's the 2400 MAC or the MAC is configured for RGMII
+ */
+ priv->rclk = devm_clk_get_optional(priv->dev, "RCLK");
+ clk_prepare_enable(priv->rclk);
+
+ return 0;
}

static int ftgmac100_probe(struct platform_device *pdev)
@@ -1853,8 +1866,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 +1902,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 +1928,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

2019-10-08 12:41:19

by Joel Stanley

[permalink] [raw]
Subject: Re: [PATCH 1/3] dt-bindings: net: ftgmac100: Document AST2600 compatible

On Tue, 8 Oct 2019 at 11:50, Andrew Jeffery <[email protected]> wrote:
>
> The AST2600 contains an FTGMAC100-compatible MAC, although it no-longer
> contains an MDIO controller.
>
> Signed-off-by: Andrew Jeffery <[email protected]>

Acked-by: Joel Stanley <[email protected]>

> ---
> Documentation/devicetree/bindings/net/ftgmac100.txt | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt b/Documentation/devicetree/bindings/net/ftgmac100.txt
> index 72e7aaf7242e..04cc0191b7dd 100644
> --- a/Documentation/devicetree/bindings/net/ftgmac100.txt
> +++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
> @@ -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
> --
> 2.20.1
>

2019-10-08 12:45:41

by Joel Stanley

[permalink] [raw]
Subject: Re: [PATCH 2/3] dt-bindings: net: ftgmac100: Describe clock properties

On Tue, 8 Oct 2019 at 11:50, Andrew Jeffery <[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.
> +- clocks: In accordance with the generic clock bindings. Must describe the MAC
> + IP clock, and optionally an RMII RCLK gate for the AST2600.

or AST2500.

With that fixed you can add my ack.


> +- clock-names:
> +
> + - "MACCLK": The MAC IP clock
> + - "RCLK": Clock gate for the RMII RCLK
>
> Example:
>
> --
> 2.20.1
>

2019-10-08 12:47:11

by Joel Stanley

[permalink] [raw]
Subject: Re: [PATCH 3/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs

On Tue, 8 Oct 2019 at 11:50, Andrew Jeffery <[email protected]> wrote:
>
> The 50MHz RCLK has to be enabled before the RMII interface will function.
>
> Signed-off-by: Andrew Jeffery <[email protected]>
> ---
> drivers/net/ethernet/faraday/ftgmac100.c | 35 +++++++++++++++++++-----
> 1 file changed, 28 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> index 9b7af94a40bb..9ff791fb0449 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> @@ -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,12 +1721,14 @@ 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;
>
> + clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
> + if (IS_ERR(clk))
> + return PTR_ERR(clk);
> + priv->clk = clk;
> clk_prepare_enable(priv->clk);
>
> /* Aspeed specifies a 100MHz clock is required for up to
> @@ -1732,6 +1737,14 @@ static void ftgmac100_setup_clk(struct ftgmac100 *priv)
> */
> clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
> FTGMAC_100MHZ);
> +
> + /* RCLK is for RMII, typically used for NCSI. Optional because its not
> + * necessary if it's the 2400 MAC or the MAC is configured for RGMII
> + */

Or for non-ASPEED users of this driver, assuming they exist.

Reviewed-by: Joel Stanley <[email protected]>


> + priv->rclk = devm_clk_get_optional(priv->dev, "RCLK");
> + clk_prepare_enable(priv->rclk);
> +
> + return 0;
> }
>
> static int ftgmac100_probe(struct platform_device *pdev)
> @@ -1853,8 +1866,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 +1902,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 +1928,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
>

2019-10-09 00:19:28

by Andrew Jeffery

[permalink] [raw]
Subject: Re: [PATCH 2/3] dt-bindings: net: ftgmac100: Describe clock properties



On Tue, 8 Oct 2019, at 23:12, Joel Stanley wrote:
> On Tue, 8 Oct 2019 at 11:50, Andrew Jeffery <[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.
> > +- clocks: In accordance with the generic clock bindings. Must describe the MAC
> > + IP clock, and optionally an RMII RCLK gate for the AST2600.
>
> or AST2500.
>
> With that fixed you can add my ack.

I'll do a v2 and fix the comments in the driver patch as well.

Cheers,

Andrew

2019-10-09 00:38:41

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH 0/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs



On 10/8/2019 4:51 AM, Andrew Jeffery wrote:
> Hello,
>
> This series slightly extends the devicetree binding and driver for the
> FTGMAC100 to describe an optional RMII RCLK gate in the clocks property.
> Currently it's necessary for the kernel to ungate RCLK on the AST2600 in NCSI
> configurations as u-boot does not yet support NCSI (which uses the RMII).

RMII as in Reduced MII or Reverse MII in that context?

>
> Please review!
>
> Andrew
>
> Andrew Jeffery (3):
> dt-bindings: net: ftgmac100: Document AST2600 compatible
> dt-bindings: net: ftgmac100: Describe clock properties
> net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs
>
> .../devicetree/bindings/net/ftgmac100.txt | 7 ++++
> drivers/net/ethernet/faraday/ftgmac100.c | 35 +++++++++++++++----
> 2 files changed, 35 insertions(+), 7 deletions(-)
>

--
Florian

2019-10-09 01:12:21

by Joel Stanley

[permalink] [raw]
Subject: Re: [PATCH 0/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs

On Wed, 9 Oct 2019 at 00:38, Florian Fainelli <[email protected]> wrote:
>
>
>
> On 10/8/2019 4:51 AM, Andrew Jeffery wrote:
> > Hello,
> >
> > This series slightly extends the devicetree binding and driver for the
> > FTGMAC100 to describe an optional RMII RCLK gate in the clocks property.
> > Currently it's necessary for the kernel to ungate RCLK on the AST2600 in NCSI
> > configurations as u-boot does not yet support NCSI (which uses the RMII).
>
> RMII as in Reduced MII or Reverse MII in that context?

Reduced MII ( https://en.wikipedia.org/wiki/NC-SI#Hardware_interface )

Cheers,

Joel

2019-10-09 04:42:35

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH 1/3] dt-bindings: net: ftgmac100: Document AST2600 compatible

On Tue, 2019-10-08 at 22:21 +1030, Andrew Jeffery wrote:
> The AST2600 contains an FTGMAC100-compatible MAC, although it no-
> longer
> contains an MDIO controller.

How do you talk to the PHY then ?

Cheers,
Ben.

> Signed-off-by: Andrew Jeffery <[email protected]>
> ---
> Documentation/devicetree/bindings/net/ftgmac100.txt | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt
> b/Documentation/devicetree/bindings/net/ftgmac100.txt
> index 72e7aaf7242e..04cc0191b7dd 100644
> --- a/Documentation/devicetree/bindings/net/ftgmac100.txt
> +++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
> @@ -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

2019-10-09 04:49:46

by Andrew Jeffery

[permalink] [raw]
Subject: Re: [PATCH 1/3] dt-bindings: net: ftgmac100: Document AST2600 compatible



On Wed, 9 Oct 2019, at 15:08, Benjamin Herrenschmidt wrote:
> On Tue, 2019-10-08 at 22:21 +1030, Andrew Jeffery wrote:
> > The AST2600 contains an FTGMAC100-compatible MAC, although it no-
> > longer
> > contains an MDIO controller.
>
> How do you talk to the PHY then ?

There are still MDIO controllers, they're just not in the MAC IP on the 2600.

Andrew

2019-10-09 04:55:19

by Andrew Jeffery

[permalink] [raw]
Subject: Re: [PATCH 1/3] dt-bindings: net: ftgmac100: Document AST2600 compatible



On Wed, 9 Oct 2019, at 15:19, Andrew Jeffery wrote:
>
>
> On Wed, 9 Oct 2019, at 15:08, Benjamin Herrenschmidt wrote:
> > On Tue, 2019-10-08 at 22:21 +1030, Andrew Jeffery wrote:
> > > The AST2600 contains an FTGMAC100-compatible MAC, although it no-
> > > longer
> > > contains an MDIO controller.
> >
> > How do you talk to the PHY then ?
>
> There are still MDIO controllers, they're just not in the MAC IP on the 2600.

Sorry, on reflection that description is a little ambiguous in its use of 'it'. I'll
fix that in v2 as well. Does this read better?

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

Andrew

2019-10-10 00:14:07

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH 1/3] dt-bindings: net: ftgmac100: Document AST2600 compatible

On Wed, 2019-10-09 at 15:25 +1030, Andrew Jeffery wrote:
>
> On Wed, 9 Oct 2019, at 15:19, Andrew Jeffery wrote:
> >
> >
> > On Wed, 9 Oct 2019, at 15:08, Benjamin Herrenschmidt wrote:
> > > On Tue, 2019-10-08 at 22:21 +1030, Andrew Jeffery wrote:
> > > > The AST2600 contains an FTGMAC100-compatible MAC, although it
> > > > no-
> > > > longer
> > > > contains an MDIO controller.
> > >
> > > How do you talk to the PHY then ?
> >
> > There are still MDIO controllers, they're just not in the MAC IP on
> > the 2600.
>
> Sorry, on reflection that description is a little ambiguous in its
> use of 'it'. I'll
> fix that in v2 as well. Does this read better?
>
> "The AST2600 contains an FTGMAC100-compatible MAC, although the MAC
> no-longer contains an MDIO controller."

That's fine. Or to be pendantic, say the MDIO controller has been moved
of the MAC unit into its own separate block or something along those
lines so people like me don't get anxious :)

Cheers,
Ben.