aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/dsa/microchip/lan937x_main.c
diff options
context:
space:
mode:
authorArun Ramadoss <[email protected]>2022-07-24 09:28:15 +0000
committerDavid S. Miller <[email protected]>2022-07-27 08:39:16 +0000
commit46f80fa8981bcbb0ab522b34c919d0186a0cff02 (patch)
treeb451e4f0c176b1c065802c600fb95bbfbbf4ae05 /drivers/net/dsa/microchip/lan937x_main.c
parentselftests: net: Fix typo 'the the' in comment (diff)
downloadkernel-46f80fa8981bcbb0ab522b34c919d0186a0cff02.tar.gz
kernel-46f80fa8981bcbb0ab522b34c919d0186a0cff02.zip
net: dsa: microchip: add common gigabit set and get function
This patch add helper function for setting and getting the gigabit enable for the ksz series switch. KSZ8795 switch has different register address compared to all other ksz switches. KSZ8795 series uses the Port 5 Interface control 6 Bit 6 for configuring the 1Gbps or 100/10Mbps speed selection. All other switches uses the xMII control 1 0xN301 register Bit6 for gigabit. Further, for KSZ8795 & KSZ9893 switches if bit 1 then 1Gbps is chosen and if bit 0 then 100/10Mbps is chosen. It is other way around for other switches bit 0 is for 1Gbps. So, this patch implements the common function for configuring the gigabit set and get capability. Signed-off-by: Arun Ramadoss <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
Diffstat (limited to 'drivers/net/dsa/microchip/lan937x_main.c')
-rw-r--r--drivers/net/dsa/microchip/lan937x_main.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c
index c29d175ca6f7..efca96b02e15 100644
--- a/drivers/net/dsa/microchip/lan937x_main.c
+++ b/drivers/net/dsa/microchip/lan937x_main.c
@@ -312,14 +312,6 @@ int lan937x_change_mtu(struct ksz_device *dev, int port, int new_mtu)
return 0;
}
-static void lan937x_config_gbit(struct ksz_device *dev, bool gbit, u8 *data)
-{
- if (gbit)
- *data &= ~PORT_MII_NOT_1GBIT;
- else
- *data |= PORT_MII_NOT_1GBIT;
-}
-
static void lan937x_mac_config(struct ksz_device *dev, int port,
phy_interface_t interface)
{
@@ -333,11 +325,11 @@ static void lan937x_mac_config(struct ksz_device *dev, int port,
/* configure MAC based on interface */
switch (interface) {
case PHY_INTERFACE_MODE_MII:
- lan937x_config_gbit(dev, false, &data8);
+ ksz_set_gbit(dev, port, false);
data8 |= PORT_MII_SEL;
break;
case PHY_INTERFACE_MODE_RMII:
- lan937x_config_gbit(dev, false, &data8);
+ ksz_set_gbit(dev, port, false);
data8 |= PORT_RMII_SEL;
break;
default:
@@ -363,9 +355,9 @@ static void lan937x_config_interface(struct ksz_device *dev, int port,
PORT_MII_TX_FLOW_CTRL | PORT_MII_RX_FLOW_CTRL);
if (speed == SPEED_1000)
- lan937x_config_gbit(dev, true, &xmii_ctrl1);
+ ksz_set_gbit(dev, port, true);
else
- lan937x_config_gbit(dev, false, &xmii_ctrl1);
+ ksz_set_gbit(dev, port, false);
if (speed == SPEED_100)
xmii_ctrl0 |= PORT_MII_100MBIT;