summaryrefslogtreecommitdiff
path: root/drivers/net/dsa/microchip/lan937x_main.c
diff options
context:
space:
mode:
authorArun Ramadoss <arun.ramadoss@microchip.com>2022-07-24 14:58:15 +0530
committerDavid S. Miller <davem@davemloft.net>2022-07-27 09:39:16 +0100
commit46f80fa8981bcbb0ab522b34c919d0186a0cff02 (patch)
treeb451e4f0c176b1c065802c600fb95bbfbbf4ae05 /drivers/net/dsa/microchip/lan937x_main.c
parent060468f0ddbbd3396944ad234077e44af1841efc (diff)
downloadlinux-46f80fa8981bcbb0ab522b34c919d0186a0cff02.tar.gz
linux-46f80fa8981bcbb0ab522b34c919d0186a0cff02.tar.bz2
linux-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 <arun.ramadoss@microchip.com> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
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;