]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: ftgmac100: Add optional reset control for RMII mode on Aspeed SoCs
authorJacky Chou <jacky_chou@aspeedtech.com>
Wed, 9 Jul 2025 07:08:09 +0000 (15:08 +0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 11 Jul 2025 01:13:52 +0000 (18:13 -0700)
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>
drivers/net/ethernet/faraday/ftgmac100.c

index a98d5af3f9e3c6756c95292e4d073fb7db5f1aad..05b8e3743a79f129aa06de427148a106d111714a 100644 (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)