Commit af350ee7 authored by Jacky Chou's avatar Jacky Chou Committed by Jakub Kicinski
Browse files

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: default avatarJacky Chou <jacky_chou@aspeedtech.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20250709070809.2560688-5-jacky_chou@aspeedtech.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 4dc5f7b2
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -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)