Skip to content

Commit af350ee

Browse files
aspeedJackykuba-moo
authored andcommitted
net: ftgmac100: Add optional reset control for RMII mode on Aspeed SoCs
On Aspeed SoCs, the internal MAC reset is insufficient to fully reset the RMII interface; only the SoC-level reset line can properly reset the RMII logic. This patch adds support for an optional "resets" property in the device tree, allowing the driver to assert and deassert the SoC reset line when operating in RMII mode. This ensures the MAC and RMII interface are correctly reset and initialized. Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://patch.msgid.link/20250709070809.2560688-5-jacky_chou@aspeedtech.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 4dc5f7b commit af350ee

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/net/ethernet/faraday/ftgmac100.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1010

1111
#include <linux/clk.h>
12+
#include <linux/reset.h>
1213
#include <linux/dma-mapping.h>
1314
#include <linux/etherdevice.h>
1415
#include <linux/ethtool.h>
@@ -101,6 +102,8 @@ struct ftgmac100 {
101102

102103
/* AST2500/AST2600 RMII ref clock gate */
103104
struct clk *rclk;
105+
/* Aspeed reset control */
106+
struct reset_control *rst;
104107

105108
/* Link management */
106109
int cur_speed;
@@ -148,6 +151,23 @@ static int ftgmac100_reset_and_config_mac(struct ftgmac100 *priv)
148151
{
149152
u32 maccr = 0;
150153

154+
/* Aspeed RMII needs SCU reset to clear status */
155+
if (priv->is_aspeed && priv->netdev->phydev->interface == PHY_INTERFACE_MODE_RMII) {
156+
int err;
157+
158+
err = reset_control_assert(priv->rst);
159+
if (err) {
160+
dev_err(priv->dev, "Failed to reset mac (%d)\n", err);
161+
return err;
162+
}
163+
usleep_range(10000, 20000);
164+
err = reset_control_deassert(priv->rst);
165+
if (err) {
166+
dev_err(priv->dev, "Failed to deassert mac reset (%d)\n", err);
167+
return err;
168+
}
169+
}
170+
151171
switch (priv->cur_speed) {
152172
case SPEED_10:
153173
case 0: /* no link */
@@ -1968,6 +1988,12 @@ static int ftgmac100_probe(struct platform_device *pdev)
19681988

19691989
}
19701990

1991+
priv->rst = devm_reset_control_get_optional_exclusive(priv->dev, NULL);
1992+
if (IS_ERR(priv->rst)) {
1993+
err = PTR_ERR(priv->rst);
1994+
goto err_phy_connect;
1995+
}
1996+
19711997
if (priv->is_aspeed) {
19721998
err = ftgmac100_setup_clk(priv);
19731999
if (err)

0 commit comments

Comments
 (0)