Netdev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 0/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs
@ 2019-10-10  2:07 Andrew Jeffery
  2019-10-10  2:07 ` [PATCH v2 1/3] dt-bindings: net: ftgmac100: Document AST2600 compatible Andrew Jeffery
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Andrew Jeffery @ 2019-10-10  2:07 UTC (permalink / raw)
  To: netdev
  Cc: davem, robh+dt, mark.rutland, devicetree, linux-kernel, joel,
	benh, linux-aspeed

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
R(educed)MII).

v2:
* Clear up Reduced vs Reversed MII in the cover letter
* Mitigate anxiety in the commit message for 1/3 
* Clarify that AST2500 is also affected in the clocks property description in
  2/3
* Rework the error paths and update some comments in 3/3

v1 can be found here: https://lore.kernel.org/netdev/20191008115143.14149-1-andrew@aj.id.au/

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     |  8 +++
 drivers/net/ethernet/faraday/ftgmac100.c      | 50 +++++++++++++++----
 2 files changed, 48 insertions(+), 10 deletions(-)

-- 
2.20.1


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

* [PATCH v2 1/3] dt-bindings: net: ftgmac100: Document AST2600 compatible
  2019-10-10  2:07 [PATCH v2 0/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs Andrew Jeffery
@ 2019-10-10  2:07 ` Andrew Jeffery
  2019-10-11 17:01   ` Rob Herring
  2019-10-10  2:07 ` [PATCH v2 2/3] dt-bindings: net: ftgmac100: Describe clock properties Andrew Jeffery
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Andrew Jeffery @ 2019-10-10  2:07 UTC (permalink / raw)
  To: netdev
  Cc: davem, robh+dt, mark.rutland, devicetree, linux-kernel, joel,
	benh, linux-aspeed

The AST2600 contains an FTGMAC100-compatible MAC, although the MDIO
controller previously embedded in the MAC has been moved out to a
dedicated MDIO block.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Acked-by: Joel Stanley <joel@jms.id.au>
---
 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


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

* [PATCH v2 2/3] dt-bindings: net: ftgmac100: Describe clock properties
  2019-10-10  2:07 [PATCH v2 0/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs Andrew Jeffery
  2019-10-10  2:07 ` [PATCH v2 1/3] dt-bindings: net: ftgmac100: Document AST2600 compatible Andrew Jeffery
@ 2019-10-10  2:07 ` Andrew Jeffery
  2019-10-11 17:02   ` Rob Herring
  2019-10-10  2:07 ` [PATCH v2 3/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs Andrew Jeffery
  2019-10-12  3:38 ` [PATCH v2 0/3] " David Miller
  3 siblings, 1 reply; 8+ messages in thread
From: Andrew Jeffery @ 2019-10-10  2:07 UTC (permalink / raw)
  To: netdev
  Cc: davem, robh+dt, mark.rutland, devicetree, linux-kernel, joel,
	benh, linux-aspeed

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

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Acked-by: Joel Stanley <joel@jms.id.au>
---
 Documentation/devicetree/bindings/net/ftgmac100.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt b/Documentation/devicetree/bindings/net/ftgmac100.txt
index 04cc0191b7dd..f878c1103463 100644
--- a/Documentation/devicetree/bindings/net/ftgmac100.txt
+++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
@@ -24,6 +24,13 @@ 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 AST2500/AST2600. The
+  required MAC clock must be the first cell.
+- clock-names:
+
+      - "MACCLK": The MAC IP clock
+      - "RCLK": Clock gate for the RMII RCLK
 
 Example:
 
-- 
2.20.1


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

* [PATCH v2 3/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs
  2019-10-10  2:07 [PATCH v2 0/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs Andrew Jeffery
  2019-10-10  2:07 ` [PATCH v2 1/3] dt-bindings: net: ftgmac100: Document AST2600 compatible Andrew Jeffery
  2019-10-10  2:07 ` [PATCH v2 2/3] dt-bindings: net: ftgmac100: Describe clock properties Andrew Jeffery
@ 2019-10-10  2:07 ` Andrew Jeffery
  2019-10-10 23:44   ` Joel Stanley
  2019-10-12  3:38 ` [PATCH v2 0/3] " David Miller
  3 siblings, 1 reply; 8+ messages in thread
From: Andrew Jeffery @ 2019-10-10  2:07 UTC (permalink / raw)
  To: netdev
  Cc: davem, robh+dt, mark.rutland, devicetree, linux-kernel, joel,
	benh, linux-aspeed

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

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
v2: Mainly a rework of error case handling, some changes to comments

 drivers/net/ethernet/faraday/ftgmac100.c | 50 +++++++++++++++++++-----
 1 file changed, 40 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 9b7af94a40bb..824310253099 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;
 
+	/* AST2500/AST2600 RMII ref clock gate */
+	struct clk *rclk;
+
 	/* Link management */
 	int cur_speed;
 	int cur_duplex;
@@ -1718,20 +1721,41 @@ 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;
+	int rc;
 
-	clk_prepare_enable(priv->clk);
+	clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+	priv->clk = clk;
+	rc = clk_prepare_enable(priv->clk);
+	if (rc)
+		return rc;
 
 	/* Aspeed specifies a 100MHz clock is required for up to
 	 * 1000Mbit link speeds. As NCSI is limited to 100Mbit, 25MHz
 	 * is sufficient
 	 */
-	clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
-			FTGMAC_100MHZ);
+	rc = clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
+			  FTGMAC_100MHZ);
+	if (rc)
+		goto cleanup_clk;
+
+	/* RCLK is for RMII, typically used for NCSI. Optional because its not
+	 * necessary if it's the AST2400 MAC, or the MAC is configured for
+	 * RGMII, or the controller is not an ASPEED-based controller.
+	 */
+	priv->rclk = devm_clk_get_optional(priv->dev, "RCLK");
+	rc = clk_prepare_enable(priv->rclk);
+	if (!rc)
+		return 0;
+
+cleanup_clk:
+	clk_disable_unprepare(priv->clk);
+
+	return rc;
 }
 
 static int ftgmac100_probe(struct platform_device *pdev)
@@ -1853,8 +1877,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 +1913,10 @@ static int ftgmac100_probe(struct platform_device *pdev)
 
 	return 0;
 
-err_ncsi_dev:
 err_register_netdev:
+	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 +1938,7 @@ static int ftgmac100_remove(struct platform_device *pdev)
 
 	unregister_netdev(netdev);
 
+	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


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

* Re: [PATCH v2 3/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs
  2019-10-10  2:07 ` [PATCH v2 3/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs Andrew Jeffery
@ 2019-10-10 23:44   ` Joel Stanley
  0 siblings, 0 replies; 8+ messages in thread
From: Joel Stanley @ 2019-10-10 23:44 UTC (permalink / raw)
  To: Andrew Jeffery
  Cc: netdev, David S . Miller, Rob Herring, Mark Rutland, devicetree,
	Linux Kernel Mailing List, Benjamin Herrenschmidt, linux-aspeed

On Thu, 10 Oct 2019 at 02:07, Andrew Jeffery <andrew@aj.id.au> wrote:
>
> The 50MHz RCLK has to be enabled before the RMII interface will function.
>
> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

Reviewed-by: Joel Stanley <joel@jms.id.au>

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

* Re: [PATCH v2 1/3] dt-bindings: net: ftgmac100: Document AST2600 compatible
  2019-10-10  2:07 ` [PATCH v2 1/3] dt-bindings: net: ftgmac100: Document AST2600 compatible Andrew Jeffery
@ 2019-10-11 17:01   ` Rob Herring
  0 siblings, 0 replies; 8+ messages in thread
From: Rob Herring @ 2019-10-11 17:01 UTC (permalink / raw)
  To: Andrew Jeffery
  Cc: netdev, davem, robh+dt, mark.rutland, devicetree, linux-kernel,
	joel, benh, linux-aspeed

On Thu, 10 Oct 2019 12:37:54 +1030, Andrew Jeffery wrote:
> The AST2600 contains an FTGMAC100-compatible MAC, although the MDIO
> controller previously embedded in the MAC has been moved out to a
> dedicated MDIO block.
> 
> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> Acked-by: Joel Stanley <joel@jms.id.au>
> ---
>  Documentation/devicetree/bindings/net/ftgmac100.txt | 1 +
>  1 file changed, 1 insertion(+)
> 

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v2 2/3] dt-bindings: net: ftgmac100: Describe clock properties
  2019-10-10  2:07 ` [PATCH v2 2/3] dt-bindings: net: ftgmac100: Describe clock properties Andrew Jeffery
@ 2019-10-11 17:02   ` Rob Herring
  0 siblings, 0 replies; 8+ messages in thread
From: Rob Herring @ 2019-10-11 17:02 UTC (permalink / raw)
  To: Andrew Jeffery
  Cc: netdev, davem, robh+dt, mark.rutland, devicetree, linux-kernel,
	joel, benh, linux-aspeed

On Thu, 10 Oct 2019 12:37:55 +1030, Andrew Jeffery wrote:
> Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is
> in use.
> 
> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> Acked-by: Joel Stanley <joel@jms.id.au>
> ---
>  Documentation/devicetree/bindings/net/ftgmac100.txt | 7 +++++++
>  1 file changed, 7 insertions(+)
> 

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v2 0/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs
  2019-10-10  2:07 [PATCH v2 0/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs Andrew Jeffery
                   ` (2 preceding siblings ...)
  2019-10-10  2:07 ` [PATCH v2 3/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs Andrew Jeffery
@ 2019-10-12  3:38 ` " David Miller
  3 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2019-10-12  3:38 UTC (permalink / raw)
  To: andrew
  Cc: netdev, robh+dt, mark.rutland, devicetree, linux-kernel, joel,
	benh, linux-aspeed

From: Andrew Jeffery <andrew@aj.id.au>
Date: Thu, 10 Oct 2019 12:37:53 +1030

> 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
> R(educed)MII).
> 
> v2:
> * Clear up Reduced vs Reversed MII in the cover letter
> * Mitigate anxiety in the commit message for 1/3 
> * Clarify that AST2500 is also affected in the clocks property description in
>   2/3
> * Rework the error paths and update some comments in 3/3
> 
> v1 can be found here: https://lore.kernel.org/netdev/20191008115143.14149-1-andrew@aj.id.au/

Series applied to net-next, thank you.

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

end of thread, back to index

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-10  2:07 [PATCH v2 0/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs Andrew Jeffery
2019-10-10  2:07 ` [PATCH v2 1/3] dt-bindings: net: ftgmac100: Document AST2600 compatible Andrew Jeffery
2019-10-11 17:01   ` Rob Herring
2019-10-10  2:07 ` [PATCH v2 2/3] dt-bindings: net: ftgmac100: Describe clock properties Andrew Jeffery
2019-10-11 17:02   ` Rob Herring
2019-10-10  2:07 ` [PATCH v2 3/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs Andrew Jeffery
2019-10-10 23:44   ` Joel Stanley
2019-10-12  3:38 ` [PATCH v2 0/3] " David Miller

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org netdev@archiver.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox