Skip to content

Commit 69f7f89

Browse files
colin-foster-in-advantagedavem330
authored andcommitted
net: mscc: ocelot: expose generic phylink_mac_config routine
The ocelot-switch driver can utilize the phylink_mac_config routine. Move this to the ocelot library location and export the symbol to make this possible. Signed-off-by: Colin Foster <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fec53f4 commit 69f7f89

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

drivers/net/ethernet/mscc/ocelot.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,32 @@ static int ocelot_port_flush(struct ocelot *ocelot, int port)
809809
return err;
810810
}
811811

812+
void ocelot_phylink_mac_config(struct ocelot *ocelot, int port,
813+
unsigned int link_an_mode,
814+
const struct phylink_link_state *state)
815+
{
816+
struct ocelot_port *ocelot_port = ocelot->ports[port];
817+
818+
/* Disable HDX fast control */
819+
ocelot_port_writel(ocelot_port, DEV_PORT_MISC_HDX_FAST_DIS,
820+
DEV_PORT_MISC);
821+
822+
/* SGMII only for now */
823+
ocelot_port_writel(ocelot_port, PCS1G_MODE_CFG_SGMII_MODE_ENA,
824+
PCS1G_MODE_CFG);
825+
ocelot_port_writel(ocelot_port, PCS1G_SD_CFG_SD_SEL, PCS1G_SD_CFG);
826+
827+
/* Enable PCS */
828+
ocelot_port_writel(ocelot_port, PCS1G_CFG_PCS_ENA, PCS1G_CFG);
829+
830+
/* No aneg on SGMII */
831+
ocelot_port_writel(ocelot_port, 0, PCS1G_ANEG_CFG);
832+
833+
/* No loopback */
834+
ocelot_port_writel(ocelot_port, 0, PCS1G_LB_CFG);
835+
}
836+
EXPORT_SYMBOL_GPL(ocelot_phylink_mac_config);
837+
812838
void ocelot_phylink_mac_link_down(struct ocelot *ocelot, int port,
813839
unsigned int link_an_mode,
814840
phy_interface_t interface,

drivers/net/ethernet/mscc/ocelot_net.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,25 +1675,10 @@ static void vsc7514_phylink_mac_config(struct phylink_config *config,
16751675
{
16761676
struct net_device *ndev = to_net_dev(config->dev);
16771677
struct ocelot_port_private *priv = netdev_priv(ndev);
1678-
struct ocelot_port *ocelot_port = &priv->port;
1679-
1680-
/* Disable HDX fast control */
1681-
ocelot_port_writel(ocelot_port, DEV_PORT_MISC_HDX_FAST_DIS,
1682-
DEV_PORT_MISC);
1683-
1684-
/* SGMII only for now */
1685-
ocelot_port_writel(ocelot_port, PCS1G_MODE_CFG_SGMII_MODE_ENA,
1686-
PCS1G_MODE_CFG);
1687-
ocelot_port_writel(ocelot_port, PCS1G_SD_CFG_SD_SEL, PCS1G_SD_CFG);
1688-
1689-
/* Enable PCS */
1690-
ocelot_port_writel(ocelot_port, PCS1G_CFG_PCS_ENA, PCS1G_CFG);
1691-
1692-
/* No aneg on SGMII */
1693-
ocelot_port_writel(ocelot_port, 0, PCS1G_ANEG_CFG);
1678+
struct ocelot *ocelot = priv->port.ocelot;
1679+
int port = priv->port.index;
16941680

1695-
/* No loopback */
1696-
ocelot_port_writel(ocelot_port, 0, PCS1G_LB_CFG);
1681+
ocelot_phylink_mac_config(ocelot, port, link_an_mode, state);
16971682
}
16981683

16991684
static void vsc7514_phylink_mac_link_down(struct phylink_config *config,

include/soc/mscc/ocelot.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,9 @@ int ocelot_sb_occ_tc_port_bind_get(struct ocelot *ocelot, int port,
11111111
enum devlink_sb_pool_type pool_type,
11121112
u32 *p_cur, u32 *p_max);
11131113

1114+
void ocelot_phylink_mac_config(struct ocelot *ocelot, int port,
1115+
unsigned int link_an_mode,
1116+
const struct phylink_link_state *state);
11141117
void ocelot_phylink_mac_link_down(struct ocelot *ocelot, int port,
11151118
unsigned int link_an_mode,
11161119
phy_interface_t interface,

0 commit comments

Comments
 (0)