]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: dsa: lantiq_gswip: introduce bitmap for MII ports
authorDaniel Golle <daniel@makrotopia.org>
Fri, 22 Aug 2025 16:11:57 +0000 (17:11 +0100)
committerJakub Kicinski <kuba@kernel.org>
Mon, 25 Aug 2025 22:15:45 +0000 (15:15 -0700)
Instead of relying on hard-coded numbers for MII ports, introduce
a bitmap for MII ports.
This is done in order to prepare for supporting MaxLinear GSW1xx ICs
which got a different layout of ports.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Link: https://patch.msgid.link/019fc8ed06f2317976eac143320d1dc046e8f392.1755878232.git.daniel@makrotopia.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/lantiq_gswip.c
drivers/net/dsa/lantiq_gswip.h

index bd6ea4341f0baaf809f708a132b96b89a8ebad3a..dfb2c5f627f673095825593c25275836661aa4d5 100644 (file)
@@ -183,14 +183,20 @@ static void gswip_mii_mask(struct gswip_priv *priv, u32 clear, u32 set,
 static void gswip_mii_mask_cfg(struct gswip_priv *priv, u32 clear, u32 set,
                               int port)
 {
-       /* There's no MII_CFG register for the CPU port */
-       if (!dsa_is_cpu_port(priv->ds, port))
-               gswip_mii_mask(priv, clear, set, GSWIP_MII_CFGp(port));
+       /* MII_CFG register only exists for MII ports */
+       if (!(priv->hw_info->mii_ports & BIT(port)))
+               return;
+
+       gswip_mii_mask(priv, clear, set, GSWIP_MII_CFGp(port));
 }
 
 static void gswip_mii_mask_pcdu(struct gswip_priv *priv, u32 clear, u32 set,
                                int port)
 {
+       /* MII_PCDU register only exists for MII ports */
+       if (!(priv->hw_info->mii_ports & BIT(port)))
+               return;
+
        switch (port) {
        case 0:
                gswip_mii_mask(priv, clear, set, GSWIP_MII_PCDU0);
@@ -1992,12 +1998,14 @@ static void gswip_shutdown(struct platform_device *pdev)
 static const struct gswip_hw_info gswip_xrx200 = {
        .max_ports = 7,
        .allowed_cpu_ports = BIT(6),
+       .mii_ports = BIT(0) | BIT(1) | BIT(5),
        .phylink_get_caps = gswip_xrx200_phylink_get_caps,
 };
 
 static const struct gswip_hw_info gswip_xrx300 = {
        .max_ports = 7,
        .allowed_cpu_ports = BIT(6),
+       .mii_ports = BIT(0) | BIT(5),
        .phylink_get_caps = gswip_xrx300_phylink_get_caps,
 };
 
index 8703c947028a64cb75f89e686f75d41580d98099..1bd05348f1e1d3ae57c065ce20842705a44c4b2a 100644 (file)
 struct gswip_hw_info {
        int max_ports;
        unsigned int allowed_cpu_ports;
+       unsigned int mii_ports;
        void (*phylink_get_caps)(struct dsa_switch *ds, int port,
                                 struct phylink_config *config);
 };