aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/dsa/microchip/lan937x_main.c
diff options
context:
space:
mode:
authorArun Ramadoss <[email protected]>2022-07-24 09:28:16 +0000
committerDavid S. Miller <[email protected]>2022-07-27 08:39:17 +0000
commitaa5b8b73d4bd34618508165bc0e5b7eb4b7c2c20 (patch)
tree33e4bf8185606148c612a1a23bad0c815d9bf38a /drivers/net/dsa/microchip/lan937x_main.c
parentnet: dsa: microchip: add common gigabit set and get function (diff)
downloadkernel-aa5b8b73d4bd34618508165bc0e5b7eb4b7c2c20.tar.gz
kernel-aa5b8b73d4bd34618508165bc0e5b7eb4b7c2c20.zip
net: dsa: microchip: add common ksz port xmii speed selection function
This patch adds the function for configuring the 100/10Mbps speed selection for the ksz switches. KSZ8795 switch uses Global control 4 register 0x06 bit 4 for choosing 100/10Mpbs. Other switches uses xMII control 1 0xN300 for it. For KSZ8795, if the bit is set then 10Mbps is chosen and if bit is clear then 100Mbps chosen. For all other switches it is other way around, if the bit is set then 100Mbps is chosen. So, this patch add the generic function for ksz switch to select the 100/10Mbps speed selection. While configuring, first it disables the gigabit functionality and then configure the respective speed. Signed-off-by: Arun Ramadoss <[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.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c
index efca96b02e15..c48bae285758 100644
--- a/drivers/net/dsa/microchip/lan937x_main.c
+++ b/drivers/net/dsa/microchip/lan937x_main.c
@@ -346,21 +346,14 @@ static void lan937x_config_interface(struct ksz_device *dev, int port,
int speed, int duplex,
bool tx_pause, bool rx_pause)
{
- u8 xmii_ctrl0, xmii_ctrl1;
+ u8 xmii_ctrl0;
- ksz_pread8(dev, port, REG_PORT_XMII_CTRL_0, &xmii_ctrl0);
- ksz_pread8(dev, port, REG_PORT_XMII_CTRL_1, &xmii_ctrl1);
-
- xmii_ctrl0 &= ~(PORT_MII_100MBIT | PORT_MII_FULL_DUPLEX |
- PORT_MII_TX_FLOW_CTRL | PORT_MII_RX_FLOW_CTRL);
+ ksz_port_set_xmii_speed(dev, port, speed);
- if (speed == SPEED_1000)
- ksz_set_gbit(dev, port, true);
- else
- ksz_set_gbit(dev, port, false);
+ ksz_pread8(dev, port, REG_PORT_XMII_CTRL_0, &xmii_ctrl0);
- if (speed == SPEED_100)
- xmii_ctrl0 |= PORT_MII_100MBIT;
+ xmii_ctrl0 &= ~(PORT_MII_FULL_DUPLEX | PORT_MII_TX_FLOW_CTRL |
+ PORT_MII_RX_FLOW_CTRL);
if (duplex)
xmii_ctrl0 |= PORT_MII_FULL_DUPLEX;
@@ -372,7 +365,6 @@ static void lan937x_config_interface(struct ksz_device *dev, int port,
xmii_ctrl0 |= PORT_MII_RX_FLOW_CTRL;
ksz_pwrite8(dev, port, REG_PORT_XMII_CTRL_0, xmii_ctrl0);
- ksz_pwrite8(dev, port, REG_PORT_XMII_CTRL_1, xmii_ctrl1);
}
void lan937x_phylink_get_caps(struct ksz_device *dev, int port,