Skip to content

Commit

Permalink
net: dsa: microchip: add support for common phylink mac link up
Browse files Browse the repository at this point in the history
This patch add the support for common phylink mac link up for the ksz
series switch. The register address, bit position and values are
configured based on the chip id to the dev->info structure.

Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Arun Ramadoss authored and David S. Miller committed Jul 27, 2022
1 parent 8560664 commit da8cd08
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 33 deletions.
20 changes: 16 additions & 4 deletions drivers/net/dsa/microchip/ksz_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ static const struct ksz_dev_ops lan937x_dev_ops = {
.mirror_del = ksz9477_port_mirror_del,
.get_caps = lan937x_phylink_get_caps,
.phylink_mac_config = lan937x_phylink_mac_config,
.phylink_mac_link_up = lan937x_phylink_mac_link_up,
.fdb_dump = ksz9477_fdb_dump,
.fdb_add = ksz9477_fdb_add,
.fdb_del = ksz9477_fdb_del,
Expand Down Expand Up @@ -1467,7 +1466,7 @@ static void ksz_set_100_10mbit(struct ksz_device *dev, int port, int speed)
ksz_pwrite8(dev, port, regs[P_XMII_CTRL_0], data8);
}

void ksz_port_set_xmii_speed(struct ksz_device *dev, int port, int speed)
static void ksz_port_set_xmii_speed(struct ksz_device *dev, int port, int speed)
{
if (speed == SPEED_1000)
ksz_set_gbit(dev, port, true);
Expand All @@ -1478,8 +1477,8 @@ void ksz_port_set_xmii_speed(struct ksz_device *dev, int port, int speed)
ksz_set_100_10mbit(dev, port, speed);
}

void ksz_duplex_flowctrl(struct ksz_device *dev, int port, int duplex,
bool tx_pause, bool rx_pause)
static void ksz_duplex_flowctrl(struct ksz_device *dev, int port, int duplex,
bool tx_pause, bool rx_pause)
{
const u8 *bitval = dev->info->xmii_ctrl0;
const u32 *masks = dev->info->masks;
Expand Down Expand Up @@ -1511,6 +1510,19 @@ static void ksz_phylink_mac_link_up(struct dsa_switch *ds, int port,
int duplex, bool tx_pause, bool rx_pause)
{
struct ksz_device *dev = ds->priv;
struct ksz_port *p;

p = &dev->ports[port];

/* Internal PHYs */
if (dev->info->internal_phy[port])
return;

p->phydev.speed = speed;

ksz_port_set_xmii_speed(dev, port, speed);

ksz_duplex_flowctrl(dev, port, duplex, tx_pause, rx_pause);

if (dev->dev_ops->phylink_mac_link_up)
dev->dev_ops->phylink_mac_link_up(dev, port, mode, interface,
Expand Down
3 changes: 0 additions & 3 deletions drivers/net/dsa/microchip/ksz_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,6 @@ void ksz_r_mib_stats64(struct ksz_device *dev, int port);
void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state);
bool ksz_get_gbit(struct ksz_device *dev, int port);
void ksz_set_gbit(struct ksz_device *dev, int port, bool gbit);
void ksz_port_set_xmii_speed(struct ksz_device *dev, int port, int speed);
void ksz_duplex_flowctrl(struct ksz_device *dev, int port, int duplex,
bool tx_pause, bool rx_pause);
extern const struct ksz_chip_data ksz_switch_chips[];

/* Common register access functions */
Expand Down
4 changes: 0 additions & 4 deletions drivers/net/dsa/microchip/lan937x.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ void lan937x_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val);
int lan937x_change_mtu(struct ksz_device *dev, int port, int new_mtu);
void lan937x_phylink_get_caps(struct ksz_device *dev, int port,
struct phylink_config *config);
void lan937x_phylink_mac_link_up(struct ksz_device *dev, int port,
unsigned int mode, phy_interface_t interface,
struct phy_device *phydev, int speed,
int duplex, bool tx_pause, bool rx_pause);
void lan937x_phylink_mac_config(struct ksz_device *dev, int port,
unsigned int mode,
const struct phylink_link_state *state);
Expand Down
22 changes: 0 additions & 22 deletions drivers/net/dsa/microchip/lan937x_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,6 @@ static void lan937x_mac_config(struct ksz_device *dev, int port,
ksz_pwrite8(dev, port, REG_PORT_XMII_CTRL_1, data8);
}

static void lan937x_config_interface(struct ksz_device *dev, int port,
int speed, int duplex,
bool tx_pause, bool rx_pause)
{
ksz_port_set_xmii_speed(dev, port, speed);

ksz_duplex_flowctrl(dev, port, duplex, tx_pause, rx_pause);
}

void lan937x_phylink_get_caps(struct ksz_device *dev, int port,
struct phylink_config *config)
{
Expand All @@ -366,19 +357,6 @@ void lan937x_phylink_get_caps(struct ksz_device *dev, int port,
}
}

void lan937x_phylink_mac_link_up(struct ksz_device *dev, int port,
unsigned int mode, phy_interface_t interface,
struct phy_device *phydev, int speed,
int duplex, bool tx_pause, bool rx_pause)
{
/* Internal PHYs */
if (dev->info->internal_phy[port])
return;

lan937x_config_interface(dev, port, speed, duplex,
tx_pause, rx_pause);
}

void lan937x_phylink_mac_config(struct ksz_device *dev, int port,
unsigned int mode,
const struct phylink_link_state *state)
Expand Down

0 comments on commit da8cd08

Please sign in to comment.