@@ -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
17371761static 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 :
18901916err_register_netdev :
1917+ clk_disable_unprepare (priv -> rclk );
1918+ clk_disable_unprepare (priv -> clk );
1919+ err_ncsi_dev :
18911920 ftgmac100_destroy_mdio (netdev );
18921921err_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