]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: dsa: b53: detect BCM5325 variants
authorÁlvaro Fernández Rojas <noltari@gmail.com>
Sat, 14 Jun 2025 07:59:50 +0000 (09:59 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 18 Jun 2025 00:52:06 +0000 (17:52 -0700)
We need to be able to differentiate the BCM5325 variants because:
- BCM5325M switches lack the ARLIO_PAGE->VLAN_ID_IDX register.
- BCM5325E have less 512 ARL buckets instead of 1024.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20250614080000.1884236-5-noltari@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/b53/b53_common.c
drivers/net/dsa/b53/b53_priv.h

index 9a038992f043c9ade7074d29baafe2124787097e..a7c75f44369a9b43055f65f3333c822cb246c4b6 100644 (file)
@@ -1778,7 +1778,8 @@ static int b53_arl_op(struct b53_device *dev, int op, int port,
 
        /* Perform a read for the given MAC and VID */
        b53_write48(dev, B53_ARLIO_PAGE, B53_MAC_ADDR_IDX, mac);
-       b53_write16(dev, B53_ARLIO_PAGE, B53_VLAN_ID_IDX, vid);
+       if (!is5325m(dev))
+               b53_write16(dev, B53_ARLIO_PAGE, B53_VLAN_ID_IDX, vid);
 
        /* Issue a read operation for this MAC */
        ret = b53_arl_rw_op(dev, 1);
@@ -2833,6 +2834,9 @@ static int b53_switch_init(struct b53_device *dev)
                }
        }
 
+       if (is5325e(dev))
+               dev->num_arl_buckets = 512;
+
        dev->num_ports = fls(dev->enabled_ports);
 
        dev->ds->num_ports = min_t(unsigned int, dev->num_ports, DSA_MAX_PORTS);
@@ -2934,10 +2938,24 @@ int b53_switch_detect(struct b53_device *dev)
                b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_TABLE_ACCESS_25, 0xf);
                b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_TABLE_ACCESS_25, &tmp);
 
-               if (tmp == 0xf)
+               if (tmp == 0xf) {
+                       u32 phy_id;
+                       int val;
+
                        dev->chip_id = BCM5325_DEVICE_ID;
-               else
+
+                       val = b53_phy_read16(dev->ds, 0, MII_PHYSID1);
+                       phy_id = (val & 0xffff) << 16;
+                       val = b53_phy_read16(dev->ds, 0, MII_PHYSID2);
+                       phy_id |= (val & 0xfff0);
+
+                       if (phy_id == 0x00406330)
+                               dev->variant_id = B53_VARIANT_5325M;
+                       else if (phy_id == 0x0143bc30)
+                               dev->variant_id = B53_VARIANT_5325E;
+               } else {
                        dev->chip_id = BCM5365_DEVICE_ID;
+               }
                break;
        case BCM5389_DEVICE_ID:
        case BCM5395_DEVICE_ID:
index a5ef7071ba07b118f052c19dd3caf8f10b3114c9..e8689410b5d00d5c0bc6550b47922419d4e5ef41 100644 (file)
@@ -84,6 +84,12 @@ enum {
        BCM53134_DEVICE_ID = 0x5075,
 };
 
+enum b53_variant_id {
+       B53_VARIANT_NONE = 0,
+       B53_VARIANT_5325E,
+       B53_VARIANT_5325M,
+};
+
 struct b53_pcs {
        struct phylink_pcs pcs;
        struct b53_device *dev;
@@ -118,6 +124,7 @@ struct b53_device {
 
        /* chip specific data */
        u32 chip_id;
+       enum b53_variant_id variant_id;
        u8 core_rev;
        u8 vta_regs[3];
        u8 duplex_reg;
@@ -165,6 +172,18 @@ static inline int is5325(struct b53_device *dev)
        return dev->chip_id == BCM5325_DEVICE_ID;
 }
 
+static inline int is5325e(struct b53_device *dev)
+{
+       return is5325(dev) &&
+               dev->variant_id == B53_VARIANT_5325E;
+}
+
+static inline int is5325m(struct b53_device *dev)
+{
+       return is5325(dev) &&
+               dev->variant_id == B53_VARIANT_5325M;
+}
+
 static inline int is5365(struct b53_device *dev)
 {
 #ifdef CONFIG_BCM47XX