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>
This commit is contained in:
Jacky Chou 2025-07-09 15:08:09 +08:00 committed by Jakub Kicinski
parent 4dc5f7b2c0
commit af350ee72e

View File

@ -9,6 +9,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/clk.h>
#include <linux/reset.h>
#include <linux/dma-mapping.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
@ -101,6 +102,8 @@ struct ftgmac100 {
/* AST2500/AST2600 RMII ref clock gate */
struct clk *rclk;
/* Aspeed reset control */
struct reset_control *rst;
/* Link management */
int cur_speed;
@ -148,6 +151,23 @@ static int ftgmac100_reset_and_config_mac(struct ftgmac100 *priv)
{
u32 maccr = 0;
/* Aspeed RMII needs SCU reset to clear status */
if (priv->is_aspeed && priv->netdev->phydev->interface == PHY_INTERFACE_MODE_RMII) {
int err;
err = reset_control_assert(priv->rst);
if (err) {
dev_err(priv->dev, "Failed to reset mac (%d)\n", err);
return err;
}
usleep_range(10000, 20000);
err = reset_control_deassert(priv->rst);
if (err) {
dev_err(priv->dev, "Failed to deassert mac reset (%d)\n", err);
return err;
}
}
switch (priv->cur_speed) {
case SPEED_10:
case 0: /* no link */
@ -1968,6 +1988,12 @@ static int ftgmac100_probe(struct platform_device *pdev)
}
priv->rst = devm_reset_control_get_optional_exclusive(priv->dev, NULL);
if (IS_ERR(priv->rst)) {
err = PTR_ERR(priv->rst);
goto err_phy_connect;
}
if (priv->is_aspeed) {
err = ftgmac100_setup_clk(priv);
if (err)