]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: mdio: realtek-rtl9300: Add registers for high port count models
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Wed, 10 Jun 2026 19:41:44 +0000 (21:41 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 13 Jun 2026 00:24:11 +0000 (17:24 -0700)
The high port count models of the Realtek Otto switches have additional
registers to instrument the MDIO controller. These are:

- High port mask: A bitfield that extends the already existing low port
  mask to select ports starting from 32.
- Broadcast: This takes the port number during reads on the RTL931x.
- Extended page: Some additional page info. The SDK does not give much
  information about this. Basically some fixed value must be written
  into it during access.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://patch.msgid.link/20260610194145.4153668-5-markus.stockhausen@gmx.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/mdio/mdio-realtek-rtl9300.c

index 5aa447ed6424db1a7708e7aefae1baad101eda4c..1cdf2049cfa52b6f2bfbee1750e2db108082d45d 100644 (file)
@@ -91,6 +91,10 @@ struct otto_emdio_cmd_regs {
        u32 c45_data;
        u32 io_data;
        u32 port_mask_low;
+       /* additional registers for high port count models RTL839x/RTL931x */
+       u32 port_mask_high;
+       u32 broadcast;
+       u32 ext_page;
 };
 
 struct otto_emdio_priv {
@@ -164,6 +168,22 @@ static int otto_emdio_run_cmd(struct mii_bus *bus, u32 cmd,
                return ret;
 
        /* Fill all registers. Hardware will read only the needed bits depending on command */
+       if (info->cmd_regs.port_mask_high) {
+               /* Fill extra registers for high port count models */
+               ret = regmap_write(priv->regmap, info->cmd_regs.broadcast, cmd_data->broadcast);
+               if (ret)
+                       return ret;
+
+               ret = regmap_write(priv->regmap, info->cmd_regs.ext_page, cmd_data->ext_page);
+               if (ret)
+                       return ret;
+
+               ret = regmap_write(priv->regmap,
+                                  info->cmd_regs.port_mask_high, cmd_data->port_mask_high);
+               if (ret)
+                       return ret;
+       }
+
        ret = regmap_write(priv->regmap, info->cmd_regs.port_mask_low, cmd_data->port_mask_low);
        if (ret)
                return ret;