]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: dsa: microchip: lan9371/2: update MAC capabilities for port 4
authorOleksij Rempel <o.rempel@pengutronix.de>
Fri, 5 Jul 2024 08:47:15 +0000 (10:47 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Jul 2024 12:41:56 +0000 (13:41 +0100)
Set proper MAC capabilities for port 4 on LAN9371 and LAN9372 switches with
integrated 100BaseTX PHY. And introduce the is_lan937x_tx_phy() function to
reuse it where applicable.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Acked-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/microchip/ksz_common.h
drivers/net/dsa/microchip/lan937x_main.c

index c4a4664c0385984c7e7082737659401b0ef9b252..5f0a628b9849e8fceeace0d92f602ff583bca45a 100644 (file)
@@ -638,6 +638,12 @@ static inline int is_lan937x(struct ksz_device *dev)
                dev->chip_id == LAN9374_CHIP_ID;
 }
 
+static inline bool is_lan937x_tx_phy(struct ksz_device *dev, int port)
+{
+       return (dev->chip_id == LAN9371_CHIP_ID ||
+               dev->chip_id == LAN9372_CHIP_ID) && port == KSZ_PORT_4;
+}
+
 /* STP State Defines */
 #define PORT_TX_ENABLE                 BIT(2)
 #define PORT_RX_ENABLE                 BIT(1)
index 83ac33fede3f56f52c22b7984e34b7d0e257a7ba..824d9309a3d35ee08165bc9bc8e1d969f834fa70 100644 (file)
@@ -55,8 +55,7 @@ static int lan937x_vphy_ind_addr_wr(struct ksz_device *dev, int addr, int reg)
        u16 addr_base = REG_PORT_T1_PHY_CTRL_BASE;
        u16 temp;
 
-       if ((dev->info->chip_id == LAN9371_CHIP_ID ||
-            dev->info->chip_id == LAN9372_CHIP_ID) && addr == KSZ_PORT_4)
+       if (is_lan937x_tx_phy(dev, addr))
                addr_base = REG_PORT_TX_PHY_CTRL_BASE;
 
        /* get register address based on the logical port */
@@ -324,6 +323,9 @@ void lan937x_phylink_get_caps(struct ksz_device *dev, int port,
                /* MII/RMII/RGMII ports */
                config->mac_capabilities |= MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
                                            MAC_100HD | MAC_10 | MAC_1000FD;
+       } else if (is_lan937x_tx_phy(dev, port)) {
+               config->mac_capabilities |= MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
+                                           MAC_100HD | MAC_10;
        }
 }