Commit c857486a authored by Hubert Feurstein's avatar Hubert Feurstein Committed by David S. Miller

net: dsa: mv88e6xxx: introduce invalid_port_mask in mv88e6xxx_info

With this it is possible to mark certain chip ports as invalid. This is
required for example for the MV88E6220 (which is in general a MV88E6250
with 7 ports) but the ports 2-4 are not routed to pins.

If a user configures an invalid port, an error is returned.
Signed-off-by: default avatarHubert Feurstein <h.feurstein@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 83c5ee31
...@@ -2485,6 +2485,14 @@ static int mv88e6xxx_setup(struct dsa_switch *ds) ...@@ -2485,6 +2485,14 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
/* Setup Switch Port Registers */ /* Setup Switch Port Registers */
for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
/* Prevent the use of an invalid port. */
if (mv88e6xxx_is_invalid_port(chip, i) &&
!dsa_is_unused_port(ds, i)) {
dev_err(chip->dev, "port %d is invalid\n", i);
err = -EINVAL;
goto unlock;
}
if (dsa_is_unused_port(ds, i)) { if (dsa_is_unused_port(ds, i)) {
err = mv88e6xxx_port_set_state(chip, i, err = mv88e6xxx_port_set_state(chip, i,
BR_STATE_DISABLED); BR_STATE_DISABLED);
...@@ -4286,6 +4294,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = { ...@@ -4286,6 +4294,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
*/ */
.num_ports = 7, .num_ports = 7,
.num_internal_phys = 2, .num_internal_phys = 2,
.invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
.max_vid = 4095, .max_vid = 4095,
.port_base_addr = 0x08, .port_base_addr = 0x08,
.phy_base_addr = 0x00, .phy_base_addr = 0x00,
......
...@@ -106,6 +106,11 @@ struct mv88e6xxx_info { ...@@ -106,6 +106,11 @@ struct mv88e6xxx_info {
unsigned int g2_irqs; unsigned int g2_irqs;
bool pvt; bool pvt;
/* Mark certain ports as invalid. This is required for example for the
* MV88E6220 (which is in general a MV88E6250 with 7 ports) but the
* ports 2-4 are not routet to pins.
*/
unsigned int invalid_port_mask;
/* Multi-chip Addressing Mode. /* Multi-chip Addressing Mode.
* Some chips respond to only 2 registers of its own SMI device address * Some chips respond to only 2 registers of its own SMI device address
* when it is non-zero, and use indirect access to internal registers. * when it is non-zero, and use indirect access to internal registers.
...@@ -571,6 +576,11 @@ static inline unsigned int mv88e6xxx_num_gpio(struct mv88e6xxx_chip *chip) ...@@ -571,6 +576,11 @@ static inline unsigned int mv88e6xxx_num_gpio(struct mv88e6xxx_chip *chip)
return chip->info->num_gpio; return chip->info->num_gpio;
} }
static inline bool mv88e6xxx_is_invalid_port(struct mv88e6xxx_chip *chip, int port)
{
return (chip->info->invalid_port_mask & BIT(port)) != 0;
}
int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val); int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val);
int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val); int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val);
int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg,
......
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