summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2019-03-08 16:46:50 +0000
committerRussell King <rmk+kernel@armlinux.org.uk>2019-07-09 12:20:56 +0100
commitb78dc79665d2debaebfc0470e74409713011c3c9 (patch)
tree16088470e3e8ac344f6ed9cace291fb4101e72d2
parent516efbc61d0cd8551a595cf4fdb264e28e4e37ce (diff)
net: marvell: mvpp2x: update mvpp2x's comphy support
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
-rw-r--r--drivers/net/ethernet/marvell/mvpp2x/mv_pp2x.h1
-rw-r--r--drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_ethtool.c51
-rw-r--r--drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_main.c67
3 files changed, 38 insertions, 81 deletions
diff --git a/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x.h b/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x.h
index ff52329701f4..eb3fe355ea31 100644
--- a/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x.h
+++ b/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x.h
@@ -628,7 +628,6 @@ struct mv_pp2x_port {
struct mv_pp2x_bm_pool *pool_short; /* Pointer to the short pool_id */
struct phy *comphy; /* comphy handler */
- enum phy_mode modes[4];
int txq_stop_limit;
u32 num_qvector;
diff --git a/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_ethtool.c b/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_ethtool.c
index c4a8316e4d63..3f8a6831de85 100644
--- a/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_ethtool.c
+++ b/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_ethtool.c
@@ -38,7 +38,6 @@
#include <net/ip.h>
#include <net/ipv6.h>
#include <linux/phy/phy.h>
-#include <dt-bindings/phy/phy-mvebu-comphy.h>
#include "mv_pp2x.h"
#include "mv_pp2x_hw.h"
@@ -556,17 +555,17 @@ void mv_pp2x_ethtool_set_gmac_config(struct mv_port_link_status status, struct g
mv_gop110_force_link_mode_set(gop, mac, false, false);
}
-int mv_pp2x_get_new_comphy_mode(const struct ethtool_link_ksettings *kset, int port_id)
+static int mv_pp2x_get_new_interface_mode(const struct ethtool_link_ksettings *kset)
{
- if (kset->base.speed == SPEED_10000 && port_id == 0)
- return COMPHY_DEF(COMPHY_SFI_MODE, port_id);
- else if (kset->base.speed == SPEED_2500)
- return COMPHY_DEF(COMPHY_HS_SGMII_MODE, port_id);
- else if (kset->base.speed == SPEED_1000 || kset->base.speed == SPEED_100 ||
- kset->base.speed == SPEED_10)
- return COMPHY_DEF(COMPHY_SGMII_MODE, port_id);
- else
- return -EINVAL;
+ if (kset->base.speed == SPEED_10000)
+ return PHY_INTERFACE_MODE_10GKR;
+ if (kset->base.speed == SPEED_2500)
+ return PHY_INTERFACE_MODE_2500BASEX;
+ if (kset->base.speed == SPEED_1000 ||
+ kset->base.speed == SPEED_100 ||
+ kset->base.speed == SPEED_10)
+ return PHY_INTERFACE_MODE_SGMII;
+ return -EINVAL;
}
void mv_pp2x_set_new_phy_mode(const struct ethtool_link_ksettings *kset, struct mv_mac_data *mac)
@@ -604,24 +603,16 @@ static int mv_pp2x_ethtool_set_link_ksettings(struct net_device *dev,
return phy_ethtool_set_link_ksettings(dev, kset);
if (port->comphy) {
- int comphy_old_mode, comphy_new_mode;
+ int new_mode;
- comphy_new_mode = mv_pp2x_get_new_comphy_mode(kset, port->id);
+ new_mode = mv_pp2x_get_new_interface_mode(kset);
- if (comphy_new_mode < 0) {
+ if (new_mode < 0) {
pr_err("Port ID %d: unsupported speed set\n", port->id);
- return comphy_new_mode;
+ return new_mode;
}
- comphy_old_mode = phy_get_mode(port->comphy);
-
- if (comphy_old_mode != comphy_new_mode) {
- err = phy_set_mode(port->comphy, comphy_new_mode);
- if (err < 0) {
- phy_set_mode(port->comphy, comphy_old_mode);
- pr_err("Port ID %d: COMPHY lane is busy\n", port->id);
- return err;
- }
+ if (new_mode != mac->phy_mode) {
if (mac->flags & MV_EMAC_F_PORT_UP) {
netif_carrier_off(port->dev);
mv_gop110_port_events_mask(gop, mac);
@@ -629,6 +620,18 @@ static int mv_pp2x_ethtool_set_link_ksettings(struct net_device *dev,
phy_power_off(port->comphy);
}
+ err = phy_set_mode_ext(port->comphy, PHY_MODE_ETHERNET,
+ new_mode);
+ if (err < 0) {
+ pr_err("Port ID %d: COMPHY lane is busy\n", port->id);
+ if (mac->flags & MV_EMAC_F_PORT_UP) {
+ mv_gop110_port_events_unmask(gop, mac);
+ mv_gop110_port_enable(gop, mac);
+ phy_power_on(port->comphy);
+ }
+ return err;
+ }
+
mv_pp2x_set_new_phy_mode(kset, mac);
phy_mode_update = true;
}
diff --git a/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_main.c b/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_main.c
index f00e0f7bab24..9dd4c87d7ebb 100644
--- a/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2x/mv_pp2x_main.c
@@ -48,7 +48,6 @@
#include <net/busy_poll.h>
#include <asm/cacheflush.h>
#include <linux/dma-mapping.h>
-#include <dt-bindings/phy/phy-mvebu-comphy.h>
#include "mv_pp2x.h"
#include "mv_pp2x_hw.h"
@@ -1711,37 +1710,29 @@ static bool mv_pp2x_reconfig_port(struct mv_pp2x_port *port,
{
struct gop_hw *gop = &port->priv->hw.gop;
struct mv_mac_data *mac = &port->mac_data;
- unsigned int com_mode, old_mode;
u64 flags = mac->flags;
bool reconfig = false;
- com_mode = old_mode = phy_get_mode(port->comphy);
-
switch (interface) {
case PHY_INTERFACE_MODE_10GKR:
- com_mode = port->modes[0];
flags &= ~MV_EMAC_F_SGMII2_5;
break;
case PHY_INTERFACE_MODE_SGMII:
case PHY_INTERFACE_MODE_1000BASEX:
case PHY_INTERFACE_MODE_2500BASEX:
interface = PHY_INTERFACE_MODE_SGMII;
- if (sgmii_hs) {
- com_mode = port->modes[1];
+ if (sgmii_hs)
flags |= MV_EMAC_F_SGMII2_5;
- } else {
- com_mode = port->modes[2];
+ else
flags &= ~MV_EMAC_F_SGMII2_5;
- }
break;
default:
break;
}
netdev_printk(KERN_DEBUG, port->dev,
- "reconfig: pm %x->%x cm %x->%x f %llx->%llx\n",
- mac->phy_mode, interface,
- old_mode, com_mode, mac->flags, flags);
+ "reconfig: pm %x->%x f %llx->%llx\n",
+ mac->phy_mode, interface, mac->flags, flags);
if (mac->phy_mode != interface || mac->flags != flags) {
netdev_dbg(port->dev, "disabling port\n");
@@ -1751,7 +1742,7 @@ static bool mv_pp2x_reconfig_port(struct mv_pp2x_port *port,
phy_power_off(port->comphy);
netdev_dbg(port->dev, "comphy set mode\n");
- if (phy_set_mode(port->comphy, com_mode) == 0) {
+ if (phy_set_mode_ext(port->comphy, PHY_MODE_ETHERNET, interface) == 0) {
mac->phy_mode = interface;
mac->flags = flags;
} else {
@@ -3626,31 +3617,7 @@ static void mv_pp2x_port_irqs_dispose_mapping(struct mv_pp2x_port *port)
static void mv_serdes_port_init(struct mv_pp2x_port *port)
{
- int mode;
-
- switch (port->mac_data.phy_mode) {
- case PHY_INTERFACE_MODE_RGMII:
- break;
- case PHY_INTERFACE_MODE_SGMII:
- case PHY_INTERFACE_MODE_QSGMII:
- if (port->mac_data.flags & MV_EMAC_F_SGMII2_5)
- mode = port->modes[1];
- else
- mode = port->modes[2];
- phy_set_mode(port->comphy, mode);
- break;
- case PHY_INTERFACE_MODE_XAUI:
- case PHY_INTERFACE_MODE_RXAUI:
- mode = port->modes[3];
- phy_set_mode(port->comphy, mode);
- break;
- case PHY_INTERFACE_MODE_10GKR:
- mode = port->modes[0];
- phy_set_mode(port->comphy, mode);
- break;
- default:
- pr_err("%s: Wrong port mode (%d)", __func__, port->mac_data.phy_mode);
- }
+ phy_set_mode_ext(port->comphy, PHY_MODE_ETHERNET, port->mac_data.phy_mode);
}
int mvcpn110_mac_hw_init(struct mv_pp2x_port *port)
@@ -3892,18 +3859,18 @@ static int mv_pp2x_phy_connect(struct mv_pp2x_port *port)
dev_err(port->dev->dev.parent, "port ID: %d cannot connect to phy\n", port->id);
return -ENODEV;
}
- phy_dev->supported &= PHY_10BT_FEATURES |
+
+ phy_dev->supported[0] &= PHY_10BT_FEATURES |
PHY_100BT_FEATURES |
SUPPORTED_1000baseT_Full |
SUPPORTED_Autoneg | SUPPORTED_TP |
SUPPORTED_MII | SUPPORTED_FIBRE |
SUPPORTED_10000baseT_Full |
SUPPORTED_Backplane |
- SUPPORTED_Pause |
- SUPPORTED_Asym_Pause |
SUPPORTED_2500baseX_Full |
SUPPORTED_10000baseKR_Full;
- phy_dev->advertising = phy_dev->supported;
+
+ phy_support_sym_pause(phy_dev);
port->mac_data.phy_dev = phy_dev;
port->mac_data.link = 0;
@@ -4938,20 +4905,8 @@ static int mv_pp2x_port_probe(struct platform_device *pdev,
comphy = devm_of_phy_get(&pdev->dev, emac_node, "comphy");
- if (!IS_ERR(comphy)) {
+ if (!IS_ERR(comphy))
port->comphy = comphy;
- if (!strcmp(comphy->dev.parent->driver->name, "mvebu-comphy")) {
- port->modes[0] = PHY_MODE_10GKR;
- port->modes[1] = PHY_MODE_2500SGMII;
- port->modes[2] = PHY_MODE_SGMII;
- port->modes[3] = PHY_MODE_INVALID; /* no AUI modes currently supported */
- } else {
- port->modes[0] = COMPHY_DEF(COMPHY_SFI_MODE, port->id);
- port->modes[1] = COMPHY_DEF(COMPHY_HS_SGMII_MODE, port->id);;
- port->modes[2] = COMPHY_DEF(COMPHY_SGMII_MODE, port->id);
- port->modes[3] = COMPHY_DEF(COMPHY_RXAUI_MODE, port->id);
- }
- }
}
if (port->mac_data.phy_mode == PHY_INTERFACE_MODE_SGMII ||