Commit e001d28e authored by David S. Miller's avatar David S. Miller

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/20191008115143.14149-1-andrew@aj.id.au/
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 41441d85 9bce4b27
......@@ -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
......@@ -23,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:
......
......@@ -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 :
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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment