2019-05-27 14:55:01 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2016-11-04 10:23:26 +08:00
|
|
|
/*
|
|
|
|
* Marvell 88E6xxx Switch Port Registers support
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008 Marvell Semiconductor
|
|
|
|
*
|
2017-03-29 03:10:36 +08:00
|
|
|
* Copyright (c) 2016-2017 Savoir-faire Linux Inc.
|
|
|
|
* Vivien Didelot <vivien.didelot@savoirfairelinux.com>
|
2016-11-04 10:23:26 +08:00
|
|
|
*/
|
|
|
|
|
2017-06-18 11:07:14 +08:00
|
|
|
#include <linux/bitfield.h>
|
2017-06-09 06:34:10 +08:00
|
|
|
#include <linux/if_bridge.h>
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
#include <linux/phy.h>
|
2018-05-11 04:17:35 +08:00
|
|
|
#include <linux/phylink.h>
|
2017-06-03 05:06:15 +08:00
|
|
|
|
|
|
|
#include "chip.h"
|
2016-11-04 10:23:26 +08:00
|
|
|
#include "port.h"
|
2018-08-09 21:38:46 +08:00
|
|
|
#include "serdes.h"
|
2016-11-04 10:23:26 +08:00
|
|
|
|
|
|
|
int mv88e6xxx_port_read(struct mv88e6xxx_chip *chip, int port, int reg,
|
|
|
|
u16 *val)
|
|
|
|
{
|
|
|
|
int addr = chip->info->port_base_addr + port;
|
|
|
|
|
|
|
|
return mv88e6xxx_read(chip, addr, reg, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
int mv88e6xxx_port_write(struct mv88e6xxx_chip *chip, int port, int reg,
|
|
|
|
u16 val)
|
|
|
|
{
|
|
|
|
int addr = chip->info->port_base_addr + port;
|
|
|
|
|
|
|
|
return mv88e6xxx_write(chip, addr, reg, val);
|
|
|
|
}
|
2016-11-04 10:23:27 +08:00
|
|
|
|
2018-08-09 21:38:37 +08:00
|
|
|
/* Offset 0x00: MAC (or PCS or Physical) Status Register
|
|
|
|
*
|
|
|
|
* For most devices, this is read only. However the 6185 has the MyPause
|
|
|
|
* bit read/write.
|
|
|
|
*/
|
|
|
|
int mv88e6185_port_set_pause(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
int pause)
|
|
|
|
{
|
|
|
|
u16 reg;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, ®);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (pause)
|
|
|
|
reg |= MV88E6XXX_PORT_STS_MY_PAUSE;
|
|
|
|
else
|
|
|
|
reg &= ~MV88E6XXX_PORT_STS_MY_PAUSE;
|
|
|
|
|
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_STS, reg);
|
|
|
|
}
|
|
|
|
|
2016-11-04 10:23:32 +08:00
|
|
|
/* Offset 0x01: MAC (or PCS or Physical) Control Register
|
|
|
|
*
|
|
|
|
* Link, Duplex and Flow Control have one force bit, one value bit.
|
2016-11-04 10:23:35 +08:00
|
|
|
*
|
|
|
|
* For port's MAC speed, ForceSpd (or SpdValue) bits 1:0 program the value.
|
|
|
|
* Alternative values require the 200BASE (or AltSpeed) bit 12 set.
|
|
|
|
* Newer chips need a ForcedSpd bit 13 set to consider the value.
|
2016-11-04 10:23:32 +08:00
|
|
|
*/
|
|
|
|
|
2016-11-04 10:23:34 +08:00
|
|
|
static int mv88e6xxx_port_set_rgmii_delay(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
phy_interface_t mode)
|
|
|
|
{
|
|
|
|
u16 reg;
|
|
|
|
int err;
|
|
|
|
|
2017-06-13 00:37:34 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_MAC_CTL, ®);
|
2016-11-04 10:23:34 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:34 +08:00
|
|
|
reg &= ~(MV88E6XXX_PORT_MAC_CTL_RGMII_DELAY_RXCLK |
|
|
|
|
MV88E6XXX_PORT_MAC_CTL_RGMII_DELAY_TXCLK);
|
2016-11-04 10:23:34 +08:00
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case PHY_INTERFACE_MODE_RGMII_RXID:
|
2017-06-13 00:37:34 +08:00
|
|
|
reg |= MV88E6XXX_PORT_MAC_CTL_RGMII_DELAY_RXCLK;
|
2016-11-04 10:23:34 +08:00
|
|
|
break;
|
|
|
|
case PHY_INTERFACE_MODE_RGMII_TXID:
|
2017-06-13 00:37:34 +08:00
|
|
|
reg |= MV88E6XXX_PORT_MAC_CTL_RGMII_DELAY_TXCLK;
|
2016-11-04 10:23:34 +08:00
|
|
|
break;
|
|
|
|
case PHY_INTERFACE_MODE_RGMII_ID:
|
2017-06-13 00:37:34 +08:00
|
|
|
reg |= MV88E6XXX_PORT_MAC_CTL_RGMII_DELAY_RXCLK |
|
|
|
|
MV88E6XXX_PORT_MAC_CTL_RGMII_DELAY_TXCLK;
|
2016-11-04 10:23:34 +08:00
|
|
|
break;
|
2016-11-10 22:44:00 +08:00
|
|
|
case PHY_INTERFACE_MODE_RGMII:
|
2016-11-04 10:23:34 +08:00
|
|
|
break;
|
2016-11-10 22:44:00 +08:00
|
|
|
default:
|
|
|
|
return 0;
|
2016-11-04 10:23:34 +08:00
|
|
|
}
|
|
|
|
|
2017-06-13 00:37:34 +08:00
|
|
|
err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_MAC_CTL, reg);
|
2016-11-04 10:23:34 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-09 06:34:08 +08:00
|
|
|
dev_dbg(chip->dev, "p%d: delay RXCLK %s, TXCLK %s\n", port,
|
2017-06-13 00:37:34 +08:00
|
|
|
reg & MV88E6XXX_PORT_MAC_CTL_RGMII_DELAY_RXCLK ? "yes" : "no",
|
|
|
|
reg & MV88E6XXX_PORT_MAC_CTL_RGMII_DELAY_TXCLK ? "yes" : "no");
|
2016-11-04 10:23:34 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int mv88e6352_port_set_rgmii_delay(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
phy_interface_t mode)
|
|
|
|
{
|
|
|
|
if (port < 5)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return mv88e6xxx_port_set_rgmii_delay(chip, port, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
int mv88e6390_port_set_rgmii_delay(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
phy_interface_t mode)
|
|
|
|
{
|
|
|
|
if (port != 0)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return mv88e6xxx_port_set_rgmii_delay(chip, port, mode);
|
|
|
|
}
|
|
|
|
|
2016-11-04 10:23:32 +08:00
|
|
|
int mv88e6xxx_port_set_link(struct mv88e6xxx_chip *chip, int port, int link)
|
|
|
|
{
|
|
|
|
u16 reg;
|
|
|
|
int err;
|
|
|
|
|
2017-06-13 00:37:34 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_MAC_CTL, ®);
|
2016-11-04 10:23:32 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:34 +08:00
|
|
|
reg &= ~(MV88E6XXX_PORT_MAC_CTL_FORCE_LINK |
|
|
|
|
MV88E6XXX_PORT_MAC_CTL_LINK_UP);
|
2016-11-04 10:23:32 +08:00
|
|
|
|
|
|
|
switch (link) {
|
|
|
|
case LINK_FORCED_DOWN:
|
2017-06-13 00:37:34 +08:00
|
|
|
reg |= MV88E6XXX_PORT_MAC_CTL_FORCE_LINK;
|
2016-11-04 10:23:32 +08:00
|
|
|
break;
|
|
|
|
case LINK_FORCED_UP:
|
2017-06-13 00:37:34 +08:00
|
|
|
reg |= MV88E6XXX_PORT_MAC_CTL_FORCE_LINK |
|
|
|
|
MV88E6XXX_PORT_MAC_CTL_LINK_UP;
|
2016-11-04 10:23:32 +08:00
|
|
|
break;
|
|
|
|
case LINK_UNFORCED:
|
|
|
|
/* normal link detection */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-06-13 00:37:34 +08:00
|
|
|
err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_MAC_CTL, reg);
|
2016-11-04 10:23:32 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-09 06:34:08 +08:00
|
|
|
dev_dbg(chip->dev, "p%d: %s link %s\n", port,
|
2017-06-13 00:37:34 +08:00
|
|
|
reg & MV88E6XXX_PORT_MAC_CTL_FORCE_LINK ? "Force" : "Unforce",
|
|
|
|
reg & MV88E6XXX_PORT_MAC_CTL_LINK_UP ? "up" : "down");
|
2016-11-04 10:23:32 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-11-04 10:23:33 +08:00
|
|
|
int mv88e6xxx_port_set_duplex(struct mv88e6xxx_chip *chip, int port, int dup)
|
|
|
|
{
|
|
|
|
u16 reg;
|
|
|
|
int err;
|
|
|
|
|
2017-06-13 00:37:34 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_MAC_CTL, ®);
|
2016-11-04 10:23:33 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:34 +08:00
|
|
|
reg &= ~(MV88E6XXX_PORT_MAC_CTL_FORCE_DUPLEX |
|
|
|
|
MV88E6XXX_PORT_MAC_CTL_DUPLEX_FULL);
|
2016-11-04 10:23:33 +08:00
|
|
|
|
|
|
|
switch (dup) {
|
|
|
|
case DUPLEX_HALF:
|
2017-06-13 00:37:34 +08:00
|
|
|
reg |= MV88E6XXX_PORT_MAC_CTL_FORCE_DUPLEX;
|
2016-11-04 10:23:33 +08:00
|
|
|
break;
|
|
|
|
case DUPLEX_FULL:
|
2017-06-13 00:37:34 +08:00
|
|
|
reg |= MV88E6XXX_PORT_MAC_CTL_FORCE_DUPLEX |
|
|
|
|
MV88E6XXX_PORT_MAC_CTL_DUPLEX_FULL;
|
2016-11-04 10:23:33 +08:00
|
|
|
break;
|
|
|
|
case DUPLEX_UNFORCED:
|
|
|
|
/* normal duplex detection */
|
|
|
|
break;
|
|
|
|
default:
|
2019-03-02 02:53:57 +08:00
|
|
|
return -EOPNOTSUPP;
|
2016-11-04 10:23:33 +08:00
|
|
|
}
|
|
|
|
|
2017-06-13 00:37:34 +08:00
|
|
|
err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_MAC_CTL, reg);
|
2016-11-04 10:23:33 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-09 06:34:08 +08:00
|
|
|
dev_dbg(chip->dev, "p%d: %s %s duplex\n", port,
|
2017-06-13 00:37:34 +08:00
|
|
|
reg & MV88E6XXX_PORT_MAC_CTL_FORCE_DUPLEX ? "Force" : "Unforce",
|
|
|
|
reg & MV88E6XXX_PORT_MAC_CTL_DUPLEX_FULL ? "full" : "half");
|
2016-11-04 10:23:33 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-11-04 10:23:35 +08:00
|
|
|
static int mv88e6xxx_port_set_speed(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
int speed, bool alt_bit, bool force_bit)
|
|
|
|
{
|
|
|
|
u16 reg, ctrl;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
switch (speed) {
|
|
|
|
case 10:
|
2017-06-13 00:37:34 +08:00
|
|
|
ctrl = MV88E6XXX_PORT_MAC_CTL_SPEED_10;
|
2016-11-04 10:23:35 +08:00
|
|
|
break;
|
|
|
|
case 100:
|
2017-06-13 00:37:34 +08:00
|
|
|
ctrl = MV88E6XXX_PORT_MAC_CTL_SPEED_100;
|
2016-11-04 10:23:35 +08:00
|
|
|
break;
|
|
|
|
case 200:
|
|
|
|
if (alt_bit)
|
2017-06-13 00:37:34 +08:00
|
|
|
ctrl = MV88E6XXX_PORT_MAC_CTL_SPEED_100 |
|
|
|
|
MV88E6390_PORT_MAC_CTL_ALTSPEED;
|
2016-11-04 10:23:35 +08:00
|
|
|
else
|
2017-06-13 00:37:34 +08:00
|
|
|
ctrl = MV88E6065_PORT_MAC_CTL_SPEED_200;
|
2016-11-04 10:23:35 +08:00
|
|
|
break;
|
|
|
|
case 1000:
|
2017-06-13 00:37:34 +08:00
|
|
|
ctrl = MV88E6XXX_PORT_MAC_CTL_SPEED_1000;
|
2016-11-04 10:23:35 +08:00
|
|
|
break;
|
|
|
|
case 2500:
|
2018-10-13 20:40:31 +08:00
|
|
|
if (alt_bit)
|
|
|
|
ctrl = MV88E6390_PORT_MAC_CTL_SPEED_10000 |
|
|
|
|
MV88E6390_PORT_MAC_CTL_ALTSPEED;
|
|
|
|
else
|
|
|
|
ctrl = MV88E6390_PORT_MAC_CTL_SPEED_10000;
|
2016-11-04 10:23:35 +08:00
|
|
|
break;
|
|
|
|
case 10000:
|
|
|
|
/* all bits set, fall through... */
|
|
|
|
case SPEED_UNFORCED:
|
2017-06-13 00:37:34 +08:00
|
|
|
ctrl = MV88E6XXX_PORT_MAC_CTL_SPEED_UNFORCED;
|
2016-11-04 10:23:35 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2017-06-13 00:37:34 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_MAC_CTL, ®);
|
2016-11-04 10:23:35 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:34 +08:00
|
|
|
reg &= ~MV88E6XXX_PORT_MAC_CTL_SPEED_MASK;
|
2016-11-04 10:23:35 +08:00
|
|
|
if (alt_bit)
|
2017-06-13 00:37:34 +08:00
|
|
|
reg &= ~MV88E6390_PORT_MAC_CTL_ALTSPEED;
|
2016-11-04 10:23:35 +08:00
|
|
|
if (force_bit) {
|
2017-06-13 00:37:34 +08:00
|
|
|
reg &= ~MV88E6390_PORT_MAC_CTL_FORCE_SPEED;
|
2016-11-16 11:26:48 +08:00
|
|
|
if (speed != SPEED_UNFORCED)
|
2017-06-13 00:37:34 +08:00
|
|
|
ctrl |= MV88E6390_PORT_MAC_CTL_FORCE_SPEED;
|
2016-11-04 10:23:35 +08:00
|
|
|
}
|
|
|
|
reg |= ctrl;
|
|
|
|
|
2017-06-13 00:37:34 +08:00
|
|
|
err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_MAC_CTL, reg);
|
2016-11-04 10:23:35 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (speed)
|
2017-06-09 06:34:08 +08:00
|
|
|
dev_dbg(chip->dev, "p%d: Speed set to %d Mbps\n", port, speed);
|
2016-11-04 10:23:35 +08:00
|
|
|
else
|
2017-06-09 06:34:08 +08:00
|
|
|
dev_dbg(chip->dev, "p%d: Speed unforced\n", port);
|
2016-11-04 10:23:35 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Support 10, 100, 200 Mbps (e.g. 88E6065 family) */
|
|
|
|
int mv88e6065_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
|
|
|
|
{
|
|
|
|
if (speed == SPEED_MAX)
|
|
|
|
speed = 200;
|
|
|
|
|
|
|
|
if (speed > 200)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
/* Setting 200 Mbps on port 0 to 3 selects 100 Mbps */
|
|
|
|
return mv88e6xxx_port_set_speed(chip, port, speed, false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Support 10, 100, 1000 Mbps (e.g. 88E6185 family) */
|
|
|
|
int mv88e6185_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
|
|
|
|
{
|
|
|
|
if (speed == SPEED_MAX)
|
|
|
|
speed = 1000;
|
|
|
|
|
|
|
|
if (speed == 200 || speed > 1000)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return mv88e6xxx_port_set_speed(chip, port, speed, false, false);
|
|
|
|
}
|
|
|
|
|
2019-06-04 15:34:29 +08:00
|
|
|
/* Support 10, 100 Mbps (e.g. 88E6250 family) */
|
|
|
|
int mv88e6250_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
|
|
|
|
{
|
|
|
|
if (speed == SPEED_MAX)
|
|
|
|
speed = 100;
|
|
|
|
|
|
|
|
if (speed > 100)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return mv88e6xxx_port_set_speed(chip, port, speed, false, false);
|
|
|
|
}
|
|
|
|
|
2018-10-13 20:40:31 +08:00
|
|
|
/* Support 10, 100, 200, 1000, 2500 Mbps (e.g. 88E6341) */
|
|
|
|
int mv88e6341_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
|
|
|
|
{
|
|
|
|
if (speed == SPEED_MAX)
|
|
|
|
speed = port < 5 ? 1000 : 2500;
|
|
|
|
|
|
|
|
if (speed > 2500)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (speed == 200 && port != 0)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (speed == 2500 && port < 5)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return mv88e6xxx_port_set_speed(chip, port, speed, !port, true);
|
|
|
|
}
|
|
|
|
|
2019-03-08 08:21:27 +08:00
|
|
|
phy_interface_t mv88e6341_port_max_speed_mode(int port)
|
|
|
|
{
|
|
|
|
if (port == 5)
|
|
|
|
return PHY_INTERFACE_MODE_2500BASEX;
|
|
|
|
|
|
|
|
return PHY_INTERFACE_MODE_NA;
|
|
|
|
}
|
|
|
|
|
2016-11-04 10:23:35 +08:00
|
|
|
/* Support 10, 100, 200, 1000 Mbps (e.g. 88E6352 family) */
|
|
|
|
int mv88e6352_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
|
|
|
|
{
|
|
|
|
if (speed == SPEED_MAX)
|
|
|
|
speed = 1000;
|
|
|
|
|
|
|
|
if (speed > 1000)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (speed == 200 && port < 5)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return mv88e6xxx_port_set_speed(chip, port, speed, true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Support 10, 100, 200, 1000, 2500 Mbps (e.g. 88E6390) */
|
|
|
|
int mv88e6390_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
|
|
|
|
{
|
|
|
|
if (speed == SPEED_MAX)
|
|
|
|
speed = port < 9 ? 1000 : 2500;
|
|
|
|
|
|
|
|
if (speed > 2500)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (speed == 200 && port != 0)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (speed == 2500 && port < 9)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return mv88e6xxx_port_set_speed(chip, port, speed, true, true);
|
|
|
|
}
|
|
|
|
|
2019-03-08 08:21:27 +08:00
|
|
|
phy_interface_t mv88e6390_port_max_speed_mode(int port)
|
|
|
|
{
|
|
|
|
if (port == 9 || port == 10)
|
|
|
|
return PHY_INTERFACE_MODE_2500BASEX;
|
|
|
|
|
|
|
|
return PHY_INTERFACE_MODE_NA;
|
|
|
|
}
|
|
|
|
|
2016-11-04 10:23:35 +08:00
|
|
|
/* Support 10, 100, 200, 1000, 2500, 10000 Mbps (e.g. 88E6190X) */
|
|
|
|
int mv88e6390x_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
|
|
|
|
{
|
|
|
|
if (speed == SPEED_MAX)
|
|
|
|
speed = port < 9 ? 1000 : 10000;
|
|
|
|
|
|
|
|
if (speed == 200 && port != 0)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (speed >= 2500 && port < 9)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return mv88e6xxx_port_set_speed(chip, port, speed, true, true);
|
|
|
|
}
|
|
|
|
|
2019-03-08 08:21:27 +08:00
|
|
|
phy_interface_t mv88e6390x_port_max_speed_mode(int port)
|
|
|
|
{
|
|
|
|
if (port == 9 || port == 10)
|
|
|
|
return PHY_INTERFACE_MODE_XAUI;
|
|
|
|
|
|
|
|
return PHY_INTERFACE_MODE_NA;
|
|
|
|
}
|
|
|
|
|
2019-08-27 05:31:55 +08:00
|
|
|
static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
phy_interface_t mode)
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
{
|
2019-08-27 05:31:52 +08:00
|
|
|
u8 lane;
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
u16 cmode;
|
2018-08-09 21:38:49 +08:00
|
|
|
u16 reg;
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
int err;
|
|
|
|
|
2018-11-11 07:32:16 +08:00
|
|
|
/* Default to a slow mode, so freeing up SERDES interfaces for
|
|
|
|
* other ports which might use them for SFPs.
|
|
|
|
*/
|
|
|
|
if (mode == PHY_INTERFACE_MODE_NA)
|
|
|
|
mode = PHY_INTERFACE_MODE_1000BASEX;
|
|
|
|
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
switch (mode) {
|
|
|
|
case PHY_INTERFACE_MODE_1000BASEX:
|
2019-08-27 05:31:54 +08:00
|
|
|
cmode = MV88E6XXX_PORT_STS_CMODE_1000BASEX;
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
break;
|
|
|
|
case PHY_INTERFACE_MODE_SGMII:
|
2017-06-13 00:37:33 +08:00
|
|
|
cmode = MV88E6XXX_PORT_STS_CMODE_SGMII;
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
break;
|
|
|
|
case PHY_INTERFACE_MODE_2500BASEX:
|
2017-06-13 00:37:33 +08:00
|
|
|
cmode = MV88E6XXX_PORT_STS_CMODE_2500BASEX;
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
break;
|
|
|
|
case PHY_INTERFACE_MODE_XGMII:
|
2017-12-12 17:29:46 +08:00
|
|
|
case PHY_INTERFACE_MODE_XAUI:
|
2017-06-13 00:37:33 +08:00
|
|
|
cmode = MV88E6XXX_PORT_STS_CMODE_XAUI;
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
break;
|
|
|
|
case PHY_INTERFACE_MODE_RXAUI:
|
2017-06-13 00:37:33 +08:00
|
|
|
cmode = MV88E6XXX_PORT_STS_CMODE_RXAUI;
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cmode = 0;
|
|
|
|
}
|
|
|
|
|
2019-02-28 14:39:15 +08:00
|
|
|
/* cmode doesn't change, nothing to do for us */
|
|
|
|
if (cmode == chip->ports[port].cmode)
|
|
|
|
return 0;
|
|
|
|
|
2019-09-01 04:18:30 +08:00
|
|
|
lane = mv88e6xxx_serdes_get_lane(chip, port);
|
|
|
|
if (lane) {
|
2019-03-24 02:41:32 +08:00
|
|
|
if (chip->ports[port].serdes_irq) {
|
2019-09-01 04:18:34 +08:00
|
|
|
err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
|
2019-03-24 02:41:32 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2019-09-01 04:18:33 +08:00
|
|
|
err = mv88e6xxx_serdes_power_down(chip, port, lane);
|
2018-08-09 21:38:49 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2019-03-24 02:41:32 +08:00
|
|
|
chip->ports[port].cmode = 0;
|
2018-08-09 21:38:46 +08:00
|
|
|
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
if (cmode) {
|
2017-06-13 00:37:33 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, ®);
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:33 +08:00
|
|
|
reg &= ~MV88E6XXX_PORT_STS_CMODE_MASK;
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
reg |= cmode;
|
|
|
|
|
2017-06-13 00:37:33 +08:00
|
|
|
err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_STS, reg);
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
2018-08-09 21:38:46 +08:00
|
|
|
|
2019-03-24 02:41:32 +08:00
|
|
|
chip->ports[port].cmode = cmode;
|
|
|
|
|
2019-09-01 04:18:30 +08:00
|
|
|
lane = mv88e6xxx_serdes_get_lane(chip, port);
|
|
|
|
if (!lane)
|
|
|
|
return -ENODEV;
|
2019-03-24 02:41:32 +08:00
|
|
|
|
2019-09-01 04:18:33 +08:00
|
|
|
err = mv88e6xxx_serdes_power_up(chip, port, lane);
|
2018-08-09 21:38:46 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
2018-08-09 21:38:49 +08:00
|
|
|
|
|
|
|
if (chip->ports[port].serdes_irq) {
|
2019-09-01 04:18:34 +08:00
|
|
|
err = mv88e6xxx_serdes_irq_enable(chip, port, lane);
|
2018-08-09 21:38:49 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-08-27 05:31:55 +08:00
|
|
|
int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
phy_interface_t mode)
|
|
|
|
{
|
|
|
|
if (port != 9 && port != 10)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return mv88e6xxx_port_set_cmode(chip, port, mode);
|
|
|
|
}
|
|
|
|
|
2018-11-11 07:32:15 +08:00
|
|
|
int mv88e6390_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
phy_interface_t mode)
|
|
|
|
{
|
2019-08-27 05:31:55 +08:00
|
|
|
if (port != 9 && port != 10)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case PHY_INTERFACE_MODE_NA:
|
|
|
|
return 0;
|
|
|
|
case PHY_INTERFACE_MODE_XGMII:
|
|
|
|
case PHY_INTERFACE_MODE_XAUI:
|
|
|
|
case PHY_INTERFACE_MODE_RXAUI:
|
|
|
|
return -EINVAL;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mv88e6xxx_port_set_cmode(chip, port, mode);
|
|
|
|
}
|
|
|
|
|
2019-08-29 00:26:59 +08:00
|
|
|
static int mv88e6341_port_set_cmode_writable(struct mv88e6xxx_chip *chip,
|
|
|
|
int port)
|
2019-08-27 05:31:55 +08:00
|
|
|
{
|
|
|
|
int err, addr;
|
|
|
|
u16 reg, bits;
|
|
|
|
|
|
|
|
if (port != 5)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
addr = chip->info->port_base_addr + port;
|
|
|
|
|
|
|
|
err = mv88e6xxx_port_hidden_read(chip, 0x7, addr, 0, ®);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
bits = MV88E6341_PORT_RESERVED_1A_FORCE_CMODE |
|
|
|
|
MV88E6341_PORT_RESERVED_1A_SGMII_AN;
|
|
|
|
|
|
|
|
if ((reg & bits) == bits)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
reg |= bits;
|
|
|
|
return mv88e6xxx_port_hidden_write(chip, 0x7, addr, 0, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
int mv88e6341_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
phy_interface_t mode)
|
|
|
|
{
|
2019-08-29 00:26:59 +08:00
|
|
|
int err;
|
|
|
|
|
2019-08-27 05:31:55 +08:00
|
|
|
if (port != 5)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2018-11-11 07:32:15 +08:00
|
|
|
switch (mode) {
|
2019-02-25 19:39:54 +08:00
|
|
|
case PHY_INTERFACE_MODE_NA:
|
|
|
|
return 0;
|
2018-11-11 07:32:15 +08:00
|
|
|
case PHY_INTERFACE_MODE_XGMII:
|
|
|
|
case PHY_INTERFACE_MODE_XAUI:
|
|
|
|
case PHY_INTERFACE_MODE_RXAUI:
|
|
|
|
return -EINVAL;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-08-29 00:26:59 +08:00
|
|
|
err = mv88e6341_port_set_cmode_writable(chip, port);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2019-08-27 05:31:55 +08:00
|
|
|
return mv88e6xxx_port_set_cmode(chip, port, mode);
|
2018-11-11 07:32:15 +08:00
|
|
|
}
|
|
|
|
|
2018-08-09 21:38:45 +08:00
|
|
|
int mv88e6185_port_get_cmode(struct mv88e6xxx_chip *chip, int port, u8 *cmode)
|
2018-08-09 21:38:39 +08:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
u16 reg;
|
|
|
|
|
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, ®);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2018-08-09 21:38:45 +08:00
|
|
|
*cmode = reg & MV88E6185_PORT_STS_CMODE_MASK;
|
|
|
|
|
|
|
|
return 0;
|
2018-08-09 21:38:39 +08:00
|
|
|
}
|
|
|
|
|
2018-08-09 21:38:45 +08:00
|
|
|
int mv88e6352_port_get_cmode(struct mv88e6xxx_chip *chip, int port, u8 *cmode)
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
u16 reg;
|
|
|
|
|
2017-06-13 00:37:33 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, ®);
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:33 +08:00
|
|
|
*cmode = reg & MV88E6XXX_PORT_STS_CMODE_MASK;
|
net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10
Unlike most ports, ports 9 and 10 of the 6390X family have configurable
PHY modes. Set the mode as part of adjust_link().
Ordering is important, because the SERDES interfaces connected to
ports 9 and 10 can be split and assigned to other ports. The CMODE has
to be correctly set before the SERDES interface on another port can be
configured. Such configuration is likely to be performed in
port_enable() and port_disabled(), called on slave_open() and
slave_close().
The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
called early in the switch setup.
When ports 9 or 10 are used as user ports, and have a fixed-phy, when
the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
which results in the adjust_link function being called, setting the
cmode. The port_enable() will for other ports will be called much
later.
When ports 9 or 10 are used as user ports and have a real phy attached
which does not use all the available SERDES interface, e.g. a 1Gbps
SGMII, there is currently no mechanism in place to set the CMODE of
the port from software. It must be hoped the stripping resistors are
correct.
At the same time, add a function to get the cmode. This will be needed
when configuring the SERDES interfaces.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-05 03:02:50 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
net: dsa: mv88e6xxx: implement port_link_state for mv88e6250
The mv88e6250 has a rather different way of reporting the link, speed
and duplex status. A simple difference is that the link bit is bit 12
rather than bit 11 of the port status register.
It gets more complicated for speed and duplex, which do not have
separate fields. Instead, there's a four-bit PortMode field, and
decoding that depends on whether it's a phy or mii port. For the phy
ports, only four of the 16 values have defined meaning; the rest are
called "reserved", so returning {SPEED,DUPLEX}_UNKNOWN seems
reasonable.
For the mii ports, most possible values are documented (0x3 and 0x5
are reserved), but I'm unable to make sense of them all. Since the
bits simply reflect the Px_MODE[3:0] configuration pins, just support
the subset that I'm certain about. Support for other setups can be
added later.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-06-04 15:34:30 +08:00
|
|
|
int mv88e6250_port_link_state(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
struct phylink_link_state *state)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
u16 reg;
|
|
|
|
|
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, ®);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (port < 5) {
|
|
|
|
switch (reg & MV88E6250_PORT_STS_PORTMODE_MASK) {
|
|
|
|
case MV88E6250_PORT_STS_PORTMODE_PHY_10_HALF:
|
|
|
|
state->speed = SPEED_10;
|
|
|
|
state->duplex = DUPLEX_HALF;
|
|
|
|
break;
|
|
|
|
case MV88E6250_PORT_STS_PORTMODE_PHY_100_HALF:
|
|
|
|
state->speed = SPEED_100;
|
|
|
|
state->duplex = DUPLEX_HALF;
|
|
|
|
break;
|
|
|
|
case MV88E6250_PORT_STS_PORTMODE_PHY_10_FULL:
|
|
|
|
state->speed = SPEED_10;
|
|
|
|
state->duplex = DUPLEX_FULL;
|
|
|
|
break;
|
|
|
|
case MV88E6250_PORT_STS_PORTMODE_PHY_100_FULL:
|
|
|
|
state->speed = SPEED_100;
|
|
|
|
state->duplex = DUPLEX_FULL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
state->speed = SPEED_UNKNOWN;
|
|
|
|
state->duplex = DUPLEX_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (reg & MV88E6250_PORT_STS_PORTMODE_MASK) {
|
|
|
|
case MV88E6250_PORT_STS_PORTMODE_MII_10_HALF:
|
|
|
|
state->speed = SPEED_10;
|
|
|
|
state->duplex = DUPLEX_HALF;
|
|
|
|
break;
|
|
|
|
case MV88E6250_PORT_STS_PORTMODE_MII_100_HALF:
|
|
|
|
state->speed = SPEED_100;
|
|
|
|
state->duplex = DUPLEX_HALF;
|
|
|
|
break;
|
|
|
|
case MV88E6250_PORT_STS_PORTMODE_MII_10_FULL:
|
|
|
|
state->speed = SPEED_10;
|
|
|
|
state->duplex = DUPLEX_FULL;
|
|
|
|
break;
|
|
|
|
case MV88E6250_PORT_STS_PORTMODE_MII_100_FULL:
|
|
|
|
state->speed = SPEED_100;
|
|
|
|
state->duplex = DUPLEX_FULL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
state->speed = SPEED_UNKNOWN;
|
|
|
|
state->duplex = DUPLEX_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
state->link = !!(reg & MV88E6250_PORT_STS_LINK);
|
|
|
|
state->an_enabled = 1;
|
|
|
|
state->an_complete = state->link;
|
2019-08-14 22:40:24 +08:00
|
|
|
state->interface = PHY_INTERFACE_MODE_NA;
|
net: dsa: mv88e6xxx: implement port_link_state for mv88e6250
The mv88e6250 has a rather different way of reporting the link, speed
and duplex status. A simple difference is that the link bit is bit 12
rather than bit 11 of the port status register.
It gets more complicated for speed and duplex, which do not have
separate fields. Instead, there's a four-bit PortMode field, and
decoding that depends on whether it's a phy or mii port. For the phy
ports, only four of the 16 values have defined meaning; the rest are
called "reserved", so returning {SPEED,DUPLEX}_UNKNOWN seems
reasonable.
For the mii ports, most possible values are documented (0x3 and 0x5
are reserved), but I'm unable to make sense of them all. Since the
bits simply reflect the Px_MODE[3:0] configuration pins, just support
the subset that I'm certain about. Support for other setups can be
added later.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-06-04 15:34:30 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-08-09 21:38:39 +08:00
|
|
|
int mv88e6352_port_link_state(struct mv88e6xxx_chip *chip, int port,
|
2018-05-11 04:17:35 +08:00
|
|
|
struct phylink_link_state *state)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
u16 reg;
|
|
|
|
|
2019-08-14 22:40:24 +08:00
|
|
|
switch (chip->ports[port].cmode) {
|
|
|
|
case MV88E6XXX_PORT_STS_CMODE_RGMII:
|
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_MAC_CTL,
|
|
|
|
®);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if ((reg & MV88E6XXX_PORT_MAC_CTL_RGMII_DELAY_RXCLK) &&
|
|
|
|
(reg & MV88E6XXX_PORT_MAC_CTL_RGMII_DELAY_TXCLK))
|
|
|
|
state->interface = PHY_INTERFACE_MODE_RGMII_ID;
|
|
|
|
else if (reg & MV88E6XXX_PORT_MAC_CTL_RGMII_DELAY_RXCLK)
|
|
|
|
state->interface = PHY_INTERFACE_MODE_RGMII_RXID;
|
|
|
|
else if (reg & MV88E6XXX_PORT_MAC_CTL_RGMII_DELAY_TXCLK)
|
|
|
|
state->interface = PHY_INTERFACE_MODE_RGMII_TXID;
|
|
|
|
else
|
|
|
|
state->interface = PHY_INTERFACE_MODE_RGMII;
|
|
|
|
break;
|
2019-08-27 05:31:54 +08:00
|
|
|
case MV88E6XXX_PORT_STS_CMODE_1000BASEX:
|
2019-08-14 22:40:24 +08:00
|
|
|
state->interface = PHY_INTERFACE_MODE_1000BASEX;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_PORT_STS_CMODE_SGMII:
|
|
|
|
state->interface = PHY_INTERFACE_MODE_SGMII;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_PORT_STS_CMODE_2500BASEX:
|
|
|
|
state->interface = PHY_INTERFACE_MODE_2500BASEX;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_PORT_STS_CMODE_XAUI:
|
|
|
|
state->interface = PHY_INTERFACE_MODE_XAUI;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_PORT_STS_CMODE_RXAUI:
|
|
|
|
state->interface = PHY_INTERFACE_MODE_RXAUI;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* we do not support other cmode values here */
|
|
|
|
state->interface = PHY_INTERFACE_MODE_NA;
|
|
|
|
}
|
|
|
|
|
2018-05-11 04:17:35 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, ®);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
switch (reg & MV88E6XXX_PORT_STS_SPEED_MASK) {
|
|
|
|
case MV88E6XXX_PORT_STS_SPEED_10:
|
|
|
|
state->speed = SPEED_10;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_PORT_STS_SPEED_100:
|
|
|
|
state->speed = SPEED_100;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_PORT_STS_SPEED_1000:
|
|
|
|
state->speed = SPEED_1000;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_PORT_STS_SPEED_10000:
|
2018-08-09 21:38:39 +08:00
|
|
|
if ((reg & MV88E6XXX_PORT_STS_CMODE_MASK) ==
|
2018-05-11 04:17:35 +08:00
|
|
|
MV88E6XXX_PORT_STS_CMODE_2500BASEX)
|
|
|
|
state->speed = SPEED_2500;
|
|
|
|
else
|
|
|
|
state->speed = SPEED_10000;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
state->duplex = reg & MV88E6XXX_PORT_STS_DUPLEX ?
|
|
|
|
DUPLEX_FULL : DUPLEX_HALF;
|
|
|
|
state->link = !!(reg & MV88E6XXX_PORT_STS_LINK);
|
|
|
|
state->an_enabled = 1;
|
|
|
|
state->an_complete = state->link;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-08-09 21:38:39 +08:00
|
|
|
int mv88e6185_port_link_state(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
struct phylink_link_state *state)
|
|
|
|
{
|
|
|
|
if (state->interface == PHY_INTERFACE_MODE_1000BASEX) {
|
2018-08-09 21:38:45 +08:00
|
|
|
u8 cmode = chip->ports[port].cmode;
|
2018-08-09 21:38:39 +08:00
|
|
|
|
|
|
|
/* When a port is in "Cross-chip serdes" mode, it uses
|
|
|
|
* 1000Base-X full duplex mode, but there is no automatic
|
|
|
|
* link detection. Use the sync OK status for link (as it
|
|
|
|
* would do for 1000Base-X mode.)
|
|
|
|
*/
|
|
|
|
if (cmode == MV88E6185_PORT_STS_CMODE_SERDES) {
|
|
|
|
u16 mac;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = mv88e6xxx_port_read(chip, port,
|
|
|
|
MV88E6XXX_PORT_MAC_CTL, &mac);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
state->link = !!(mac & MV88E6185_PORT_MAC_CTL_SYNC_OK);
|
|
|
|
state->an_enabled = 1;
|
|
|
|
state->an_complete =
|
|
|
|
!!(mac & MV88E6185_PORT_MAC_CTL_AN_DONE);
|
|
|
|
state->duplex =
|
|
|
|
state->link ? DUPLEX_FULL : DUPLEX_UNKNOWN;
|
|
|
|
state->speed =
|
|
|
|
state->link ? SPEED_1000 : SPEED_UNKNOWN;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return mv88e6352_port_link_state(chip, port, state);
|
|
|
|
}
|
|
|
|
|
2017-06-13 00:37:35 +08:00
|
|
|
/* Offset 0x02: Jamming Control
|
2016-12-03 11:45:19 +08:00
|
|
|
*
|
|
|
|
* Do not limit the period of time that this port can be paused for by
|
|
|
|
* the remote end or the period of time that this port can pause the
|
|
|
|
* remote end.
|
|
|
|
*/
|
2017-06-09 06:34:12 +08:00
|
|
|
int mv88e6097_port_pause_limit(struct mv88e6xxx_chip *chip, int port, u8 in,
|
|
|
|
u8 out)
|
2016-12-03 11:45:19 +08:00
|
|
|
{
|
2017-06-13 00:37:35 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6097_PORT_JAM_CTL,
|
|
|
|
out << 8 | in);
|
2016-12-03 11:45:19 +08:00
|
|
|
}
|
|
|
|
|
2017-06-09 06:34:12 +08:00
|
|
|
int mv88e6390_port_pause_limit(struct mv88e6xxx_chip *chip, int port, u8 in,
|
|
|
|
u8 out)
|
2016-12-03 11:45:20 +08:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2017-06-13 00:37:35 +08:00
|
|
|
err = mv88e6xxx_port_write(chip, port, MV88E6390_PORT_FLOW_CTL,
|
|
|
|
MV88E6390_PORT_FLOW_CTL_UPDATE |
|
|
|
|
MV88E6390_PORT_FLOW_CTL_LIMIT_IN | in);
|
2016-12-03 11:45:20 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:35 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6390_PORT_FLOW_CTL,
|
|
|
|
MV88E6390_PORT_FLOW_CTL_UPDATE |
|
|
|
|
MV88E6390_PORT_FLOW_CTL_LIMIT_OUT | out);
|
2016-12-03 11:45:20 +08:00
|
|
|
}
|
|
|
|
|
2016-11-04 10:23:27 +08:00
|
|
|
/* Offset 0x04: Port Control Register */
|
|
|
|
|
|
|
|
static const char * const mv88e6xxx_port_state_names[] = {
|
2017-06-13 00:37:37 +08:00
|
|
|
[MV88E6XXX_PORT_CTL0_STATE_DISABLED] = "Disabled",
|
|
|
|
[MV88E6XXX_PORT_CTL0_STATE_BLOCKING] = "Blocking/Listening",
|
|
|
|
[MV88E6XXX_PORT_CTL0_STATE_LEARNING] = "Learning",
|
|
|
|
[MV88E6XXX_PORT_CTL0_STATE_FORWARDING] = "Forwarding",
|
2016-11-04 10:23:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
int mv88e6xxx_port_set_state(struct mv88e6xxx_chip *chip, int port, u8 state)
|
|
|
|
{
|
|
|
|
u16 reg;
|
|
|
|
int err;
|
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL0, ®);
|
2016-11-04 10:23:27 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
reg &= ~MV88E6XXX_PORT_CTL0_STATE_MASK;
|
2017-06-09 06:34:10 +08:00
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case BR_STATE_DISABLED:
|
2017-06-13 00:37:37 +08:00
|
|
|
state = MV88E6XXX_PORT_CTL0_STATE_DISABLED;
|
2017-06-09 06:34:10 +08:00
|
|
|
break;
|
|
|
|
case BR_STATE_BLOCKING:
|
|
|
|
case BR_STATE_LISTENING:
|
2017-06-13 00:37:37 +08:00
|
|
|
state = MV88E6XXX_PORT_CTL0_STATE_BLOCKING;
|
2017-06-09 06:34:10 +08:00
|
|
|
break;
|
|
|
|
case BR_STATE_LEARNING:
|
2017-06-13 00:37:37 +08:00
|
|
|
state = MV88E6XXX_PORT_CTL0_STATE_LEARNING;
|
2017-06-09 06:34:10 +08:00
|
|
|
break;
|
|
|
|
case BR_STATE_FORWARDING:
|
2017-06-13 00:37:37 +08:00
|
|
|
state = MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
|
2017-06-09 06:34:10 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2016-11-04 10:23:27 +08:00
|
|
|
reg |= state;
|
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
|
2016-11-04 10:23:27 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-09 06:34:08 +08:00
|
|
|
dev_dbg(chip->dev, "p%d: PortState set to %s\n", port,
|
|
|
|
mv88e6xxx_port_state_names[state]);
|
2016-11-04 10:23:27 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-11-04 10:23:28 +08:00
|
|
|
|
2016-12-03 11:35:19 +08:00
|
|
|
int mv88e6xxx_port_set_egress_mode(struct mv88e6xxx_chip *chip, int port,
|
2017-06-09 06:34:09 +08:00
|
|
|
enum mv88e6xxx_egress_mode mode)
|
2016-12-03 11:35:19 +08:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
u16 reg;
|
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL0, ®);
|
2016-12-03 11:35:19 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
reg &= ~MV88E6XXX_PORT_CTL0_EGRESS_MODE_MASK;
|
2017-06-09 06:34:09 +08:00
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case MV88E6XXX_EGRESS_MODE_UNMODIFIED:
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL0_EGRESS_MODE_UNMODIFIED;
|
2017-06-09 06:34:09 +08:00
|
|
|
break;
|
|
|
|
case MV88E6XXX_EGRESS_MODE_UNTAGGED:
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL0_EGRESS_MODE_UNTAGGED;
|
2017-06-09 06:34:09 +08:00
|
|
|
break;
|
|
|
|
case MV88E6XXX_EGRESS_MODE_TAGGED:
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL0_EGRESS_MODE_TAGGED;
|
2017-06-09 06:34:09 +08:00
|
|
|
break;
|
|
|
|
case MV88E6XXX_EGRESS_MODE_ETHERTYPE:
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL0_EGRESS_MODE_ETHER_TYPE_DSA;
|
2017-06-09 06:34:09 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2016-12-03 11:35:19 +08:00
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
|
2016-12-03 11:35:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int mv88e6085_port_set_frame_mode(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
enum mv88e6xxx_frame_mode mode)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
u16 reg;
|
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL0, ®);
|
2016-12-03 11:35:19 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
reg &= ~MV88E6XXX_PORT_CTL0_FRAME_MODE_MASK;
|
2016-12-03 11:35:19 +08:00
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case MV88E6XXX_FRAME_MODE_NORMAL:
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL0_FRAME_MODE_NORMAL;
|
2016-12-03 11:35:19 +08:00
|
|
|
break;
|
|
|
|
case MV88E6XXX_FRAME_MODE_DSA:
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL0_FRAME_MODE_DSA;
|
2016-12-03 11:35:19 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
|
2016-12-03 11:35:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int mv88e6351_port_set_frame_mode(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
enum mv88e6xxx_frame_mode mode)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
u16 reg;
|
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL0, ®);
|
2016-12-03 11:35:19 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
reg &= ~MV88E6XXX_PORT_CTL0_FRAME_MODE_MASK;
|
2016-12-03 11:35:19 +08:00
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case MV88E6XXX_FRAME_MODE_NORMAL:
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL0_FRAME_MODE_NORMAL;
|
2016-12-03 11:35:19 +08:00
|
|
|
break;
|
|
|
|
case MV88E6XXX_FRAME_MODE_DSA:
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL0_FRAME_MODE_DSA;
|
2016-12-03 11:35:19 +08:00
|
|
|
break;
|
|
|
|
case MV88E6XXX_FRAME_MODE_PROVIDER:
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL0_FRAME_MODE_PROVIDER;
|
2016-12-03 11:35:19 +08:00
|
|
|
break;
|
|
|
|
case MV88E6XXX_FRAME_MODE_ETHERTYPE:
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL0_FRAME_MODE_ETHER_TYPE_DSA;
|
2016-12-03 11:35:19 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
|
2016-12-03 11:35:19 +08:00
|
|
|
}
|
|
|
|
|
2017-03-12 05:13:00 +08:00
|
|
|
static int mv88e6185_port_set_forward_unknown(struct mv88e6xxx_chip *chip,
|
|
|
|
int port, bool unicast)
|
2016-12-03 11:35:19 +08:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
u16 reg;
|
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL0, ®);
|
2016-12-03 11:35:19 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-03-12 05:13:00 +08:00
|
|
|
if (unicast)
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6185_PORT_CTL0_FORWARD_UNKNOWN;
|
2016-12-03 11:35:19 +08:00
|
|
|
else
|
2017-06-13 00:37:37 +08:00
|
|
|
reg &= ~MV88E6185_PORT_CTL0_FORWARD_UNKNOWN;
|
2016-12-03 11:35:19 +08:00
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
|
2016-12-03 11:35:19 +08:00
|
|
|
}
|
|
|
|
|
2017-03-12 05:13:00 +08:00
|
|
|
int mv88e6352_port_set_egress_floods(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
bool unicast, bool multicast)
|
2016-12-03 11:35:19 +08:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
u16 reg;
|
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL0, ®);
|
2016-12-03 11:35:19 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
reg &= ~MV88E6352_PORT_CTL0_EGRESS_FLOODS_MASK;
|
2017-03-12 05:13:00 +08:00
|
|
|
|
|
|
|
if (unicast && multicast)
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6352_PORT_CTL0_EGRESS_FLOODS_ALL_UNKNOWN_DA;
|
2017-03-12 05:13:00 +08:00
|
|
|
else if (unicast)
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6352_PORT_CTL0_EGRESS_FLOODS_NO_UNKNOWN_MC_DA;
|
2017-03-12 05:13:00 +08:00
|
|
|
else if (multicast)
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6352_PORT_CTL0_EGRESS_FLOODS_NO_UNKNOWN_UC_DA;
|
2016-12-03 11:35:19 +08:00
|
|
|
else
|
2017-06-13 00:37:37 +08:00
|
|
|
reg |= MV88E6352_PORT_CTL0_EGRESS_FLOODS_NO_UNKNOWN_DA;
|
2016-12-03 11:35:19 +08:00
|
|
|
|
2017-06-13 00:37:37 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
|
2016-12-03 11:35:19 +08:00
|
|
|
}
|
|
|
|
|
2016-11-04 10:23:29 +08:00
|
|
|
/* Offset 0x05: Port Control 1 */
|
|
|
|
|
2017-03-12 05:12:50 +08:00
|
|
|
int mv88e6xxx_port_set_message_port(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
bool message_port)
|
|
|
|
{
|
|
|
|
u16 val;
|
|
|
|
int err;
|
|
|
|
|
2017-06-13 00:37:38 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL1, &val);
|
2017-03-12 05:12:50 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (message_port)
|
2017-06-13 00:37:38 +08:00
|
|
|
val |= MV88E6XXX_PORT_CTL1_MESSAGE_PORT;
|
2017-03-12 05:12:50 +08:00
|
|
|
else
|
2017-06-13 00:37:38 +08:00
|
|
|
val &= ~MV88E6XXX_PORT_CTL1_MESSAGE_PORT;
|
2017-03-12 05:12:50 +08:00
|
|
|
|
2017-06-13 00:37:38 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL1, val);
|
2017-03-12 05:12:50 +08:00
|
|
|
}
|
|
|
|
|
2016-11-04 10:23:28 +08:00
|
|
|
/* Offset 0x06: Port Based VLAN Map */
|
|
|
|
|
|
|
|
int mv88e6xxx_port_set_vlan_map(struct mv88e6xxx_chip *chip, int port, u16 map)
|
|
|
|
{
|
2017-03-12 05:12:47 +08:00
|
|
|
const u16 mask = mv88e6xxx_port_mask(chip);
|
2016-11-04 10:23:28 +08:00
|
|
|
u16 reg;
|
|
|
|
int err;
|
|
|
|
|
2017-06-13 00:37:39 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_BASE_VLAN, ®);
|
2016-11-04 10:23:28 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
reg &= ~mask;
|
|
|
|
reg |= map & mask;
|
|
|
|
|
2017-06-13 00:37:39 +08:00
|
|
|
err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_BASE_VLAN, reg);
|
2016-11-04 10:23:28 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-09 06:34:08 +08:00
|
|
|
dev_dbg(chip->dev, "p%d: VLANTable set to %.3x\n", port, map);
|
2016-11-04 10:23:28 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-11-04 10:23:29 +08:00
|
|
|
|
|
|
|
int mv88e6xxx_port_get_fid(struct mv88e6xxx_chip *chip, int port, u16 *fid)
|
|
|
|
{
|
|
|
|
const u16 upper_mask = (mv88e6xxx_num_databases(chip) - 1) >> 4;
|
|
|
|
u16 reg;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
/* Port's default FID lower 4 bits are located in reg 0x06, offset 12 */
|
2017-06-13 00:37:39 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_BASE_VLAN, ®);
|
2016-11-04 10:23:29 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
*fid = (reg & 0xf000) >> 12;
|
|
|
|
|
|
|
|
/* Port's default FID upper bits are located in reg 0x05, offset 0 */
|
|
|
|
if (upper_mask) {
|
2017-06-13 00:37:38 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL1,
|
|
|
|
®);
|
2016-11-04 10:23:29 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
*fid |= (reg & upper_mask) << 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int mv88e6xxx_port_set_fid(struct mv88e6xxx_chip *chip, int port, u16 fid)
|
|
|
|
{
|
|
|
|
const u16 upper_mask = (mv88e6xxx_num_databases(chip) - 1) >> 4;
|
|
|
|
u16 reg;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (fid >= mv88e6xxx_num_databases(chip))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Port's default FID lower 4 bits are located in reg 0x06, offset 12 */
|
2017-06-13 00:37:39 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_BASE_VLAN, ®);
|
2016-11-04 10:23:29 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
reg &= 0x0fff;
|
|
|
|
reg |= (fid & 0x000f) << 12;
|
|
|
|
|
2017-06-13 00:37:39 +08:00
|
|
|
err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_BASE_VLAN, reg);
|
2016-11-04 10:23:29 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
/* Port's default FID upper bits are located in reg 0x05, offset 0 */
|
|
|
|
if (upper_mask) {
|
2017-06-13 00:37:38 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL1,
|
|
|
|
®);
|
2016-11-04 10:23:29 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
reg &= ~upper_mask;
|
|
|
|
reg |= (fid >> 4) & upper_mask;
|
|
|
|
|
2017-06-13 00:37:38 +08:00
|
|
|
err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL1,
|
|
|
|
reg);
|
2016-11-04 10:23:29 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2017-06-09 06:34:08 +08:00
|
|
|
dev_dbg(chip->dev, "p%d: FID set to %u\n", port, fid);
|
2016-11-04 10:23:29 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-11-04 10:23:30 +08:00
|
|
|
|
|
|
|
/* Offset 0x07: Default Port VLAN ID & Priority */
|
|
|
|
|
|
|
|
int mv88e6xxx_port_get_pvid(struct mv88e6xxx_chip *chip, int port, u16 *pvid)
|
|
|
|
{
|
|
|
|
u16 reg;
|
|
|
|
int err;
|
|
|
|
|
2017-06-13 00:37:40 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN,
|
|
|
|
®);
|
2016-11-04 10:23:30 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:40 +08:00
|
|
|
*pvid = reg & MV88E6XXX_PORT_DEFAULT_VLAN_MASK;
|
2016-11-04 10:23:30 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int mv88e6xxx_port_set_pvid(struct mv88e6xxx_chip *chip, int port, u16 pvid)
|
|
|
|
{
|
|
|
|
u16 reg;
|
|
|
|
int err;
|
|
|
|
|
2017-06-13 00:37:40 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN,
|
|
|
|
®);
|
2016-11-04 10:23:30 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:40 +08:00
|
|
|
reg &= ~MV88E6XXX_PORT_DEFAULT_VLAN_MASK;
|
|
|
|
reg |= pvid & MV88E6XXX_PORT_DEFAULT_VLAN_MASK;
|
2016-11-04 10:23:30 +08:00
|
|
|
|
2017-06-13 00:37:40 +08:00
|
|
|
err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN,
|
|
|
|
reg);
|
2016-11-04 10:23:30 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-09 06:34:08 +08:00
|
|
|
dev_dbg(chip->dev, "p%d: DefaultVID set to %u\n", port, pvid);
|
2016-11-04 10:23:30 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-11-04 10:23:31 +08:00
|
|
|
|
|
|
|
/* Offset 0x08: Port Control 2 Register */
|
|
|
|
|
|
|
|
static const char * const mv88e6xxx_port_8021q_mode_names[] = {
|
2017-06-13 00:37:41 +08:00
|
|
|
[MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED] = "Disabled",
|
|
|
|
[MV88E6XXX_PORT_CTL2_8021Q_MODE_FALLBACK] = "Fallback",
|
|
|
|
[MV88E6XXX_PORT_CTL2_8021Q_MODE_CHECK] = "Check",
|
|
|
|
[MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE] = "Secure",
|
2016-11-04 10:23:31 +08:00
|
|
|
};
|
|
|
|
|
2017-03-12 05:13:00 +08:00
|
|
|
static int mv88e6185_port_set_default_forward(struct mv88e6xxx_chip *chip,
|
|
|
|
int port, bool multicast)
|
2017-02-05 03:15:28 +08:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
u16 reg;
|
|
|
|
|
2017-06-13 00:37:41 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL2, ®);
|
2017-02-05 03:15:28 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-03-12 05:13:00 +08:00
|
|
|
if (multicast)
|
2017-06-13 00:37:41 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL2_DEFAULT_FORWARD;
|
2017-02-05 03:15:28 +08:00
|
|
|
else
|
2017-06-13 00:37:41 +08:00
|
|
|
reg &= ~MV88E6XXX_PORT_CTL2_DEFAULT_FORWARD;
|
2017-02-05 03:15:28 +08:00
|
|
|
|
2017-06-13 00:37:41 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL2, reg);
|
2017-02-05 03:15:28 +08:00
|
|
|
}
|
|
|
|
|
2017-03-12 05:13:00 +08:00
|
|
|
int mv88e6185_port_set_egress_floods(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
bool unicast, bool multicast)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = mv88e6185_port_set_forward_unknown(chip, port, unicast);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
return mv88e6185_port_set_default_forward(chip, port, multicast);
|
|
|
|
}
|
|
|
|
|
2017-02-05 03:15:28 +08:00
|
|
|
int mv88e6095_port_set_upstream_port(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
int upstream_port)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
u16 reg;
|
|
|
|
|
2017-06-13 00:37:41 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL2, ®);
|
2017-02-05 03:15:28 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:41 +08:00
|
|
|
reg &= ~MV88E6095_PORT_CTL2_CPU_PORT_MASK;
|
2017-02-05 03:15:28 +08:00
|
|
|
reg |= upstream_port;
|
|
|
|
|
2017-06-13 00:37:41 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL2, reg);
|
2017-02-05 03:15:28 +08:00
|
|
|
}
|
|
|
|
|
2016-11-04 10:23:31 +08:00
|
|
|
int mv88e6xxx_port_set_8021q_mode(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
u16 mode)
|
|
|
|
{
|
|
|
|
u16 reg;
|
|
|
|
int err;
|
|
|
|
|
2017-06-13 00:37:41 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL2, ®);
|
2016-11-04 10:23:31 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:41 +08:00
|
|
|
reg &= ~MV88E6XXX_PORT_CTL2_8021Q_MODE_MASK;
|
|
|
|
reg |= mode & MV88E6XXX_PORT_CTL2_8021Q_MODE_MASK;
|
2016-11-04 10:23:31 +08:00
|
|
|
|
2017-06-13 00:37:41 +08:00
|
|
|
err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL2, reg);
|
2016-11-04 10:23:31 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-09 06:34:08 +08:00
|
|
|
dev_dbg(chip->dev, "p%d: 802.1QMode set to %s\n", port,
|
|
|
|
mv88e6xxx_port_8021q_mode_names[mode]);
|
2016-11-04 10:23:31 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-12-03 11:35:16 +08:00
|
|
|
|
2017-02-05 03:15:28 +08:00
|
|
|
int mv88e6xxx_port_set_map_da(struct mv88e6xxx_chip *chip, int port)
|
|
|
|
{
|
|
|
|
u16 reg;
|
|
|
|
int err;
|
|
|
|
|
2017-06-13 00:37:41 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL2, ®);
|
2017-02-05 03:15:28 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:41 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL2_MAP_DA;
|
2017-02-05 03:15:28 +08:00
|
|
|
|
2017-06-13 00:37:41 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL2, reg);
|
2017-02-05 03:15:28 +08:00
|
|
|
}
|
|
|
|
|
2017-06-09 06:34:13 +08:00
|
|
|
int mv88e6165_port_set_jumbo_size(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
size_t size)
|
2016-12-03 11:45:17 +08:00
|
|
|
{
|
|
|
|
u16 reg;
|
|
|
|
int err;
|
|
|
|
|
2017-06-13 00:37:41 +08:00
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL2, ®);
|
2016-12-03 11:45:17 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:41 +08:00
|
|
|
reg &= ~MV88E6XXX_PORT_CTL2_JUMBO_MODE_MASK;
|
2017-06-09 06:34:13 +08:00
|
|
|
|
|
|
|
if (size <= 1522)
|
2017-06-13 00:37:41 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL2_JUMBO_MODE_1522;
|
2017-06-09 06:34:13 +08:00
|
|
|
else if (size <= 2048)
|
2017-06-13 00:37:41 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL2_JUMBO_MODE_2048;
|
2017-06-09 06:34:13 +08:00
|
|
|
else if (size <= 10240)
|
2017-06-13 00:37:41 +08:00
|
|
|
reg |= MV88E6XXX_PORT_CTL2_JUMBO_MODE_10240;
|
2017-06-09 06:34:13 +08:00
|
|
|
else
|
|
|
|
return -ERANGE;
|
2016-12-03 11:45:17 +08:00
|
|
|
|
2017-06-13 00:37:41 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL2, reg);
|
2016-12-03 11:45:17 +08:00
|
|
|
}
|
|
|
|
|
2016-12-03 11:45:18 +08:00
|
|
|
/* Offset 0x09: Port Rate Control */
|
|
|
|
|
|
|
|
int mv88e6095_port_egress_rate_limiting(struct mv88e6xxx_chip *chip, int port)
|
|
|
|
{
|
2017-06-13 00:37:42 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL1,
|
|
|
|
0x0000);
|
2016-12-03 11:45:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int mv88e6097_port_egress_rate_limiting(struct mv88e6xxx_chip *chip, int port)
|
|
|
|
{
|
2017-06-13 00:37:42 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL1,
|
|
|
|
0x0001);
|
2016-12-03 11:45:18 +08:00
|
|
|
}
|
|
|
|
|
2017-03-12 05:13:01 +08:00
|
|
|
/* Offset 0x0C: Port ATU Control */
|
|
|
|
|
|
|
|
int mv88e6xxx_port_disable_learn_limit(struct mv88e6xxx_chip *chip, int port)
|
|
|
|
{
|
2017-06-13 00:37:45 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ATU_CTL, 0);
|
2017-03-12 05:13:01 +08:00
|
|
|
}
|
|
|
|
|
2017-03-12 05:13:02 +08:00
|
|
|
/* Offset 0x0D: (Priority) Override Register */
|
|
|
|
|
|
|
|
int mv88e6xxx_port_disable_pri_override(struct mv88e6xxx_chip *chip, int port)
|
|
|
|
{
|
2017-06-13 00:37:45 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_PRI_OVERRIDE, 0);
|
2017-03-12 05:13:02 +08:00
|
|
|
}
|
|
|
|
|
2016-12-03 11:35:19 +08:00
|
|
|
/* Offset 0x0f: Port Ether type */
|
|
|
|
|
|
|
|
int mv88e6351_port_set_ether_type(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
u16 etype)
|
|
|
|
{
|
2017-06-13 00:37:45 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ETH_TYPE, etype);
|
2016-12-03 11:35:19 +08:00
|
|
|
}
|
|
|
|
|
2016-12-03 11:35:16 +08:00
|
|
|
/* Offset 0x18: Port IEEE Priority Remapping Registers [0-3]
|
|
|
|
* Offset 0x19: Port IEEE Priority Remapping Registers [4-7]
|
|
|
|
*/
|
|
|
|
|
|
|
|
int mv88e6095_port_tag_remap(struct mv88e6xxx_chip *chip, int port)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
/* Use a direct priority mapping for all IEEE tagged frames */
|
2017-06-13 00:37:44 +08:00
|
|
|
err = mv88e6xxx_port_write(chip, port,
|
|
|
|
MV88E6095_PORT_IEEE_PRIO_REMAP_0123,
|
|
|
|
0x3210);
|
2016-12-03 11:35:16 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:44 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port,
|
|
|
|
MV88E6095_PORT_IEEE_PRIO_REMAP_4567,
|
|
|
|
0x7654);
|
2016-12-03 11:35:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mv88e6xxx_port_ieeepmt_write(struct mv88e6xxx_chip *chip,
|
2017-06-18 11:07:14 +08:00
|
|
|
int port, u16 table, u8 ptr, u16 data)
|
2016-12-03 11:35:16 +08:00
|
|
|
{
|
|
|
|
u16 reg;
|
|
|
|
|
2017-06-18 11:07:14 +08:00
|
|
|
reg = MV88E6390_PORT_IEEE_PRIO_MAP_TABLE_UPDATE | table |
|
|
|
|
(ptr << __bf_shf(MV88E6390_PORT_IEEE_PRIO_MAP_TABLE_PTR_MASK)) |
|
|
|
|
(data & MV88E6390_PORT_IEEE_PRIO_MAP_TABLE_DATA_MASK);
|
2016-12-03 11:35:16 +08:00
|
|
|
|
2017-06-13 00:37:44 +08:00
|
|
|
return mv88e6xxx_port_write(chip, port,
|
|
|
|
MV88E6390_PORT_IEEE_PRIO_MAP_TABLE, reg);
|
2016-12-03 11:35:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int mv88e6390_port_tag_remap(struct mv88e6xxx_chip *chip, int port)
|
|
|
|
{
|
|
|
|
int err, i;
|
2017-06-13 00:37:44 +08:00
|
|
|
u16 table;
|
2016-12-03 11:35:16 +08:00
|
|
|
|
|
|
|
for (i = 0; i <= 7; i++) {
|
2017-06-13 00:37:44 +08:00
|
|
|
table = MV88E6390_PORT_IEEE_PRIO_MAP_TABLE_INGRESS_PCP;
|
|
|
|
err = mv88e6xxx_port_ieeepmt_write(chip, port, table, i,
|
|
|
|
(i | i << 4));
|
2016-12-03 11:35:16 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:44 +08:00
|
|
|
table = MV88E6390_PORT_IEEE_PRIO_MAP_TABLE_EGRESS_GREEN_PCP;
|
|
|
|
err = mv88e6xxx_port_ieeepmt_write(chip, port, table, i, i);
|
2016-12-03 11:35:16 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:44 +08:00
|
|
|
table = MV88E6390_PORT_IEEE_PRIO_MAP_TABLE_EGRESS_YELLOW_PCP;
|
|
|
|
err = mv88e6xxx_port_ieeepmt_write(chip, port, table, i, i);
|
2016-12-03 11:35:16 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2017-06-13 00:37:44 +08:00
|
|
|
table = MV88E6390_PORT_IEEE_PRIO_MAP_TABLE_EGRESS_AVB_PCP;
|
|
|
|
err = mv88e6xxx_port_ieeepmt_write(chip, port, table, i, i);
|
2016-12-03 11:35:16 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2019-09-08 04:00:48 +08:00
|
|
|
|
|
|
|
/* Offset 0x0E: Policy Control Register */
|
|
|
|
|
|
|
|
int mv88e6352_port_set_policy(struct mv88e6xxx_chip *chip, int port,
|
|
|
|
enum mv88e6xxx_policy_mapping mapping,
|
|
|
|
enum mv88e6xxx_policy_action action)
|
|
|
|
{
|
|
|
|
u16 reg, mask, val;
|
|
|
|
int shift;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
switch (mapping) {
|
|
|
|
case MV88E6XXX_POLICY_MAPPING_DA:
|
|
|
|
shift = __bf_shf(MV88E6XXX_PORT_POLICY_CTL_DA_MASK);
|
|
|
|
mask = MV88E6XXX_PORT_POLICY_CTL_DA_MASK;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_POLICY_MAPPING_SA:
|
|
|
|
shift = __bf_shf(MV88E6XXX_PORT_POLICY_CTL_SA_MASK);
|
|
|
|
mask = MV88E6XXX_PORT_POLICY_CTL_SA_MASK;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_POLICY_MAPPING_VTU:
|
|
|
|
shift = __bf_shf(MV88E6XXX_PORT_POLICY_CTL_VTU_MASK);
|
|
|
|
mask = MV88E6XXX_PORT_POLICY_CTL_VTU_MASK;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_POLICY_MAPPING_ETYPE:
|
|
|
|
shift = __bf_shf(MV88E6XXX_PORT_POLICY_CTL_ETYPE_MASK);
|
|
|
|
mask = MV88E6XXX_PORT_POLICY_CTL_ETYPE_MASK;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_POLICY_MAPPING_PPPOE:
|
|
|
|
shift = __bf_shf(MV88E6XXX_PORT_POLICY_CTL_PPPOE_MASK);
|
|
|
|
mask = MV88E6XXX_PORT_POLICY_CTL_PPPOE_MASK;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_POLICY_MAPPING_VBAS:
|
|
|
|
shift = __bf_shf(MV88E6XXX_PORT_POLICY_CTL_VBAS_MASK);
|
|
|
|
mask = MV88E6XXX_PORT_POLICY_CTL_VBAS_MASK;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_POLICY_MAPPING_OPT82:
|
|
|
|
shift = __bf_shf(MV88E6XXX_PORT_POLICY_CTL_OPT82_MASK);
|
|
|
|
mask = MV88E6XXX_PORT_POLICY_CTL_OPT82_MASK;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_POLICY_MAPPING_UDP:
|
|
|
|
shift = __bf_shf(MV88E6XXX_PORT_POLICY_CTL_UDP_MASK);
|
|
|
|
mask = MV88E6XXX_PORT_POLICY_CTL_UDP_MASK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case MV88E6XXX_POLICY_ACTION_NORMAL:
|
|
|
|
val = MV88E6XXX_PORT_POLICY_CTL_NORMAL;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_POLICY_ACTION_MIRROR:
|
|
|
|
val = MV88E6XXX_PORT_POLICY_CTL_MIRROR;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_POLICY_ACTION_TRAP:
|
|
|
|
val = MV88E6XXX_PORT_POLICY_CTL_TRAP;
|
|
|
|
break;
|
|
|
|
case MV88E6XXX_POLICY_ACTION_DISCARD:
|
|
|
|
val = MV88E6XXX_PORT_POLICY_CTL_DISCARD;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_POLICY_CTL, ®);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
reg &= ~mask;
|
|
|
|
reg |= (val << shift) & mask;
|
|
|
|
|
|
|
|
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_POLICY_CTL, reg);
|
|
|
|
}
|