net: dsa: microchip: lan937x: add support for configuing xMII register

This patch add the common ksz_set_xmii function for ksz series switch
and update the lan937x code phylink mac config. The register address for
the ksz8795 is Port 5 Interface control 6 and for all other switch is
xMII Control 1.
The bit value for selecting the interface is same for
KSZ8795 and KSZ9893 are same. The bit values for KSZ9477 and lan973x are
same. So, this patch add the bit value for each switches in
ksz_chip_data and configure the registers based on the chip id.

Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Arun Ramadoss
2022-07-24 14:58:19 +05:30
committed by David S. Miller
parent da8cd08520
commit dc1c596edb
4 changed files with 53 additions and 40 deletions

View File

@@ -315,36 +315,6 @@ int lan937x_change_mtu(struct ksz_device *dev, int port, int new_mtu)
return 0;
}
static void lan937x_mac_config(struct ksz_device *dev, int port,
phy_interface_t interface)
{
u8 data8;
ksz_pread8(dev, port, REG_PORT_XMII_CTRL_1, &data8);
/* clear MII selection & set it based on interface later */
data8 &= ~PORT_MII_SEL_M;
/* configure MAC based on interface */
switch (interface) {
case PHY_INTERFACE_MODE_MII:
ksz_set_gbit(dev, port, false);
data8 |= PORT_MII_SEL;
break;
case PHY_INTERFACE_MODE_RMII:
ksz_set_gbit(dev, port, false);
data8 |= PORT_RMII_SEL;
break;
default:
dev_err(dev->dev, "Unsupported interface '%s' for port %d\n",
phy_modes(interface), port);
return;
}
/* Write the updated value */
ksz_pwrite8(dev, port, REG_PORT_XMII_CTRL_1, data8);
}
void lan937x_phylink_get_caps(struct ksz_device *dev, int port,
struct phylink_config *config)
{
@@ -370,7 +340,7 @@ void lan937x_phylink_mac_config(struct ksz_device *dev, int port,
return;
}
lan937x_mac_config(dev, port, state->interface);
ksz_set_xmii(dev, port, state->interface);
}
int lan937x_setup(struct dsa_switch *ds)