Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 2 | /* |
Vivien Didelot | 0d3cd4b | 2016-06-21 12:28:19 -0400 | [diff] [blame] | 3 | * Marvell 88e6xxx Ethernet switch single-chip support |
| 4 | * |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 5 | * Copyright (c) 2008 Marvell Semiconductor |
| 6 | * |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 7 | * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch> |
| 8 | * |
Vivien Didelot | 4333d61 | 2017-03-28 15:10:36 -0400 | [diff] [blame] | 9 | * Copyright (c) 2016-2017 Savoir-faire Linux Inc. |
| 10 | * Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
Vivien Didelot | 19fb7f6 | 2019-08-09 18:47:55 -0400 | [diff] [blame] | 13 | #include <linux/bitfield.h> |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 14 | #include <linux/delay.h> |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 15 | #include <linux/dsa/mv88e6xxx.h> |
Guenter Roeck | defb05b | 2015-03-26 18:36:38 -0700 | [diff] [blame] | 16 | #include <linux/etherdevice.h> |
Andrew Lunn | dea8702 | 2015-08-31 15:56:47 +0200 | [diff] [blame] | 17 | #include <linux/ethtool.h> |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 18 | #include <linux/if_bridge.h> |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 19 | #include <linux/interrupt.h> |
| 20 | #include <linux/irq.h> |
| 21 | #include <linux/irqdomain.h> |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 22 | #include <linux/jiffies.h> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 23 | #include <linux/list.h> |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 24 | #include <linux/mdio.h> |
Paul Gortmaker | 2bbba27 | 2012-01-24 10:41:40 +0000 | [diff] [blame] | 25 | #include <linux/module.h> |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 26 | #include <linux/of_device.h> |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 27 | #include <linux/of_irq.h> |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 28 | #include <linux/of_mdio.h> |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 29 | #include <linux/platform_data/mv88e6xxx.h> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 30 | #include <linux/netdevice.h> |
Andrew Lunn | c8c1b39a | 2015-11-20 03:56:24 +0100 | [diff] [blame] | 31 | #include <linux/gpio/consumer.h> |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 32 | #include <linux/phylink.h> |
Ben Hutchings | c8f0b86 | 2011-11-27 17:06:08 +0000 | [diff] [blame] | 33 | #include <net/dsa.h> |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 34 | |
Vivien Didelot | 4d5f2ba7 | 2017-06-02 17:06:15 -0400 | [diff] [blame] | 35 | #include "chip.h" |
Andrew Lunn | 9dd43aa | 2020-09-18 21:11:05 +0200 | [diff] [blame] | 36 | #include "devlink.h" |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 37 | #include "global1.h" |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 38 | #include "global2.h" |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 39 | #include "hwtstamp.h" |
Andrew Lunn | 10fa5bf | 2017-05-26 01:03:20 +0200 | [diff] [blame] | 40 | #include "phy.h" |
Vivien Didelot | 18abed2 | 2016-11-04 03:23:26 +0100 | [diff] [blame] | 41 | #include "port.h" |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 42 | #include "ptp.h" |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 43 | #include "serdes.h" |
Vivien Didelot | e7ba0fa | 2019-05-03 19:28:22 -0400 | [diff] [blame] | 44 | #include "smi.h" |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 45 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 46 | static void assert_reg_lock(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 3996a4f | 2015-10-30 18:56:45 -0400 | [diff] [blame] | 47 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 48 | if (unlikely(!mutex_is_locked(&chip->reg_lock))) { |
| 49 | dev_err(chip->dev, "Switch registers lock not held!\n"); |
Vivien Didelot | 3996a4f | 2015-10-30 18:56:45 -0400 | [diff] [blame] | 50 | dump_stack(); |
| 51 | } |
| 52 | } |
| 53 | |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 54 | int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val) |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 55 | { |
| 56 | int err; |
| 57 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 58 | assert_reg_lock(chip); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 59 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 60 | err = mv88e6xxx_smi_read(chip, addr, reg, val); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 61 | if (err) |
| 62 | return err; |
| 63 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 64 | dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n", |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 65 | addr, reg, *val); |
| 66 | |
| 67 | return 0; |
| 68 | } |
| 69 | |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 70 | int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val) |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 71 | { |
| 72 | int err; |
| 73 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 74 | assert_reg_lock(chip); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 75 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 76 | err = mv88e6xxx_smi_write(chip, addr, reg, val); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 77 | if (err) |
| 78 | return err; |
| 79 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 80 | dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n", |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 81 | addr, reg, val); |
| 82 | |
| 83 | return 0; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 84 | } |
| 85 | |
Vivien Didelot | 683f224 | 2019-08-09 18:47:54 -0400 | [diff] [blame] | 86 | int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg, |
| 87 | u16 mask, u16 val) |
| 88 | { |
| 89 | u16 data; |
| 90 | int err; |
| 91 | int i; |
| 92 | |
| 93 | /* There's no bus specific operation to wait for a mask */ |
| 94 | for (i = 0; i < 16; i++) { |
| 95 | err = mv88e6xxx_read(chip, addr, reg, &data); |
| 96 | if (err) |
| 97 | return err; |
| 98 | |
| 99 | if ((data & mask) == val) |
| 100 | return 0; |
| 101 | |
| 102 | usleep_range(1000, 2000); |
| 103 | } |
| 104 | |
| 105 | dev_err(chip->dev, "Timeout while waiting for switch\n"); |
| 106 | return -ETIMEDOUT; |
| 107 | } |
| 108 | |
Vivien Didelot | 19fb7f6 | 2019-08-09 18:47:55 -0400 | [diff] [blame] | 109 | int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg, |
| 110 | int bit, int val) |
| 111 | { |
| 112 | return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit), |
| 113 | val ? BIT(bit) : 0x0000); |
| 114 | } |
| 115 | |
Andrew Lunn | 10fa5bf | 2017-05-26 01:03:20 +0200 | [diff] [blame] | 116 | struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip) |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 117 | { |
| 118 | struct mv88e6xxx_mdio_bus *mdio_bus; |
| 119 | |
| 120 | mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus, |
| 121 | list); |
| 122 | if (!mdio_bus) |
| 123 | return NULL; |
| 124 | |
| 125 | return mdio_bus->bus; |
| 126 | } |
| 127 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 128 | static void mv88e6xxx_g1_irq_mask(struct irq_data *d) |
| 129 | { |
| 130 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 131 | unsigned int n = d->hwirq; |
| 132 | |
| 133 | chip->g1_irq.masked |= (1 << n); |
| 134 | } |
| 135 | |
| 136 | static void mv88e6xxx_g1_irq_unmask(struct irq_data *d) |
| 137 | { |
| 138 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 139 | unsigned int n = d->hwirq; |
| 140 | |
| 141 | chip->g1_irq.masked &= ~(1 << n); |
| 142 | } |
| 143 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 144 | static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 145 | { |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 146 | unsigned int nhandled = 0; |
| 147 | unsigned int sub_irq; |
| 148 | unsigned int n; |
| 149 | u16 reg; |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 150 | u16 ctl1; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 151 | int err; |
| 152 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 153 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 8246692 | 2017-06-15 12:13:59 -0400 | [diff] [blame] | 154 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 155 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 156 | |
| 157 | if (err) |
| 158 | goto out; |
| 159 | |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 160 | do { |
| 161 | for (n = 0; n < chip->g1_irq.nirqs; ++n) { |
| 162 | if (reg & (1 << n)) { |
| 163 | sub_irq = irq_find_mapping(chip->g1_irq.domain, |
| 164 | n); |
| 165 | handle_nested_irq(sub_irq); |
| 166 | ++nhandled; |
| 167 | } |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 168 | } |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 169 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 170 | mv88e6xxx_reg_lock(chip); |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 171 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1); |
| 172 | if (err) |
| 173 | goto unlock; |
| 174 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); |
| 175 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 176 | mv88e6xxx_reg_unlock(chip); |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 177 | if (err) |
| 178 | goto out; |
| 179 | ctl1 &= GENMASK(chip->g1_irq.nirqs, 0); |
| 180 | } while (reg & ctl1); |
| 181 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 182 | out: |
| 183 | return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE); |
| 184 | } |
| 185 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 186 | static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id) |
| 187 | { |
| 188 | struct mv88e6xxx_chip *chip = dev_id; |
| 189 | |
| 190 | return mv88e6xxx_g1_irq_thread_work(chip); |
| 191 | } |
| 192 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 193 | static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d) |
| 194 | { |
| 195 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 196 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 197 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d) |
| 201 | { |
| 202 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 203 | u16 mask = GENMASK(chip->g1_irq.nirqs, 0); |
| 204 | u16 reg; |
| 205 | int err; |
| 206 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 207 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, ®); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 208 | if (err) |
| 209 | goto out; |
| 210 | |
| 211 | reg &= ~mask; |
| 212 | reg |= (~chip->g1_irq.masked & mask); |
| 213 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 214 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 215 | if (err) |
| 216 | goto out; |
| 217 | |
| 218 | out: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 219 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 220 | } |
| 221 | |
Bhumika Goyal | 6eb15e2 | 2017-08-19 16:25:52 +0530 | [diff] [blame] | 222 | static const struct irq_chip mv88e6xxx_g1_irq_chip = { |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 223 | .name = "mv88e6xxx-g1", |
| 224 | .irq_mask = mv88e6xxx_g1_irq_mask, |
| 225 | .irq_unmask = mv88e6xxx_g1_irq_unmask, |
| 226 | .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock, |
| 227 | .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock, |
| 228 | }; |
| 229 | |
| 230 | static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d, |
| 231 | unsigned int irq, |
| 232 | irq_hw_number_t hwirq) |
| 233 | { |
| 234 | struct mv88e6xxx_chip *chip = d->host_data; |
| 235 | |
| 236 | irq_set_chip_data(irq, d->host_data); |
| 237 | irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq); |
| 238 | irq_set_noprobe(irq); |
| 239 | |
| 240 | return 0; |
| 241 | } |
| 242 | |
| 243 | static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = { |
| 244 | .map = mv88e6xxx_g1_irq_domain_map, |
| 245 | .xlate = irq_domain_xlate_twocell, |
| 246 | }; |
| 247 | |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 248 | /* To be called with reg_lock held */ |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 249 | static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 250 | { |
| 251 | int irq, virq; |
Andrew Lunn | 3460a57 | 2016-11-20 20:14:16 +0100 | [diff] [blame] | 252 | u16 mask; |
| 253 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 254 | mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask); |
Andrew Lunn | 3d5fdba | 2017-12-07 01:05:56 +0100 | [diff] [blame] | 255 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 256 | mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | 3460a57 | 2016-11-20 20:14:16 +0100 | [diff] [blame] | 257 | |
Andreas Färber | 5edef2f | 2016-11-27 23:26:28 +0100 | [diff] [blame] | 258 | for (irq = 0; irq < chip->g1_irq.nirqs; irq++) { |
Andrew Lunn | a3db3d3 | 2016-11-20 20:14:14 +0100 | [diff] [blame] | 259 | virq = irq_find_mapping(chip->g1_irq.domain, irq); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 260 | irq_dispose_mapping(virq); |
| 261 | } |
| 262 | |
Andrew Lunn | a3db3d3 | 2016-11-20 20:14:14 +0100 | [diff] [blame] | 263 | irq_domain_remove(chip->g1_irq.domain); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 264 | } |
| 265 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 266 | static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip) |
| 267 | { |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 268 | /* |
| 269 | * free_irq must be called without reg_lock taken because the irq |
| 270 | * handler takes this lock, too. |
| 271 | */ |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 272 | free_irq(chip->irq, chip); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 273 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 274 | mv88e6xxx_reg_lock(chip); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 275 | mv88e6xxx_g1_irq_free_common(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 276 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 280 | { |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 281 | int err, irq, virq; |
| 282 | u16 reg, mask; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 283 | |
| 284 | chip->g1_irq.nirqs = chip->info->g1_irqs; |
| 285 | chip->g1_irq.domain = irq_domain_add_simple( |
| 286 | NULL, chip->g1_irq.nirqs, 0, |
| 287 | &mv88e6xxx_g1_irq_domain_ops, chip); |
| 288 | if (!chip->g1_irq.domain) |
| 289 | return -ENOMEM; |
| 290 | |
| 291 | for (irq = 0; irq < chip->g1_irq.nirqs; irq++) |
| 292 | irq_create_mapping(chip->g1_irq.domain, irq); |
| 293 | |
| 294 | chip->g1_irq.chip = mv88e6xxx_g1_irq_chip; |
| 295 | chip->g1_irq.masked = ~0; |
| 296 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 297 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 298 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 299 | goto out_mapping; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 300 | |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 301 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 302 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 303 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 304 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 305 | goto out_disable; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 306 | |
| 307 | /* Reading the interrupt status clears (most of) them */ |
Vivien Didelot | 8246692 | 2017-06-15 12:13:59 -0400 | [diff] [blame] | 308 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 309 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 310 | goto out_disable; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 311 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 312 | return 0; |
| 313 | |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 314 | out_disable: |
Andrew Lunn | 3d5fdba | 2017-12-07 01:05:56 +0100 | [diff] [blame] | 315 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 316 | mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 317 | |
| 318 | out_mapping: |
| 319 | for (irq = 0; irq < 16; irq++) { |
| 320 | virq = irq_find_mapping(chip->g1_irq.domain, irq); |
| 321 | irq_dispose_mapping(virq); |
| 322 | } |
| 323 | |
| 324 | irq_domain_remove(chip->g1_irq.domain); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 325 | |
| 326 | return err; |
| 327 | } |
| 328 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 329 | static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip) |
| 330 | { |
Andrew Lunn | f6d9758 | 2019-02-23 17:43:56 +0100 | [diff] [blame] | 331 | static struct lock_class_key lock_key; |
| 332 | static struct lock_class_key request_key; |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 333 | int err; |
| 334 | |
| 335 | err = mv88e6xxx_g1_irq_setup_common(chip); |
| 336 | if (err) |
| 337 | return err; |
| 338 | |
Andrew Lunn | f6d9758 | 2019-02-23 17:43:56 +0100 | [diff] [blame] | 339 | /* These lock classes tells lockdep that global 1 irqs are in |
| 340 | * a different category than their parent GPIO, so it won't |
| 341 | * report false recursion. |
| 342 | */ |
| 343 | irq_set_lockdep_class(chip->irq, &lock_key, &request_key); |
| 344 | |
Andrew Lunn | 3095383 | 2020-01-06 17:13:48 +0100 | [diff] [blame] | 345 | snprintf(chip->irq_name, sizeof(chip->irq_name), |
| 346 | "mv88e6xxx-%s", dev_name(chip->dev)); |
| 347 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 348 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 349 | err = request_threaded_irq(chip->irq, NULL, |
| 350 | mv88e6xxx_g1_irq_thread_fn, |
Marek Behún | 0340376 | 2018-08-30 02:13:50 +0200 | [diff] [blame] | 351 | IRQF_ONESHOT | IRQF_SHARED, |
Andrew Lunn | 3095383 | 2020-01-06 17:13:48 +0100 | [diff] [blame] | 352 | chip->irq_name, chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 353 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 354 | if (err) |
| 355 | mv88e6xxx_g1_irq_free_common(chip); |
| 356 | |
| 357 | return err; |
| 358 | } |
| 359 | |
| 360 | static void mv88e6xxx_irq_poll(struct kthread_work *work) |
| 361 | { |
| 362 | struct mv88e6xxx_chip *chip = container_of(work, |
| 363 | struct mv88e6xxx_chip, |
| 364 | irq_poll_work.work); |
| 365 | mv88e6xxx_g1_irq_thread_work(chip); |
| 366 | |
| 367 | kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work, |
| 368 | msecs_to_jiffies(100)); |
| 369 | } |
| 370 | |
| 371 | static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip) |
| 372 | { |
| 373 | int err; |
| 374 | |
| 375 | err = mv88e6xxx_g1_irq_setup_common(chip); |
| 376 | if (err) |
| 377 | return err; |
| 378 | |
| 379 | kthread_init_delayed_work(&chip->irq_poll_work, |
| 380 | mv88e6xxx_irq_poll); |
| 381 | |
Florian Fainelli | 3f8b869 | 2019-02-21 20:09:27 -0800 | [diff] [blame] | 382 | chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev)); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 383 | if (IS_ERR(chip->kworker)) |
| 384 | return PTR_ERR(chip->kworker); |
| 385 | |
| 386 | kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work, |
| 387 | msecs_to_jiffies(100)); |
| 388 | |
| 389 | return 0; |
| 390 | } |
| 391 | |
| 392 | static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip) |
| 393 | { |
| 394 | kthread_cancel_delayed_work_sync(&chip->irq_poll_work); |
| 395 | kthread_destroy_worker(chip->kworker); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 396 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 397 | mv88e6xxx_reg_lock(chip); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 398 | mv88e6xxx_g1_irq_free_common(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 399 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 400 | } |
| 401 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 402 | static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip, |
| 403 | int port, phy_interface_t interface) |
| 404 | { |
| 405 | int err; |
| 406 | |
| 407 | if (chip->info->ops->port_set_rgmii_delay) { |
| 408 | err = chip->info->ops->port_set_rgmii_delay(chip, port, |
| 409 | interface); |
| 410 | if (err && err != -EOPNOTSUPP) |
| 411 | return err; |
| 412 | } |
| 413 | |
| 414 | if (chip->info->ops->port_set_cmode) { |
| 415 | err = chip->info->ops->port_set_cmode(chip, port, |
| 416 | interface); |
| 417 | if (err && err != -EOPNOTSUPP) |
| 418 | return err; |
| 419 | } |
| 420 | |
| 421 | return 0; |
| 422 | } |
| 423 | |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 424 | static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, |
| 425 | int link, int speed, int duplex, int pause, |
| 426 | phy_interface_t mode) |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 427 | { |
| 428 | int err; |
| 429 | |
| 430 | if (!chip->info->ops->port_set_link) |
| 431 | return 0; |
| 432 | |
| 433 | /* Port's MAC control must not be changed unless the link is down */ |
Hubert Feurstein | 43c8e0a | 2019-07-30 12:11:42 +0200 | [diff] [blame] | 434 | err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 435 | if (err) |
| 436 | return err; |
| 437 | |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 438 | if (chip->info->ops->port_set_speed_duplex) { |
| 439 | err = chip->info->ops->port_set_speed_duplex(chip, port, |
| 440 | speed, duplex); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 441 | if (err && err != -EOPNOTSUPP) |
| 442 | goto restore_link; |
| 443 | } |
| 444 | |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 445 | if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode) |
| 446 | mode = chip->info->ops->port_max_speed_mode(port); |
| 447 | |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 448 | if (chip->info->ops->port_set_pause) { |
| 449 | err = chip->info->ops->port_set_pause(chip, port, pause); |
| 450 | if (err) |
| 451 | goto restore_link; |
| 452 | } |
| 453 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 454 | err = mv88e6xxx_port_config_interface(chip, port, mode); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 455 | restore_link: |
| 456 | if (chip->info->ops->port_set_link(chip, port, link)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 457 | dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 458 | |
| 459 | return err; |
| 460 | } |
| 461 | |
Marek Vasut | d700ec4 | 2018-09-12 00:15:24 +0200 | [diff] [blame] | 462 | static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port) |
| 463 | { |
| 464 | struct mv88e6xxx_chip *chip = ds->priv; |
| 465 | |
| 466 | return port < chip->info->num_internal_phys; |
| 467 | } |
| 468 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 469 | static int mv88e6xxx_port_ppu_updates(struct mv88e6xxx_chip *chip, int port) |
| 470 | { |
| 471 | u16 reg; |
| 472 | int err; |
| 473 | |
| 474 | err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, ®); |
| 475 | if (err) { |
| 476 | dev_err(chip->dev, |
| 477 | "p%d: %s: failed to read port status\n", |
| 478 | port, __func__); |
| 479 | return err; |
| 480 | } |
| 481 | |
| 482 | return !!(reg & MV88E6XXX_PORT_STS_PHY_DETECT); |
| 483 | } |
| 484 | |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 485 | static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port, |
| 486 | struct phylink_link_state *state) |
| 487 | { |
| 488 | struct mv88e6xxx_chip *chip = ds->priv; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 489 | int lane; |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 490 | int err; |
| 491 | |
| 492 | mv88e6xxx_reg_lock(chip); |
| 493 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 494 | if (lane >= 0 && chip->info->ops->serdes_pcs_get_state) |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 495 | err = chip->info->ops->serdes_pcs_get_state(chip, port, lane, |
| 496 | state); |
| 497 | else |
| 498 | err = -EOPNOTSUPP; |
| 499 | mv88e6xxx_reg_unlock(chip); |
| 500 | |
| 501 | return err; |
| 502 | } |
| 503 | |
| 504 | static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port, |
| 505 | unsigned int mode, |
| 506 | phy_interface_t interface, |
| 507 | const unsigned long *advertise) |
| 508 | { |
| 509 | const struct mv88e6xxx_ops *ops = chip->info->ops; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 510 | int lane; |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 511 | |
| 512 | if (ops->serdes_pcs_config) { |
| 513 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 514 | if (lane >= 0) |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 515 | return ops->serdes_pcs_config(chip, port, lane, mode, |
| 516 | interface, advertise); |
| 517 | } |
| 518 | |
| 519 | return 0; |
| 520 | } |
| 521 | |
| 522 | static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port) |
| 523 | { |
| 524 | struct mv88e6xxx_chip *chip = ds->priv; |
| 525 | const struct mv88e6xxx_ops *ops; |
| 526 | int err = 0; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 527 | int lane; |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 528 | |
| 529 | ops = chip->info->ops; |
| 530 | |
| 531 | if (ops->serdes_pcs_an_restart) { |
| 532 | mv88e6xxx_reg_lock(chip); |
| 533 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 534 | if (lane >= 0) |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 535 | err = ops->serdes_pcs_an_restart(chip, port, lane); |
| 536 | mv88e6xxx_reg_unlock(chip); |
| 537 | |
| 538 | if (err) |
| 539 | dev_err(ds->dev, "p%d: failed to restart AN\n", port); |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port, |
| 544 | unsigned int mode, |
| 545 | int speed, int duplex) |
| 546 | { |
| 547 | const struct mv88e6xxx_ops *ops = chip->info->ops; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 548 | int lane; |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 549 | |
| 550 | if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) { |
| 551 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 552 | if (lane >= 0) |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 553 | return ops->serdes_pcs_link_up(chip, port, lane, |
| 554 | speed, duplex); |
| 555 | } |
| 556 | |
| 557 | return 0; |
| 558 | } |
| 559 | |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 560 | static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 561 | unsigned long *mask, |
| 562 | struct phylink_link_state *state) |
| 563 | { |
| 564 | if (!phy_interface_mode_is_8023z(state->interface)) { |
| 565 | /* 10M and 100M are only supported in non-802.3z mode */ |
| 566 | phylink_set(mask, 10baseT_Half); |
| 567 | phylink_set(mask, 10baseT_Full); |
| 568 | phylink_set(mask, 100baseT_Half); |
| 569 | phylink_set(mask, 100baseT_Full); |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 574 | unsigned long *mask, |
| 575 | struct phylink_link_state *state) |
| 576 | { |
| 577 | /* FIXME: if the port is in 1000Base-X mode, then it only supports |
| 578 | * 1000M FD speeds. In this case, CMODE will indicate 5. |
| 579 | */ |
| 580 | phylink_set(mask, 1000baseT_Full); |
| 581 | phylink_set(mask, 1000baseX_Full); |
| 582 | |
| 583 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 584 | } |
| 585 | |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 586 | static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 587 | unsigned long *mask, |
| 588 | struct phylink_link_state *state) |
| 589 | { |
| 590 | if (port >= 5) |
| 591 | phylink_set(mask, 2500baseX_Full); |
| 592 | |
| 593 | /* No ethtool bits for 200Mbps */ |
| 594 | phylink_set(mask, 1000baseT_Full); |
| 595 | phylink_set(mask, 1000baseX_Full); |
| 596 | |
| 597 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 598 | } |
| 599 | |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 600 | static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 601 | unsigned long *mask, |
| 602 | struct phylink_link_state *state) |
| 603 | { |
| 604 | /* No ethtool bits for 200Mbps */ |
| 605 | phylink_set(mask, 1000baseT_Full); |
| 606 | phylink_set(mask, 1000baseX_Full); |
| 607 | |
| 608 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 609 | } |
| 610 | |
| 611 | static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 612 | unsigned long *mask, |
| 613 | struct phylink_link_state *state) |
| 614 | { |
Andrew Lunn | ec26016 | 2019-02-08 22:25:44 +0100 | [diff] [blame] | 615 | if (port >= 9) { |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 616 | phylink_set(mask, 2500baseX_Full); |
Andrew Lunn | ec26016 | 2019-02-08 22:25:44 +0100 | [diff] [blame] | 617 | phylink_set(mask, 2500baseT_Full); |
| 618 | } |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 619 | |
| 620 | /* No ethtool bits for 200Mbps */ |
| 621 | phylink_set(mask, 1000baseT_Full); |
| 622 | phylink_set(mask, 1000baseX_Full); |
| 623 | |
| 624 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 625 | } |
| 626 | |
| 627 | static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 628 | unsigned long *mask, |
| 629 | struct phylink_link_state *state) |
| 630 | { |
| 631 | if (port >= 9) { |
| 632 | phylink_set(mask, 10000baseT_Full); |
| 633 | phylink_set(mask, 10000baseKR_Full); |
| 634 | } |
| 635 | |
| 636 | mv88e6390_phylink_validate(chip, port, mask, state); |
| 637 | } |
| 638 | |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 639 | static void mv88e6393x_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 640 | unsigned long *mask, |
| 641 | struct phylink_link_state *state) |
| 642 | { |
Marek Behún | dc2fc9f | 2021-11-04 18:17:47 +0100 | [diff] [blame] | 643 | bool is_6191x = |
| 644 | chip->info->prod_num == MV88E6XXX_PORT_SWITCH_ID_PROD_6191X; |
| 645 | |
| 646 | if (((port == 0 || port == 9) && !is_6191x) || port == 10) { |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 647 | phylink_set(mask, 10000baseT_Full); |
| 648 | phylink_set(mask, 10000baseKR_Full); |
| 649 | phylink_set(mask, 10000baseCR_Full); |
| 650 | phylink_set(mask, 10000baseSR_Full); |
| 651 | phylink_set(mask, 10000baseLR_Full); |
| 652 | phylink_set(mask, 10000baseLRM_Full); |
| 653 | phylink_set(mask, 10000baseER_Full); |
| 654 | phylink_set(mask, 5000baseT_Full); |
| 655 | phylink_set(mask, 2500baseX_Full); |
| 656 | phylink_set(mask, 2500baseT_Full); |
| 657 | } |
| 658 | |
| 659 | phylink_set(mask, 1000baseT_Full); |
| 660 | phylink_set(mask, 1000baseX_Full); |
| 661 | |
| 662 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 663 | } |
| 664 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 665 | static void mv88e6xxx_validate(struct dsa_switch *ds, int port, |
| 666 | unsigned long *supported, |
| 667 | struct phylink_link_state *state) |
| 668 | { |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 669 | __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; |
| 670 | struct mv88e6xxx_chip *chip = ds->priv; |
| 671 | |
| 672 | /* Allow all the expected bits */ |
| 673 | phylink_set(mask, Autoneg); |
| 674 | phylink_set(mask, Pause); |
| 675 | phylink_set_port_modes(mask); |
| 676 | |
| 677 | if (chip->info->ops->phylink_validate) |
| 678 | chip->info->ops->phylink_validate(chip, port, mask, state); |
| 679 | |
Sean Anderson | 4973056 | 2021-10-22 18:41:04 -0400 | [diff] [blame] | 680 | linkmode_and(supported, supported, mask); |
| 681 | linkmode_and(state->advertising, state->advertising, mask); |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 682 | |
| 683 | /* We can only operate at 2500BaseX or 1000BaseX. If requested |
| 684 | * to advertise both, only report advertising at 2500BaseX. |
| 685 | */ |
| 686 | phylink_helper_basex_speed(state); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 687 | } |
| 688 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 689 | static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port, |
| 690 | unsigned int mode, |
| 691 | const struct phylink_link_state *state) |
| 692 | { |
| 693 | struct mv88e6xxx_chip *chip = ds->priv; |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 694 | struct mv88e6xxx_port *p; |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 695 | int err; |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 696 | |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 697 | p = &chip->ports[port]; |
| 698 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 699 | /* FIXME: is this the correct test? If we're in fixed mode on an |
| 700 | * internal port, why should we process this any different from |
| 701 | * PHY mode? On the other hand, the port may be automedia between |
| 702 | * an internal PHY and the serdes... |
| 703 | */ |
Marek Vasut | d700ec4 | 2018-09-12 00:15:24 +0200 | [diff] [blame] | 704 | if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port)) |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 705 | return; |
| 706 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 707 | mv88e6xxx_reg_lock(chip); |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 708 | /* In inband mode, the link may come up at any time while the link |
| 709 | * is not forced down. Force the link down while we reconfigure the |
| 710 | * interface mode. |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 711 | */ |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 712 | if (mode == MLO_AN_INBAND && p->interface != state->interface && |
| 713 | chip->info->ops->port_set_link) |
| 714 | chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN); |
| 715 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 716 | err = mv88e6xxx_port_config_interface(chip, port, state->interface); |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 717 | if (err && err != -EOPNOTSUPP) |
| 718 | goto err_unlock; |
| 719 | |
| 720 | err = mv88e6xxx_serdes_pcs_config(chip, port, mode, state->interface, |
| 721 | state->advertising); |
| 722 | /* FIXME: we should restart negotiation if something changed - which |
| 723 | * is something we get if we convert to using phylinks PCS operations. |
| 724 | */ |
| 725 | if (err > 0) |
| 726 | err = 0; |
| 727 | |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 728 | /* Undo the forced down state above after completing configuration |
| 729 | * irrespective of its state on entry, which allows the link to come up. |
| 730 | */ |
| 731 | if (mode == MLO_AN_INBAND && p->interface != state->interface && |
| 732 | chip->info->ops->port_set_link) |
| 733 | chip->info->ops->port_set_link(chip, port, LINK_UNFORCED); |
| 734 | |
| 735 | p->interface = state->interface; |
| 736 | |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 737 | err_unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 738 | mv88e6xxx_reg_unlock(chip); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 739 | |
| 740 | if (err && err != -EOPNOTSUPP) |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 741 | dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 742 | } |
| 743 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 744 | static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port, |
| 745 | unsigned int mode, |
| 746 | phy_interface_t interface) |
| 747 | { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 748 | struct mv88e6xxx_chip *chip = ds->priv; |
| 749 | const struct mv88e6xxx_ops *ops; |
| 750 | int err = 0; |
| 751 | |
| 752 | ops = chip->info->ops; |
| 753 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 754 | mv88e6xxx_reg_lock(chip); |
Maarten Zanders | 4a3e0ae | 2021-10-11 16:27:20 +0200 | [diff] [blame] | 755 | /* Internal PHYs propagate their configuration directly to the MAC. |
| 756 | * External PHYs depend on whether the PPU is enabled for this port. |
| 757 | */ |
| 758 | if (((!mv88e6xxx_phy_is_internal(ds, port) && |
| 759 | !mv88e6xxx_port_ppu_updates(chip, port)) || |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 760 | mode == MLO_AN_FIXED) && ops->port_sync_link) |
| 761 | err = ops->port_sync_link(chip, port, mode, false); |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 762 | mv88e6xxx_reg_unlock(chip); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 763 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 764 | if (err) |
| 765 | dev_err(chip->dev, |
| 766 | "p%d: failed to force MAC link down\n", port); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port, |
| 770 | unsigned int mode, phy_interface_t interface, |
Russell King | 5b502a7 | 2020-02-26 10:23:46 +0000 | [diff] [blame] | 771 | struct phy_device *phydev, |
| 772 | int speed, int duplex, |
| 773 | bool tx_pause, bool rx_pause) |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 774 | { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 775 | struct mv88e6xxx_chip *chip = ds->priv; |
| 776 | const struct mv88e6xxx_ops *ops; |
| 777 | int err = 0; |
| 778 | |
| 779 | ops = chip->info->ops; |
| 780 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 781 | mv88e6xxx_reg_lock(chip); |
Maarten Zanders | 4a3e0ae | 2021-10-11 16:27:20 +0200 | [diff] [blame] | 782 | /* Internal PHYs propagate their configuration directly to the MAC. |
| 783 | * External PHYs depend on whether the PPU is enabled for this port. |
| 784 | */ |
| 785 | if ((!mv88e6xxx_phy_is_internal(ds, port) && |
| 786 | !mv88e6xxx_port_ppu_updates(chip, port)) || |
| 787 | mode == MLO_AN_FIXED) { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 788 | /* FIXME: for an automedia port, should we force the link |
| 789 | * down here - what if the link comes up due to "other" media |
| 790 | * while we're bringing the port up, how is the exclusivity |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 791 | * handled in the Marvell hardware? E.g. port 2 on 88E6390 |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 792 | * shared between internal PHY and Serdes. |
| 793 | */ |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 794 | err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed, |
| 795 | duplex); |
| 796 | if (err) |
| 797 | goto error; |
| 798 | |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 799 | if (ops->port_set_speed_duplex) { |
| 800 | err = ops->port_set_speed_duplex(chip, port, |
| 801 | speed, duplex); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 802 | if (err && err != -EOPNOTSUPP) |
| 803 | goto error; |
| 804 | } |
| 805 | |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 806 | if (ops->port_sync_link) |
| 807 | err = ops->port_sync_link(chip, port, mode, true); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 808 | } |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 809 | error: |
| 810 | mv88e6xxx_reg_unlock(chip); |
| 811 | |
| 812 | if (err && err != -EOPNOTSUPP) |
| 813 | dev_err(ds->dev, |
| 814 | "p%d: failed to configure MAC link up\n", port); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 815 | } |
| 816 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 817 | static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 818 | { |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 819 | if (!chip->info->ops->stats_snapshot) |
| 820 | return -EOPNOTSUPP; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 821 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 822 | return chip->info->ops->stats_snapshot(chip, port); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 823 | } |
| 824 | |
Andrew Lunn | e413e7e | 2015-04-02 04:06:38 +0200 | [diff] [blame] | 825 | static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = { |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 826 | { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, }, |
| 827 | { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, }, |
| 828 | { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, }, |
| 829 | { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, }, |
| 830 | { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, }, |
| 831 | { "in_pause", 4, 0x16, STATS_TYPE_BANK0, }, |
| 832 | { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, }, |
| 833 | { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, }, |
| 834 | { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, }, |
| 835 | { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, }, |
| 836 | { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, }, |
| 837 | { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, }, |
| 838 | { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, }, |
| 839 | { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, }, |
| 840 | { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, }, |
| 841 | { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, }, |
| 842 | { "out_pause", 4, 0x15, STATS_TYPE_BANK0, }, |
| 843 | { "excessive", 4, 0x11, STATS_TYPE_BANK0, }, |
| 844 | { "collisions", 4, 0x1e, STATS_TYPE_BANK0, }, |
| 845 | { "deferred", 4, 0x05, STATS_TYPE_BANK0, }, |
| 846 | { "single", 4, 0x14, STATS_TYPE_BANK0, }, |
| 847 | { "multiple", 4, 0x17, STATS_TYPE_BANK0, }, |
| 848 | { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, }, |
| 849 | { "late", 4, 0x1f, STATS_TYPE_BANK0, }, |
| 850 | { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, }, |
| 851 | { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, }, |
| 852 | { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, }, |
| 853 | { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, }, |
| 854 | { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, }, |
| 855 | { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, }, |
| 856 | { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, }, |
| 857 | { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, }, |
| 858 | { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, }, |
| 859 | { "in_discards", 4, 0x00, STATS_TYPE_BANK1, }, |
| 860 | { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, }, |
| 861 | { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, }, |
| 862 | { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, }, |
| 863 | { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, }, |
| 864 | { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, }, |
| 865 | { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, }, |
| 866 | { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, }, |
| 867 | { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, }, |
| 868 | { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, }, |
| 869 | { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, }, |
| 870 | { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, }, |
| 871 | { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, }, |
| 872 | { "in_management", 4, 0x0f, STATS_TYPE_BANK1, }, |
| 873 | { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, }, |
| 874 | { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, }, |
| 875 | { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, }, |
| 876 | { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, }, |
| 877 | { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, }, |
| 878 | { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, }, |
| 879 | { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, }, |
| 880 | { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, }, |
| 881 | { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, }, |
| 882 | { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, }, |
| 883 | { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, }, |
| 884 | { "out_management", 4, 0x1f, STATS_TYPE_BANK1, }, |
Andrew Lunn | e413e7e | 2015-04-02 04:06:38 +0200 | [diff] [blame] | 885 | }; |
| 886 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 887 | static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip, |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 888 | struct mv88e6xxx_hw_stat *s, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 889 | int port, u16 bank1_select, |
| 890 | u16 histogram) |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 891 | { |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 892 | u32 low; |
| 893 | u32 high = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 894 | u16 reg = 0; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 895 | int err; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 896 | u64 value; |
| 897 | |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 898 | switch (s->type) { |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 899 | case STATS_TYPE_PORT: |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 900 | err = mv88e6xxx_port_read(chip, port, s->reg, ®); |
| 901 | if (err) |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 902 | return U64_MAX; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 903 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 904 | low = reg; |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 905 | if (s->size == 4) { |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 906 | err = mv88e6xxx_port_read(chip, port, s->reg + 1, ®); |
| 907 | if (err) |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 908 | return U64_MAX; |
Rasmus Villemoes | 84b3fd1 | 2019-05-29 07:02:11 +0000 | [diff] [blame] | 909 | low |= ((u32)reg) << 16; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 910 | } |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 911 | break; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 912 | case STATS_TYPE_BANK1: |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 913 | reg = bank1_select; |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 914 | fallthrough; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 915 | case STATS_TYPE_BANK0: |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 916 | reg |= s->reg | histogram; |
Andrew Lunn | 7f9ef3a | 2016-11-21 23:27:05 +0100 | [diff] [blame] | 917 | mv88e6xxx_g1_stats_read(chip, reg, &low); |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 918 | if (s->size == 8) |
Andrew Lunn | 7f9ef3a | 2016-11-21 23:27:05 +0100 | [diff] [blame] | 919 | mv88e6xxx_g1_stats_read(chip, reg + 1, &high); |
Gustavo A. R. Silva | 9fc3e4d | 2017-05-11 22:11:29 -0500 | [diff] [blame] | 920 | break; |
| 921 | default: |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 922 | return U64_MAX; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 923 | } |
Andrew Lunn | 6e46e2d | 2019-02-28 18:14:03 +0100 | [diff] [blame] | 924 | value = (((u64)high) << 32) | low; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 925 | return value; |
| 926 | } |
| 927 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 928 | static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 929 | uint8_t *data, int types) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 930 | { |
| 931 | struct mv88e6xxx_hw_stat *stat; |
| 932 | int i, j; |
| 933 | |
| 934 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 935 | stat = &mv88e6xxx_hw_stats[i]; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 936 | if (stat->type & types) { |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 937 | memcpy(data + j * ETH_GSTRING_LEN, stat->string, |
| 938 | ETH_GSTRING_LEN); |
| 939 | j++; |
| 940 | } |
| 941 | } |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 942 | |
| 943 | return j; |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 944 | } |
| 945 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 946 | static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 947 | uint8_t *data) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 948 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 949 | return mv88e6xxx_stats_get_strings(chip, data, |
| 950 | STATS_TYPE_BANK0 | STATS_TYPE_PORT); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 951 | } |
| 952 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 953 | static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 954 | uint8_t *data) |
| 955 | { |
| 956 | return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0); |
| 957 | } |
| 958 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 959 | static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 960 | uint8_t *data) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 961 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 962 | return mv88e6xxx_stats_get_strings(chip, data, |
| 963 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 964 | } |
| 965 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 966 | static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = { |
| 967 | "atu_member_violation", |
| 968 | "atu_miss_violation", |
| 969 | "atu_full_violation", |
| 970 | "vtu_member_violation", |
| 971 | "vtu_miss_violation", |
| 972 | }; |
| 973 | |
| 974 | static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data) |
| 975 | { |
| 976 | unsigned int i; |
| 977 | |
| 978 | for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++) |
| 979 | strlcpy(data + i * ETH_GSTRING_LEN, |
| 980 | mv88e6xxx_atu_vtu_stats_strings[i], |
| 981 | ETH_GSTRING_LEN); |
| 982 | } |
| 983 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 984 | static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port, |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 985 | u32 stringset, uint8_t *data) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 986 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 987 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 988 | int count = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 989 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 990 | if (stringset != ETH_SS_STATS) |
| 991 | return; |
| 992 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 993 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 994 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 995 | if (chip->info->ops->stats_get_strings) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 996 | count = chip->info->ops->stats_get_strings(chip, data); |
| 997 | |
| 998 | if (chip->info->ops->serdes_get_strings) { |
| 999 | data += count * ETH_GSTRING_LEN; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1000 | count = chip->info->ops->serdes_get_strings(chip, port, data); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1001 | } |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 1002 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1003 | data += count * ETH_GSTRING_LEN; |
| 1004 | mv88e6xxx_atu_vtu_get_strings(data); |
| 1005 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1006 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1007 | } |
| 1008 | |
| 1009 | static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip, |
| 1010 | int types) |
| 1011 | { |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 1012 | struct mv88e6xxx_hw_stat *stat; |
| 1013 | int i, j; |
| 1014 | |
| 1015 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 1016 | stat = &mv88e6xxx_hw_stats[i]; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1017 | if (stat->type & types) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 1018 | j++; |
| 1019 | } |
| 1020 | return j; |
| 1021 | } |
| 1022 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1023 | static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 1024 | { |
| 1025 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 | |
| 1026 | STATS_TYPE_PORT); |
| 1027 | } |
| 1028 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 1029 | static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 1030 | { |
| 1031 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0); |
| 1032 | } |
| 1033 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1034 | static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 1035 | { |
| 1036 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 | |
| 1037 | STATS_TYPE_BANK1); |
| 1038 | } |
| 1039 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 1040 | static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1041 | { |
| 1042 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1043 | int serdes_count = 0; |
| 1044 | int count = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1045 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 1046 | if (sset != ETH_SS_STATS) |
| 1047 | return 0; |
| 1048 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1049 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1050 | if (chip->info->ops->stats_get_sset_count) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1051 | count = chip->info->ops->stats_get_sset_count(chip); |
| 1052 | if (count < 0) |
| 1053 | goto out; |
| 1054 | |
| 1055 | if (chip->info->ops->serdes_get_sset_count) |
| 1056 | serdes_count = chip->info->ops->serdes_get_sset_count(chip, |
| 1057 | port); |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1058 | if (serdes_count < 0) { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1059 | count = serdes_count; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1060 | goto out; |
| 1061 | } |
| 1062 | count += serdes_count; |
| 1063 | count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); |
| 1064 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1065 | out: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1066 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1067 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1068 | return count; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1069 | } |
| 1070 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1071 | static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1072 | uint64_t *data, int types, |
| 1073 | u16 bank1_select, u16 histogram) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1074 | { |
| 1075 | struct mv88e6xxx_hw_stat *stat; |
| 1076 | int i, j; |
| 1077 | |
| 1078 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 1079 | stat = &mv88e6xxx_hw_stats[i]; |
| 1080 | if (stat->type & types) { |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1081 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1082 | data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port, |
| 1083 | bank1_select, |
| 1084 | histogram); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1085 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 1086 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1087 | j++; |
| 1088 | } |
| 1089 | } |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1090 | return j; |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1091 | } |
| 1092 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1093 | static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1094 | uint64_t *data) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1095 | { |
| 1096 | return mv88e6xxx_stats_get_stats(chip, port, data, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1097 | STATS_TYPE_BANK0 | STATS_TYPE_PORT, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1098 | 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1099 | } |
| 1100 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 1101 | static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1102 | uint64_t *data) |
| 1103 | { |
| 1104 | return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0, |
| 1105 | 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
| 1106 | } |
| 1107 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1108 | static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1109 | uint64_t *data) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1110 | { |
| 1111 | return mv88e6xxx_stats_get_stats(chip, port, data, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1112 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1113 | MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9, |
| 1114 | MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1115 | } |
| 1116 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1117 | static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1118 | uint64_t *data) |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1119 | { |
| 1120 | return mv88e6xxx_stats_get_stats(chip, port, data, |
| 1121 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1122 | MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10, |
| 1123 | 0); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1124 | } |
| 1125 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1126 | static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1127 | uint64_t *data) |
| 1128 | { |
| 1129 | *data++ = chip->ports[port].atu_member_violation; |
| 1130 | *data++ = chip->ports[port].atu_miss_violation; |
| 1131 | *data++ = chip->ports[port].atu_full_violation; |
| 1132 | *data++ = chip->ports[port].vtu_member_violation; |
| 1133 | *data++ = chip->ports[port].vtu_miss_violation; |
| 1134 | } |
| 1135 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1136 | static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1137 | uint64_t *data) |
| 1138 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1139 | int count = 0; |
| 1140 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1141 | if (chip->info->ops->stats_get_stats) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1142 | count = chip->info->ops->stats_get_stats(chip, port, data); |
| 1143 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1144 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1145 | if (chip->info->ops->serdes_get_stats) { |
| 1146 | data += count; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1147 | count = chip->info->ops->serdes_get_stats(chip, port, data); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1148 | } |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1149 | data += count; |
| 1150 | mv88e6xxx_atu_vtu_get_stats(chip, port, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1151 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1152 | } |
| 1153 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1154 | static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port, |
| 1155 | uint64_t *data) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1156 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1157 | struct mv88e6xxx_chip *chip = ds->priv; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1158 | int ret; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1159 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1160 | mv88e6xxx_reg_lock(chip); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1161 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 1162 | ret = mv88e6xxx_stats_snapshot(chip, port); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1163 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 1164 | |
| 1165 | if (ret < 0) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1166 | return; |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1167 | |
| 1168 | mv88e6xxx_get_stats(chip, port, data); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1169 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1170 | } |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 1171 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1172 | static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port) |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1173 | { |
Andrew Lunn | 0d30bbd | 2020-02-16 18:54:13 +0100 | [diff] [blame] | 1174 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1175 | int len; |
| 1176 | |
| 1177 | len = 32 * sizeof(u16); |
| 1178 | if (chip->info->ops->serdes_get_regs_len) |
| 1179 | len += chip->info->ops->serdes_get_regs_len(chip, port); |
| 1180 | |
| 1181 | return len; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1182 | } |
| 1183 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1184 | static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port, |
| 1185 | struct ethtool_regs *regs, void *_p) |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1186 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1187 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1188 | int err; |
| 1189 | u16 reg; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1190 | u16 *p = _p; |
| 1191 | int i; |
| 1192 | |
Vivien Didelot | a5f3932 | 2018-12-17 16:05:21 -0500 | [diff] [blame] | 1193 | regs->version = chip->info->prod_num; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1194 | |
| 1195 | memset(p, 0xff, 32 * sizeof(u16)); |
| 1196 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1197 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 2306251 | 2016-05-09 13:22:45 -0400 | [diff] [blame] | 1198 | |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1199 | for (i = 0; i < 32; i++) { |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1200 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1201 | err = mv88e6xxx_port_read(chip, port, i, ®); |
| 1202 | if (!err) |
| 1203 | p[i] = reg; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1204 | } |
Vivien Didelot | 2306251 | 2016-05-09 13:22:45 -0400 | [diff] [blame] | 1205 | |
Andrew Lunn | 0d30bbd | 2020-02-16 18:54:13 +0100 | [diff] [blame] | 1206 | if (chip->info->ops->serdes_get_regs) |
| 1207 | chip->info->ops->serdes_get_regs(chip, port, &p[i]); |
| 1208 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1209 | mv88e6xxx_reg_unlock(chip); |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1210 | } |
| 1211 | |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 1212 | static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port, |
| 1213 | struct ethtool_eee *e) |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1214 | { |
Vivien Didelot | 5480db6 | 2017-08-01 16:32:40 -0400 | [diff] [blame] | 1215 | /* Nothing to do on the port's MAC */ |
| 1216 | return 0; |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1217 | } |
| 1218 | |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 1219 | static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port, |
| 1220 | struct ethtool_eee *e) |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1221 | { |
Vivien Didelot | 5480db6 | 2017-08-01 16:32:40 -0400 | [diff] [blame] | 1222 | /* Nothing to do on the port's MAC */ |
| 1223 | return 0; |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1224 | } |
| 1225 | |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1226 | /* Mask of the local ports allowed to receive frames from a given fabric port */ |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1227 | static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port) |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1228 | { |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1229 | struct dsa_switch *ds = chip->ds; |
| 1230 | struct dsa_switch_tree *dst = ds->dst; |
Vladimir Oltean | 6514406 | 2021-12-06 18:57:51 +0200 | [diff] [blame] | 1231 | struct dsa_port *dp, *other_dp; |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1232 | bool found = false; |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1233 | u16 pvlan; |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1234 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1235 | /* dev is a physical switch */ |
| 1236 | if (dev <= dst->last_switch) { |
| 1237 | list_for_each_entry(dp, &dst->ports, list) { |
| 1238 | if (dp->ds->index == dev && dp->index == port) { |
| 1239 | /* dp might be a DSA link or a user port, so it |
Vladimir Oltean | 6514406 | 2021-12-06 18:57:51 +0200 | [diff] [blame] | 1240 | * might or might not have a bridge. |
| 1241 | * Use the "found" variable for both cases. |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1242 | */ |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1243 | found = true; |
| 1244 | break; |
| 1245 | } |
| 1246 | } |
| 1247 | /* dev is a virtual bridge */ |
| 1248 | } else { |
| 1249 | list_for_each_entry(dp, &dst->ports, list) { |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1250 | unsigned int bridge_num = dsa_port_bridge_num_get(dp); |
| 1251 | |
| 1252 | if (!bridge_num) |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1253 | continue; |
| 1254 | |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1255 | if (bridge_num + dst->last_switch != dev) |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1256 | continue; |
| 1257 | |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1258 | found = true; |
| 1259 | break; |
| 1260 | } |
| 1261 | } |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1262 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1263 | /* Prevent frames from unknown switch or virtual bridge */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1264 | if (!found) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1265 | return 0; |
| 1266 | |
| 1267 | /* Frames from DSA links and CPU ports can egress any local port */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1268 | if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1269 | return mv88e6xxx_port_mask(chip); |
| 1270 | |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1271 | pvlan = 0; |
| 1272 | |
| 1273 | /* Frames from user ports can egress any local DSA links and CPU ports, |
| 1274 | * as well as any local member of their bridge group. |
| 1275 | */ |
Vladimir Oltean | 6514406 | 2021-12-06 18:57:51 +0200 | [diff] [blame] | 1276 | dsa_switch_for_each_port(other_dp, ds) |
| 1277 | if (other_dp->type == DSA_PORT_TYPE_CPU || |
| 1278 | other_dp->type == DSA_PORT_TYPE_DSA || |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1279 | dsa_port_bridge_same(dp, other_dp)) |
Vladimir Oltean | 6514406 | 2021-12-06 18:57:51 +0200 | [diff] [blame] | 1280 | pvlan |= BIT(other_dp->index); |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1281 | |
| 1282 | return pvlan; |
| 1283 | } |
| 1284 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 1285 | static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1286 | { |
| 1287 | u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port); |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1288 | |
| 1289 | /* prevent frames from going back out of the port they came in on */ |
| 1290 | output_ports &= ~BIT(port); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1291 | |
Vivien Didelot | 5a7921f | 2016-11-04 03:23:28 +0100 | [diff] [blame] | 1292 | return mv88e6xxx_port_set_vlan_map(chip, port, output_ports); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1293 | } |
| 1294 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1295 | static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port, |
| 1296 | u8 state) |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1297 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1298 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 553eb54 | 2016-05-13 20:38:23 -0400 | [diff] [blame] | 1299 | int err; |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1300 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1301 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | f894c29 | 2017-06-08 18:34:10 -0400 | [diff] [blame] | 1302 | err = mv88e6xxx_port_set_state(chip, port, state); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1303 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 553eb54 | 2016-05-13 20:38:23 -0400 | [diff] [blame] | 1304 | |
| 1305 | if (err) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1306 | dev_err(ds->dev, "p%d: failed to update state\n", port); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1307 | } |
| 1308 | |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 1309 | static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip) |
| 1310 | { |
| 1311 | int err; |
| 1312 | |
| 1313 | if (chip->info->ops->ieee_pri_map) { |
| 1314 | err = chip->info->ops->ieee_pri_map(chip); |
| 1315 | if (err) |
| 1316 | return err; |
| 1317 | } |
| 1318 | |
| 1319 | if (chip->info->ops->ip_pri_map) { |
| 1320 | err = chip->info->ops->ip_pri_map(chip); |
| 1321 | if (err) |
| 1322 | return err; |
| 1323 | } |
| 1324 | |
| 1325 | return 0; |
| 1326 | } |
| 1327 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1328 | static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip) |
| 1329 | { |
Vivien Didelot | c5f5176 | 2019-10-30 22:09:13 -0400 | [diff] [blame] | 1330 | struct dsa_switch *ds = chip->ds; |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1331 | int target, port; |
| 1332 | int err; |
| 1333 | |
| 1334 | if (!chip->info->global2_addr) |
| 1335 | return 0; |
| 1336 | |
| 1337 | /* Initialize the routing port to the 32 possible target devices */ |
| 1338 | for (target = 0; target < 32; target++) { |
Vivien Didelot | c5f5176 | 2019-10-30 22:09:13 -0400 | [diff] [blame] | 1339 | port = dsa_routing_port(ds, target); |
| 1340 | if (port == ds->num_ports) |
| 1341 | port = 0x1f; |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1342 | |
| 1343 | err = mv88e6xxx_g2_device_mapping_write(chip, target, port); |
| 1344 | if (err) |
| 1345 | return err; |
| 1346 | } |
| 1347 | |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 1348 | if (chip->info->ops->set_cascade_port) { |
| 1349 | port = MV88E6XXX_CASCADE_PORT_MULTIPLE; |
| 1350 | err = chip->info->ops->set_cascade_port(chip, port); |
| 1351 | if (err) |
| 1352 | return err; |
| 1353 | } |
| 1354 | |
Vivien Didelot | 23c9891 | 2018-05-09 11:38:50 -0400 | [diff] [blame] | 1355 | err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index); |
| 1356 | if (err) |
| 1357 | return err; |
| 1358 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1359 | return 0; |
| 1360 | } |
| 1361 | |
Vivien Didelot | b28f872 | 2018-04-26 21:56:44 -0400 | [diff] [blame] | 1362 | static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip) |
| 1363 | { |
| 1364 | /* Clear all trunk masks and mapping */ |
| 1365 | if (chip->info->global2_addr) |
| 1366 | return mv88e6xxx_g2_trunk_clear(chip); |
| 1367 | |
| 1368 | return 0; |
| 1369 | } |
| 1370 | |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 1371 | static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip) |
| 1372 | { |
| 1373 | if (chip->info->ops->rmu_disable) |
| 1374 | return chip->info->ops->rmu_disable(chip); |
| 1375 | |
| 1376 | return 0; |
| 1377 | } |
| 1378 | |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 1379 | static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip) |
| 1380 | { |
| 1381 | if (chip->info->ops->pot_clear) |
| 1382 | return chip->info->ops->pot_clear(chip); |
| 1383 | |
| 1384 | return 0; |
| 1385 | } |
| 1386 | |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 1387 | static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip) |
| 1388 | { |
| 1389 | if (chip->info->ops->mgmt_rsvd2cpu) |
| 1390 | return chip->info->ops->mgmt_rsvd2cpu(chip); |
| 1391 | |
| 1392 | return 0; |
| 1393 | } |
| 1394 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 1395 | static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip) |
| 1396 | { |
Vivien Didelot | c3a7d4a | 2017-03-11 16:12:51 -0500 | [diff] [blame] | 1397 | int err; |
| 1398 | |
Vivien Didelot | daefc94 | 2017-03-11 16:12:54 -0500 | [diff] [blame] | 1399 | err = mv88e6xxx_g1_atu_flush(chip, 0, true); |
| 1400 | if (err) |
| 1401 | return err; |
| 1402 | |
Rasmus Villemoes | 49506a9 | 2020-12-10 12:06:44 +0100 | [diff] [blame] | 1403 | /* The chips that have a "learn2all" bit in Global1, ATU |
| 1404 | * Control are precisely those whose port registers have a |
| 1405 | * Message Port bit in Port Control 1 and hence implement |
| 1406 | * ->port_setup_message_port. |
| 1407 | */ |
| 1408 | if (chip->info->ops->port_setup_message_port) { |
| 1409 | err = mv88e6xxx_g1_atu_set_learn2all(chip, true); |
| 1410 | if (err) |
| 1411 | return err; |
| 1412 | } |
Vivien Didelot | c3a7d4a | 2017-03-11 16:12:51 -0500 | [diff] [blame] | 1413 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 1414 | return mv88e6xxx_g1_atu_set_age_time(chip, 300000); |
| 1415 | } |
| 1416 | |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 1417 | static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip) |
| 1418 | { |
| 1419 | int port; |
| 1420 | int err; |
| 1421 | |
| 1422 | if (!chip->info->ops->irl_init_all) |
| 1423 | return 0; |
| 1424 | |
| 1425 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 1426 | /* Disable ingress rate limiting by resetting all per port |
| 1427 | * ingress rate limit resources to their initial state. |
| 1428 | */ |
| 1429 | err = chip->info->ops->irl_init_all(chip, port); |
| 1430 | if (err) |
| 1431 | return err; |
| 1432 | } |
| 1433 | |
| 1434 | return 0; |
| 1435 | } |
| 1436 | |
Vivien Didelot | 04a69a1 | 2017-10-13 14:18:05 -0400 | [diff] [blame] | 1437 | static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip) |
| 1438 | { |
| 1439 | if (chip->info->ops->set_switch_mac) { |
| 1440 | u8 addr[ETH_ALEN]; |
| 1441 | |
| 1442 | eth_random_addr(addr); |
| 1443 | |
| 1444 | return chip->info->ops->set_switch_mac(chip, addr); |
| 1445 | } |
| 1446 | |
| 1447 | return 0; |
| 1448 | } |
| 1449 | |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1450 | static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port) |
| 1451 | { |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1452 | struct dsa_switch_tree *dst = chip->ds->dst; |
| 1453 | struct dsa_switch *ds; |
| 1454 | struct dsa_port *dp; |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1455 | u16 pvlan = 0; |
| 1456 | |
| 1457 | if (!mv88e6xxx_has_pvt(chip)) |
Vivien Didelot | d14939b | 2019-10-21 16:51:25 -0400 | [diff] [blame] | 1458 | return 0; |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1459 | |
| 1460 | /* Skip the local source device, which uses in-chip port VLAN */ |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1461 | if (dev != chip->ds->index) { |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 1462 | pvlan = mv88e6xxx_port_vlan(chip, dev, port); |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1463 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1464 | ds = dsa_switch_find(dst->index, dev); |
| 1465 | dp = ds ? dsa_to_port(ds, port) : NULL; |
| 1466 | if (dp && dp->lag_dev) { |
| 1467 | /* As the PVT is used to limit flooding of |
| 1468 | * FORWARD frames, which use the LAG ID as the |
| 1469 | * source port, we must translate dev/port to |
| 1470 | * the special "LAG device" in the PVT, using |
| 1471 | * the LAG ID as the port number. |
| 1472 | */ |
Tobias Waldekranz | 78e70db | 2021-04-21 14:04:52 +0200 | [diff] [blame] | 1473 | dev = MV88E6XXX_G2_PVT_ADDR_DEV_TRUNK; |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1474 | port = dsa_lag_id(dst, dp->lag_dev); |
| 1475 | } |
| 1476 | } |
| 1477 | |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1478 | return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan); |
| 1479 | } |
| 1480 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1481 | static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip) |
| 1482 | { |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1483 | int dev, port; |
| 1484 | int err; |
| 1485 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1486 | if (!mv88e6xxx_has_pvt(chip)) |
| 1487 | return 0; |
| 1488 | |
| 1489 | /* Clear 5 Bit Port for usage with Marvell Link Street devices: |
| 1490 | * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev. |
| 1491 | */ |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1492 | err = mv88e6xxx_g2_misc_4_bit_port(chip); |
| 1493 | if (err) |
| 1494 | return err; |
| 1495 | |
| 1496 | for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) { |
| 1497 | for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) { |
| 1498 | err = mv88e6xxx_pvt_map(chip, dev, port); |
| 1499 | if (err) |
| 1500 | return err; |
| 1501 | } |
| 1502 | } |
| 1503 | |
| 1504 | return 0; |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1505 | } |
| 1506 | |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1507 | static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port) |
| 1508 | { |
| 1509 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1510 | int err; |
| 1511 | |
Tobias Waldekranz | ffcec3f | 2021-03-18 20:25:34 +0100 | [diff] [blame] | 1512 | if (dsa_to_port(ds, port)->lag_dev) |
| 1513 | /* Hardware is incapable of fast-aging a LAG through a |
| 1514 | * regular ATU move operation. Until we have something |
| 1515 | * more fancy in place this is a no-op. |
| 1516 | */ |
| 1517 | return; |
| 1518 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1519 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 1520 | err = mv88e6xxx_g1_atu_remove(chip, 0, port, false); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1521 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1522 | |
| 1523 | if (err) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1524 | dev_err(ds->dev, "p%d: failed to flush ATU\n", port); |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1525 | } |
| 1526 | |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 1527 | static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip) |
| 1528 | { |
Tobias Waldekranz | e545f86 | 2020-11-10 19:57:20 +0100 | [diff] [blame] | 1529 | if (!mv88e6xxx_max_vid(chip)) |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 1530 | return 0; |
| 1531 | |
| 1532 | return mv88e6xxx_g1_vtu_flush(chip); |
| 1533 | } |
| 1534 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1535 | static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid, |
| 1536 | struct mv88e6xxx_vtu_entry *entry) |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1537 | { |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1538 | int err; |
| 1539 | |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1540 | if (!chip->info->ops->vtu_getnext) |
| 1541 | return -EOPNOTSUPP; |
| 1542 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1543 | entry->vid = vid ? vid - 1 : mv88e6xxx_max_vid(chip); |
| 1544 | entry->valid = false; |
| 1545 | |
| 1546 | err = chip->info->ops->vtu_getnext(chip, entry); |
| 1547 | |
| 1548 | if (entry->vid != vid) |
| 1549 | entry->valid = false; |
| 1550 | |
| 1551 | return err; |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1552 | } |
| 1553 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 1554 | static int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip, |
| 1555 | int (*cb)(struct mv88e6xxx_chip *chip, |
| 1556 | const struct mv88e6xxx_vtu_entry *entry, |
| 1557 | void *priv), |
| 1558 | void *priv) |
| 1559 | { |
| 1560 | struct mv88e6xxx_vtu_entry entry = { |
| 1561 | .vid = mv88e6xxx_max_vid(chip), |
| 1562 | .valid = false, |
| 1563 | }; |
| 1564 | int err; |
| 1565 | |
| 1566 | if (!chip->info->ops->vtu_getnext) |
| 1567 | return -EOPNOTSUPP; |
| 1568 | |
| 1569 | do { |
| 1570 | err = chip->info->ops->vtu_getnext(chip, &entry); |
| 1571 | if (err) |
| 1572 | return err; |
| 1573 | |
| 1574 | if (!entry.valid) |
| 1575 | break; |
| 1576 | |
| 1577 | err = cb(chip, &entry, priv); |
| 1578 | if (err) |
| 1579 | return err; |
| 1580 | } while (entry.vid < mv88e6xxx_max_vid(chip)); |
| 1581 | |
| 1582 | return 0; |
| 1583 | } |
| 1584 | |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 1585 | static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip, |
| 1586 | struct mv88e6xxx_vtu_entry *entry) |
| 1587 | { |
| 1588 | if (!chip->info->ops->vtu_loadpurge) |
| 1589 | return -EOPNOTSUPP; |
| 1590 | |
| 1591 | return chip->info->ops->vtu_loadpurge(chip, entry); |
| 1592 | } |
| 1593 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 1594 | static int mv88e6xxx_fid_map_vlan(struct mv88e6xxx_chip *chip, |
| 1595 | const struct mv88e6xxx_vtu_entry *entry, |
| 1596 | void *_fid_bitmap) |
| 1597 | { |
| 1598 | unsigned long *fid_bitmap = _fid_bitmap; |
| 1599 | |
| 1600 | set_bit(entry->fid, fid_bitmap); |
| 1601 | return 0; |
| 1602 | } |
| 1603 | |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1604 | int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap) |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1605 | { |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1606 | int i, err; |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1607 | u16 fid; |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1608 | |
| 1609 | bitmap_zero(fid_bitmap, MV88E6XXX_N_FID); |
| 1610 | |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1611 | /* Set every FID bit used by the (un)bridged ports */ |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 1612 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1613 | err = mv88e6xxx_port_get_fid(chip, i, &fid); |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1614 | if (err) |
| 1615 | return err; |
| 1616 | |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1617 | set_bit(fid, fid_bitmap); |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1618 | } |
| 1619 | |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1620 | /* Set every FID bit used by the VLAN entries */ |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 1621 | return mv88e6xxx_vtu_walk(chip, mv88e6xxx_fid_map_vlan, fid_bitmap); |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1622 | } |
| 1623 | |
| 1624 | static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid) |
| 1625 | { |
| 1626 | DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID); |
| 1627 | int err; |
| 1628 | |
| 1629 | err = mv88e6xxx_fid_map(chip, fid_bitmap); |
| 1630 | if (err) |
| 1631 | return err; |
| 1632 | |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1633 | /* The reset value 0x000 is used to indicate that multiple address |
| 1634 | * databases are not needed. Return the next positive available. |
| 1635 | */ |
| 1636 | *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1637 | if (unlikely(*fid >= mv88e6xxx_num_databases(chip))) |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1638 | return -ENOSPC; |
| 1639 | |
| 1640 | /* Clear the database */ |
Vivien Didelot | daefc94 | 2017-03-11 16:12:54 -0500 | [diff] [blame] | 1641 | return mv88e6xxx_g1_atu_flush(chip, *fid, true); |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1642 | } |
| 1643 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1644 | static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1645 | u16 vid) |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1646 | { |
Vladimir Oltean | 0493fa7 | 2021-12-06 18:57:50 +0200 | [diff] [blame] | 1647 | struct dsa_port *dp = dsa_to_port(ds, port), *other_dp; |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1648 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 1649 | struct mv88e6xxx_vtu_entry vlan; |
Vladimir Oltean | 0493fa7 | 2021-12-06 18:57:50 +0200 | [diff] [blame] | 1650 | int err; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1651 | |
Andrew Lunn | db06ae41 | 2017-09-25 23:32:20 +0200 | [diff] [blame] | 1652 | /* DSA and CPU ports have to be members of multiple vlans */ |
Vladimir Oltean | 0493fa7 | 2021-12-06 18:57:50 +0200 | [diff] [blame] | 1653 | if (dsa_port_is_dsa(dp) || dsa_port_is_cpu(dp)) |
Andrew Lunn | db06ae41 | 2017-09-25 23:32:20 +0200 | [diff] [blame] | 1654 | return 0; |
| 1655 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1656 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1657 | if (err) |
| 1658 | return err; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1659 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1660 | if (!vlan.valid) |
| 1661 | return 0; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1662 | |
Vladimir Oltean | 0493fa7 | 2021-12-06 18:57:50 +0200 | [diff] [blame] | 1663 | dsa_switch_for_each_user_port(other_dp, ds) { |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1664 | struct net_device *other_br; |
| 1665 | |
Vladimir Oltean | 0493fa7 | 2021-12-06 18:57:50 +0200 | [diff] [blame] | 1666 | if (vlan.member[other_dp->index] == |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1667 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) |
| 1668 | continue; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1669 | |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1670 | if (dsa_port_bridge_same(dp, other_dp)) |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1671 | break; /* same bridge, check next VLAN */ |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1672 | |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1673 | other_br = dsa_port_bridge_dev_get(other_dp); |
| 1674 | if (!other_br) |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1675 | continue; |
Andrew Lunn | 66e2809 | 2016-12-11 21:07:19 +0100 | [diff] [blame] | 1676 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1677 | dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n", |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1678 | port, vlan.vid, other_dp->index, netdev_name(other_br)); |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1679 | return -EOPNOTSUPP; |
| 1680 | } |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1681 | |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1682 | return 0; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1683 | } |
| 1684 | |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1685 | static int mv88e6xxx_port_commit_pvid(struct mv88e6xxx_chip *chip, int port) |
| 1686 | { |
| 1687 | struct dsa_port *dp = dsa_to_port(chip->ds, port); |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1688 | struct net_device *br = dsa_port_bridge_dev_get(dp); |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1689 | struct mv88e6xxx_port *p = &chip->ports[port]; |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 1690 | u16 pvid = MV88E6XXX_VID_STANDALONE; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1691 | bool drop_untagged = false; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1692 | int err; |
| 1693 | |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1694 | if (br) { |
| 1695 | if (br_vlan_enabled(br)) { |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 1696 | pvid = p->bridge_pvid.vid; |
| 1697 | drop_untagged = !p->bridge_pvid.valid; |
| 1698 | } else { |
| 1699 | pvid = MV88E6XXX_VID_BRIDGED; |
| 1700 | } |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1701 | } |
| 1702 | |
| 1703 | err = mv88e6xxx_port_set_pvid(chip, port, pvid); |
| 1704 | if (err) |
| 1705 | return err; |
| 1706 | |
| 1707 | return mv88e6xxx_port_drop_untagged(chip, port, drop_untagged); |
| 1708 | } |
| 1709 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1710 | static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port, |
Vladimir Oltean | 89153ed | 2021-02-13 22:43:19 +0200 | [diff] [blame] | 1711 | bool vlan_filtering, |
| 1712 | struct netlink_ext_ack *extack) |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1713 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1714 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 81c6edb | 2017-06-12 12:37:41 -0400 | [diff] [blame] | 1715 | u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE : |
| 1716 | MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1717 | int err; |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1718 | |
Vladimir Oltean | bae33f2 | 2021-01-09 02:01:50 +0200 | [diff] [blame] | 1719 | if (!mv88e6xxx_max_vid(chip)) |
| 1720 | return -EOPNOTSUPP; |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1721 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1722 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1723 | |
Vivien Didelot | 385a099 | 2016-11-04 03:23:31 +0100 | [diff] [blame] | 1724 | err = mv88e6xxx_port_set_8021q_mode(chip, port, mode); |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1725 | if (err) |
| 1726 | goto unlock; |
| 1727 | |
| 1728 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 1729 | if (err) |
| 1730 | goto unlock; |
| 1731 | |
| 1732 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1733 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1734 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1735 | return err; |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1736 | } |
| 1737 | |
Vivien Didelot | 57d3231 | 2016-06-20 13:13:58 -0400 | [diff] [blame] | 1738 | static int |
| 1739 | mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port, |
Vivien Didelot | 80e0236 | 2017-11-30 11:23:57 -0500 | [diff] [blame] | 1740 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1741 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1742 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1743 | int err; |
| 1744 | |
Tobias Waldekranz | e545f86 | 2020-11-10 19:57:20 +0100 | [diff] [blame] | 1745 | if (!mv88e6xxx_max_vid(chip)) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1746 | return -EOPNOTSUPP; |
| 1747 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1748 | /* If the requested port doesn't belong to the same bridge as the VLAN |
| 1749 | * members, do not support it (yet) and fallback to software VLAN. |
| 1750 | */ |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1751 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1752 | err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid); |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1753 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1754 | |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1755 | return err; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1756 | } |
| 1757 | |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1758 | static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port, |
| 1759 | const unsigned char *addr, u16 vid, |
| 1760 | u8 state) |
| 1761 | { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1762 | struct mv88e6xxx_atu_entry entry; |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1763 | struct mv88e6xxx_vtu_entry vlan; |
| 1764 | u16 fid; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1765 | int err; |
| 1766 | |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 1767 | /* Ports have two private address databases: one for when the port is |
| 1768 | * standalone and one for when the port is under a bridge and the |
| 1769 | * 802.1Q mode is disabled. When the port is standalone, DSA wants its |
| 1770 | * address database to remain 100% empty, so we never load an ATU entry |
| 1771 | * into a standalone port's database. Therefore, translate the null |
| 1772 | * VLAN ID into the port's database used for VLAN-unaware bridging. |
| 1773 | */ |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1774 | if (vid == 0) { |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 1775 | fid = MV88E6XXX_FID_BRIDGED; |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1776 | } else { |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1777 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1778 | if (err) |
| 1779 | return err; |
| 1780 | |
| 1781 | /* switchdev expects -EOPNOTSUPP to honor software VLANs */ |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1782 | if (!vlan.valid) |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1783 | return -EOPNOTSUPP; |
| 1784 | |
| 1785 | fid = vlan.fid; |
| 1786 | } |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1787 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1788 | entry.state = 0; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1789 | ether_addr_copy(entry.mac, addr); |
| 1790 | eth_addr_dec(entry.mac); |
| 1791 | |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1792 | err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry); |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1793 | if (err) |
| 1794 | return err; |
| 1795 | |
| 1796 | /* Initialize a fresh ATU entry if it isn't found */ |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1797 | if (!entry.state || !ether_addr_equal(entry.mac, addr)) { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1798 | memset(&entry, 0, sizeof(entry)); |
| 1799 | ether_addr_copy(entry.mac, addr); |
| 1800 | } |
| 1801 | |
| 1802 | /* Purge the ATU entry only if no port is using it anymore */ |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1803 | if (!state) { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1804 | entry.portvec &= ~BIT(port); |
| 1805 | if (!entry.portvec) |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1806 | entry.state = 0; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1807 | } else { |
DENG Qingfang | f72f2fb | 2021-01-30 21:43:34 +0800 | [diff] [blame] | 1808 | if (state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC) |
| 1809 | entry.portvec = BIT(port); |
| 1810 | else |
| 1811 | entry.portvec |= BIT(port); |
| 1812 | |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1813 | entry.state = state; |
| 1814 | } |
| 1815 | |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1816 | return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry); |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1817 | } |
| 1818 | |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 1819 | static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port, |
| 1820 | const struct mv88e6xxx_policy *policy) |
| 1821 | { |
| 1822 | enum mv88e6xxx_policy_mapping mapping = policy->mapping; |
| 1823 | enum mv88e6xxx_policy_action action = policy->action; |
| 1824 | const u8 *addr = policy->addr; |
| 1825 | u16 vid = policy->vid; |
| 1826 | u8 state; |
| 1827 | int err; |
| 1828 | int id; |
| 1829 | |
| 1830 | if (!chip->info->ops->port_set_policy) |
| 1831 | return -EOPNOTSUPP; |
| 1832 | |
| 1833 | switch (mapping) { |
| 1834 | case MV88E6XXX_POLICY_MAPPING_DA: |
| 1835 | case MV88E6XXX_POLICY_MAPPING_SA: |
| 1836 | if (action == MV88E6XXX_POLICY_ACTION_NORMAL) |
| 1837 | state = 0; /* Dissociate the port and address */ |
| 1838 | else if (action == MV88E6XXX_POLICY_ACTION_DISCARD && |
| 1839 | is_multicast_ether_addr(addr)) |
| 1840 | state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY; |
| 1841 | else if (action == MV88E6XXX_POLICY_ACTION_DISCARD && |
| 1842 | is_unicast_ether_addr(addr)) |
| 1843 | state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY; |
| 1844 | else |
| 1845 | return -EOPNOTSUPP; |
| 1846 | |
| 1847 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, |
| 1848 | state); |
| 1849 | if (err) |
| 1850 | return err; |
| 1851 | break; |
| 1852 | default: |
| 1853 | return -EOPNOTSUPP; |
| 1854 | } |
| 1855 | |
| 1856 | /* Skip the port's policy clearing if the mapping is still in use */ |
| 1857 | if (action == MV88E6XXX_POLICY_ACTION_NORMAL) |
| 1858 | idr_for_each_entry(&chip->policies, policy, id) |
| 1859 | if (policy->port == port && |
| 1860 | policy->mapping == mapping && |
| 1861 | policy->action != action) |
| 1862 | return 0; |
| 1863 | |
| 1864 | return chip->info->ops->port_set_policy(chip, port, mapping, action); |
| 1865 | } |
| 1866 | |
| 1867 | static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port, |
| 1868 | struct ethtool_rx_flow_spec *fs) |
| 1869 | { |
| 1870 | struct ethhdr *mac_entry = &fs->h_u.ether_spec; |
| 1871 | struct ethhdr *mac_mask = &fs->m_u.ether_spec; |
| 1872 | enum mv88e6xxx_policy_mapping mapping; |
| 1873 | enum mv88e6xxx_policy_action action; |
| 1874 | struct mv88e6xxx_policy *policy; |
| 1875 | u16 vid = 0; |
| 1876 | u8 *addr; |
| 1877 | int err; |
| 1878 | int id; |
| 1879 | |
| 1880 | if (fs->location != RX_CLS_LOC_ANY) |
| 1881 | return -EINVAL; |
| 1882 | |
| 1883 | if (fs->ring_cookie == RX_CLS_FLOW_DISC) |
| 1884 | action = MV88E6XXX_POLICY_ACTION_DISCARD; |
| 1885 | else |
| 1886 | return -EOPNOTSUPP; |
| 1887 | |
| 1888 | switch (fs->flow_type & ~FLOW_EXT) { |
| 1889 | case ETHER_FLOW: |
| 1890 | if (!is_zero_ether_addr(mac_mask->h_dest) && |
| 1891 | is_zero_ether_addr(mac_mask->h_source)) { |
| 1892 | mapping = MV88E6XXX_POLICY_MAPPING_DA; |
| 1893 | addr = mac_entry->h_dest; |
| 1894 | } else if (is_zero_ether_addr(mac_mask->h_dest) && |
| 1895 | !is_zero_ether_addr(mac_mask->h_source)) { |
| 1896 | mapping = MV88E6XXX_POLICY_MAPPING_SA; |
| 1897 | addr = mac_entry->h_source; |
| 1898 | } else { |
| 1899 | /* Cannot support DA and SA mapping in the same rule */ |
| 1900 | return -EOPNOTSUPP; |
| 1901 | } |
| 1902 | break; |
| 1903 | default: |
| 1904 | return -EOPNOTSUPP; |
| 1905 | } |
| 1906 | |
| 1907 | if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) { |
Andrew Lunn | 0484428 | 2020-07-05 21:38:08 +0200 | [diff] [blame] | 1908 | if (fs->m_ext.vlan_tci != htons(0xffff)) |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 1909 | return -EOPNOTSUPP; |
| 1910 | vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK; |
| 1911 | } |
| 1912 | |
| 1913 | idr_for_each_entry(&chip->policies, policy, id) { |
| 1914 | if (policy->port == port && policy->mapping == mapping && |
| 1915 | policy->action == action && policy->vid == vid && |
| 1916 | ether_addr_equal(policy->addr, addr)) |
| 1917 | return -EEXIST; |
| 1918 | } |
| 1919 | |
| 1920 | policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL); |
| 1921 | if (!policy) |
| 1922 | return -ENOMEM; |
| 1923 | |
| 1924 | fs->location = 0; |
| 1925 | err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff, |
| 1926 | GFP_KERNEL); |
| 1927 | if (err) { |
| 1928 | devm_kfree(chip->dev, policy); |
| 1929 | return err; |
| 1930 | } |
| 1931 | |
| 1932 | memcpy(&policy->fs, fs, sizeof(*fs)); |
| 1933 | ether_addr_copy(policy->addr, addr); |
| 1934 | policy->mapping = mapping; |
| 1935 | policy->action = action; |
| 1936 | policy->port = port; |
| 1937 | policy->vid = vid; |
| 1938 | |
| 1939 | err = mv88e6xxx_policy_apply(chip, port, policy); |
| 1940 | if (err) { |
| 1941 | idr_remove(&chip->policies, fs->location); |
| 1942 | devm_kfree(chip->dev, policy); |
| 1943 | return err; |
| 1944 | } |
| 1945 | |
| 1946 | return 0; |
| 1947 | } |
| 1948 | |
| 1949 | static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port, |
| 1950 | struct ethtool_rxnfc *rxnfc, u32 *rule_locs) |
| 1951 | { |
| 1952 | struct ethtool_rx_flow_spec *fs = &rxnfc->fs; |
| 1953 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1954 | struct mv88e6xxx_policy *policy; |
| 1955 | int err; |
| 1956 | int id; |
| 1957 | |
| 1958 | mv88e6xxx_reg_lock(chip); |
| 1959 | |
| 1960 | switch (rxnfc->cmd) { |
| 1961 | case ETHTOOL_GRXCLSRLCNT: |
| 1962 | rxnfc->data = 0; |
| 1963 | rxnfc->data |= RX_CLS_LOC_SPECIAL; |
| 1964 | rxnfc->rule_cnt = 0; |
| 1965 | idr_for_each_entry(&chip->policies, policy, id) |
| 1966 | if (policy->port == port) |
| 1967 | rxnfc->rule_cnt++; |
| 1968 | err = 0; |
| 1969 | break; |
| 1970 | case ETHTOOL_GRXCLSRULE: |
| 1971 | err = -ENOENT; |
| 1972 | policy = idr_find(&chip->policies, fs->location); |
| 1973 | if (policy) { |
| 1974 | memcpy(fs, &policy->fs, sizeof(*fs)); |
| 1975 | err = 0; |
| 1976 | } |
| 1977 | break; |
| 1978 | case ETHTOOL_GRXCLSRLALL: |
| 1979 | rxnfc->data = 0; |
| 1980 | rxnfc->rule_cnt = 0; |
| 1981 | idr_for_each_entry(&chip->policies, policy, id) |
| 1982 | if (policy->port == port) |
| 1983 | rule_locs[rxnfc->rule_cnt++] = id; |
| 1984 | err = 0; |
| 1985 | break; |
| 1986 | default: |
| 1987 | err = -EOPNOTSUPP; |
| 1988 | break; |
| 1989 | } |
| 1990 | |
| 1991 | mv88e6xxx_reg_unlock(chip); |
| 1992 | |
| 1993 | return err; |
| 1994 | } |
| 1995 | |
| 1996 | static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port, |
| 1997 | struct ethtool_rxnfc *rxnfc) |
| 1998 | { |
| 1999 | struct ethtool_rx_flow_spec *fs = &rxnfc->fs; |
| 2000 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2001 | struct mv88e6xxx_policy *policy; |
| 2002 | int err; |
| 2003 | |
| 2004 | mv88e6xxx_reg_lock(chip); |
| 2005 | |
| 2006 | switch (rxnfc->cmd) { |
| 2007 | case ETHTOOL_SRXCLSRLINS: |
| 2008 | err = mv88e6xxx_policy_insert(chip, port, fs); |
| 2009 | break; |
| 2010 | case ETHTOOL_SRXCLSRLDEL: |
| 2011 | err = -ENOENT; |
| 2012 | policy = idr_remove(&chip->policies, fs->location); |
| 2013 | if (policy) { |
| 2014 | policy->action = MV88E6XXX_POLICY_ACTION_NORMAL; |
| 2015 | err = mv88e6xxx_policy_apply(chip, port, policy); |
| 2016 | devm_kfree(chip->dev, policy); |
| 2017 | } |
| 2018 | break; |
| 2019 | default: |
| 2020 | err = -EOPNOTSUPP; |
| 2021 | break; |
| 2022 | } |
| 2023 | |
| 2024 | mv88e6xxx_reg_unlock(chip); |
| 2025 | |
| 2026 | return err; |
| 2027 | } |
| 2028 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2029 | static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port, |
| 2030 | u16 vid) |
| 2031 | { |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2032 | u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC; |
Tobias Waldekranz | 0806dd46 | 2021-03-18 20:25:37 +0100 | [diff] [blame] | 2033 | u8 broadcast[ETH_ALEN]; |
| 2034 | |
| 2035 | eth_broadcast_addr(broadcast); |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2036 | |
| 2037 | return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state); |
| 2038 | } |
| 2039 | |
| 2040 | static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid) |
| 2041 | { |
| 2042 | int port; |
| 2043 | int err; |
| 2044 | |
| 2045 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 2046 | struct dsa_port *dp = dsa_to_port(chip->ds, port); |
| 2047 | struct net_device *brport; |
| 2048 | |
| 2049 | if (dsa_is_unused_port(chip->ds, port)) |
| 2050 | continue; |
| 2051 | |
| 2052 | brport = dsa_port_to_bridge_port(dp); |
| 2053 | if (brport && !br_port_flag_is_set(brport, BR_BCAST_FLOOD)) |
| 2054 | /* Skip bridged user ports where broadcast |
| 2055 | * flooding is disabled. |
| 2056 | */ |
| 2057 | continue; |
| 2058 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2059 | err = mv88e6xxx_port_add_broadcast(chip, port, vid); |
| 2060 | if (err) |
| 2061 | return err; |
| 2062 | } |
| 2063 | |
| 2064 | return 0; |
| 2065 | } |
| 2066 | |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 2067 | struct mv88e6xxx_port_broadcast_sync_ctx { |
| 2068 | int port; |
| 2069 | bool flood; |
| 2070 | }; |
| 2071 | |
| 2072 | static int |
| 2073 | mv88e6xxx_port_broadcast_sync_vlan(struct mv88e6xxx_chip *chip, |
| 2074 | const struct mv88e6xxx_vtu_entry *vlan, |
| 2075 | void *_ctx) |
| 2076 | { |
| 2077 | struct mv88e6xxx_port_broadcast_sync_ctx *ctx = _ctx; |
| 2078 | u8 broadcast[ETH_ALEN]; |
| 2079 | u8 state; |
| 2080 | |
| 2081 | if (ctx->flood) |
| 2082 | state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC; |
| 2083 | else |
| 2084 | state = MV88E6XXX_G1_ATU_DATA_STATE_MC_UNUSED; |
| 2085 | |
| 2086 | eth_broadcast_addr(broadcast); |
| 2087 | |
| 2088 | return mv88e6xxx_port_db_load_purge(chip, ctx->port, broadcast, |
| 2089 | vlan->vid, state); |
| 2090 | } |
| 2091 | |
| 2092 | static int mv88e6xxx_port_broadcast_sync(struct mv88e6xxx_chip *chip, int port, |
| 2093 | bool flood) |
| 2094 | { |
| 2095 | struct mv88e6xxx_port_broadcast_sync_ctx ctx = { |
| 2096 | .port = port, |
| 2097 | .flood = flood, |
| 2098 | }; |
| 2099 | struct mv88e6xxx_vtu_entry vid0 = { |
| 2100 | .vid = 0, |
| 2101 | }; |
| 2102 | int err; |
| 2103 | |
| 2104 | /* Update the port's private database... */ |
| 2105 | err = mv88e6xxx_port_broadcast_sync_vlan(chip, &vid0, &ctx); |
| 2106 | if (err) |
| 2107 | return err; |
| 2108 | |
| 2109 | /* ...and the database for all VLANs. */ |
| 2110 | return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_broadcast_sync_vlan, |
| 2111 | &ctx); |
| 2112 | } |
| 2113 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2114 | static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port, |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2115 | u16 vid, u8 member, bool warn) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2116 | { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2117 | const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 2118 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2119 | int i, err; |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 2120 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2121 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2122 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2123 | return err; |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2124 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2125 | if (!vlan.valid) { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2126 | memset(&vlan, 0, sizeof(vlan)); |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 2127 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2128 | err = mv88e6xxx_atu_new(chip, &vlan.fid); |
| 2129 | if (err) |
| 2130 | return err; |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2131 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2132 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) |
| 2133 | if (i == port) |
| 2134 | vlan.member[i] = member; |
| 2135 | else |
| 2136 | vlan.member[i] = non_member; |
| 2137 | |
| 2138 | vlan.vid = vid; |
| 2139 | vlan.valid = true; |
| 2140 | |
| 2141 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
| 2142 | if (err) |
| 2143 | return err; |
| 2144 | |
| 2145 | err = mv88e6xxx_broadcast_setup(chip, vlan.vid); |
| 2146 | if (err) |
| 2147 | return err; |
| 2148 | } else if (vlan.member[port] != member) { |
| 2149 | vlan.member[port] = member; |
| 2150 | |
| 2151 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
| 2152 | if (err) |
| 2153 | return err; |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2154 | } else if (warn) { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2155 | dev_info(chip->dev, "p%d: already a member of VLAN %d\n", |
| 2156 | port, vid); |
| 2157 | } |
| 2158 | |
| 2159 | return 0; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2160 | } |
| 2161 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2162 | static int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, |
Vladimir Oltean | 31046a5 | 2021-02-13 22:43:18 +0200 | [diff] [blame] | 2163 | const struct switchdev_obj_port_vlan *vlan, |
| 2164 | struct netlink_ext_ack *extack) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2165 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2166 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2167 | bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; |
| 2168 | bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2169 | struct mv88e6xxx_port *p = &chip->ports[port]; |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2170 | bool warn; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2171 | u8 member; |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2172 | int err; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2173 | |
Eldar Gasanov | b8b79c4 | 2021-06-21 11:54:38 +0300 | [diff] [blame] | 2174 | if (!vlan->vid) |
| 2175 | return 0; |
| 2176 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2177 | err = mv88e6xxx_port_vlan_prepare(ds, port, vlan); |
| 2178 | if (err) |
| 2179 | return err; |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 2180 | |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2181 | if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2182 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2183 | else if (untagged) |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2184 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2185 | else |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2186 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2187 | |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2188 | /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port |
| 2189 | * and then the CPU port. Do not warn for duplicates for the CPU port. |
| 2190 | */ |
| 2191 | warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port); |
| 2192 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2193 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2194 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2195 | err = mv88e6xxx_port_vlan_join(chip, port, vlan->vid, member, warn); |
| 2196 | if (err) { |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 2197 | dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port, |
| 2198 | vlan->vid, untagged ? 'u' : 't'); |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2199 | goto out; |
| 2200 | } |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2201 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2202 | if (pvid) { |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2203 | p->bridge_pvid.vid = vlan->vid; |
| 2204 | p->bridge_pvid.valid = true; |
| 2205 | |
| 2206 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 2207 | if (err) |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2208 | goto out; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2209 | } else if (vlan->vid && p->bridge_pvid.vid == vlan->vid) { |
| 2210 | /* The old pvid was reinstalled as a non-pvid VLAN */ |
| 2211 | p->bridge_pvid.valid = false; |
| 2212 | |
| 2213 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 2214 | if (err) |
| 2215 | goto out; |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2216 | } |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2217 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2218 | out: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2219 | mv88e6xxx_reg_unlock(chip); |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2220 | |
| 2221 | return err; |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 2222 | } |
| 2223 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2224 | static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip, |
| 2225 | int port, u16 vid) |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2226 | { |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 2227 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2228 | int i, err; |
| 2229 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2230 | if (!vid) |
Vladimir Oltean | c92c741 | 2021-07-22 16:05:51 +0300 | [diff] [blame] | 2231 | return 0; |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2232 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2233 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2234 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2235 | return err; |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2236 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2237 | /* If the VLAN doesn't exist in hardware or the port isn't a member, |
| 2238 | * tell switchdev that this VLAN is likely handled in software. |
| 2239 | */ |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2240 | if (!vlan.valid || |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2241 | vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) |
Vivien Didelot | 3c06f08 | 2016-02-05 14:04:39 -0500 | [diff] [blame] | 2242 | return -EOPNOTSUPP; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2243 | |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2244 | vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2245 | |
| 2246 | /* keep the VLAN unless all ports are excluded */ |
Vivien Didelot | f02bdff | 2015-10-11 18:08:36 -0400 | [diff] [blame] | 2247 | vlan.valid = false; |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 2248 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2249 | if (vlan.member[i] != |
| 2250 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) { |
Vivien Didelot | f02bdff | 2015-10-11 18:08:36 -0400 | [diff] [blame] | 2251 | vlan.valid = true; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2252 | break; |
| 2253 | } |
| 2254 | } |
| 2255 | |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2256 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2257 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2258 | return err; |
| 2259 | |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 2260 | return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2261 | } |
| 2262 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2263 | static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, |
| 2264 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2265 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2266 | struct mv88e6xxx_chip *chip = ds->priv; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2267 | struct mv88e6xxx_port *p = &chip->ports[port]; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2268 | int err = 0; |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 2269 | u16 pvid; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2270 | |
Tobias Waldekranz | e545f86 | 2020-11-10 19:57:20 +0100 | [diff] [blame] | 2271 | if (!mv88e6xxx_max_vid(chip)) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 2272 | return -EOPNOTSUPP; |
| 2273 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2274 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2275 | |
Vivien Didelot | 77064f3 | 2016-11-04 03:23:30 +0100 | [diff] [blame] | 2276 | err = mv88e6xxx_port_get_pvid(chip, port, &pvid); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2277 | if (err) |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2278 | goto unlock; |
| 2279 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 2280 | err = mv88e6xxx_port_vlan_leave(chip, port, vlan->vid); |
| 2281 | if (err) |
| 2282 | goto unlock; |
| 2283 | |
| 2284 | if (vlan->vid == pvid) { |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2285 | p->bridge_pvid.valid = false; |
| 2286 | |
| 2287 | err = mv88e6xxx_port_commit_pvid(chip, port); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2288 | if (err) |
| 2289 | goto unlock; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2290 | } |
| 2291 | |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2292 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2293 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2294 | |
| 2295 | return err; |
| 2296 | } |
| 2297 | |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2298 | static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port, |
| 2299 | const unsigned char *addr, u16 vid) |
Guenter Roeck | defb05b | 2015-03-26 18:36:38 -0700 | [diff] [blame] | 2300 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2301 | struct mv88e6xxx_chip *chip = ds->priv; |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2302 | int err; |
Vivien Didelot | 6630e23 | 2015-08-06 01:44:07 -0400 | [diff] [blame] | 2303 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2304 | mv88e6xxx_reg_lock(chip); |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2305 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, |
| 2306 | MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2307 | mv88e6xxx_reg_unlock(chip); |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2308 | |
| 2309 | return err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2310 | } |
| 2311 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2312 | static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port, |
Arkadi Sharshevsky | 6c2c1dc | 2017-08-06 16:15:39 +0300 | [diff] [blame] | 2313 | const unsigned char *addr, u16 vid) |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2314 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2315 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2316 | int err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2317 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2318 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2319 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2320 | mv88e6xxx_reg_unlock(chip); |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2321 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2322 | return err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2323 | } |
| 2324 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2325 | static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip, |
| 2326 | u16 fid, u16 vid, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2327 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2328 | { |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2329 | struct mv88e6xxx_atu_entry addr; |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2330 | bool is_static; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2331 | int err; |
| 2332 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2333 | addr.state = 0; |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2334 | eth_broadcast_addr(addr.mac); |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2335 | |
| 2336 | do { |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2337 | err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr); |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2338 | if (err) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2339 | return err; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2340 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2341 | if (!addr.state) |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2342 | break; |
| 2343 | |
Vivien Didelot | 01bd96c | 2017-03-11 16:12:57 -0500 | [diff] [blame] | 2344 | if (addr.trunk || (addr.portvec & BIT(port)) == 0) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2345 | continue; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2346 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2347 | if (!is_unicast_ether_addr(addr.mac)) |
| 2348 | continue; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2349 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2350 | is_static = (addr.state == |
| 2351 | MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); |
| 2352 | err = cb(addr.mac, vid, is_static, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2353 | if (err) |
| 2354 | return err; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2355 | } while (!is_broadcast_ether_addr(addr.mac)); |
| 2356 | |
| 2357 | return err; |
| 2358 | } |
| 2359 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 2360 | struct mv88e6xxx_port_db_dump_vlan_ctx { |
| 2361 | int port; |
| 2362 | dsa_fdb_dump_cb_t *cb; |
| 2363 | void *data; |
| 2364 | }; |
| 2365 | |
| 2366 | static int mv88e6xxx_port_db_dump_vlan(struct mv88e6xxx_chip *chip, |
| 2367 | const struct mv88e6xxx_vtu_entry *entry, |
| 2368 | void *_data) |
| 2369 | { |
| 2370 | struct mv88e6xxx_port_db_dump_vlan_ctx *ctx = _data; |
| 2371 | |
| 2372 | return mv88e6xxx_port_db_dump_fid(chip, entry->fid, entry->vid, |
| 2373 | ctx->port, ctx->cb, ctx->data); |
| 2374 | } |
| 2375 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2376 | static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2377 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2378 | { |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 2379 | struct mv88e6xxx_port_db_dump_vlan_ctx ctx = { |
| 2380 | .port = port, |
| 2381 | .cb = cb, |
| 2382 | .data = data, |
| 2383 | }; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2384 | u16 fid; |
| 2385 | int err; |
| 2386 | |
| 2387 | /* Dump port's default Filtering Information Database (VLAN ID 0) */ |
Vivien Didelot | b4e48c5 | 2016-11-04 03:23:29 +0100 | [diff] [blame] | 2388 | err = mv88e6xxx_port_get_fid(chip, port, &fid); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2389 | if (err) |
| 2390 | return err; |
| 2391 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2392 | err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2393 | if (err) |
| 2394 | return err; |
| 2395 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 2396 | return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_db_dump_vlan, &ctx); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2397 | } |
| 2398 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2399 | static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2400 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2401 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2402 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2403 | int err; |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2404 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2405 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2406 | err = mv88e6xxx_port_db_dump(chip, port, cb, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2407 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2408 | |
| 2409 | return err; |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2410 | } |
| 2411 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2412 | static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip, |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame^] | 2413 | struct dsa_bridge bridge) |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2414 | { |
Vivien Didelot | ef2025e | 2019-10-21 16:51:27 -0400 | [diff] [blame] | 2415 | struct dsa_switch *ds = chip->ds; |
| 2416 | struct dsa_switch_tree *dst = ds->dst; |
| 2417 | struct dsa_port *dp; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2418 | int err; |
| 2419 | |
Vivien Didelot | ef2025e | 2019-10-21 16:51:27 -0400 | [diff] [blame] | 2420 | list_for_each_entry(dp, &dst->ports, list) { |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame^] | 2421 | if (dsa_port_offloads_bridge(dp, &bridge)) { |
Vivien Didelot | ef2025e | 2019-10-21 16:51:27 -0400 | [diff] [blame] | 2422 | if (dp->ds == ds) { |
| 2423 | /* This is a local bridge group member, |
| 2424 | * remap its Port VLAN Map. |
| 2425 | */ |
| 2426 | err = mv88e6xxx_port_vlan_map(chip, dp->index); |
| 2427 | if (err) |
| 2428 | return err; |
| 2429 | } else { |
| 2430 | /* This is an external bridge group member, |
| 2431 | * remap its cross-chip Port VLAN Table entry. |
| 2432 | */ |
| 2433 | err = mv88e6xxx_pvt_map(chip, dp->ds->index, |
| 2434 | dp->index); |
Vivien Didelot | e96a6e0 | 2017-03-30 17:37:13 -0400 | [diff] [blame] | 2435 | if (err) |
| 2436 | return err; |
| 2437 | } |
| 2438 | } |
| 2439 | } |
| 2440 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2441 | return 0; |
| 2442 | } |
| 2443 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2444 | static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame^] | 2445 | struct dsa_bridge bridge) |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2446 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2447 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2448 | int err; |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2449 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2450 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2451 | |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame^] | 2452 | err = mv88e6xxx_bridge_map(chip, bridge); |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2453 | if (err) |
| 2454 | goto unlock; |
| 2455 | |
| 2456 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 2457 | if (err) |
| 2458 | goto unlock; |
| 2459 | |
| 2460 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2461 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | a669275 | 2016-02-12 12:09:39 -0500 | [diff] [blame] | 2462 | |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2463 | return err; |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2464 | } |
| 2465 | |
Vivien Didelot | f123f2f | 2017-01-27 15:29:41 -0500 | [diff] [blame] | 2466 | static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port, |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame^] | 2467 | struct dsa_bridge bridge) |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2468 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2469 | struct mv88e6xxx_chip *chip = ds->priv; |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2470 | int err; |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2471 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2472 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2473 | |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame^] | 2474 | if (mv88e6xxx_bridge_map(chip, bridge) || |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2475 | mv88e6xxx_port_vlan_map(chip, port)) |
| 2476 | dev_err(ds->dev, "failed to remap in-chip Port VLAN\n"); |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2477 | |
| 2478 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 2479 | if (err) |
| 2480 | dev_err(ds->dev, |
| 2481 | "port %d failed to restore standalone pvid: %pe\n", |
| 2482 | port, ERR_PTR(err)); |
| 2483 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2484 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 66d9cd0 | 2016-02-05 14:07:14 -0500 | [diff] [blame] | 2485 | } |
| 2486 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2487 | static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, |
| 2488 | int tree_index, int sw_index, |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame^] | 2489 | int port, struct dsa_bridge bridge) |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2490 | { |
| 2491 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2492 | int err; |
| 2493 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2494 | if (tree_index != ds->dst->index) |
| 2495 | return 0; |
| 2496 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2497 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2498 | err = mv88e6xxx_pvt_map(chip, sw_index, port); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2499 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2500 | |
| 2501 | return err; |
| 2502 | } |
| 2503 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2504 | static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, |
| 2505 | int tree_index, int sw_index, |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame^] | 2506 | int port, struct dsa_bridge bridge) |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2507 | { |
| 2508 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2509 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2510 | if (tree_index != ds->dst->index) |
| 2511 | return; |
| 2512 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2513 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2514 | if (mv88e6xxx_pvt_map(chip, sw_index, port)) |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2515 | dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2516 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2517 | } |
| 2518 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 2519 | /* Treat the software bridge as a virtual single-port switch behind the |
| 2520 | * CPU and map in the PVT. First dst->last_switch elements are taken by |
| 2521 | * physical switches, so start from beyond that range. |
| 2522 | */ |
| 2523 | static int mv88e6xxx_map_virtual_bridge_to_pvt(struct dsa_switch *ds, |
Vladimir Oltean | 3f9bb03 | 2021-12-06 18:57:47 +0200 | [diff] [blame] | 2524 | unsigned int bridge_num) |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 2525 | { |
Vladimir Oltean | 3f9bb03 | 2021-12-06 18:57:47 +0200 | [diff] [blame] | 2526 | u8 dev = bridge_num + ds->dst->last_switch; |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 2527 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2528 | int err; |
| 2529 | |
| 2530 | mv88e6xxx_reg_lock(chip); |
| 2531 | err = mv88e6xxx_pvt_map(chip, dev, 0); |
| 2532 | mv88e6xxx_reg_unlock(chip); |
| 2533 | |
| 2534 | return err; |
| 2535 | } |
| 2536 | |
| 2537 | static int mv88e6xxx_bridge_tx_fwd_offload(struct dsa_switch *ds, int port, |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame^] | 2538 | struct dsa_bridge bridge) |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 2539 | { |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame^] | 2540 | return mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge.num); |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 2541 | } |
| 2542 | |
| 2543 | static void mv88e6xxx_bridge_tx_fwd_unoffload(struct dsa_switch *ds, int port, |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame^] | 2544 | struct dsa_bridge bridge) |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 2545 | { |
| 2546 | int err; |
| 2547 | |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame^] | 2548 | err = mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge.num); |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 2549 | if (err) { |
| 2550 | dev_err(ds->dev, "failed to remap cross-chip Port VLAN: %pe\n", |
| 2551 | ERR_PTR(err)); |
| 2552 | } |
| 2553 | } |
| 2554 | |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2555 | static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip) |
| 2556 | { |
| 2557 | if (chip->info->ops->reset) |
| 2558 | return chip->info->ops->reset(chip); |
| 2559 | |
| 2560 | return 0; |
| 2561 | } |
| 2562 | |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2563 | static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip) |
| 2564 | { |
| 2565 | struct gpio_desc *gpiod = chip->reset; |
| 2566 | |
| 2567 | /* If there is a GPIO connected to the reset pin, toggle it */ |
| 2568 | if (gpiod) { |
| 2569 | gpiod_set_value_cansleep(gpiod, 1); |
| 2570 | usleep_range(10000, 20000); |
| 2571 | gpiod_set_value_cansleep(gpiod, 0); |
| 2572 | usleep_range(10000, 20000); |
Andrew Lunn | a3dcb3e | 2020-11-16 08:43:01 -0800 | [diff] [blame] | 2573 | |
| 2574 | mv88e6xxx_g1_wait_eeprom_done(chip); |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2575 | } |
| 2576 | } |
| 2577 | |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2578 | static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip) |
| 2579 | { |
| 2580 | int i, err; |
| 2581 | |
| 2582 | /* Set all ports to the Disabled state */ |
| 2583 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
Vivien Didelot | f894c29 | 2017-06-08 18:34:10 -0400 | [diff] [blame] | 2584 | err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED); |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2585 | if (err) |
| 2586 | return err; |
| 2587 | } |
| 2588 | |
| 2589 | /* Wait for transmit queues to drain, |
| 2590 | * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps. |
| 2591 | */ |
| 2592 | usleep_range(2000, 4000); |
| 2593 | |
| 2594 | return 0; |
| 2595 | } |
| 2596 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2597 | static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2598 | { |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 2599 | int err; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2600 | |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2601 | err = mv88e6xxx_disable_ports(chip); |
| 2602 | if (err) |
| 2603 | return err; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2604 | |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2605 | mv88e6xxx_hardware_reset(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2606 | |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2607 | return mv88e6xxx_software_reset(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2608 | } |
| 2609 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2610 | static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2611 | enum mv88e6xxx_frame_mode frame, |
| 2612 | enum mv88e6xxx_egress_mode egress, u16 etype) |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2613 | { |
| 2614 | int err; |
| 2615 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2616 | if (!chip->info->ops->port_set_frame_mode) |
| 2617 | return -EOPNOTSUPP; |
| 2618 | |
| 2619 | err = mv88e6xxx_port_set_egress_mode(chip, port, egress); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2620 | if (err) |
| 2621 | return err; |
| 2622 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2623 | err = chip->info->ops->port_set_frame_mode(chip, port, frame); |
| 2624 | if (err) |
| 2625 | return err; |
| 2626 | |
| 2627 | if (chip->info->ops->port_set_ether_type) |
| 2628 | return chip->info->ops->port_set_ether_type(chip, port, etype); |
| 2629 | |
| 2630 | return 0; |
| 2631 | } |
| 2632 | |
| 2633 | static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port) |
| 2634 | { |
| 2635 | return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2636 | MV88E6XXX_EGRESS_MODE_UNMODIFIED, |
Vivien Didelot | b810959 | 2017-06-12 12:37:45 -0400 | [diff] [blame] | 2637 | MV88E6XXX_PORT_ETH_TYPE_DEFAULT); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2638 | } |
| 2639 | |
| 2640 | static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port) |
| 2641 | { |
| 2642 | return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2643 | MV88E6XXX_EGRESS_MODE_UNMODIFIED, |
Vivien Didelot | b810959 | 2017-06-12 12:37:45 -0400 | [diff] [blame] | 2644 | MV88E6XXX_PORT_ETH_TYPE_DEFAULT); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2645 | } |
| 2646 | |
| 2647 | static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port) |
| 2648 | { |
| 2649 | return mv88e6xxx_set_port_mode(chip, port, |
| 2650 | MV88E6XXX_FRAME_MODE_ETHERTYPE, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2651 | MV88E6XXX_EGRESS_MODE_ETHERTYPE, |
| 2652 | ETH_P_EDSA); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2653 | } |
| 2654 | |
| 2655 | static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port) |
| 2656 | { |
| 2657 | if (dsa_is_dsa_port(chip->ds, port)) |
| 2658 | return mv88e6xxx_set_port_mode_dsa(chip, port); |
| 2659 | |
Vivien Didelot | 2b3e989 | 2017-10-26 11:22:54 -0400 | [diff] [blame] | 2660 | if (dsa_is_user_port(chip->ds, port)) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2661 | return mv88e6xxx_set_port_mode_normal(chip, port); |
| 2662 | |
| 2663 | /* Setup CPU port mode depending on its supported tag format */ |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 2664 | if (chip->tag_protocol == DSA_TAG_PROTO_DSA) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2665 | return mv88e6xxx_set_port_mode_dsa(chip, port); |
| 2666 | |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 2667 | if (chip->tag_protocol == DSA_TAG_PROTO_EDSA) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2668 | return mv88e6xxx_set_port_mode_edsa(chip, port); |
| 2669 | |
| 2670 | return -EINVAL; |
| 2671 | } |
| 2672 | |
Vivien Didelot | ea698f4 | 2017-03-11 16:12:50 -0500 | [diff] [blame] | 2673 | static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port) |
| 2674 | { |
| 2675 | bool message = dsa_is_dsa_port(chip->ds, port); |
| 2676 | |
| 2677 | return mv88e6xxx_port_set_message_port(chip, port, message); |
| 2678 | } |
| 2679 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2680 | static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port) |
| 2681 | { |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2682 | int err; |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2683 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2684 | if (chip->info->ops->port_set_ucast_flood) { |
Tobias Waldekranz | 7b9f16f | 2021-03-18 20:25:38 +0100 | [diff] [blame] | 2685 | err = chip->info->ops->port_set_ucast_flood(chip, port, true); |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2686 | if (err) |
| 2687 | return err; |
| 2688 | } |
| 2689 | if (chip->info->ops->port_set_mcast_flood) { |
Tobias Waldekranz | 7b9f16f | 2021-03-18 20:25:38 +0100 | [diff] [blame] | 2690 | err = chip->info->ops->port_set_mcast_flood(chip, port, true); |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2691 | if (err) |
| 2692 | return err; |
| 2693 | } |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2694 | |
David S. Miller | 407308f | 2019-06-15 13:35:29 -0700 | [diff] [blame] | 2695 | return 0; |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2696 | } |
| 2697 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2698 | static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id) |
| 2699 | { |
| 2700 | struct mv88e6xxx_port *mvp = dev_id; |
| 2701 | struct mv88e6xxx_chip *chip = mvp->chip; |
| 2702 | irqreturn_t ret = IRQ_NONE; |
| 2703 | int port = mvp->port; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2704 | int lane; |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2705 | |
| 2706 | mv88e6xxx_reg_lock(chip); |
| 2707 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2708 | if (lane >= 0) |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2709 | ret = mv88e6xxx_serdes_irq_status(chip, port, lane); |
| 2710 | mv88e6xxx_reg_unlock(chip); |
| 2711 | |
| 2712 | return ret; |
| 2713 | } |
| 2714 | |
| 2715 | static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port, |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2716 | int lane) |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2717 | { |
| 2718 | struct mv88e6xxx_port *dev_id = &chip->ports[port]; |
| 2719 | unsigned int irq; |
| 2720 | int err; |
| 2721 | |
| 2722 | /* Nothing to request if this SERDES port has no IRQ */ |
| 2723 | irq = mv88e6xxx_serdes_irq_mapping(chip, port); |
| 2724 | if (!irq) |
| 2725 | return 0; |
| 2726 | |
Andrew Lunn | e6f2f6b | 2020-01-06 17:13:49 +0100 | [diff] [blame] | 2727 | snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name), |
| 2728 | "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port); |
| 2729 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2730 | /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */ |
| 2731 | mv88e6xxx_reg_unlock(chip); |
| 2732 | err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn, |
Andrew Lunn | e6f2f6b | 2020-01-06 17:13:49 +0100 | [diff] [blame] | 2733 | IRQF_ONESHOT, dev_id->serdes_irq_name, |
| 2734 | dev_id); |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2735 | mv88e6xxx_reg_lock(chip); |
| 2736 | if (err) |
| 2737 | return err; |
| 2738 | |
| 2739 | dev_id->serdes_irq = irq; |
| 2740 | |
| 2741 | return mv88e6xxx_serdes_irq_enable(chip, port, lane); |
| 2742 | } |
| 2743 | |
| 2744 | static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port, |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2745 | int lane) |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2746 | { |
| 2747 | struct mv88e6xxx_port *dev_id = &chip->ports[port]; |
| 2748 | unsigned int irq = dev_id->serdes_irq; |
| 2749 | int err; |
| 2750 | |
| 2751 | /* Nothing to free if no IRQ has been requested */ |
| 2752 | if (!irq) |
| 2753 | return 0; |
| 2754 | |
| 2755 | err = mv88e6xxx_serdes_irq_disable(chip, port, lane); |
| 2756 | |
| 2757 | /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */ |
| 2758 | mv88e6xxx_reg_unlock(chip); |
| 2759 | free_irq(irq, dev_id); |
| 2760 | mv88e6xxx_reg_lock(chip); |
| 2761 | |
| 2762 | dev_id->serdes_irq = 0; |
| 2763 | |
| 2764 | return err; |
| 2765 | } |
| 2766 | |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2767 | static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port, |
| 2768 | bool on) |
| 2769 | { |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2770 | int lane; |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2771 | int err; |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2772 | |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2773 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2774 | if (lane < 0) |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2775 | return 0; |
| 2776 | |
| 2777 | if (on) { |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2778 | err = mv88e6xxx_serdes_power_up(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2779 | if (err) |
| 2780 | return err; |
| 2781 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2782 | err = mv88e6xxx_serdes_irq_request(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2783 | } else { |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2784 | err = mv88e6xxx_serdes_irq_free(chip, port, lane); |
| 2785 | if (err) |
| 2786 | return err; |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2787 | |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2788 | err = mv88e6xxx_serdes_power_down(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2789 | } |
| 2790 | |
| 2791 | return err; |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2792 | } |
| 2793 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2794 | static int mv88e6xxx_set_egress_port(struct mv88e6xxx_chip *chip, |
| 2795 | enum mv88e6xxx_egress_direction direction, |
| 2796 | int port) |
| 2797 | { |
| 2798 | int err; |
| 2799 | |
| 2800 | if (!chip->info->ops->set_egress_port) |
| 2801 | return -EOPNOTSUPP; |
| 2802 | |
| 2803 | err = chip->info->ops->set_egress_port(chip, direction, port); |
| 2804 | if (err) |
| 2805 | return err; |
| 2806 | |
| 2807 | if (direction == MV88E6XXX_EGRESS_DIR_INGRESS) |
| 2808 | chip->ingress_dest_port = port; |
| 2809 | else |
| 2810 | chip->egress_dest_port = port; |
| 2811 | |
| 2812 | return 0; |
| 2813 | } |
| 2814 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2815 | static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port) |
| 2816 | { |
| 2817 | struct dsa_switch *ds = chip->ds; |
| 2818 | int upstream_port; |
| 2819 | int err; |
| 2820 | |
Vivien Didelot | 07073c7 | 2017-12-05 15:34:13 -0500 | [diff] [blame] | 2821 | upstream_port = dsa_upstream_port(ds, port); |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2822 | if (chip->info->ops->port_set_upstream_port) { |
| 2823 | err = chip->info->ops->port_set_upstream_port(chip, port, |
| 2824 | upstream_port); |
| 2825 | if (err) |
| 2826 | return err; |
| 2827 | } |
| 2828 | |
Vivien Didelot | 0ea54dd | 2017-12-05 15:34:11 -0500 | [diff] [blame] | 2829 | if (port == upstream_port) { |
| 2830 | if (chip->info->ops->set_cpu_port) { |
| 2831 | err = chip->info->ops->set_cpu_port(chip, |
| 2832 | upstream_port); |
| 2833 | if (err) |
| 2834 | return err; |
| 2835 | } |
| 2836 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2837 | err = mv88e6xxx_set_egress_port(chip, |
Iwan R Timmer | 5c74c54 | 2019-11-07 22:11:13 +0100 | [diff] [blame] | 2838 | MV88E6XXX_EGRESS_DIR_INGRESS, |
| 2839 | upstream_port); |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2840 | if (err && err != -EOPNOTSUPP) |
| 2841 | return err; |
Iwan R Timmer | 5c74c54 | 2019-11-07 22:11:13 +0100 | [diff] [blame] | 2842 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2843 | err = mv88e6xxx_set_egress_port(chip, |
Iwan R Timmer | 5c74c54 | 2019-11-07 22:11:13 +0100 | [diff] [blame] | 2844 | MV88E6XXX_EGRESS_DIR_EGRESS, |
| 2845 | upstream_port); |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2846 | if (err && err != -EOPNOTSUPP) |
| 2847 | return err; |
Vivien Didelot | 0ea54dd | 2017-12-05 15:34:11 -0500 | [diff] [blame] | 2848 | } |
| 2849 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2850 | return 0; |
| 2851 | } |
| 2852 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2853 | static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2854 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2855 | struct dsa_switch *ds = chip->ds; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2856 | int err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2857 | u16 reg; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2858 | |
Andrew Lunn | 7b89846 | 2018-08-09 15:38:47 +0200 | [diff] [blame] | 2859 | chip->ports[port].chip = chip; |
| 2860 | chip->ports[port].port = port; |
| 2861 | |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2862 | /* MAC Forcing register: don't force link, speed, duplex or flow control |
| 2863 | * state to any particular values on physical ports, but force the CPU |
| 2864 | * port and all DSA ports to their maximum bandwidth and full duplex. |
| 2865 | */ |
| 2866 | if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) |
| 2867 | err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP, |
| 2868 | SPEED_MAX, DUPLEX_FULL, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 2869 | PAUSE_OFF, |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2870 | PHY_INTERFACE_MODE_NA); |
| 2871 | else |
| 2872 | err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED, |
| 2873 | SPEED_UNFORCED, DUPLEX_UNFORCED, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 2874 | PAUSE_ON, |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2875 | PHY_INTERFACE_MODE_NA); |
| 2876 | if (err) |
| 2877 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2878 | |
| 2879 | /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock, |
| 2880 | * disable Header mode, enable IGMP/MLD snooping, disable VLAN |
| 2881 | * tunneling, determine priority by looking at 802.1p and IP |
| 2882 | * priority fields (IP prio has precedence), and set STP state |
| 2883 | * to Forwarding. |
| 2884 | * |
| 2885 | * If this is the CPU link, use DSA or EDSA tagging depending |
| 2886 | * on which tagging mode was configured. |
| 2887 | * |
| 2888 | * If this is a link to another switch, use DSA tagging mode. |
| 2889 | * |
| 2890 | * If this is the upstream port for this switch, enable |
| 2891 | * forwarding of unknown unicasts and multicasts. |
| 2892 | */ |
Vivien Didelot | a89b433be | 2017-06-12 12:37:37 -0400 | [diff] [blame] | 2893 | reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP | |
| 2894 | MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP | |
| 2895 | MV88E6XXX_PORT_CTL0_STATE_FORWARDING; |
| 2896 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2897 | if (err) |
| 2898 | return err; |
Andrew Lunn | 6083ce7 | 2015-08-17 23:52:52 +0200 | [diff] [blame] | 2899 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2900 | err = mv88e6xxx_setup_port_mode(chip, port); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2901 | if (err) |
| 2902 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2903 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2904 | err = mv88e6xxx_setup_egress_floods(chip, port); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2905 | if (err) |
| 2906 | return err; |
| 2907 | |
Andrew Lunn | b92ce2f | 2021-09-26 19:41:25 +0200 | [diff] [blame] | 2908 | /* Port Control 2: don't force a good FCS, set the MTU size to |
| 2909 | * 10222 bytes, disable 802.1q tags checking, don't discard tagged or |
Vivien Didelot | 8efdda4 | 2015-08-13 12:52:23 -0400 | [diff] [blame] | 2910 | * untagged frames on this port, do a destination address lookup on all |
| 2911 | * received packets as usual, disable ARP mirroring and don't send a |
| 2912 | * copy of all transmitted/received frames on this port to the CPU. |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2913 | */ |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2914 | err = mv88e6xxx_port_set_map_da(chip, port); |
| 2915 | if (err) |
| 2916 | return err; |
| 2917 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2918 | err = mv88e6xxx_setup_upstream_port(chip, port); |
| 2919 | if (err) |
| 2920 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2921 | |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2922 | err = mv88e6xxx_port_set_8021q_mode(chip, port, |
Vivien Didelot | 81c6edb | 2017-06-12 12:37:41 -0400 | [diff] [blame] | 2923 | MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED); |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2924 | if (err) |
| 2925 | return err; |
| 2926 | |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2927 | /* Associate MV88E6XXX_VID_BRIDGED with MV88E6XXX_FID_BRIDGED in the |
| 2928 | * ATU by virtue of the fact that mv88e6xxx_atu_new() will pick it as |
| 2929 | * the first free FID after MV88E6XXX_FID_STANDALONE. This will be used |
| 2930 | * as the private PVID on ports under a VLAN-unaware bridge. |
| 2931 | * Shared (DSA and CPU) ports must also be members of it, to translate |
| 2932 | * the VID from the DSA tag into MV88E6XXX_FID_BRIDGED, instead of |
| 2933 | * relying on their port default FID. |
| 2934 | */ |
| 2935 | err = mv88e6xxx_port_vlan_join(chip, port, MV88E6XXX_VID_BRIDGED, |
| 2936 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED, |
| 2937 | false); |
| 2938 | if (err) |
| 2939 | return err; |
| 2940 | |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2941 | if (chip->info->ops->port_set_jumbo_size) { |
Andrew Lunn | b92ce2f | 2021-09-26 19:41:25 +0200 | [diff] [blame] | 2942 | err = chip->info->ops->port_set_jumbo_size(chip, port, 10218); |
Andrew Lunn | 5f43666 | 2016-12-03 04:45:17 +0100 | [diff] [blame] | 2943 | if (err) |
| 2944 | return err; |
| 2945 | } |
| 2946 | |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 2947 | /* Port Association Vector: disable automatic address learning |
| 2948 | * on all user ports since they start out in standalone |
| 2949 | * mode. When joining a bridge, learning will be configured to |
| 2950 | * match the bridge port settings. Enable learning on all |
| 2951 | * DSA/CPU ports. NOTE: FROM_CPU frames always bypass the |
| 2952 | * learning process. |
| 2953 | * |
| 2954 | * Disable HoldAt1, IntOnAgeOut, LockedPort, IgnoreWrongData, |
| 2955 | * and RefreshLocked. I.e. setup standard automatic learning. |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2956 | */ |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 2957 | if (dsa_is_user_port(ds, port)) |
Vivien Didelot | 65fa402 | 2016-04-14 14:42:07 -0400 | [diff] [blame] | 2958 | reg = 0; |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 2959 | else |
| 2960 | reg = 1 << port; |
Andrew Lunn | 4c7ea3c | 2015-11-03 10:52:36 -0500 | [diff] [blame] | 2961 | |
Vivien Didelot | 2a4614e | 2017-06-12 12:37:43 -0400 | [diff] [blame] | 2962 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR, |
| 2963 | reg); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2964 | if (err) |
| 2965 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2966 | |
| 2967 | /* Egress rate control 2: disable egress rate control. */ |
Vivien Didelot | 2cb8cb1 | 2017-06-12 12:37:42 -0400 | [diff] [blame] | 2968 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2, |
| 2969 | 0x0000); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2970 | if (err) |
| 2971 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2972 | |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2973 | if (chip->info->ops->port_pause_limit) { |
| 2974 | err = chip->info->ops->port_pause_limit(chip, port, 0, 0); |
Andrew Lunn | b35d322a | 2016-12-03 04:45:19 +0100 | [diff] [blame] | 2975 | if (err) |
| 2976 | return err; |
| 2977 | } |
| 2978 | |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2979 | if (chip->info->ops->port_disable_learn_limit) { |
| 2980 | err = chip->info->ops->port_disable_learn_limit(chip, port); |
| 2981 | if (err) |
| 2982 | return err; |
| 2983 | } |
| 2984 | |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2985 | if (chip->info->ops->port_disable_pri_override) { |
| 2986 | err = chip->info->ops->port_disable_pri_override(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2987 | if (err) |
| 2988 | return err; |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2989 | } |
Andrew Lunn | 2bbb33b | 2016-08-22 16:01:02 +0200 | [diff] [blame] | 2990 | |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2991 | if (chip->info->ops->port_tag_remap) { |
| 2992 | err = chip->info->ops->port_tag_remap(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2993 | if (err) |
| 2994 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2995 | } |
| 2996 | |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2997 | if (chip->info->ops->port_egress_rate_limiting) { |
| 2998 | err = chip->info->ops->port_egress_rate_limiting(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2999 | if (err) |
| 3000 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 3001 | } |
| 3002 | |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3003 | if (chip->info->ops->port_setup_message_port) { |
| 3004 | err = chip->info->ops->port_setup_message_port(chip, port); |
| 3005 | if (err) |
| 3006 | return err; |
| 3007 | } |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 3008 | |
Vivien Didelot | 207afda | 2016-04-14 14:42:09 -0400 | [diff] [blame] | 3009 | /* Port based VLAN map: give each port the same default address |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 3010 | * database, and allow bidirectional communication between the |
| 3011 | * CPU and DSA port(s), and the other ports. |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 3012 | */ |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 3013 | err = mv88e6xxx_port_set_fid(chip, port, MV88E6XXX_FID_STANDALONE); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 3014 | if (err) |
| 3015 | return err; |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 3016 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 3017 | err = mv88e6xxx_port_vlan_map(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 3018 | if (err) |
| 3019 | return err; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 3020 | |
| 3021 | /* Default VLAN ID and priority: don't set a default VLAN |
| 3022 | * ID, and set the default packet priority to zero. |
| 3023 | */ |
Vivien Didelot | b7929fb | 2017-06-12 12:37:40 -0400 | [diff] [blame] | 3024 | return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0); |
Andrew Lunn | dbde9e6 | 2015-05-06 01:09:48 +0200 | [diff] [blame] | 3025 | } |
| 3026 | |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 3027 | static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port) |
| 3028 | { |
| 3029 | struct mv88e6xxx_chip *chip = ds->priv; |
| 3030 | |
| 3031 | if (chip->info->ops->port_set_jumbo_size) |
Andrew Lunn | b9c587f | 2021-09-26 19:41:26 +0200 | [diff] [blame] | 3032 | return 10240 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3033 | else if (chip->info->ops->set_max_frame_size) |
Andrew Lunn | b9c587f | 2021-09-26 19:41:26 +0200 | [diff] [blame] | 3034 | return 1632 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; |
| 3035 | return 1522 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 3036 | } |
| 3037 | |
| 3038 | static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu) |
| 3039 | { |
| 3040 | struct mv88e6xxx_chip *chip = ds->priv; |
| 3041 | int ret = 0; |
| 3042 | |
Andrew Lunn | b9c587f | 2021-09-26 19:41:26 +0200 | [diff] [blame] | 3043 | if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) |
| 3044 | new_mtu += EDSA_HLEN; |
| 3045 | |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 3046 | mv88e6xxx_reg_lock(chip); |
| 3047 | if (chip->info->ops->port_set_jumbo_size) |
| 3048 | ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu); |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3049 | else if (chip->info->ops->set_max_frame_size) |
| 3050 | ret = chip->info->ops->set_max_frame_size(chip, new_mtu); |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 3051 | else |
| 3052 | if (new_mtu > 1522) |
| 3053 | ret = -EINVAL; |
| 3054 | mv88e6xxx_reg_unlock(chip); |
| 3055 | |
| 3056 | return ret; |
| 3057 | } |
| 3058 | |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3059 | static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port, |
| 3060 | struct phy_device *phydev) |
| 3061 | { |
| 3062 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 3063 | int err; |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3064 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3065 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 3066 | err = mv88e6xxx_serdes_power(chip, port, true); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3067 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3068 | |
| 3069 | return err; |
| 3070 | } |
| 3071 | |
Andrew Lunn | 75104db | 2019-02-24 20:44:43 +0100 | [diff] [blame] | 3072 | static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port) |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3073 | { |
| 3074 | struct mv88e6xxx_chip *chip = ds->priv; |
| 3075 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3076 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 3077 | if (mv88e6xxx_serdes_power(chip, port, false)) |
| 3078 | dev_err(chip->dev, "failed to power off SERDES\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3079 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3080 | } |
| 3081 | |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 3082 | static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds, |
| 3083 | unsigned int ageing_time) |
| 3084 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3085 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 3086 | int err; |
| 3087 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3088 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 720c634 | 2017-03-11 16:12:48 -0500 | [diff] [blame] | 3089 | err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3090 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 3091 | |
| 3092 | return err; |
| 3093 | } |
| 3094 | |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 3095 | static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 3096 | { |
| 3097 | int err; |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 3098 | |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3099 | /* Initialize the statistics unit */ |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 3100 | if (chip->info->ops->stats_set_histogram) { |
| 3101 | err = chip->info->ops->stats_set_histogram(chip); |
| 3102 | if (err) |
| 3103 | return err; |
| 3104 | } |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3105 | |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3106 | return mv88e6xxx_g1_stats_clear(chip); |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3107 | } |
| 3108 | |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3109 | /* Check if the errata has already been applied. */ |
| 3110 | static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip) |
| 3111 | { |
| 3112 | int port; |
| 3113 | int err; |
| 3114 | u16 val; |
| 3115 | |
| 3116 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Marek Behún | 6090701 | 2019-08-26 23:31:51 +0200 | [diff] [blame] | 3117 | err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val); |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3118 | if (err) { |
| 3119 | dev_err(chip->dev, |
| 3120 | "Error reading hidden register: %d\n", err); |
| 3121 | return false; |
| 3122 | } |
| 3123 | if (val != 0x01c0) |
| 3124 | return false; |
| 3125 | } |
| 3126 | |
| 3127 | return true; |
| 3128 | } |
| 3129 | |
| 3130 | /* The 6390 copper ports have an errata which require poking magic |
| 3131 | * values into undocumented hidden registers and then performing a |
| 3132 | * software reset. |
| 3133 | */ |
| 3134 | static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip) |
| 3135 | { |
| 3136 | int port; |
| 3137 | int err; |
| 3138 | |
| 3139 | if (mv88e6390_setup_errata_applied(chip)) |
| 3140 | return 0; |
| 3141 | |
| 3142 | /* Set the ports into blocking mode */ |
| 3143 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 3144 | err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED); |
| 3145 | if (err) |
| 3146 | return err; |
| 3147 | } |
| 3148 | |
| 3149 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Marek Behún | 6090701 | 2019-08-26 23:31:51 +0200 | [diff] [blame] | 3150 | err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0); |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3151 | if (err) |
| 3152 | return err; |
| 3153 | } |
| 3154 | |
| 3155 | return mv88e6xxx_software_reset(chip); |
| 3156 | } |
| 3157 | |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3158 | static void mv88e6xxx_teardown(struct dsa_switch *ds) |
| 3159 | { |
| 3160 | mv88e6xxx_teardown_devlink_params(ds); |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3161 | dsa_devlink_resources_unregister(ds); |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 3162 | mv88e6xxx_teardown_devlink_regions_global(ds); |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3163 | } |
| 3164 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3165 | static int mv88e6xxx_setup(struct dsa_switch *ds) |
Guenter Roeck | acdaffc | 2015-03-26 18:36:28 -0700 | [diff] [blame] | 3166 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3167 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3168 | u8 cmode; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3169 | int err; |
Vivien Didelot | a1a6a4d | 2016-05-09 13:22:56 -0400 | [diff] [blame] | 3170 | int i; |
| 3171 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3172 | chip->ds = ds; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3173 | ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3174 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 3175 | /* Since virtual bridges are mapped in the PVT, the number we support |
| 3176 | * depends on the physical switch topology. We need to let DSA figure |
| 3177 | * that out and therefore we cannot set this at dsa_register_switch() |
| 3178 | * time. |
| 3179 | */ |
| 3180 | if (mv88e6xxx_has_pvt(chip)) |
Vladimir Oltean | 947c874 | 2021-12-06 18:57:48 +0200 | [diff] [blame] | 3181 | ds->max_num_bridges = MV88E6XXX_MAX_PVT_SWITCHES - |
| 3182 | ds->dst->last_switch - 1; |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 3183 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3184 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3185 | |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3186 | if (chip->info->ops->setup_errata) { |
| 3187 | err = chip->info->ops->setup_errata(chip); |
| 3188 | if (err) |
| 3189 | goto unlock; |
| 3190 | } |
| 3191 | |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3192 | /* Cache the cmode of each port. */ |
| 3193 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
| 3194 | if (chip->info->ops->port_get_cmode) { |
| 3195 | err = chip->info->ops->port_get_cmode(chip, i, &cmode); |
| 3196 | if (err) |
Dan Carpenter | e29129f | 2018-08-14 12:09:05 +0300 | [diff] [blame] | 3197 | goto unlock; |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3198 | |
| 3199 | chip->ports[i].cmode = cmode; |
| 3200 | } |
| 3201 | } |
| 3202 | |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 3203 | err = mv88e6xxx_vtu_setup(chip); |
| 3204 | if (err) |
| 3205 | goto unlock; |
| 3206 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3207 | /* Setup Switch Port Registers */ |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 3208 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
Vivien Didelot | b759f52 | 2019-08-19 16:00:52 -0400 | [diff] [blame] | 3209 | if (dsa_is_unused_port(ds, i)) |
| 3210 | continue; |
| 3211 | |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 3212 | /* Prevent the use of an invalid port. */ |
Vivien Didelot | b759f52 | 2019-08-19 16:00:52 -0400 | [diff] [blame] | 3213 | if (mv88e6xxx_is_invalid_port(chip, i)) { |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 3214 | dev_err(chip->dev, "port %d is invalid\n", i); |
| 3215 | err = -EINVAL; |
| 3216 | goto unlock; |
| 3217 | } |
| 3218 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3219 | err = mv88e6xxx_setup_port(chip, i); |
| 3220 | if (err) |
| 3221 | goto unlock; |
| 3222 | } |
| 3223 | |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3224 | err = mv88e6xxx_irl_setup(chip); |
| 3225 | if (err) |
| 3226 | goto unlock; |
| 3227 | |
Vivien Didelot | 04a69a1 | 2017-10-13 14:18:05 -0400 | [diff] [blame] | 3228 | err = mv88e6xxx_mac_setup(chip); |
| 3229 | if (err) |
| 3230 | goto unlock; |
| 3231 | |
Vivien Didelot | 1b17aed | 2017-05-26 18:03:05 -0400 | [diff] [blame] | 3232 | err = mv88e6xxx_phy_setup(chip); |
| 3233 | if (err) |
| 3234 | goto unlock; |
| 3235 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 3236 | err = mv88e6xxx_pvt_setup(chip); |
| 3237 | if (err) |
| 3238 | goto unlock; |
| 3239 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 3240 | err = mv88e6xxx_atu_setup(chip); |
| 3241 | if (err) |
| 3242 | goto unlock; |
| 3243 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 3244 | err = mv88e6xxx_broadcast_setup(chip, 0); |
| 3245 | if (err) |
| 3246 | goto unlock; |
| 3247 | |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3248 | err = mv88e6xxx_pot_setup(chip); |
| 3249 | if (err) |
| 3250 | goto unlock; |
| 3251 | |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3252 | err = mv88e6xxx_rmu_setup(chip); |
| 3253 | if (err) |
| 3254 | goto unlock; |
| 3255 | |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3256 | err = mv88e6xxx_rsvd2cpu_setup(chip); |
| 3257 | if (err) |
| 3258 | goto unlock; |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 3259 | |
Vivien Didelot | b28f872 | 2018-04-26 21:56:44 -0400 | [diff] [blame] | 3260 | err = mv88e6xxx_trunk_setup(chip); |
| 3261 | if (err) |
| 3262 | goto unlock; |
| 3263 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 3264 | err = mv88e6xxx_devmap_setup(chip); |
| 3265 | if (err) |
| 3266 | goto unlock; |
| 3267 | |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3268 | err = mv88e6xxx_pri_setup(chip); |
| 3269 | if (err) |
| 3270 | goto unlock; |
| 3271 | |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 3272 | /* Setup PTP Hardware Clock and timestamping */ |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3273 | if (chip->info->ptp_support) { |
| 3274 | err = mv88e6xxx_ptp_setup(chip); |
| 3275 | if (err) |
| 3276 | goto unlock; |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 3277 | |
| 3278 | err = mv88e6xxx_hwtstamp_setup(chip); |
| 3279 | if (err) |
| 3280 | goto unlock; |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3281 | } |
| 3282 | |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 3283 | err = mv88e6xxx_stats_setup(chip); |
| 3284 | if (err) |
| 3285 | goto unlock; |
| 3286 | |
Vivien Didelot | 6b17e86 | 2015-08-13 12:52:18 -0400 | [diff] [blame] | 3287 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3288 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | db687a5 | 2015-06-20 21:31:29 +0200 | [diff] [blame] | 3289 | |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3290 | if (err) |
| 3291 | return err; |
| 3292 | |
| 3293 | /* Have to be called without holding the register lock, since |
| 3294 | * they take the devlink lock, and we later take the locks in |
| 3295 | * the reverse order when getting/setting parameters or |
| 3296 | * resource occupancy. |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3297 | */ |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3298 | err = mv88e6xxx_setup_devlink_resources(ds); |
| 3299 | if (err) |
| 3300 | return err; |
| 3301 | |
| 3302 | err = mv88e6xxx_setup_devlink_params(ds); |
| 3303 | if (err) |
Andrew Lunn | bfb2554 | 2020-09-18 21:11:07 +0200 | [diff] [blame] | 3304 | goto out_resources; |
| 3305 | |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 3306 | err = mv88e6xxx_setup_devlink_regions_global(ds); |
Andrew Lunn | bfb2554 | 2020-09-18 21:11:07 +0200 | [diff] [blame] | 3307 | if (err) |
| 3308 | goto out_params; |
| 3309 | |
| 3310 | return 0; |
| 3311 | |
| 3312 | out_params: |
| 3313 | mv88e6xxx_teardown_devlink_params(ds); |
| 3314 | out_resources: |
| 3315 | dsa_devlink_resources_unregister(ds); |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3316 | |
| 3317 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 3318 | } |
| 3319 | |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 3320 | static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port) |
| 3321 | { |
| 3322 | return mv88e6xxx_setup_devlink_regions_port(ds, port); |
| 3323 | } |
| 3324 | |
| 3325 | static void mv88e6xxx_port_teardown(struct dsa_switch *ds, int port) |
| 3326 | { |
| 3327 | mv88e6xxx_teardown_devlink_regions_port(ds, port); |
| 3328 | } |
| 3329 | |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3330 | /* prod_id for switch families which do not have a PHY model number */ |
| 3331 | static const u16 family_prod_id_table[] = { |
| 3332 | [MV88E6XXX_FAMILY_6341] = MV88E6XXX_PORT_SWITCH_ID_PROD_6341, |
| 3333 | [MV88E6XXX_FAMILY_6390] = MV88E6XXX_PORT_SWITCH_ID_PROD_6390, |
Marek Behún | c5d015b | 2021-04-20 09:54:02 +0200 | [diff] [blame] | 3334 | [MV88E6XXX_FAMILY_6393] = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X, |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3335 | }; |
| 3336 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3337 | static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg) |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3338 | { |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3339 | struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; |
| 3340 | struct mv88e6xxx_chip *chip = mdio_bus->chip; |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3341 | u16 prod_id; |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3342 | u16 val; |
| 3343 | int err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3344 | |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3345 | if (!chip->info->ops->phy_read) |
| 3346 | return -EOPNOTSUPP; |
| 3347 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3348 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3349 | err = chip->info->ops->phy_read(chip, bus, phy, reg, &val); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3350 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3351 | |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3352 | /* Some internal PHYs don't have a model number. */ |
| 3353 | if (reg == MII_PHYSID2 && !(val & 0x3f0) && |
| 3354 | chip->info->family < ARRAY_SIZE(family_prod_id_table)) { |
| 3355 | prod_id = family_prod_id_table[chip->info->family]; |
| 3356 | if (prod_id) |
| 3357 | val |= prod_id >> 4; |
Andrew Lunn | da9f330 | 2017-02-01 03:40:05 +0100 | [diff] [blame] | 3358 | } |
| 3359 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3360 | return err ? err : val; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3361 | } |
| 3362 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3363 | static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val) |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3364 | { |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3365 | struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; |
| 3366 | struct mv88e6xxx_chip *chip = mdio_bus->chip; |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3367 | int err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3368 | |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3369 | if (!chip->info->ops->phy_write) |
| 3370 | return -EOPNOTSUPP; |
| 3371 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3372 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3373 | err = chip->info->ops->phy_write(chip, bus, phy, reg, val); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3374 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3375 | |
| 3376 | return err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3377 | } |
| 3378 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3379 | static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip, |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3380 | struct device_node *np, |
| 3381 | bool external) |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3382 | { |
| 3383 | static int index; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3384 | struct mv88e6xxx_mdio_bus *mdio_bus; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3385 | struct mii_bus *bus; |
| 3386 | int err; |
| 3387 | |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3388 | if (external) { |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3389 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3390 | err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3391 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3392 | |
| 3393 | if (err) |
| 3394 | return err; |
| 3395 | } |
| 3396 | |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3397 | bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus)); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3398 | if (!bus) |
| 3399 | return -ENOMEM; |
| 3400 | |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3401 | mdio_bus = bus->priv; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3402 | mdio_bus->bus = bus; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3403 | mdio_bus->chip = chip; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3404 | INIT_LIST_HEAD(&mdio_bus->list); |
| 3405 | mdio_bus->external = external; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3406 | |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3407 | if (np) { |
| 3408 | bus->name = np->full_name; |
Rob Herring | f7ce910 | 2017-07-18 16:43:19 -0500 | [diff] [blame] | 3409 | snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3410 | } else { |
| 3411 | bus->name = "mv88e6xxx SMI"; |
| 3412 | snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++); |
| 3413 | } |
| 3414 | |
| 3415 | bus->read = mv88e6xxx_mdio_read; |
| 3416 | bus->write = mv88e6xxx_mdio_write; |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3417 | bus->parent = chip->dev; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3418 | |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3419 | if (!external) { |
| 3420 | err = mv88e6xxx_g2_irq_mdio_setup(chip, bus); |
| 3421 | if (err) |
| 3422 | return err; |
| 3423 | } |
| 3424 | |
Florian Fainelli | 00e798c | 2018-05-15 16:56:19 -0700 | [diff] [blame] | 3425 | err = of_mdiobus_register(bus, np); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3426 | if (err) { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3427 | dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err); |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3428 | mv88e6xxx_g2_irq_mdio_free(chip, bus); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3429 | return err; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3430 | } |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3431 | |
| 3432 | if (external) |
| 3433 | list_add_tail(&mdio_bus->list, &chip->mdios); |
| 3434 | else |
| 3435 | list_add(&mdio_bus->list, &chip->mdios); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3436 | |
| 3437 | return 0; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3438 | } |
| 3439 | |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3440 | static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip) |
| 3441 | |
| 3442 | { |
| 3443 | struct mv88e6xxx_mdio_bus *mdio_bus; |
| 3444 | struct mii_bus *bus; |
| 3445 | |
| 3446 | list_for_each_entry(mdio_bus, &chip->mdios, list) { |
| 3447 | bus = mdio_bus->bus; |
| 3448 | |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3449 | if (!mdio_bus->external) |
| 3450 | mv88e6xxx_g2_irq_mdio_free(chip, bus); |
| 3451 | |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3452 | mdiobus_unregister(bus); |
| 3453 | } |
| 3454 | } |
| 3455 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3456 | static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, |
| 3457 | struct device_node *np) |
| 3458 | { |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3459 | struct device_node *child; |
| 3460 | int err; |
| 3461 | |
| 3462 | /* Always register one mdio bus for the internal/default mdio |
| 3463 | * bus. This maybe represented in the device tree, but is |
| 3464 | * optional. |
| 3465 | */ |
| 3466 | child = of_get_child_by_name(np, "mdio"); |
| 3467 | err = mv88e6xxx_mdio_register(chip, child, false); |
| 3468 | if (err) |
| 3469 | return err; |
| 3470 | |
| 3471 | /* Walk the device tree, and see if there are any other nodes |
| 3472 | * which say they are compatible with the external mdio |
| 3473 | * bus. |
| 3474 | */ |
| 3475 | for_each_available_child_of_node(np, child) { |
Andrew Lunn | ceb96fa | 2020-09-01 04:32:57 +0200 | [diff] [blame] | 3476 | if (of_device_is_compatible( |
| 3477 | child, "marvell,mv88e6xxx-mdio-external")) { |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3478 | err = mv88e6xxx_mdio_register(chip, child, true); |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3479 | if (err) { |
| 3480 | mv88e6xxx_mdios_unregister(chip); |
Nishka Dasgupta | 78e4204 | 2019-07-23 16:13:07 +0530 | [diff] [blame] | 3481 | of_node_put(child); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3482 | return err; |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3483 | } |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3484 | } |
| 3485 | } |
| 3486 | |
| 3487 | return 0; |
| 3488 | } |
| 3489 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3490 | static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds) |
| 3491 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3492 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3493 | |
| 3494 | return chip->eeprom_len; |
| 3495 | } |
| 3496 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3497 | static int mv88e6xxx_get_eeprom(struct dsa_switch *ds, |
| 3498 | struct ethtool_eeprom *eeprom, u8 *data) |
| 3499 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3500 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3501 | int err; |
| 3502 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3503 | if (!chip->info->ops->get_eeprom) |
| 3504 | return -EOPNOTSUPP; |
| 3505 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3506 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3507 | err = chip->info->ops->get_eeprom(chip, eeprom, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3508 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3509 | |
| 3510 | if (err) |
| 3511 | return err; |
| 3512 | |
| 3513 | eeprom->magic = 0xc3ec4951; |
| 3514 | |
| 3515 | return 0; |
| 3516 | } |
| 3517 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3518 | static int mv88e6xxx_set_eeprom(struct dsa_switch *ds, |
| 3519 | struct ethtool_eeprom *eeprom, u8 *data) |
| 3520 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3521 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3522 | int err; |
| 3523 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3524 | if (!chip->info->ops->set_eeprom) |
| 3525 | return -EOPNOTSUPP; |
| 3526 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3527 | if (eeprom->magic != 0xc3ec4951) |
| 3528 | return -EINVAL; |
| 3529 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3530 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3531 | err = chip->info->ops->set_eeprom(chip, eeprom, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3532 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3533 | |
| 3534 | return err; |
| 3535 | } |
| 3536 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3537 | static const struct mv88e6xxx_ops mv88e6085_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3538 | /* MV88E6XXX_FAMILY_6097 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3539 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3540 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3541 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3542 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3543 | .phy_read = mv88e6185_phy_ppu_read, |
| 3544 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3545 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3546 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3547 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3548 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3549 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3550 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3551 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3552 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3553 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3554 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3555 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3556 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3557 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3558 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3559 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3560 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3561 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3562 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3563 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3564 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3565 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3566 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3567 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3568 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3569 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 3570 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3571 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3572 | .rmu_disable = mv88e6085_g1_rmu_disable, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3573 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3574 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3575 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3576 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3577 | }; |
| 3578 | |
| 3579 | static const struct mv88e6xxx_ops mv88e6095_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3580 | /* MV88E6XXX_FAMILY_6095 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3581 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3582 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3583 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3584 | .phy_read = mv88e6185_phy_ppu_read, |
| 3585 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3586 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3587 | .port_sync_link = mv88e6185_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3588 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3589 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3590 | .port_set_ucast_flood = mv88e6185_port_set_forward_unknown, |
| 3591 | .port_set_mcast_flood = mv88e6185_port_set_default_forward, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 3592 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3593 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3594 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3595 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3596 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3597 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3598 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3599 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3600 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Chris Packham | f5be107 | 2020-11-24 17:34:38 +1300 | [diff] [blame] | 3601 | .serdes_power = mv88e6185_serdes_power, |
| 3602 | .serdes_get_lane = mv88e6185_serdes_get_lane, |
| 3603 | .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3604 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 3605 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3606 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3607 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3608 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3609 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3610 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3611 | }; |
| 3612 | |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3613 | static const struct mv88e6xxx_ops mv88e6097_ops = { |
Stefan Eichenberger | 15da3cc | 2016-11-25 09:41:30 +0100 | [diff] [blame] | 3614 | /* MV88E6XXX_FAMILY_6097 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3615 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3616 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3617 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3618 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3619 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3620 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3621 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3622 | .port_sync_link = mv88e6185_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3623 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3624 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3625 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3626 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3627 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3628 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3629 | .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3630 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3631 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3632 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3633 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3634 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3635 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3636 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3637 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3638 | .stats_get_strings = mv88e6095_stats_get_strings, |
| 3639 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3640 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3641 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Volodymyr Bendiuga | 91eaa47 | 2017-02-14 11:29:30 +0100 | [diff] [blame] | 3642 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3643 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Chris Packham | f5be107 | 2020-11-24 17:34:38 +1300 | [diff] [blame] | 3644 | .serdes_power = mv88e6185_serdes_power, |
| 3645 | .serdes_get_lane = mv88e6185_serdes_get_lane, |
| 3646 | .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, |
Chris Packham | 5c19bc8 | 2020-11-24 17:34:39 +1300 | [diff] [blame] | 3647 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
| 3648 | .serdes_irq_enable = mv88e6097_serdes_irq_enable, |
| 3649 | .serdes_irq_status = mv88e6097_serdes_irq_status, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3650 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3651 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3652 | .rmu_disable = mv88e6085_g1_rmu_disable, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3653 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3654 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3655 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3656 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3657 | }; |
| 3658 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3659 | static const struct mv88e6xxx_ops mv88e6123_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3660 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3661 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3662 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3663 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3664 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | ec8378b | 2017-06-02 23:22:45 +0200 | [diff] [blame] | 3665 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3666 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3667 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3668 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3669 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3670 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3671 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3672 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3673 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3674 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3675 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3676 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 0ac64c3 | 2017-06-02 23:22:46 +0200 | [diff] [blame] | 3677 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3678 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3679 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3680 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3681 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3682 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3683 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3684 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3685 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3686 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3687 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3688 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3689 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3690 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3691 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3692 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3693 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3694 | }; |
| 3695 | |
| 3696 | static const struct mv88e6xxx_ops mv88e6131_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3697 | /* MV88E6XXX_FAMILY_6185 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3698 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3699 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3700 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3701 | .phy_read = mv88e6185_phy_ppu_read, |
| 3702 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3703 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3704 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3705 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3706 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3707 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3708 | .port_set_ucast_flood = mv88e6185_port_set_forward_unknown, |
| 3709 | .port_set_mcast_flood = mv88e6185_port_set_default_forward, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3710 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 3711 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3712 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3713 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3714 | .port_pause_limit = mv88e6097_port_pause_limit, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 3715 | .port_set_pause = mv88e6185_port_set_pause, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3716 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3717 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3718 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3719 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3720 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3721 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3722 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3723 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3724 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3725 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3726 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3727 | .ppu_enable = mv88e6185_g1_ppu_enable, |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 3728 | .set_cascade_port = mv88e6185_g1_set_cascade_port, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3729 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3730 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3731 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3732 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3733 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3734 | }; |
| 3735 | |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3736 | static const struct mv88e6xxx_ops mv88e6141_ops = { |
| 3737 | /* MV88E6XXX_FAMILY_6341 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3738 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3739 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3740 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3741 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3742 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 3743 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3744 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3745 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3746 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3747 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3748 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3749 | .port_set_speed_duplex = mv88e6341_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 3750 | .port_max_speed_mode = mv88e6341_port_max_speed_mode, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3751 | .port_tag_remap = mv88e6095_port_tag_remap, |
Marek Behún | 7da467d | 2021-07-01 00:22:26 +0200 | [diff] [blame] | 3752 | .port_set_policy = mv88e6352_port_set_policy, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3753 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3754 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3755 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3756 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3757 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3758 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3759 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3760 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 3761 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3762 | .port_get_cmode = mv88e6352_port_get_cmode, |
Marek Behún | 7a3007d | 2019-08-26 23:31:55 +0200 | [diff] [blame] | 3763 | .port_set_cmode = mv88e6341_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3764 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3765 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Marek Behún | 11527f3 | 2021-07-01 00:22:27 +0200 | [diff] [blame] | 3766 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3767 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3768 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 3769 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3770 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 3771 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3772 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 3773 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3774 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3775 | .reset = mv88e6352_g1_reset, |
Marek Behún | 3709488 | 2021-07-01 00:22:28 +0200 | [diff] [blame] | 3776 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Marek Behún | c07fff3 | 2021-07-01 00:22:29 +0200 | [diff] [blame] | 3777 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3778 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3779 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3780 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 3781 | .serdes_power = mv88e6390_serdes_power, |
| 3782 | .serdes_get_lane = mv88e6341_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 3783 | /* Check status register pause & lpa register */ |
| 3784 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 3785 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 3786 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 3787 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 3788 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 3789 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 3790 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3791 | .gpio_ops = &mv88e6352_gpio_ops, |
Marek Behún | a03b98d | 2021-07-01 00:22:30 +0200 | [diff] [blame] | 3792 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 3793 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 3794 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Marek Behún | 953b0dc | 2021-07-01 00:22:31 +0200 | [diff] [blame] | 3795 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 3796 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 3797 | .phylink_validate = mv88e6341_phylink_validate, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3798 | }; |
| 3799 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3800 | static const struct mv88e6xxx_ops mv88e6161_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3801 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3802 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3803 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3804 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3805 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | ec8378b | 2017-06-02 23:22:45 +0200 | [diff] [blame] | 3806 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3807 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3808 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3809 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3810 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3811 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3812 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3813 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3814 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3815 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3816 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3817 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3818 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3819 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3820 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3821 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a6da21b | 2019-03-01 23:43:39 +0100 | [diff] [blame] | 3822 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3823 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3824 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3825 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3826 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3827 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3828 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3829 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3830 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3831 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3832 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3833 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3834 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3835 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3836 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | a469a61 | 2018-07-18 22:38:21 +0200 | [diff] [blame] | 3837 | .avb_ops = &mv88e6165_avb_ops, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 3838 | .ptp_ops = &mv88e6165_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3839 | .phylink_validate = mv88e6185_phylink_validate, |
Andrew Lunn | fe23036 | 2021-09-26 19:41:24 +0200 | [diff] [blame] | 3840 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3841 | }; |
| 3842 | |
| 3843 | static const struct mv88e6xxx_ops mv88e6165_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3844 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3845 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3846 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3847 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3848 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | efb3e74 | 2017-01-24 14:53:47 +0100 | [diff] [blame] | 3849 | .phy_read = mv88e6165_phy_read, |
| 3850 | .phy_write = mv88e6165_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3851 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3852 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3853 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3854 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3855 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3856 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3857 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3858 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3859 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3860 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3861 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3862 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3863 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3864 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3865 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3866 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3867 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3868 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3869 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3870 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3871 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3872 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | a469a61 | 2018-07-18 22:38:21 +0200 | [diff] [blame] | 3873 | .avb_ops = &mv88e6165_avb_ops, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 3874 | .ptp_ops = &mv88e6165_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3875 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3876 | }; |
| 3877 | |
| 3878 | static const struct mv88e6xxx_ops mv88e6171_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3879 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3880 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3881 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3882 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3883 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3884 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3885 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3886 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3887 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 3888 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3889 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3890 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3891 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3892 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3893 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3894 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3895 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3896 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3897 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3898 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3899 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3900 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3901 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3902 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3903 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3904 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3905 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3906 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3907 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3908 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3909 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3910 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3911 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3912 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3913 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3914 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3915 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3916 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3917 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3918 | }; |
| 3919 | |
| 3920 | static const struct mv88e6xxx_ops mv88e6172_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3921 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3922 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3923 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3924 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3925 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 3926 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3927 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3928 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3929 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3930 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3931 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 3932 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3933 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3934 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 3935 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3936 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3937 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3938 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3939 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3940 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3941 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3942 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3943 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3944 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3945 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3946 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3947 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3948 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3949 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3950 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3951 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3952 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3953 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3954 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3955 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3956 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3957 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3958 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3959 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3960 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3961 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3962 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 3963 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 3964 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 3965 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 3966 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 3967 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 3968 | .serdes_power = mv88e6352_serdes_power, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 3969 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 3970 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3971 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3972 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3973 | }; |
| 3974 | |
| 3975 | static const struct mv88e6xxx_ops mv88e6175_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3976 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3977 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3978 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3979 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3980 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3981 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3982 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3983 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3984 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 3985 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3986 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3987 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3988 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3989 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3990 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3991 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3992 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3993 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3994 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3995 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3996 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3997 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3998 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3999 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4000 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4001 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4002 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4003 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4004 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4005 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4006 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4007 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4008 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4009 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4010 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4011 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4012 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4013 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4014 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4015 | }; |
| 4016 | |
| 4017 | static const struct mv88e6xxx_ops mv88e6176_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4018 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4019 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4020 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4021 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4022 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4023 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4024 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4025 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4026 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4027 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4028 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4029 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4030 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4031 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4032 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4033 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4034 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4035 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4036 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4037 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4038 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4039 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4040 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4041 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4042 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4043 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4044 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4045 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4046 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4047 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4048 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4049 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4050 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4051 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4052 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4053 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4054 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4055 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4056 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4057 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4058 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4059 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4060 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4061 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 4062 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 4063 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 4064 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4065 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4066 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4067 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4068 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4069 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4070 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4071 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4072 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4073 | }; |
| 4074 | |
| 4075 | static const struct mv88e6xxx_ops mv88e6185_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4076 | /* MV88E6XXX_FAMILY_6185 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4077 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4078 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4079 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 4080 | .phy_read = mv88e6185_phy_ppu_read, |
| 4081 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4082 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4083 | .port_sync_link = mv88e6185_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4084 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4085 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4086 | .port_set_ucast_flood = mv88e6185_port_set_forward_unknown, |
| 4087 | .port_set_mcast_flood = mv88e6185_port_set_default_forward, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4088 | .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 4089 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 4090 | .port_set_pause = mv88e6185_port_set_pause, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4091 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4092 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4093 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4094 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4095 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4096 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4097 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4098 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4099 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4100 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4101 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Chris Packham | f5be107 | 2020-11-24 17:34:38 +1300 | [diff] [blame] | 4102 | .serdes_power = mv88e6185_serdes_power, |
| 4103 | .serdes_get_lane = mv88e6185_serdes_get_lane, |
| 4104 | .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 4105 | .set_cascade_port = mv88e6185_g1_set_cascade_port, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 4106 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 4107 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4108 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4109 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4110 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4111 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 4112 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4113 | }; |
| 4114 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4115 | static const struct mv88e6xxx_ops mv88e6190_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4116 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4117 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4118 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4119 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4120 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4121 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4122 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4123 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4124 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4125 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4126 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4127 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4128 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4129 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4130 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4131 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4132 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4133 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4134 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Chris Packham | e8b34c6 | 2020-07-24 11:21:21 +1200 | [diff] [blame] | 4135 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4136 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4137 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4138 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4139 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4140 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4141 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4142 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4143 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4144 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4145 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4146 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4147 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4148 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4149 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4150 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4151 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4152 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4153 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4154 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4155 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4156 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4157 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4158 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4159 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4160 | /* Check status register pause & lpa register */ |
| 4161 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4162 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4163 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4164 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4165 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4166 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4167 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4168 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4169 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4170 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4171 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4172 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4173 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4174 | }; |
| 4175 | |
| 4176 | static const struct mv88e6xxx_ops mv88e6190x_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4177 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4178 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4179 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4180 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4181 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4182 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4183 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4184 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4185 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4186 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4187 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4188 | .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4189 | .port_max_speed_mode = mv88e6390x_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4190 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4191 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4192 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4193 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4194 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4195 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Chris Packham | e8b34c6 | 2020-07-24 11:21:21 +1200 | [diff] [blame] | 4196 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4197 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4198 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4199 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4200 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4201 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4202 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4203 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4204 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4205 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4206 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4207 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4208 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4209 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4210 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4211 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4212 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4213 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4214 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4215 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4216 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4217 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4218 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4219 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4220 | .serdes_get_lane = mv88e6390x_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4221 | /* Check status register pause & lpa register */ |
| 4222 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4223 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4224 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4225 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4226 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4227 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4228 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4229 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4230 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4231 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4232 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4233 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4234 | .phylink_validate = mv88e6390x_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4235 | }; |
| 4236 | |
| 4237 | static const struct mv88e6xxx_ops mv88e6191_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4238 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4239 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4240 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4241 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4242 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4243 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4244 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4245 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4246 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4247 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4248 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4249 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4250 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4251 | .port_tag_remap = mv88e6390_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4252 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4253 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4254 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4255 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4256 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4257 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4258 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4259 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4260 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4261 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4262 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4263 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4264 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4265 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4266 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4267 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4268 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4269 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4270 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4271 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4272 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4273 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4274 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4275 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4276 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4277 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4278 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4279 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4280 | /* Check status register pause & lpa register */ |
| 4281 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4282 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4283 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4284 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4285 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4286 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4287 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4288 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4289 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4290 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4291 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4292 | .avb_ops = &mv88e6390_avb_ops, |
| 4293 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4294 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4295 | }; |
| 4296 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4297 | static const struct mv88e6xxx_ops mv88e6240_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4298 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4299 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4300 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4301 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4302 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4303 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4304 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4305 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4306 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4307 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4308 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4309 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4310 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4311 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4312 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4313 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4314 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4315 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4316 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4317 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4318 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4319 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4320 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4321 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4322 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4323 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4324 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4325 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4326 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4327 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4328 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4329 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4330 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4331 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4332 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4333 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4334 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4335 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4336 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4337 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4338 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4339 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4340 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4341 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 4342 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 4343 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 4344 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4345 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4346 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4347 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4348 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4349 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4350 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4351 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4352 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4353 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4354 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4355 | }; |
| 4356 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4357 | static const struct mv88e6xxx_ops mv88e6250_ops = { |
| 4358 | /* MV88E6XXX_FAMILY_6250 */ |
| 4359 | .ieee_pri_map = mv88e6250_g1_ieee_pri_map, |
| 4360 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
| 4361 | .irl_init_all = mv88e6352_g2_irl_init_all, |
| 4362 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4363 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
| 4364 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4365 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4366 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4367 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4368 | .port_sync_link = mv88e6xxx_port_sync_link, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4369 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4370 | .port_set_speed_duplex = mv88e6250_port_set_speed_duplex, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4371 | .port_tag_remap = mv88e6095_port_tag_remap, |
| 4372 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4373 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4374 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4375 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
| 4376 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
| 4377 | .port_pause_limit = mv88e6097_port_pause_limit, |
| 4378 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4379 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
| 4380 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
| 4381 | .stats_get_sset_count = mv88e6250_stats_get_sset_count, |
| 4382 | .stats_get_strings = mv88e6250_stats_get_strings, |
| 4383 | .stats_get_stats = mv88e6250_stats_get_stats, |
| 4384 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4385 | .set_egress_port = mv88e6095_g1_set_egress_port, |
| 4386 | .watchdog_ops = &mv88e6250_watchdog_ops, |
| 4387 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
| 4388 | .pot_clear = mv88e6xxx_g2_pot_clear, |
| 4389 | .reset = mv88e6250_g1_reset, |
Rasmus Villemoes | 67c9ed1 | 2021-01-25 16:04:48 +0100 | [diff] [blame] | 4390 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Rasmus Villemoes | b28f3f3 | 2021-01-25 16:04:49 +0100 | [diff] [blame] | 4391 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 4392 | .avb_ops = &mv88e6352_avb_ops, |
| 4393 | .ptp_ops = &mv88e6250_ptp_ops, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4394 | .phylink_validate = mv88e6065_phylink_validate, |
| 4395 | }; |
| 4396 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4397 | static const struct mv88e6xxx_ops mv88e6290_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4398 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4399 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4400 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4401 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4402 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4403 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4404 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4405 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4406 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4407 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4408 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4409 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4410 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4411 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4412 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4413 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4414 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4415 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4416 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4417 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4418 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4419 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4420 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4421 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4422 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4423 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4424 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4425 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4426 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4427 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4428 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4429 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4430 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4431 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4432 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4433 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4434 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4435 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4436 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4437 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4438 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4439 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4440 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4441 | /* Check status register pause & lpa register */ |
| 4442 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4443 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4444 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4445 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4446 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4447 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4448 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4449 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4450 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4451 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4452 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4453 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4454 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4455 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4456 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4457 | }; |
| 4458 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4459 | static const struct mv88e6xxx_ops mv88e6320_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4460 | /* MV88E6XXX_FAMILY_6320 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4461 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4462 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4463 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4464 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4465 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4466 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4467 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4468 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4469 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4470 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4471 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4472 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4473 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4474 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4475 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4476 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4477 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4478 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4479 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4480 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4481 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4482 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4483 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4484 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4485 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4486 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4487 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4488 | .stats_get_stats = mv88e6320_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4489 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4490 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | 9c7f37e | 2018-12-19 18:28:54 +0100 | [diff] [blame] | 4491 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4492 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4493 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4494 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4495 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4496 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4497 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4498 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4499 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4500 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4501 | }; |
| 4502 | |
| 4503 | static const struct mv88e6xxx_ops mv88e6321_ops = { |
Vivien Didelot | bd80720 | 2017-07-17 13:03:37 -0400 | [diff] [blame] | 4504 | /* MV88E6XXX_FAMILY_6320 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4505 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4506 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4507 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4508 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4509 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4510 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4511 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4512 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4513 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4514 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4515 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4516 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4517 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4518 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4519 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4520 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4521 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4522 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4523 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4524 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4525 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4526 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4527 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4528 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4529 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4530 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4531 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4532 | .stats_get_stats = mv88e6320_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4533 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4534 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | 9c7f37e | 2018-12-19 18:28:54 +0100 | [diff] [blame] | 4535 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4536 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4537 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4538 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4539 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4540 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4541 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4542 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4543 | }; |
| 4544 | |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4545 | static const struct mv88e6xxx_ops mv88e6341_ops = { |
| 4546 | /* MV88E6XXX_FAMILY_6341 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4547 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4548 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4549 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4550 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4551 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 4552 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4553 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4554 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4555 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4556 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4557 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4558 | .port_set_speed_duplex = mv88e6341_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4559 | .port_max_speed_mode = mv88e6341_port_max_speed_mode, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4560 | .port_tag_remap = mv88e6095_port_tag_remap, |
Marek Behún | 7da467d | 2021-07-01 00:22:26 +0200 | [diff] [blame] | 4561 | .port_set_policy = mv88e6352_port_set_policy, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4562 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4563 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4564 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4565 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4566 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4567 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4568 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4569 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 4570 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4571 | .port_get_cmode = mv88e6352_port_get_cmode, |
Marek Behún | 7a3007d | 2019-08-26 23:31:55 +0200 | [diff] [blame] | 4572 | .port_set_cmode = mv88e6341_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4573 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4574 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Marek Behún | 11527f3 | 2021-07-01 00:22:27 +0200 | [diff] [blame] | 4575 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4576 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4577 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 4578 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4579 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4580 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4581 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 4582 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4583 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4584 | .reset = mv88e6352_g1_reset, |
Marek Behún | 3709488 | 2021-07-01 00:22:28 +0200 | [diff] [blame] | 4585 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Marek Behún | c07fff3 | 2021-07-01 00:22:29 +0200 | [diff] [blame] | 4586 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4587 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4588 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4589 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4590 | .serdes_power = mv88e6390_serdes_power, |
| 4591 | .serdes_get_lane = mv88e6341_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4592 | /* Check status register pause & lpa register */ |
| 4593 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4594 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4595 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4596 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4597 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4598 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4599 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4600 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4601 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4602 | .ptp_ops = &mv88e6352_ptp_ops, |
Marek Behún | a03b98d | 2021-07-01 00:22:30 +0200 | [diff] [blame] | 4603 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4604 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4605 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Marek Behún | 953b0dc | 2021-07-01 00:22:31 +0200 | [diff] [blame] | 4606 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4607 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 4608 | .phylink_validate = mv88e6341_phylink_validate, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4609 | }; |
| 4610 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4611 | static const struct mv88e6xxx_ops mv88e6350_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4612 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4613 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4614 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4615 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4616 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4617 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4618 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4619 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4620 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 4621 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4622 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4623 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4624 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4625 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4626 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4627 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4628 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4629 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4630 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4631 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4632 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4633 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4634 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4635 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4636 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4637 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4638 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4639 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4640 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4641 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4642 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4643 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4644 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4645 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4646 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4647 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4648 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4649 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4650 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4651 | }; |
| 4652 | |
| 4653 | static const struct mv88e6xxx_ops mv88e6351_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4654 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4655 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4656 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4657 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4658 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4659 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4660 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4661 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4662 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 4663 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4664 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4665 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4666 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4667 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4668 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4669 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4670 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4671 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4672 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4673 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4674 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4675 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4676 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4677 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4678 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4679 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4680 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4681 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4682 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4683 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4684 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4685 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4686 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4687 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4688 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4689 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4690 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4691 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4692 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4693 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4694 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4695 | }; |
| 4696 | |
| 4697 | static const struct mv88e6xxx_ops mv88e6352_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4698 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4699 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4700 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4701 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4702 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4703 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4704 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4705 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4706 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4707 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4708 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4709 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4710 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4711 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4712 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4713 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4714 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4715 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4716 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4717 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4718 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4719 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4720 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4721 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4722 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4723 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4724 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4725 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4726 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4727 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4728 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4729 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4730 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4731 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4732 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4733 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4734 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4735 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4736 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4737 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4738 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4739 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4740 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4741 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 4742 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 4743 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 4744 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4745 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4746 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4747 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4748 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4749 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4750 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4751 | .ptp_ops = &mv88e6352_ptp_ops, |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 4752 | .serdes_get_sset_count = mv88e6352_serdes_get_sset_count, |
| 4753 | .serdes_get_strings = mv88e6352_serdes_get_strings, |
| 4754 | .serdes_get_stats = mv88e6352_serdes_get_stats, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4755 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4756 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4757 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4758 | }; |
| 4759 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4760 | static const struct mv88e6xxx_ops mv88e6390_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4761 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4762 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4763 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4764 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4765 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4766 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4767 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4768 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4769 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4770 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4771 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4772 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4773 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4774 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4775 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4776 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4777 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4778 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4779 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4780 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4781 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4782 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4783 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4784 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4785 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4786 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4787 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4788 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4789 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4790 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4791 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4792 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4793 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4794 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4795 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4796 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4797 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4798 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4799 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4800 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4801 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4802 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4803 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4804 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4805 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4806 | /* Check status register pause & lpa register */ |
| 4807 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4808 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4809 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4810 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4811 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4812 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4813 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4814 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4815 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4816 | .ptp_ops = &mv88e6352_ptp_ops, |
Nikita Yushchenko | 0df9528 | 2019-12-25 08:22:38 +0300 | [diff] [blame] | 4817 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4818 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4819 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4820 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4821 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4822 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4823 | }; |
| 4824 | |
| 4825 | static const struct mv88e6xxx_ops mv88e6390x_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4826 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4827 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4828 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4829 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4830 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4831 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4832 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4833 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4834 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4835 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4836 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4837 | .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4838 | .port_max_speed_mode = mv88e6390x_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4839 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4840 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4841 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4842 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4843 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4844 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4845 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4846 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4847 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4848 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4849 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4850 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | b3dce4d | 2018-11-11 00:32:14 +0100 | [diff] [blame] | 4851 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4852 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4853 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4854 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4855 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4856 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4857 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4858 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4859 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4860 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4861 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4862 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4863 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4864 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4865 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4866 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4867 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4868 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4869 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4870 | .serdes_get_lane = mv88e6390x_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4871 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4872 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4873 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4874 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4875 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4876 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4877 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4878 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4879 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4880 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4881 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4882 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4883 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4884 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4885 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4886 | .phylink_validate = mv88e6390x_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4887 | }; |
| 4888 | |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 4889 | static const struct mv88e6xxx_ops mv88e6393x_ops = { |
| 4890 | /* MV88E6XXX_FAMILY_6393 */ |
| 4891 | .setup_errata = mv88e6393x_serdes_setup_errata, |
| 4892 | .irl_init_all = mv88e6390_g2_irl_init_all, |
| 4893 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4894 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 4895 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4896 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4897 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4898 | .port_set_link = mv88e6xxx_port_set_link, |
| 4899 | .port_sync_link = mv88e6xxx_port_sync_link, |
| 4900 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 4901 | .port_set_speed_duplex = mv88e6393x_port_set_speed_duplex, |
| 4902 | .port_max_speed_mode = mv88e6393x_port_max_speed_mode, |
| 4903 | .port_tag_remap = mv88e6390_port_tag_remap, |
Marek Behún | 6584b26 | 2021-03-17 14:46:43 +0100 | [diff] [blame] | 4904 | .port_set_policy = mv88e6393x_port_set_policy, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 4905 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
| 4906 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4907 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
| 4908 | .port_set_ether_type = mv88e6393x_port_set_ether_type, |
| 4909 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
| 4910 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
| 4911 | .port_pause_limit = mv88e6390_port_pause_limit, |
| 4912 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 4913 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
| 4914 | .port_get_cmode = mv88e6352_port_get_cmode, |
| 4915 | .port_set_cmode = mv88e6393x_port_set_cmode, |
| 4916 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
| 4917 | .port_set_upstream_port = mv88e6393x_port_set_upstream_port, |
| 4918 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
| 4919 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
| 4920 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4921 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 4922 | .stats_get_stats = mv88e6390_stats_get_stats, |
| 4923 | /* .set_cpu_port is missing because this family does not support a global |
| 4924 | * CPU port, only per port CPU port which is set via |
| 4925 | * .port_set_upstream_port method. |
| 4926 | */ |
| 4927 | .set_egress_port = mv88e6393x_set_egress_port, |
| 4928 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 4929 | .mgmt_rsvd2cpu = mv88e6393x_port_mgmt_rsvd2cpu, |
| 4930 | .pot_clear = mv88e6xxx_g2_pot_clear, |
| 4931 | .reset = mv88e6352_g1_reset, |
| 4932 | .rmu_disable = mv88e6390_g1_rmu_disable, |
| 4933 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4934 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
| 4935 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4936 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
| 4937 | .serdes_power = mv88e6393x_serdes_power, |
| 4938 | .serdes_get_lane = mv88e6393x_serdes_get_lane, |
| 4939 | .serdes_pcs_get_state = mv88e6393x_serdes_pcs_get_state, |
| 4940 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4941 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4942 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
| 4943 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
| 4944 | .serdes_irq_enable = mv88e6393x_serdes_irq_enable, |
| 4945 | .serdes_irq_status = mv88e6393x_serdes_irq_status, |
| 4946 | /* TODO: serdes stats */ |
| 4947 | .gpio_ops = &mv88e6352_gpio_ops, |
| 4948 | .avb_ops = &mv88e6390_avb_ops, |
| 4949 | .ptp_ops = &mv88e6352_ptp_ops, |
| 4950 | .phylink_validate = mv88e6393x_phylink_validate, |
| 4951 | }; |
| 4952 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4953 | static const struct mv88e6xxx_info mv88e6xxx_table[] = { |
| 4954 | [MV88E6085] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4955 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4956 | .family = MV88E6XXX_FAMILY_6097, |
| 4957 | .name = "Marvell 88E6085", |
| 4958 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4959 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4960 | .num_ports = 10, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4961 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4962 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4963 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4964 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4965 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4966 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4967 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4968 | .g1_irqs = 8, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4969 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4970 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4971 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4972 | .multi_chip = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4973 | .ops = &mv88e6085_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4974 | }, |
| 4975 | |
| 4976 | [MV88E6095] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4977 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4978 | .family = MV88E6XXX_FAMILY_6095, |
| 4979 | .name = "Marvell 88E6095/88E6095F", |
| 4980 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4981 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4982 | .num_ports = 11, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4983 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4984 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4985 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4986 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4987 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4988 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4989 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4990 | .g1_irqs = 8, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4991 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4992 | .multi_chip = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4993 | .ops = &mv88e6095_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4994 | }, |
| 4995 | |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4996 | [MV88E6097] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4997 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4998 | .family = MV88E6XXX_FAMILY_6097, |
| 4999 | .name = "Marvell 88E6097/88E6097F", |
| 5000 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5001 | .num_macs = 8192, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5002 | .num_ports = 11, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5003 | .num_internal_phys = 8, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5004 | .max_vid = 4095, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5005 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5006 | .phy_base_addr = 0x0, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5007 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5008 | .global2_addr = 0x1c, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5009 | .age_time_coeff = 15000, |
Stefan Eichenberger | c534178 | 2016-11-25 09:41:29 +0100 | [diff] [blame] | 5010 | .g1_irqs = 8, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5011 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5012 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5013 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5014 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5015 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5016 | .ops = &mv88e6097_ops, |
| 5017 | }, |
| 5018 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5019 | [MV88E6123] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5020 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5021 | .family = MV88E6XXX_FAMILY_6165, |
| 5022 | .name = "Marvell 88E6123", |
| 5023 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5024 | .num_macs = 1024, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5025 | .num_ports = 3, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5026 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5027 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5028 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5029 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5030 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5031 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5032 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5033 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5034 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5035 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5036 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5037 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5038 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5039 | .ops = &mv88e6123_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5040 | }, |
| 5041 | |
| 5042 | [MV88E6131] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5043 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5044 | .family = MV88E6XXX_FAMILY_6185, |
| 5045 | .name = "Marvell 88E6131", |
| 5046 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5047 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5048 | .num_ports = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5049 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5050 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5051 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5052 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5053 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5054 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5055 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5056 | .g1_irqs = 9, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5057 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5058 | .multi_chip = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5059 | .ops = &mv88e6131_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5060 | }, |
| 5061 | |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5062 | [MV88E6141] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5063 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5064 | .family = MV88E6XXX_FAMILY_6341, |
Uwe Kleine-König | 79a68b2 | 2018-03-20 10:44:40 +0100 | [diff] [blame] | 5065 | .name = "Marvell 88E6141", |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5066 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5067 | .num_macs = 2048, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5068 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5069 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5070 | .num_gpio = 11, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5071 | .max_vid = 4095, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5072 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5073 | .phy_base_addr = 0x10, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5074 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5075 | .global2_addr = 0x1c, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5076 | .age_time_coeff = 3750, |
| 5077 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | adfccf1 | 2018-03-17 20:32:03 +0100 | [diff] [blame] | 5078 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5079 | .g2_irqs = 10, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5080 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5081 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5082 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5083 | .ops = &mv88e6141_ops, |
| 5084 | }, |
| 5085 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5086 | [MV88E6161] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5087 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5088 | .family = MV88E6XXX_FAMILY_6165, |
| 5089 | .name = "Marvell 88E6161", |
| 5090 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5091 | .num_macs = 1024, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5092 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5093 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5094 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5095 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5096 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5097 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5098 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5099 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5100 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5101 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5102 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5103 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5104 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5105 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 5106 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5107 | .ops = &mv88e6161_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5108 | }, |
| 5109 | |
| 5110 | [MV88E6165] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5111 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5112 | .family = MV88E6XXX_FAMILY_6165, |
| 5113 | .name = "Marvell 88E6165", |
| 5114 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5115 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5116 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5117 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5118 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5119 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5120 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5121 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5122 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5123 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5124 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5125 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5126 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5127 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5128 | .multi_chip = true, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 5129 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5130 | .ops = &mv88e6165_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5131 | }, |
| 5132 | |
| 5133 | [MV88E6171] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5134 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5135 | .family = MV88E6XXX_FAMILY_6351, |
| 5136 | .name = "Marvell 88E6171", |
| 5137 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5138 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5139 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5140 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5141 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5142 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5143 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5144 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5145 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5146 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5147 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5148 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5149 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5150 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5151 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5152 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5153 | .ops = &mv88e6171_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5154 | }, |
| 5155 | |
| 5156 | [MV88E6172] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5157 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5158 | .family = MV88E6XXX_FAMILY_6352, |
| 5159 | .name = "Marvell 88E6172", |
| 5160 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5161 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5162 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5163 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5164 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5165 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5166 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5167 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5168 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5169 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5170 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5171 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5172 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5173 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5174 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5175 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5176 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5177 | .ops = &mv88e6172_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5178 | }, |
| 5179 | |
| 5180 | [MV88E6175] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5181 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5182 | .family = MV88E6XXX_FAMILY_6351, |
| 5183 | .name = "Marvell 88E6175", |
| 5184 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5185 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5186 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5187 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5188 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5189 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5190 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5191 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5192 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5193 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5194 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5195 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5196 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5197 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5198 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5199 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5200 | .ops = &mv88e6175_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5201 | }, |
| 5202 | |
| 5203 | [MV88E6176] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5204 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5205 | .family = MV88E6XXX_FAMILY_6352, |
| 5206 | .name = "Marvell 88E6176", |
| 5207 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5208 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5209 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5210 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5211 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5212 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5213 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5214 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5215 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5216 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5217 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5218 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5219 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5220 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5221 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5222 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5223 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5224 | .ops = &mv88e6176_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5225 | }, |
| 5226 | |
| 5227 | [MV88E6185] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5228 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5229 | .family = MV88E6XXX_FAMILY_6185, |
| 5230 | .name = "Marvell 88E6185", |
| 5231 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5232 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5233 | .num_ports = 10, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5234 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5235 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5236 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5237 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5238 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5239 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5240 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5241 | .g1_irqs = 8, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5242 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5243 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5244 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5245 | .ops = &mv88e6185_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5246 | }, |
| 5247 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5248 | [MV88E6190] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5249 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5250 | .family = MV88E6XXX_FAMILY_6390, |
| 5251 | .name = "Marvell 88E6190", |
| 5252 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5253 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5254 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5255 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5256 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5257 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5258 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5259 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5260 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5261 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5262 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5263 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5264 | .g2_irqs = 14, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5265 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5266 | .multi_chip = true, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5267 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5268 | .ops = &mv88e6190_ops, |
| 5269 | }, |
| 5270 | |
| 5271 | [MV88E6190X] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5272 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5273 | .family = MV88E6XXX_FAMILY_6390, |
| 5274 | .name = "Marvell 88E6190X", |
| 5275 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5276 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5277 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5278 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5279 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5280 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5281 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5282 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5283 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5284 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5285 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5286 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5287 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5288 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5289 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5290 | .multi_chip = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5291 | .ops = &mv88e6190x_ops, |
| 5292 | }, |
| 5293 | |
| 5294 | [MV88E6191] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5295 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5296 | .family = MV88E6XXX_FAMILY_6390, |
| 5297 | .name = "Marvell 88E6191", |
| 5298 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5299 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5300 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5301 | .num_internal_phys = 9, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5302 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5303 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5304 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5305 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5306 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5307 | .age_time_coeff = 3750, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5308 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5309 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5310 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5311 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5312 | .multi_chip = true, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5313 | .ptp_support = true, |
Vivien Didelot | 2cf4cefb | 2017-03-28 13:50:34 -0400 | [diff] [blame] | 5314 | .ops = &mv88e6191_ops, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5315 | }, |
| 5316 | |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5317 | [MV88E6191X] = { |
| 5318 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191X, |
| 5319 | .family = MV88E6XXX_FAMILY_6393, |
| 5320 | .name = "Marvell 88E6191X", |
| 5321 | .num_databases = 4096, |
| 5322 | .num_ports = 11, /* 10 + Z80 */ |
| 5323 | .num_internal_phys = 9, |
| 5324 | .max_vid = 8191, |
| 5325 | .port_base_addr = 0x0, |
| 5326 | .phy_base_addr = 0x0, |
| 5327 | .global1_addr = 0x1b, |
| 5328 | .global2_addr = 0x1c, |
| 5329 | .age_time_coeff = 3750, |
| 5330 | .g1_irqs = 10, |
| 5331 | .g2_irqs = 14, |
| 5332 | .atu_move_port_mask = 0x1f, |
| 5333 | .pvt = true, |
| 5334 | .multi_chip = true, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5335 | .ptp_support = true, |
| 5336 | .ops = &mv88e6393x_ops, |
| 5337 | }, |
| 5338 | |
| 5339 | [MV88E6193X] = { |
| 5340 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6193X, |
| 5341 | .family = MV88E6XXX_FAMILY_6393, |
| 5342 | .name = "Marvell 88E6193X", |
| 5343 | .num_databases = 4096, |
| 5344 | .num_ports = 11, /* 10 + Z80 */ |
| 5345 | .num_internal_phys = 9, |
| 5346 | .max_vid = 8191, |
| 5347 | .port_base_addr = 0x0, |
| 5348 | .phy_base_addr = 0x0, |
| 5349 | .global1_addr = 0x1b, |
| 5350 | .global2_addr = 0x1c, |
| 5351 | .age_time_coeff = 3750, |
| 5352 | .g1_irqs = 10, |
| 5353 | .g2_irqs = 14, |
| 5354 | .atu_move_port_mask = 0x1f, |
| 5355 | .pvt = true, |
| 5356 | .multi_chip = true, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5357 | .ptp_support = true, |
| 5358 | .ops = &mv88e6393x_ops, |
| 5359 | }, |
| 5360 | |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5361 | [MV88E6220] = { |
| 5362 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220, |
| 5363 | .family = MV88E6XXX_FAMILY_6250, |
| 5364 | .name = "Marvell 88E6220", |
| 5365 | .num_databases = 64, |
| 5366 | |
| 5367 | /* Ports 2-4 are not routed to pins |
| 5368 | * => usable ports 0, 1, 5, 6 |
| 5369 | */ |
| 5370 | .num_ports = 7, |
| 5371 | .num_internal_phys = 2, |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 5372 | .invalid_port_mask = BIT(2) | BIT(3) | BIT(4), |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5373 | .max_vid = 4095, |
| 5374 | .port_base_addr = 0x08, |
| 5375 | .phy_base_addr = 0x00, |
| 5376 | .global1_addr = 0x0f, |
| 5377 | .global2_addr = 0x07, |
| 5378 | .age_time_coeff = 15000, |
| 5379 | .g1_irqs = 9, |
| 5380 | .g2_irqs = 10, |
| 5381 | .atu_move_port_mask = 0xf, |
| 5382 | .dual_chip = true, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 5383 | .ptp_support = true, |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5384 | .ops = &mv88e6250_ops, |
| 5385 | }, |
| 5386 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5387 | [MV88E6240] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5388 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5389 | .family = MV88E6XXX_FAMILY_6352, |
| 5390 | .name = "Marvell 88E6240", |
| 5391 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5392 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5393 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5394 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5395 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5396 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5397 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5398 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5399 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5400 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5401 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5402 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5403 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5404 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5405 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5406 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5407 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5408 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5409 | .ops = &mv88e6240_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5410 | }, |
| 5411 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 5412 | [MV88E6250] = { |
| 5413 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250, |
| 5414 | .family = MV88E6XXX_FAMILY_6250, |
| 5415 | .name = "Marvell 88E6250", |
| 5416 | .num_databases = 64, |
| 5417 | .num_ports = 7, |
| 5418 | .num_internal_phys = 5, |
| 5419 | .max_vid = 4095, |
| 5420 | .port_base_addr = 0x08, |
| 5421 | .phy_base_addr = 0x00, |
| 5422 | .global1_addr = 0x0f, |
| 5423 | .global2_addr = 0x07, |
| 5424 | .age_time_coeff = 15000, |
| 5425 | .g1_irqs = 9, |
| 5426 | .g2_irqs = 10, |
| 5427 | .atu_move_port_mask = 0xf, |
| 5428 | .dual_chip = true, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 5429 | .ptp_support = true, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 5430 | .ops = &mv88e6250_ops, |
| 5431 | }, |
| 5432 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5433 | [MV88E6290] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5434 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5435 | .family = MV88E6XXX_FAMILY_6390, |
| 5436 | .name = "Marvell 88E6290", |
| 5437 | .num_databases = 4096, |
| 5438 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5439 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5440 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5441 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5442 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5443 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5444 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5445 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5446 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5447 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5448 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5449 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5450 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5451 | .multi_chip = true, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5452 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5453 | .ops = &mv88e6290_ops, |
| 5454 | }, |
| 5455 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5456 | [MV88E6320] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5457 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5458 | .family = MV88E6XXX_FAMILY_6320, |
| 5459 | .name = "Marvell 88E6320", |
| 5460 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5461 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5462 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5463 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5464 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5465 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5466 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5467 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5468 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5469 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5470 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5471 | .g1_irqs = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5472 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5473 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5474 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5475 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5476 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5477 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5478 | .ops = &mv88e6320_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5479 | }, |
| 5480 | |
| 5481 | [MV88E6321] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5482 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5483 | .family = MV88E6XXX_FAMILY_6320, |
| 5484 | .name = "Marvell 88E6321", |
| 5485 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5486 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5487 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5488 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5489 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5490 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5491 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5492 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5493 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5494 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5495 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5496 | .g1_irqs = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5497 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5498 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5499 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5500 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5501 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5502 | .ops = &mv88e6321_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5503 | }, |
| 5504 | |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5505 | [MV88E6341] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5506 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5507 | .family = MV88E6XXX_FAMILY_6341, |
| 5508 | .name = "Marvell 88E6341", |
| 5509 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5510 | .num_macs = 2048, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5511 | .num_internal_phys = 5, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5512 | .num_ports = 6, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5513 | .num_gpio = 11, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5514 | .max_vid = 4095, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5515 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5516 | .phy_base_addr = 0x10, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5517 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5518 | .global2_addr = 0x1c, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5519 | .age_time_coeff = 3750, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5520 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | adfccf1 | 2018-03-17 20:32:03 +0100 | [diff] [blame] | 5521 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5522 | .g2_irqs = 10, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5523 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5524 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5525 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5526 | .ptp_support = true, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5527 | .ops = &mv88e6341_ops, |
| 5528 | }, |
| 5529 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5530 | [MV88E6350] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5531 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5532 | .family = MV88E6XXX_FAMILY_6351, |
| 5533 | .name = "Marvell 88E6350", |
| 5534 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5535 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5536 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5537 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5538 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5539 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5540 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5541 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5542 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5543 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5544 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5545 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5546 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5547 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5548 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5549 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5550 | .ops = &mv88e6350_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5551 | }, |
| 5552 | |
| 5553 | [MV88E6351] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5554 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5555 | .family = MV88E6XXX_FAMILY_6351, |
| 5556 | .name = "Marvell 88E6351", |
| 5557 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5558 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5559 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5560 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5561 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5562 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5563 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5564 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5565 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5566 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5567 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5568 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5569 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5570 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5571 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5572 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5573 | .ops = &mv88e6351_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5574 | }, |
| 5575 | |
| 5576 | [MV88E6352] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5577 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5578 | .family = MV88E6XXX_FAMILY_6352, |
| 5579 | .name = "Marvell 88E6352", |
| 5580 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5581 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5582 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5583 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5584 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5585 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5586 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5587 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5588 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5589 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5590 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5591 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5592 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5593 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5594 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5595 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5596 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5597 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5598 | .ops = &mv88e6352_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5599 | }, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5600 | [MV88E6390] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5601 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5602 | .family = MV88E6XXX_FAMILY_6390, |
| 5603 | .name = "Marvell 88E6390", |
| 5604 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5605 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5606 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5607 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5608 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5609 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5610 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5611 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5612 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5613 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5614 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5615 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5616 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5617 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5618 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5619 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5620 | .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5621 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5622 | .ops = &mv88e6390_ops, |
| 5623 | }, |
| 5624 | [MV88E6390X] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5625 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5626 | .family = MV88E6XXX_FAMILY_6390, |
| 5627 | .name = "Marvell 88E6390X", |
| 5628 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5629 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5630 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5631 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5632 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5633 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5634 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5635 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5636 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5637 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5638 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5639 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5640 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5641 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5642 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5643 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5644 | .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5645 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5646 | .ops = &mv88e6390x_ops, |
| 5647 | }, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5648 | |
| 5649 | [MV88E6393X] = { |
| 5650 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X, |
| 5651 | .family = MV88E6XXX_FAMILY_6393, |
| 5652 | .name = "Marvell 88E6393X", |
| 5653 | .num_databases = 4096, |
| 5654 | .num_ports = 11, /* 10 + Z80 */ |
| 5655 | .num_internal_phys = 9, |
| 5656 | .max_vid = 8191, |
| 5657 | .port_base_addr = 0x0, |
| 5658 | .phy_base_addr = 0x0, |
| 5659 | .global1_addr = 0x1b, |
| 5660 | .global2_addr = 0x1c, |
| 5661 | .age_time_coeff = 3750, |
| 5662 | .g1_irqs = 10, |
| 5663 | .g2_irqs = 14, |
| 5664 | .atu_move_port_mask = 0x1f, |
| 5665 | .pvt = true, |
| 5666 | .multi_chip = true, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5667 | .ptp_support = true, |
| 5668 | .ops = &mv88e6393x_ops, |
| 5669 | }, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5670 | }; |
| 5671 | |
Vivien Didelot | 5f7c036 | 2016-06-20 13:14:04 -0400 | [diff] [blame] | 5672 | static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num) |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5673 | { |
Vivien Didelot | a439c06 | 2016-04-17 13:23:58 -0400 | [diff] [blame] | 5674 | int i; |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5675 | |
Vivien Didelot | 5f7c036 | 2016-06-20 13:14:04 -0400 | [diff] [blame] | 5676 | for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i) |
| 5677 | if (mv88e6xxx_table[i].prod_num == prod_num) |
| 5678 | return &mv88e6xxx_table[i]; |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5679 | |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5680 | return NULL; |
| 5681 | } |
| 5682 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5683 | static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip) |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5684 | { |
| 5685 | const struct mv88e6xxx_info *info; |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 5686 | unsigned int prod_num, rev; |
| 5687 | u16 id; |
| 5688 | int err; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5689 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5690 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5691 | err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5692 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 5693 | if (err) |
| 5694 | return err; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5695 | |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5696 | prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK; |
| 5697 | rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5698 | |
| 5699 | info = mv88e6xxx_lookup_info(prod_num); |
| 5700 | if (!info) |
| 5701 | return -ENODEV; |
| 5702 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 5703 | /* Update the compatible info with the probed one */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5704 | chip->info = info; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5705 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5706 | dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n", |
| 5707 | chip->info->prod_num, chip->info->name, rev); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5708 | |
| 5709 | return 0; |
| 5710 | } |
| 5711 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5712 | static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5713 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5714 | struct mv88e6xxx_chip *chip; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5715 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5716 | chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); |
| 5717 | if (!chip) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5718 | return NULL; |
| 5719 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5720 | chip->dev = dev; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5721 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5722 | mutex_init(&chip->reg_lock); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 5723 | INIT_LIST_HEAD(&chip->mdios); |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 5724 | idr_init(&chip->policies); |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5725 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5726 | return chip; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5727 | } |
| 5728 | |
Florian Fainelli | 5ed4e3e | 2017-11-10 15:22:52 -0800 | [diff] [blame] | 5729 | static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds, |
Florian Fainelli | 4d77648 | 2020-01-07 21:06:05 -0800 | [diff] [blame] | 5730 | int port, |
| 5731 | enum dsa_tag_protocol m) |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 5732 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5733 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 2bbb33b | 2016-08-22 16:01:02 +0200 | [diff] [blame] | 5734 | |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5735 | return chip->tag_protocol; |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 5736 | } |
| 5737 | |
Tobias Waldekranz | 9a99bef | 2021-04-20 20:53:08 +0200 | [diff] [blame] | 5738 | static int mv88e6xxx_change_tag_protocol(struct dsa_switch *ds, int port, |
| 5739 | enum dsa_tag_protocol proto) |
| 5740 | { |
| 5741 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5742 | enum dsa_tag_protocol old_protocol; |
| 5743 | int err; |
| 5744 | |
| 5745 | switch (proto) { |
| 5746 | case DSA_TAG_PROTO_EDSA: |
| 5747 | switch (chip->info->edsa_support) { |
| 5748 | case MV88E6XXX_EDSA_UNSUPPORTED: |
| 5749 | return -EPROTONOSUPPORT; |
| 5750 | case MV88E6XXX_EDSA_UNDOCUMENTED: |
| 5751 | dev_warn(chip->dev, "Relying on undocumented EDSA tagging behavior\n"); |
| 5752 | fallthrough; |
| 5753 | case MV88E6XXX_EDSA_SUPPORTED: |
| 5754 | break; |
| 5755 | } |
| 5756 | break; |
| 5757 | case DSA_TAG_PROTO_DSA: |
| 5758 | break; |
| 5759 | default: |
| 5760 | return -EPROTONOSUPPORT; |
| 5761 | } |
| 5762 | |
| 5763 | old_protocol = chip->tag_protocol; |
| 5764 | chip->tag_protocol = proto; |
| 5765 | |
| 5766 | mv88e6xxx_reg_lock(chip); |
| 5767 | err = mv88e6xxx_setup_port_mode(chip, port); |
| 5768 | mv88e6xxx_reg_unlock(chip); |
| 5769 | |
| 5770 | if (err) |
| 5771 | chip->tag_protocol = old_protocol; |
| 5772 | |
| 5773 | return err; |
| 5774 | } |
| 5775 | |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5776 | static int mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port, |
| 5777 | const struct switchdev_obj_port_mdb *mdb) |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5778 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5779 | struct mv88e6xxx_chip *chip = ds->priv; |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5780 | int err; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5781 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5782 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5783 | err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, |
| 5784 | MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5785 | mv88e6xxx_reg_unlock(chip); |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5786 | |
| 5787 | return err; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5788 | } |
| 5789 | |
| 5790 | static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port, |
| 5791 | const struct switchdev_obj_port_mdb *mdb) |
| 5792 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5793 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5794 | int err; |
| 5795 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5796 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 5797 | err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5798 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5799 | |
| 5800 | return err; |
| 5801 | } |
| 5802 | |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5803 | static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port, |
| 5804 | struct dsa_mall_mirror_tc_entry *mirror, |
| 5805 | bool ingress) |
| 5806 | { |
| 5807 | enum mv88e6xxx_egress_direction direction = ingress ? |
| 5808 | MV88E6XXX_EGRESS_DIR_INGRESS : |
| 5809 | MV88E6XXX_EGRESS_DIR_EGRESS; |
| 5810 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5811 | bool other_mirrors = false; |
| 5812 | int i; |
| 5813 | int err; |
| 5814 | |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5815 | mutex_lock(&chip->reg_lock); |
| 5816 | if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) != |
| 5817 | mirror->to_local_port) { |
| 5818 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) |
| 5819 | other_mirrors |= ingress ? |
| 5820 | chip->ports[i].mirror_ingress : |
| 5821 | chip->ports[i].mirror_egress; |
| 5822 | |
| 5823 | /* Can't change egress port when other mirror is active */ |
| 5824 | if (other_mirrors) { |
| 5825 | err = -EBUSY; |
| 5826 | goto out; |
| 5827 | } |
| 5828 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 5829 | err = mv88e6xxx_set_egress_port(chip, direction, |
| 5830 | mirror->to_local_port); |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5831 | if (err) |
| 5832 | goto out; |
| 5833 | } |
| 5834 | |
| 5835 | err = mv88e6xxx_port_set_mirror(chip, port, direction, true); |
| 5836 | out: |
| 5837 | mutex_unlock(&chip->reg_lock); |
| 5838 | |
| 5839 | return err; |
| 5840 | } |
| 5841 | |
| 5842 | static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port, |
| 5843 | struct dsa_mall_mirror_tc_entry *mirror) |
| 5844 | { |
| 5845 | enum mv88e6xxx_egress_direction direction = mirror->ingress ? |
| 5846 | MV88E6XXX_EGRESS_DIR_INGRESS : |
| 5847 | MV88E6XXX_EGRESS_DIR_EGRESS; |
| 5848 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5849 | bool other_mirrors = false; |
| 5850 | int i; |
| 5851 | |
| 5852 | mutex_lock(&chip->reg_lock); |
| 5853 | if (mv88e6xxx_port_set_mirror(chip, port, direction, false)) |
| 5854 | dev_err(ds->dev, "p%d: failed to disable mirroring\n", port); |
| 5855 | |
| 5856 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) |
| 5857 | other_mirrors |= mirror->ingress ? |
| 5858 | chip->ports[i].mirror_ingress : |
| 5859 | chip->ports[i].mirror_egress; |
| 5860 | |
| 5861 | /* Reset egress port when no other mirror is active */ |
| 5862 | if (!other_mirrors) { |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 5863 | if (mv88e6xxx_set_egress_port(chip, direction, |
| 5864 | dsa_upstream_port(ds, port))) |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5865 | dev_err(ds->dev, "failed to set egress port\n"); |
| 5866 | } |
| 5867 | |
| 5868 | mutex_unlock(&chip->reg_lock); |
| 5869 | } |
| 5870 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5871 | static int mv88e6xxx_port_pre_bridge_flags(struct dsa_switch *ds, int port, |
| 5872 | struct switchdev_brport_flags flags, |
| 5873 | struct netlink_ext_ack *extack) |
| 5874 | { |
| 5875 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5876 | const struct mv88e6xxx_ops *ops; |
| 5877 | |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 5878 | if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | |
| 5879 | BR_BCAST_FLOOD)) |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5880 | return -EINVAL; |
| 5881 | |
| 5882 | ops = chip->info->ops; |
| 5883 | |
| 5884 | if ((flags.mask & BR_FLOOD) && !ops->port_set_ucast_flood) |
| 5885 | return -EINVAL; |
| 5886 | |
| 5887 | if ((flags.mask & BR_MCAST_FLOOD) && !ops->port_set_mcast_flood) |
| 5888 | return -EINVAL; |
| 5889 | |
| 5890 | return 0; |
| 5891 | } |
| 5892 | |
| 5893 | static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port, |
| 5894 | struct switchdev_brport_flags flags, |
| 5895 | struct netlink_ext_ack *extack) |
Russell King | 4f85901 | 2019-02-20 15:35:05 -0800 | [diff] [blame] | 5896 | { |
| 5897 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5898 | int err = -EOPNOTSUPP; |
| 5899 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5900 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5901 | |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 5902 | if (flags.mask & BR_LEARNING) { |
| 5903 | bool learning = !!(flags.val & BR_LEARNING); |
| 5904 | u16 pav = learning ? (1 << port) : 0; |
| 5905 | |
| 5906 | err = mv88e6xxx_port_set_assoc_vector(chip, port, pav); |
| 5907 | if (err) |
| 5908 | goto out; |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 5909 | } |
| 5910 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5911 | if (flags.mask & BR_FLOOD) { |
| 5912 | bool unicast = !!(flags.val & BR_FLOOD); |
| 5913 | |
| 5914 | err = chip->info->ops->port_set_ucast_flood(chip, port, |
| 5915 | unicast); |
| 5916 | if (err) |
| 5917 | goto out; |
| 5918 | } |
| 5919 | |
| 5920 | if (flags.mask & BR_MCAST_FLOOD) { |
| 5921 | bool multicast = !!(flags.val & BR_MCAST_FLOOD); |
| 5922 | |
| 5923 | err = chip->info->ops->port_set_mcast_flood(chip, port, |
| 5924 | multicast); |
| 5925 | if (err) |
| 5926 | goto out; |
| 5927 | } |
| 5928 | |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 5929 | if (flags.mask & BR_BCAST_FLOOD) { |
| 5930 | bool broadcast = !!(flags.val & BR_BCAST_FLOOD); |
| 5931 | |
| 5932 | err = mv88e6xxx_port_broadcast_sync(chip, port, broadcast); |
| 5933 | if (err) |
| 5934 | goto out; |
| 5935 | } |
| 5936 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5937 | out: |
| 5938 | mv88e6xxx_reg_unlock(chip); |
| 5939 | |
| 5940 | return err; |
| 5941 | } |
| 5942 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 5943 | static bool mv88e6xxx_lag_can_offload(struct dsa_switch *ds, |
| 5944 | struct net_device *lag, |
| 5945 | struct netdev_lag_upper_info *info) |
| 5946 | { |
Tobias Waldekranz | b80dc51 | 2021-01-15 13:52:59 +0100 | [diff] [blame] | 5947 | struct mv88e6xxx_chip *chip = ds->priv; |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 5948 | struct dsa_port *dp; |
| 5949 | int id, members = 0; |
| 5950 | |
Tobias Waldekranz | b80dc51 | 2021-01-15 13:52:59 +0100 | [diff] [blame] | 5951 | if (!mv88e6xxx_has_lag(chip)) |
| 5952 | return false; |
| 5953 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 5954 | id = dsa_lag_id(ds->dst, lag); |
| 5955 | if (id < 0 || id >= ds->num_lag_ids) |
| 5956 | return false; |
| 5957 | |
| 5958 | dsa_lag_foreach_port(dp, ds->dst, lag) |
| 5959 | /* Includes the port joining the LAG */ |
| 5960 | members++; |
| 5961 | |
| 5962 | if (members > 8) |
| 5963 | return false; |
| 5964 | |
| 5965 | /* We could potentially relax this to include active |
| 5966 | * backup in the future. |
| 5967 | */ |
| 5968 | if (info->tx_type != NETDEV_LAG_TX_TYPE_HASH) |
| 5969 | return false; |
| 5970 | |
| 5971 | /* Ideally we would also validate that the hash type matches |
| 5972 | * the hardware. Alas, this is always set to unknown on team |
| 5973 | * interfaces. |
| 5974 | */ |
| 5975 | return true; |
| 5976 | } |
| 5977 | |
| 5978 | static int mv88e6xxx_lag_sync_map(struct dsa_switch *ds, struct net_device *lag) |
| 5979 | { |
| 5980 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5981 | struct dsa_port *dp; |
| 5982 | u16 map = 0; |
| 5983 | int id; |
| 5984 | |
| 5985 | id = dsa_lag_id(ds->dst, lag); |
| 5986 | |
| 5987 | /* Build the map of all ports to distribute flows destined for |
| 5988 | * this LAG. This can be either a local user port, or a DSA |
| 5989 | * port if the LAG port is on a remote chip. |
| 5990 | */ |
| 5991 | dsa_lag_foreach_port(dp, ds->dst, lag) |
| 5992 | map |= BIT(dsa_towards_port(ds, dp->ds->index, dp->index)); |
| 5993 | |
| 5994 | return mv88e6xxx_g2_trunk_mapping_write(chip, id, map); |
| 5995 | } |
| 5996 | |
| 5997 | static const u8 mv88e6xxx_lag_mask_table[8][8] = { |
| 5998 | /* Row number corresponds to the number of active members in a |
| 5999 | * LAG. Each column states which of the eight hash buckets are |
| 6000 | * mapped to the column:th port in the LAG. |
| 6001 | * |
| 6002 | * Example: In a LAG with three active ports, the second port |
| 6003 | * ([2][1]) would be selected for traffic mapped to buckets |
| 6004 | * 3,4,5 (0x38). |
| 6005 | */ |
| 6006 | { 0xff, 0, 0, 0, 0, 0, 0, 0 }, |
| 6007 | { 0x0f, 0xf0, 0, 0, 0, 0, 0, 0 }, |
| 6008 | { 0x07, 0x38, 0xc0, 0, 0, 0, 0, 0 }, |
| 6009 | { 0x03, 0x0c, 0x30, 0xc0, 0, 0, 0, 0 }, |
| 6010 | { 0x03, 0x0c, 0x30, 0x40, 0x80, 0, 0, 0 }, |
| 6011 | { 0x03, 0x0c, 0x10, 0x20, 0x40, 0x80, 0, 0 }, |
| 6012 | { 0x03, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0 }, |
| 6013 | { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, |
| 6014 | }; |
| 6015 | |
| 6016 | static void mv88e6xxx_lag_set_port_mask(u16 *mask, int port, |
| 6017 | int num_tx, int nth) |
| 6018 | { |
| 6019 | u8 active = 0; |
| 6020 | int i; |
| 6021 | |
| 6022 | num_tx = num_tx <= 8 ? num_tx : 8; |
| 6023 | if (nth < num_tx) |
| 6024 | active = mv88e6xxx_lag_mask_table[num_tx - 1][nth]; |
| 6025 | |
| 6026 | for (i = 0; i < 8; i++) { |
| 6027 | if (BIT(i) & active) |
| 6028 | mask[i] |= BIT(port); |
| 6029 | } |
| 6030 | } |
| 6031 | |
| 6032 | static int mv88e6xxx_lag_sync_masks(struct dsa_switch *ds) |
| 6033 | { |
| 6034 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6035 | unsigned int id, num_tx; |
| 6036 | struct net_device *lag; |
| 6037 | struct dsa_port *dp; |
| 6038 | int i, err, nth; |
| 6039 | u16 mask[8]; |
| 6040 | u16 ivec; |
| 6041 | |
| 6042 | /* Assume no port is a member of any LAG. */ |
| 6043 | ivec = BIT(mv88e6xxx_num_ports(chip)) - 1; |
| 6044 | |
| 6045 | /* Disable all masks for ports that _are_ members of a LAG. */ |
| 6046 | list_for_each_entry(dp, &ds->dst->ports, list) { |
| 6047 | if (!dp->lag_dev || dp->ds != ds) |
| 6048 | continue; |
| 6049 | |
| 6050 | ivec &= ~BIT(dp->index); |
| 6051 | } |
| 6052 | |
| 6053 | for (i = 0; i < 8; i++) |
| 6054 | mask[i] = ivec; |
| 6055 | |
| 6056 | /* Enable the correct subset of masks for all LAG ports that |
| 6057 | * are in the Tx set. |
| 6058 | */ |
| 6059 | dsa_lags_foreach_id(id, ds->dst) { |
| 6060 | lag = dsa_lag_dev(ds->dst, id); |
| 6061 | if (!lag) |
| 6062 | continue; |
| 6063 | |
| 6064 | num_tx = 0; |
| 6065 | dsa_lag_foreach_port(dp, ds->dst, lag) { |
| 6066 | if (dp->lag_tx_enabled) |
| 6067 | num_tx++; |
| 6068 | } |
| 6069 | |
| 6070 | if (!num_tx) |
| 6071 | continue; |
| 6072 | |
| 6073 | nth = 0; |
| 6074 | dsa_lag_foreach_port(dp, ds->dst, lag) { |
| 6075 | if (!dp->lag_tx_enabled) |
| 6076 | continue; |
| 6077 | |
| 6078 | if (dp->ds == ds) |
| 6079 | mv88e6xxx_lag_set_port_mask(mask, dp->index, |
| 6080 | num_tx, nth); |
| 6081 | |
| 6082 | nth++; |
| 6083 | } |
| 6084 | } |
| 6085 | |
| 6086 | for (i = 0; i < 8; i++) { |
| 6087 | err = mv88e6xxx_g2_trunk_mask_write(chip, i, true, mask[i]); |
| 6088 | if (err) |
| 6089 | return err; |
| 6090 | } |
| 6091 | |
| 6092 | return 0; |
| 6093 | } |
| 6094 | |
| 6095 | static int mv88e6xxx_lag_sync_masks_map(struct dsa_switch *ds, |
| 6096 | struct net_device *lag) |
| 6097 | { |
| 6098 | int err; |
| 6099 | |
| 6100 | err = mv88e6xxx_lag_sync_masks(ds); |
| 6101 | |
| 6102 | if (!err) |
| 6103 | err = mv88e6xxx_lag_sync_map(ds, lag); |
| 6104 | |
| 6105 | return err; |
| 6106 | } |
| 6107 | |
| 6108 | static int mv88e6xxx_port_lag_change(struct dsa_switch *ds, int port) |
| 6109 | { |
| 6110 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6111 | int err; |
| 6112 | |
| 6113 | mv88e6xxx_reg_lock(chip); |
| 6114 | err = mv88e6xxx_lag_sync_masks(ds); |
| 6115 | mv88e6xxx_reg_unlock(chip); |
| 6116 | return err; |
| 6117 | } |
| 6118 | |
| 6119 | static int mv88e6xxx_port_lag_join(struct dsa_switch *ds, int port, |
| 6120 | struct net_device *lag, |
| 6121 | struct netdev_lag_upper_info *info) |
| 6122 | { |
| 6123 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6124 | int err, id; |
| 6125 | |
| 6126 | if (!mv88e6xxx_lag_can_offload(ds, lag, info)) |
| 6127 | return -EOPNOTSUPP; |
| 6128 | |
| 6129 | id = dsa_lag_id(ds->dst, lag); |
| 6130 | |
| 6131 | mv88e6xxx_reg_lock(chip); |
| 6132 | |
| 6133 | err = mv88e6xxx_port_set_trunk(chip, port, true, id); |
| 6134 | if (err) |
| 6135 | goto err_unlock; |
| 6136 | |
| 6137 | err = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6138 | if (err) |
| 6139 | goto err_clear_trunk; |
| 6140 | |
| 6141 | mv88e6xxx_reg_unlock(chip); |
| 6142 | return 0; |
| 6143 | |
| 6144 | err_clear_trunk: |
| 6145 | mv88e6xxx_port_set_trunk(chip, port, false, 0); |
| 6146 | err_unlock: |
| 6147 | mv88e6xxx_reg_unlock(chip); |
| 6148 | return err; |
| 6149 | } |
| 6150 | |
| 6151 | static int mv88e6xxx_port_lag_leave(struct dsa_switch *ds, int port, |
| 6152 | struct net_device *lag) |
| 6153 | { |
| 6154 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6155 | int err_sync, err_trunk; |
| 6156 | |
| 6157 | mv88e6xxx_reg_lock(chip); |
| 6158 | err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6159 | err_trunk = mv88e6xxx_port_set_trunk(chip, port, false, 0); |
| 6160 | mv88e6xxx_reg_unlock(chip); |
| 6161 | return err_sync ? : err_trunk; |
| 6162 | } |
| 6163 | |
| 6164 | static int mv88e6xxx_crosschip_lag_change(struct dsa_switch *ds, int sw_index, |
| 6165 | int port) |
| 6166 | { |
| 6167 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6168 | int err; |
| 6169 | |
| 6170 | mv88e6xxx_reg_lock(chip); |
| 6171 | err = mv88e6xxx_lag_sync_masks(ds); |
| 6172 | mv88e6xxx_reg_unlock(chip); |
| 6173 | return err; |
| 6174 | } |
| 6175 | |
| 6176 | static int mv88e6xxx_crosschip_lag_join(struct dsa_switch *ds, int sw_index, |
| 6177 | int port, struct net_device *lag, |
| 6178 | struct netdev_lag_upper_info *info) |
| 6179 | { |
| 6180 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6181 | int err; |
| 6182 | |
| 6183 | if (!mv88e6xxx_lag_can_offload(ds, lag, info)) |
| 6184 | return -EOPNOTSUPP; |
| 6185 | |
| 6186 | mv88e6xxx_reg_lock(chip); |
| 6187 | |
| 6188 | err = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6189 | if (err) |
| 6190 | goto unlock; |
| 6191 | |
| 6192 | err = mv88e6xxx_pvt_map(chip, sw_index, port); |
| 6193 | |
| 6194 | unlock: |
| 6195 | mv88e6xxx_reg_unlock(chip); |
| 6196 | return err; |
| 6197 | } |
| 6198 | |
| 6199 | static int mv88e6xxx_crosschip_lag_leave(struct dsa_switch *ds, int sw_index, |
| 6200 | int port, struct net_device *lag) |
| 6201 | { |
| 6202 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6203 | int err_sync, err_pvt; |
| 6204 | |
| 6205 | mv88e6xxx_reg_lock(chip); |
| 6206 | err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6207 | err_pvt = mv88e6xxx_pvt_map(chip, sw_index, port); |
| 6208 | mv88e6xxx_reg_unlock(chip); |
| 6209 | return err_sync ? : err_pvt; |
| 6210 | } |
| 6211 | |
Florian Fainelli | a82f67a | 2017-01-08 14:52:08 -0800 | [diff] [blame] | 6212 | static const struct dsa_switch_ops mv88e6xxx_switch_ops = { |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 6213 | .get_tag_protocol = mv88e6xxx_get_tag_protocol, |
Tobias Waldekranz | 9a99bef | 2021-04-20 20:53:08 +0200 | [diff] [blame] | 6214 | .change_tag_protocol = mv88e6xxx_change_tag_protocol, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6215 | .setup = mv88e6xxx_setup, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 6216 | .teardown = mv88e6xxx_teardown, |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 6217 | .port_setup = mv88e6xxx_port_setup, |
| 6218 | .port_teardown = mv88e6xxx_port_teardown, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 6219 | .phylink_validate = mv88e6xxx_validate, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 6220 | .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 6221 | .phylink_mac_config = mv88e6xxx_mac_config, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 6222 | .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 6223 | .phylink_mac_link_down = mv88e6xxx_mac_link_down, |
| 6224 | .phylink_mac_link_up = mv88e6xxx_mac_link_up, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6225 | .get_strings = mv88e6xxx_get_strings, |
| 6226 | .get_ethtool_stats = mv88e6xxx_get_ethtool_stats, |
| 6227 | .get_sset_count = mv88e6xxx_get_sset_count, |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 6228 | .port_enable = mv88e6xxx_port_enable, |
| 6229 | .port_disable = mv88e6xxx_port_disable, |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 6230 | .port_max_mtu = mv88e6xxx_get_max_mtu, |
| 6231 | .port_change_mtu = mv88e6xxx_change_mtu, |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 6232 | .get_mac_eee = mv88e6xxx_get_mac_eee, |
| 6233 | .set_mac_eee = mv88e6xxx_set_mac_eee, |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 6234 | .get_eeprom_len = mv88e6xxx_get_eeprom_len, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6235 | .get_eeprom = mv88e6xxx_get_eeprom, |
| 6236 | .set_eeprom = mv88e6xxx_set_eeprom, |
| 6237 | .get_regs_len = mv88e6xxx_get_regs_len, |
| 6238 | .get_regs = mv88e6xxx_get_regs, |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 6239 | .get_rxnfc = mv88e6xxx_get_rxnfc, |
| 6240 | .set_rxnfc = mv88e6xxx_set_rxnfc, |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 6241 | .set_ageing_time = mv88e6xxx_set_ageing_time, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6242 | .port_bridge_join = mv88e6xxx_port_bridge_join, |
| 6243 | .port_bridge_leave = mv88e6xxx_port_bridge_leave, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 6244 | .port_pre_bridge_flags = mv88e6xxx_port_pre_bridge_flags, |
| 6245 | .port_bridge_flags = mv88e6xxx_port_bridge_flags, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6246 | .port_stp_state_set = mv88e6xxx_port_stp_state_set, |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 6247 | .port_fast_age = mv88e6xxx_port_fast_age, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6248 | .port_vlan_filtering = mv88e6xxx_port_vlan_filtering, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6249 | .port_vlan_add = mv88e6xxx_port_vlan_add, |
| 6250 | .port_vlan_del = mv88e6xxx_port_vlan_del, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6251 | .port_fdb_add = mv88e6xxx_port_fdb_add, |
| 6252 | .port_fdb_del = mv88e6xxx_port_fdb_del, |
| 6253 | .port_fdb_dump = mv88e6xxx_port_fdb_dump, |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 6254 | .port_mdb_add = mv88e6xxx_port_mdb_add, |
| 6255 | .port_mdb_del = mv88e6xxx_port_mdb_del, |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 6256 | .port_mirror_add = mv88e6xxx_port_mirror_add, |
| 6257 | .port_mirror_del = mv88e6xxx_port_mirror_del, |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 6258 | .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join, |
| 6259 | .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave, |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 6260 | .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set, |
| 6261 | .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get, |
| 6262 | .port_txtstamp = mv88e6xxx_port_txtstamp, |
| 6263 | .port_rxtstamp = mv88e6xxx_port_rxtstamp, |
| 6264 | .get_ts_info = mv88e6xxx_get_ts_info, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 6265 | .devlink_param_get = mv88e6xxx_devlink_param_get, |
| 6266 | .devlink_param_set = mv88e6xxx_devlink_param_set, |
Andrew Lunn | 9315730 | 2020-09-18 21:11:09 +0200 | [diff] [blame] | 6267 | .devlink_info_get = mv88e6xxx_devlink_info_get, |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 6268 | .port_lag_change = mv88e6xxx_port_lag_change, |
| 6269 | .port_lag_join = mv88e6xxx_port_lag_join, |
| 6270 | .port_lag_leave = mv88e6xxx_port_lag_leave, |
| 6271 | .crosschip_lag_change = mv88e6xxx_crosschip_lag_change, |
| 6272 | .crosschip_lag_join = mv88e6xxx_crosschip_lag_join, |
| 6273 | .crosschip_lag_leave = mv88e6xxx_crosschip_lag_leave, |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 6274 | .port_bridge_tx_fwd_offload = mv88e6xxx_bridge_tx_fwd_offload, |
| 6275 | .port_bridge_tx_fwd_unoffload = mv88e6xxx_bridge_tx_fwd_unoffload, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6276 | }; |
| 6277 | |
Florian Fainelli | 55ed0ce | 2017-01-26 10:45:51 -0800 | [diff] [blame] | 6278 | static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip) |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6279 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6280 | struct device *dev = chip->dev; |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6281 | struct dsa_switch *ds; |
| 6282 | |
Vivien Didelot | 7e99e34 | 2019-10-21 16:51:30 -0400 | [diff] [blame] | 6283 | ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6284 | if (!ds) |
| 6285 | return -ENOMEM; |
| 6286 | |
Vivien Didelot | 7e99e34 | 2019-10-21 16:51:30 -0400 | [diff] [blame] | 6287 | ds->dev = dev; |
| 6288 | ds->num_ports = mv88e6xxx_num_ports(chip); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6289 | ds->priv = chip; |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6290 | ds->dev = dev; |
Vivien Didelot | 9d490b4 | 2016-08-23 12:38:56 -0400 | [diff] [blame] | 6291 | ds->ops = &mv88e6xxx_switch_ops; |
Vivien Didelot | 9ff74f2 | 2017-03-15 15:53:50 -0400 | [diff] [blame] | 6292 | ds->ageing_time_min = chip->info->age_time_coeff; |
| 6293 | ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX; |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6294 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 6295 | /* Some chips support up to 32, but that requires enabling the |
| 6296 | * 5-bit port mode, which we do not support. 640k^W16 ought to |
| 6297 | * be enough for anyone. |
| 6298 | */ |
Tobias Waldekranz | b80dc51 | 2021-01-15 13:52:59 +0100 | [diff] [blame] | 6299 | ds->num_lag_ids = mv88e6xxx_has_lag(chip) ? 16 : 0; |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 6300 | |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6301 | dev_set_drvdata(dev, ds); |
| 6302 | |
Vivien Didelot | 23c9ee4 | 2017-05-26 18:12:51 -0400 | [diff] [blame] | 6303 | return dsa_register_switch(ds); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6304 | } |
| 6305 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6306 | static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip) |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6307 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6308 | dsa_unregister_switch(chip->ds); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6309 | } |
| 6310 | |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6311 | static const void *pdata_device_get_match_data(struct device *dev) |
| 6312 | { |
| 6313 | const struct of_device_id *matches = dev->driver->of_match_table; |
| 6314 | const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data; |
| 6315 | |
| 6316 | for (; matches->name[0] || matches->type[0] || matches->compatible[0]; |
| 6317 | matches++) { |
| 6318 | if (!strcmp(pdata->compatible, matches->compatible)) |
| 6319 | return matches->data; |
| 6320 | } |
| 6321 | return NULL; |
| 6322 | } |
| 6323 | |
Miquel Raynal | bcd3d9d | 2019-02-05 12:07:28 +0100 | [diff] [blame] | 6324 | /* There is no suspend to RAM support at DSA level yet, the switch configuration |
| 6325 | * would be lost after a power cycle so prevent it to be suspended. |
| 6326 | */ |
| 6327 | static int __maybe_unused mv88e6xxx_suspend(struct device *dev) |
| 6328 | { |
| 6329 | return -EOPNOTSUPP; |
| 6330 | } |
| 6331 | |
| 6332 | static int __maybe_unused mv88e6xxx_resume(struct device *dev) |
| 6333 | { |
| 6334 | return 0; |
| 6335 | } |
| 6336 | |
| 6337 | static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume); |
| 6338 | |
Vivien Didelot | 57d3231 | 2016-06-20 13:13:58 -0400 | [diff] [blame] | 6339 | static int mv88e6xxx_probe(struct mdio_device *mdiodev) |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6340 | { |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6341 | struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data; |
David S. Miller | 7ddae24 | 2018-05-20 19:04:24 -0400 | [diff] [blame] | 6342 | const struct mv88e6xxx_info *compat_info = NULL; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6343 | struct device *dev = &mdiodev->dev; |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 6344 | struct device_node *np = dev->of_node; |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6345 | struct mv88e6xxx_chip *chip; |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6346 | int port; |
Andrew Lunn | 52638f7 | 2016-05-10 23:27:22 +0200 | [diff] [blame] | 6347 | int err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6348 | |
Andrew Lunn | 7bb8c99 | 2018-05-31 00:15:42 +0200 | [diff] [blame] | 6349 | if (!np && !pdata) |
| 6350 | return -EINVAL; |
| 6351 | |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6352 | if (np) |
| 6353 | compat_info = of_device_get_match_data(dev); |
| 6354 | |
| 6355 | if (pdata) { |
| 6356 | compat_info = pdata_device_get_match_data(dev); |
| 6357 | |
| 6358 | if (!pdata->netdev) |
| 6359 | return -EINVAL; |
| 6360 | |
| 6361 | for (port = 0; port < DSA_MAX_PORTS; port++) { |
| 6362 | if (!(pdata->enabled_ports & (1 << port))) |
| 6363 | continue; |
| 6364 | if (strcmp(pdata->cd.port_names[port], "cpu")) |
| 6365 | continue; |
| 6366 | pdata->cd.netdev[port] = &pdata->netdev->dev; |
| 6367 | break; |
| 6368 | } |
| 6369 | } |
| 6370 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 6371 | if (!compat_info) |
| 6372 | return -EINVAL; |
| 6373 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6374 | chip = mv88e6xxx_alloc_chip(dev); |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6375 | if (!chip) { |
| 6376 | err = -ENOMEM; |
| 6377 | goto out; |
| 6378 | } |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6379 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6380 | chip->info = compat_info; |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 6381 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6382 | err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr); |
Vivien Didelot | 4a70c4a | 2016-06-20 13:14:07 -0400 | [diff] [blame] | 6383 | if (err) |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6384 | goto out; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6385 | |
Andrew Lunn | b4308f0 | 2016-11-21 23:26:55 +0100 | [diff] [blame] | 6386 | chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6387 | if (IS_ERR(chip->reset)) { |
| 6388 | err = PTR_ERR(chip->reset); |
| 6389 | goto out; |
| 6390 | } |
Baruch Siach | 7b75e49 | 2019-06-27 21:17:39 +0300 | [diff] [blame] | 6391 | if (chip->reset) |
| 6392 | usleep_range(1000, 2000); |
Andrew Lunn | b4308f0 | 2016-11-21 23:26:55 +0100 | [diff] [blame] | 6393 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6394 | err = mv88e6xxx_detect(chip); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 6395 | if (err) |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6396 | goto out; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6397 | |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 6398 | if (chip->info->edsa_support == MV88E6XXX_EDSA_SUPPORTED) |
| 6399 | chip->tag_protocol = DSA_TAG_PROTO_EDSA; |
| 6400 | else |
| 6401 | chip->tag_protocol = DSA_TAG_PROTO_DSA; |
| 6402 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 6403 | mv88e6xxx_phy_init(chip); |
| 6404 | |
Andrew Lunn | 00baabe | 2018-05-19 22:31:35 +0200 | [diff] [blame] | 6405 | if (chip->info->ops->get_eeprom) { |
| 6406 | if (np) |
| 6407 | of_property_read_u32(np, "eeprom-length", |
| 6408 | &chip->eeprom_len); |
| 6409 | else |
| 6410 | chip->eeprom_len = pdata->eeprom_len; |
| 6411 | } |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 6412 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6413 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6414 | err = mv88e6xxx_switch_reset(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6415 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 6416 | if (err) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6417 | goto out; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 6418 | |
Andrew Lunn | a27415d | 2019-05-01 00:10:50 +0200 | [diff] [blame] | 6419 | if (np) { |
| 6420 | chip->irq = of_irq_get(np, 0); |
| 6421 | if (chip->irq == -EPROBE_DEFER) { |
| 6422 | err = chip->irq; |
| 6423 | goto out; |
| 6424 | } |
Andrew Lunn | 83c0afa | 2016-06-04 21:17:07 +0200 | [diff] [blame] | 6425 | } |
| 6426 | |
Andrew Lunn | a27415d | 2019-05-01 00:10:50 +0200 | [diff] [blame] | 6427 | if (pdata) |
| 6428 | chip->irq = pdata->irq; |
| 6429 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6430 | /* Has to be performed before the MDIO bus is created, because |
Uwe Kleine-König | a708767 | 2018-03-20 10:44:41 +0100 | [diff] [blame] | 6431 | * the PHYs will link their interrupts to these interrupt |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6432 | * controllers |
| 6433 | */ |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6434 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6435 | if (chip->irq > 0) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6436 | err = mv88e6xxx_g1_irq_setup(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6437 | else |
| 6438 | err = mv88e6xxx_irq_poll_setup(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6439 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6440 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6441 | if (err) |
| 6442 | goto out; |
| 6443 | |
| 6444 | if (chip->info->g2_irqs > 0) { |
| 6445 | err = mv88e6xxx_g2_irq_setup(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6446 | if (err) |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6447 | goto out_g1_irq; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6448 | } |
| 6449 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6450 | err = mv88e6xxx_g1_atu_prob_irq_setup(chip); |
| 6451 | if (err) |
| 6452 | goto out_g2_irq; |
| 6453 | |
| 6454 | err = mv88e6xxx_g1_vtu_prob_irq_setup(chip); |
| 6455 | if (err) |
| 6456 | goto out_g1_atu_prob_irq; |
| 6457 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 6458 | err = mv88e6xxx_mdios_register(chip, np); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6459 | if (err) |
Andrew Lunn | 62eb116 | 2018-01-14 02:32:45 +0100 | [diff] [blame] | 6460 | goto out_g1_vtu_prob_irq; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6461 | |
Florian Fainelli | 55ed0ce | 2017-01-26 10:45:51 -0800 | [diff] [blame] | 6462 | err = mv88e6xxx_register_switch(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6463 | if (err) |
| 6464 | goto out_mdio; |
| 6465 | |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6466 | return 0; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6467 | |
| 6468 | out_mdio: |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 6469 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | 62eb116 | 2018-01-14 02:32:45 +0100 | [diff] [blame] | 6470 | out_g1_vtu_prob_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6471 | mv88e6xxx_g1_vtu_prob_irq_free(chip); |
Andrew Lunn | 0977644 | 2018-01-14 02:32:44 +0100 | [diff] [blame] | 6472 | out_g1_atu_prob_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6473 | mv88e6xxx_g1_atu_prob_irq_free(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6474 | out_g2_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6475 | if (chip->info->g2_irqs > 0) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6476 | mv88e6xxx_g2_irq_free(chip); |
| 6477 | out_g1_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6478 | if (chip->irq > 0) |
Andrew Lunn | 46712644 | 2016-11-20 20:14:15 +0100 | [diff] [blame] | 6479 | mv88e6xxx_g1_irq_free(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6480 | else |
| 6481 | mv88e6xxx_irq_poll_free(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6482 | out: |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6483 | if (pdata) |
| 6484 | dev_put(pdata->netdev); |
| 6485 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6486 | return err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6487 | } |
| 6488 | |
| 6489 | static void mv88e6xxx_remove(struct mdio_device *mdiodev) |
| 6490 | { |
| 6491 | struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev); |
Vladimir Oltean | 0650bf5 | 2021-09-17 16:34:33 +0300 | [diff] [blame] | 6492 | struct mv88e6xxx_chip *chip; |
| 6493 | |
| 6494 | if (!ds) |
| 6495 | return; |
| 6496 | |
| 6497 | chip = ds->priv; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6498 | |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 6499 | if (chip->info->ptp_support) { |
| 6500 | mv88e6xxx_hwtstamp_free(chip); |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 6501 | mv88e6xxx_ptp_free(chip); |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 6502 | } |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 6503 | |
Andrew Lunn | 930188c | 2016-08-22 16:01:03 +0200 | [diff] [blame] | 6504 | mv88e6xxx_phy_destroy(chip); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6505 | mv88e6xxx_unregister_switch(chip); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 6506 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6507 | |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 6508 | mv88e6xxx_g1_vtu_prob_irq_free(chip); |
| 6509 | mv88e6xxx_g1_atu_prob_irq_free(chip); |
| 6510 | |
| 6511 | if (chip->info->g2_irqs > 0) |
| 6512 | mv88e6xxx_g2_irq_free(chip); |
| 6513 | |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 6514 | if (chip->irq > 0) |
Andrew Lunn | 46712644 | 2016-11-20 20:14:15 +0100 | [diff] [blame] | 6515 | mv88e6xxx_g1_irq_free(chip); |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 6516 | else |
| 6517 | mv88e6xxx_irq_poll_free(chip); |
Vladimir Oltean | 0650bf5 | 2021-09-17 16:34:33 +0300 | [diff] [blame] | 6518 | |
| 6519 | dev_set_drvdata(&mdiodev->dev, NULL); |
| 6520 | } |
| 6521 | |
| 6522 | static void mv88e6xxx_shutdown(struct mdio_device *mdiodev) |
| 6523 | { |
| 6524 | struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev); |
| 6525 | |
| 6526 | if (!ds) |
| 6527 | return; |
| 6528 | |
| 6529 | dsa_switch_shutdown(ds); |
| 6530 | |
| 6531 | dev_set_drvdata(&mdiodev->dev, NULL); |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6532 | } |
| 6533 | |
| 6534 | static const struct of_device_id mv88e6xxx_of_match[] = { |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 6535 | { |
| 6536 | .compatible = "marvell,mv88e6085", |
| 6537 | .data = &mv88e6xxx_table[MV88E6085], |
| 6538 | }, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 6539 | { |
| 6540 | .compatible = "marvell,mv88e6190", |
| 6541 | .data = &mv88e6xxx_table[MV88E6190], |
| 6542 | }, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 6543 | { |
| 6544 | .compatible = "marvell,mv88e6250", |
| 6545 | .data = &mv88e6xxx_table[MV88E6250], |
| 6546 | }, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6547 | { /* sentinel */ }, |
| 6548 | }; |
| 6549 | |
| 6550 | MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match); |
| 6551 | |
| 6552 | static struct mdio_driver mv88e6xxx_driver = { |
| 6553 | .probe = mv88e6xxx_probe, |
| 6554 | .remove = mv88e6xxx_remove, |
Vladimir Oltean | 0650bf5 | 2021-09-17 16:34:33 +0300 | [diff] [blame] | 6555 | .shutdown = mv88e6xxx_shutdown, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6556 | .mdiodrv.driver = { |
| 6557 | .name = "mv88e6085", |
| 6558 | .of_match_table = mv88e6xxx_of_match, |
Miquel Raynal | bcd3d9d | 2019-02-05 12:07:28 +0100 | [diff] [blame] | 6559 | .pm = &mv88e6xxx_pm_ops, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6560 | }, |
| 6561 | }; |
| 6562 | |
Andrew Lunn | 7324d50 | 2019-04-27 19:19:10 +0200 | [diff] [blame] | 6563 | mdio_module_driver(mv88e6xxx_driver); |
Ben Hutchings | 3d825ed | 2011-11-25 14:37:16 +0000 | [diff] [blame] | 6564 | |
| 6565 | MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); |
| 6566 | MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips"); |
| 6567 | MODULE_LICENSE("GPL"); |