Commit 3c783b83 authored by Russell King's avatar Russell King Committed by Jakub Kicinski

net: dsa: mv88e6xxx: get rid of SPEED_MAX setting

Currently, all the device specific speed setting functions convert
SPEED_MAX to the actual speed of the port. Rather than having each
of the mv88e6xxx chip specifics handling SPEED_MAX, derive it from
the mac_capabilities instead.

This is only needed for CPU and DSA ports, so move the logic up into
mv88e6xxx_setup_port() - which allows us to kill off all users of
SPEED_MAX throughout the driver.
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent aa64bc19
...@@ -449,9 +449,6 @@ static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, ...@@ -449,9 +449,6 @@ static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
goto restore_link; goto restore_link;
} }
if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
mode = chip->info->ops->port_max_speed_mode(port);
if (chip->info->ops->port_set_pause) { if (chip->info->ops->port_set_pause) {
err = chip->info->ops->port_set_pause(chip, port, pause); err = chip->info->ops->port_set_pause(chip, port, pause);
if (err) if (err)
...@@ -3280,28 +3277,51 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) ...@@ -3280,28 +3277,51 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
{ {
struct device_node *phy_handle = NULL; struct device_node *phy_handle = NULL;
struct dsa_switch *ds = chip->ds; struct dsa_switch *ds = chip->ds;
phy_interface_t mode;
struct dsa_port *dp; struct dsa_port *dp;
int tx_amp; int tx_amp, speed;
int err; int err;
u16 reg; u16 reg;
chip->ports[port].chip = chip; chip->ports[port].chip = chip;
chip->ports[port].port = port; chip->ports[port].port = port;
dp = dsa_to_port(ds, port);
/* MAC Forcing register: don't force link, speed, duplex or flow control /* MAC Forcing register: don't force link, speed, duplex or flow control
* state to any particular values on physical ports, but force the CPU * state to any particular values on physical ports, but force the CPU
* port and all DSA ports to their maximum bandwidth and full duplex. * port and all DSA ports to their maximum bandwidth and full duplex.
*/ */
if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) {
unsigned long caps = dp->pl_config.mac_capabilities;
if (chip->info->ops->port_max_speed_mode)
mode = chip->info->ops->port_max_speed_mode(port);
else
mode = PHY_INTERFACE_MODE_NA;
if (caps & MAC_10000FD)
speed = SPEED_10000;
else if (caps & MAC_5000FD)
speed = SPEED_5000;
else if (caps & MAC_2500FD)
speed = SPEED_2500;
else if (caps & MAC_1000)
speed = SPEED_1000;
else if (caps & MAC_100)
speed = SPEED_100;
else
speed = SPEED_10;
err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP, err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
SPEED_MAX, DUPLEX_FULL, speed, DUPLEX_FULL,
PAUSE_OFF, PAUSE_OFF, mode);
PHY_INTERFACE_MODE_NA); } else {
else
err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED, err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
SPEED_UNFORCED, DUPLEX_UNFORCED, SPEED_UNFORCED, DUPLEX_UNFORCED,
PAUSE_ON, PAUSE_ON,
PHY_INTERFACE_MODE_NA); PHY_INTERFACE_MODE_NA);
}
if (err) if (err)
return err; return err;
...@@ -3473,7 +3493,6 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) ...@@ -3473,7 +3493,6 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
} }
if (chip->info->ops->serdes_set_tx_amplitude) { if (chip->info->ops->serdes_set_tx_amplitude) {
dp = dsa_to_port(ds, port);
if (dp) if (dp)
phy_handle = of_parse_phandle(dp->dn, "phy-handle", 0); phy_handle = of_parse_phandle(dp->dn, "phy-handle", 0);
......
...@@ -488,14 +488,13 @@ struct mv88e6xxx_ops { ...@@ -488,14 +488,13 @@ struct mv88e6xxx_ops {
int (*port_set_pause)(struct mv88e6xxx_chip *chip, int port, int (*port_set_pause)(struct mv88e6xxx_chip *chip, int port,
int pause); int pause);
#define SPEED_MAX INT_MAX
#define SPEED_UNFORCED -2 #define SPEED_UNFORCED -2
#define DUPLEX_UNFORCED -2 #define DUPLEX_UNFORCED -2
/* Port's MAC speed (in Mbps) and MAC duplex mode /* Port's MAC speed (in Mbps) and MAC duplex mode
* *
* Depending on the chip, 10, 100, 200, 1000, 2500, 10000 are valid. * Depending on the chip, 10, 100, 200, 1000, 2500, 10000 are valid.
* Use SPEED_UNFORCED for normal detection, SPEED_MAX for max value. * Use SPEED_UNFORCED for normal detection.
* *
* Use DUPLEX_HALF or DUPLEX_FULL to force half or full duplex, * Use DUPLEX_HALF or DUPLEX_FULL to force half or full duplex,
* or DUPLEX_UNFORCED for normal duplex detection. * or DUPLEX_UNFORCED for normal duplex detection.
......
...@@ -298,9 +298,6 @@ static int mv88e6xxx_port_set_speed_duplex(struct mv88e6xxx_chip *chip, ...@@ -298,9 +298,6 @@ static int mv88e6xxx_port_set_speed_duplex(struct mv88e6xxx_chip *chip,
int mv88e6185_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, int mv88e6185_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
int speed, int duplex) int speed, int duplex)
{ {
if (speed == SPEED_MAX)
speed = 1000;
if (speed == 200 || speed > 1000) if (speed == 200 || speed > 1000)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -312,9 +309,6 @@ int mv88e6185_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, ...@@ -312,9 +309,6 @@ int mv88e6185_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
int mv88e6250_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, int mv88e6250_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
int speed, int duplex) int speed, int duplex)
{ {
if (speed == SPEED_MAX)
speed = 100;
if (speed > 100) if (speed > 100)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -326,9 +320,6 @@ int mv88e6250_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, ...@@ -326,9 +320,6 @@ int mv88e6250_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
int mv88e6341_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, int mv88e6341_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
int speed, int duplex) int speed, int duplex)
{ {
if (speed == SPEED_MAX)
speed = port < 5 ? 1000 : 2500;
if (speed > 2500) if (speed > 2500)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -354,9 +345,6 @@ phy_interface_t mv88e6341_port_max_speed_mode(int port) ...@@ -354,9 +345,6 @@ phy_interface_t mv88e6341_port_max_speed_mode(int port)
int mv88e6352_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, int mv88e6352_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
int speed, int duplex) int speed, int duplex)
{ {
if (speed == SPEED_MAX)
speed = 1000;
if (speed > 1000) if (speed > 1000)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -371,9 +359,6 @@ int mv88e6352_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, ...@@ -371,9 +359,6 @@ int mv88e6352_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
int mv88e6390_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, int mv88e6390_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
int speed, int duplex) int speed, int duplex)
{ {
if (speed == SPEED_MAX)
speed = port < 9 ? 1000 : 2500;
if (speed > 2500) if (speed > 2500)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -399,9 +384,6 @@ phy_interface_t mv88e6390_port_max_speed_mode(int port) ...@@ -399,9 +384,6 @@ phy_interface_t mv88e6390_port_max_speed_mode(int port)
int mv88e6390x_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, int mv88e6390x_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
int speed, int duplex) int speed, int duplex)
{ {
if (speed == SPEED_MAX)
speed = port < 9 ? 1000 : 10000;
if (speed == 200 && port != 0) if (speed == 200 && port != 0)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -430,9 +412,6 @@ int mv88e6393x_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, ...@@ -430,9 +412,6 @@ int mv88e6393x_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
u16 reg, ctrl; u16 reg, ctrl;
int err; int err;
if (speed == SPEED_MAX)
speed = (port > 0 && port < 9) ? 1000 : 10000;
if (speed == 200 && port != 0) if (speed == 200 && port != 0)
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment