Skip to content

Commit e001d28

Browse files
committed
Merge branch 'net-ftgmac100-Ungate-RCLK-for-RMII-on-ASPEED-MACs'
Andrew Jeffery says: ==================== net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs 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/[email protected]/ ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 41441d8 + 9bce4b2 commit e001d28

File tree

2 files changed

+48
-10
lines changed

2 files changed

+48
-10
lines changed

Documentation/devicetree/bindings/net/ftgmac100.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Required properties:
99

1010
- "aspeed,ast2400-mac"
1111
- "aspeed,ast2500-mac"
12+
- "aspeed,ast2600-mac"
1213

1314
- reg: Address and length of the register set for the device
1415
- interrupts: Should contain ethernet controller interrupt
@@ -23,6 +24,13 @@ Optional properties:
2324
- no-hw-checksum: Used to disable HW checksum support. Here for backward
2425
compatibility as the driver now should have correct defaults based on
2526
the SoC.
27+
- clocks: In accordance with the generic clock bindings. Must describe the MAC
28+
IP clock, and optionally an RMII RCLK gate for the AST2500/AST2600. The
29+
required MAC clock must be the first cell.
30+
- clock-names:
31+
32+
- "MACCLK": The MAC IP clock
33+
- "RCLK": Clock gate for the RMII RCLK
2634

2735
Example:
2836

drivers/net/ethernet/faraday/ftgmac100.c

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ struct ftgmac100 {
9090
struct mii_bus *mii_bus;
9191
struct clk *clk;
9292

93+
/* AST2500/AST2600 RMII ref clock gate */
94+
struct clk *rclk;
95+
9396
/* Link management */
9497
int cur_speed;
9598
int cur_duplex;
@@ -1718,20 +1721,41 @@ static void ftgmac100_ncsi_handler(struct ncsi_dev *nd)
17181721
nd->link_up ? "up" : "down");
17191722
}
17201723

1721-
static void ftgmac100_setup_clk(struct ftgmac100 *priv)
1724+
static int ftgmac100_setup_clk(struct ftgmac100 *priv)
17221725
{
1723-
priv->clk = devm_clk_get(priv->dev, NULL);
1724-
if (IS_ERR(priv->clk))
1725-
return;
1726+
struct clk *clk;
1727+
int rc;
17261728

1727-
clk_prepare_enable(priv->clk);
1729+
clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
1730+
if (IS_ERR(clk))
1731+
return PTR_ERR(clk);
1732+
priv->clk = clk;
1733+
rc = clk_prepare_enable(priv->clk);
1734+
if (rc)
1735+
return rc;
17281736

17291737
/* Aspeed specifies a 100MHz clock is required for up to
17301738
* 1000Mbit link speeds. As NCSI is limited to 100Mbit, 25MHz
17311739
* is sufficient
17321740
*/
1733-
clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
1734-
FTGMAC_100MHZ);
1741+
rc = clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
1742+
FTGMAC_100MHZ);
1743+
if (rc)
1744+
goto cleanup_clk;
1745+
1746+
/* RCLK is for RMII, typically used for NCSI. Optional because its not
1747+
* necessary if it's the AST2400 MAC, or the MAC is configured for
1748+
* RGMII, or the controller is not an ASPEED-based controller.
1749+
*/
1750+
priv->rclk = devm_clk_get_optional(priv->dev, "RCLK");
1751+
rc = clk_prepare_enable(priv->rclk);
1752+
if (!rc)
1753+
return 0;
1754+
1755+
cleanup_clk:
1756+
clk_disable_unprepare(priv->clk);
1757+
1758+
return rc;
17351759
}
17361760

17371761
static int ftgmac100_probe(struct platform_device *pdev)
@@ -1853,8 +1877,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
18531877
goto err_setup_mdio;
18541878
}
18551879

1856-
if (priv->is_aspeed)
1857-
ftgmac100_setup_clk(priv);
1880+
if (priv->is_aspeed) {
1881+
err = ftgmac100_setup_clk(priv);
1882+
if (err)
1883+
goto err_ncsi_dev;
1884+
}
18581885

18591886
/* Default ring sizes */
18601887
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)
18861913

18871914
return 0;
18881915

1889-
err_ncsi_dev:
18901916
err_register_netdev:
1917+
clk_disable_unprepare(priv->rclk);
1918+
clk_disable_unprepare(priv->clk);
1919+
err_ncsi_dev:
18911920
ftgmac100_destroy_mdio(netdev);
18921921
err_setup_mdio:
18931922
iounmap(priv->base);
@@ -1909,6 +1938,7 @@ static int ftgmac100_remove(struct platform_device *pdev)
19091938

19101939
unregister_netdev(netdev);
19111940

1941+
clk_disable_unprepare(priv->rclk);
19121942
clk_disable_unprepare(priv->clk);
19131943

19141944
/* There's a small chance the reset task will have been re-queued,

0 commit comments

Comments
 (0)