Skip to content

Commit dfca93e

Browse files
colin-foster-in-advantagedavem330
authored andcommitted
net: mscc: ocelot: expose serdes configuration function
During chip initialization, ports that use SGMII / QSGMII to interface to external phys need to be configured on the VSC7513 and VSC7514. Expose this configuration routine, so it can be used by DSA drivers. Signed-off-by: Colin Foster <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 69f7f89 commit dfca93e

File tree

3 files changed

+47
-26
lines changed

3 files changed

+47
-26
lines changed

drivers/net/ethernet/mscc/ocelot.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/dsa/ocelot.h>
88
#include <linux/if_bridge.h>
99
#include <linux/iopoll.h>
10+
#include <linux/phy/phy.h>
1011
#include <soc/mscc/ocelot_hsio.h>
1112
#include <soc/mscc/ocelot_vcap.h>
1213
#include "ocelot.h"
@@ -809,6 +810,45 @@ static int ocelot_port_flush(struct ocelot *ocelot, int port)
809810
return err;
810811
}
811812

813+
int ocelot_port_configure_serdes(struct ocelot *ocelot, int port,
814+
struct device_node *portnp)
815+
{
816+
struct ocelot_port *ocelot_port = ocelot->ports[port];
817+
struct device *dev = ocelot->dev;
818+
int err;
819+
820+
/* Ensure clock signals and speed are set on all QSGMII links */
821+
if (ocelot_port->phy_mode == PHY_INTERFACE_MODE_QSGMII)
822+
ocelot_port_rmwl(ocelot_port, 0,
823+
DEV_CLOCK_CFG_MAC_TX_RST |
824+
DEV_CLOCK_CFG_MAC_RX_RST,
825+
DEV_CLOCK_CFG);
826+
827+
if (ocelot_port->phy_mode != PHY_INTERFACE_MODE_INTERNAL) {
828+
struct phy *serdes = of_phy_get(portnp, NULL);
829+
830+
if (IS_ERR(serdes)) {
831+
err = PTR_ERR(serdes);
832+
dev_err_probe(dev, err,
833+
"missing SerDes phys for port %d\n",
834+
port);
835+
return err;
836+
}
837+
838+
err = phy_set_mode_ext(serdes, PHY_MODE_ETHERNET,
839+
ocelot_port->phy_mode);
840+
of_phy_put(serdes);
841+
if (err) {
842+
dev_err(dev, "Could not SerDes mode on port %d: %pe\n",
843+
port, ERR_PTR(err));
844+
return err;
845+
}
846+
}
847+
848+
return 0;
849+
}
850+
EXPORT_SYMBOL_GPL(ocelot_port_configure_serdes);
851+
812852
void ocelot_phylink_mac_config(struct ocelot *ocelot, int port,
813853
unsigned int link_an_mode,
814854
const struct phylink_link_state *state)

drivers/net/ethernet/mscc/ocelot_net.c

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,34 +1742,11 @@ static int ocelot_port_phylink_create(struct ocelot *ocelot, int port,
17421742
return -EINVAL;
17431743
}
17441744

1745-
/* Ensure clock signals and speed are set on all QSGMII links */
1746-
if (phy_mode == PHY_INTERFACE_MODE_QSGMII)
1747-
ocelot_port_rmwl(ocelot_port, 0,
1748-
DEV_CLOCK_CFG_MAC_TX_RST |
1749-
DEV_CLOCK_CFG_MAC_RX_RST,
1750-
DEV_CLOCK_CFG);
1751-
17521745
ocelot_port->phy_mode = phy_mode;
17531746

1754-
if (phy_mode != PHY_INTERFACE_MODE_INTERNAL) {
1755-
struct phy *serdes = of_phy_get(portnp, NULL);
1756-
1757-
if (IS_ERR(serdes)) {
1758-
err = PTR_ERR(serdes);
1759-
dev_err_probe(dev, err,
1760-
"missing SerDes phys for port %d\n",
1761-
port);
1762-
return err;
1763-
}
1764-
1765-
err = phy_set_mode_ext(serdes, PHY_MODE_ETHERNET, phy_mode);
1766-
of_phy_put(serdes);
1767-
if (err) {
1768-
dev_err(dev, "Could not SerDes mode on port %d: %pe\n",
1769-
port, ERR_PTR(err));
1770-
return err;
1771-
}
1772-
}
1747+
err = ocelot_port_configure_serdes(ocelot, port, portnp);
1748+
if (err)
1749+
return err;
17731750

17741751
priv = container_of(ocelot_port, struct ocelot_port_private, port);
17751752

include/soc/mscc/ocelot.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ enum ocelot_tag_prefix {
644644
};
645645

646646
struct ocelot;
647+
struct device_node;
647648

648649
struct ocelot_ops {
649650
struct net_device *(*port_to_netdev)(struct ocelot *ocelot, int port);
@@ -1111,6 +1112,9 @@ int ocelot_sb_occ_tc_port_bind_get(struct ocelot *ocelot, int port,
11111112
enum devlink_sb_pool_type pool_type,
11121113
u32 *p_cur, u32 *p_max);
11131114

1115+
int ocelot_port_configure_serdes(struct ocelot *ocelot, int port,
1116+
struct device_node *portnp);
1117+
11141118
void ocelot_phylink_mac_config(struct ocelot *ocelot, int port,
11151119
unsigned int link_an_mode,
11161120
const struct phylink_link_state *state);

0 commit comments

Comments
 (0)