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 | { |
| 643 | if (port == 0 || port == 9 || port == 10) { |
| 644 | phylink_set(mask, 10000baseT_Full); |
| 645 | phylink_set(mask, 10000baseKR_Full); |
| 646 | phylink_set(mask, 10000baseCR_Full); |
| 647 | phylink_set(mask, 10000baseSR_Full); |
| 648 | phylink_set(mask, 10000baseLR_Full); |
| 649 | phylink_set(mask, 10000baseLRM_Full); |
| 650 | phylink_set(mask, 10000baseER_Full); |
| 651 | phylink_set(mask, 5000baseT_Full); |
| 652 | phylink_set(mask, 2500baseX_Full); |
| 653 | phylink_set(mask, 2500baseT_Full); |
| 654 | } |
| 655 | |
| 656 | phylink_set(mask, 1000baseT_Full); |
| 657 | phylink_set(mask, 1000baseX_Full); |
| 658 | |
| 659 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 660 | } |
| 661 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 662 | static void mv88e6xxx_validate(struct dsa_switch *ds, int port, |
| 663 | unsigned long *supported, |
| 664 | struct phylink_link_state *state) |
| 665 | { |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 666 | __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; |
| 667 | struct mv88e6xxx_chip *chip = ds->priv; |
| 668 | |
| 669 | /* Allow all the expected bits */ |
| 670 | phylink_set(mask, Autoneg); |
| 671 | phylink_set(mask, Pause); |
| 672 | phylink_set_port_modes(mask); |
| 673 | |
| 674 | if (chip->info->ops->phylink_validate) |
| 675 | chip->info->ops->phylink_validate(chip, port, mask, state); |
| 676 | |
| 677 | bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); |
| 678 | bitmap_and(state->advertising, state->advertising, mask, |
| 679 | __ETHTOOL_LINK_MODE_MASK_NBITS); |
| 680 | |
| 681 | /* We can only operate at 2500BaseX or 1000BaseX. If requested |
| 682 | * to advertise both, only report advertising at 2500BaseX. |
| 683 | */ |
| 684 | phylink_helper_basex_speed(state); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 685 | } |
| 686 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 687 | static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port, |
| 688 | unsigned int mode, |
| 689 | const struct phylink_link_state *state) |
| 690 | { |
| 691 | struct mv88e6xxx_chip *chip = ds->priv; |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 692 | struct mv88e6xxx_port *p; |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 693 | int err; |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 694 | |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 695 | p = &chip->ports[port]; |
| 696 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 697 | /* FIXME: is this the correct test? If we're in fixed mode on an |
| 698 | * internal port, why should we process this any different from |
| 699 | * PHY mode? On the other hand, the port may be automedia between |
| 700 | * an internal PHY and the serdes... |
| 701 | */ |
Marek Vasut | d700ec4 | 2018-09-12 00:15:24 +0200 | [diff] [blame] | 702 | if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port)) |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 703 | return; |
| 704 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 705 | mv88e6xxx_reg_lock(chip); |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 706 | /* In inband mode, the link may come up at any time while the link |
| 707 | * is not forced down. Force the link down while we reconfigure the |
| 708 | * interface mode. |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 709 | */ |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 710 | if (mode == MLO_AN_INBAND && p->interface != state->interface && |
| 711 | chip->info->ops->port_set_link) |
| 712 | chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN); |
| 713 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 714 | err = mv88e6xxx_port_config_interface(chip, port, state->interface); |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 715 | if (err && err != -EOPNOTSUPP) |
| 716 | goto err_unlock; |
| 717 | |
| 718 | err = mv88e6xxx_serdes_pcs_config(chip, port, mode, state->interface, |
| 719 | state->advertising); |
| 720 | /* FIXME: we should restart negotiation if something changed - which |
| 721 | * is something we get if we convert to using phylinks PCS operations. |
| 722 | */ |
| 723 | if (err > 0) |
| 724 | err = 0; |
| 725 | |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 726 | /* Undo the forced down state above after completing configuration |
| 727 | * irrespective of its state on entry, which allows the link to come up. |
| 728 | */ |
| 729 | if (mode == MLO_AN_INBAND && p->interface != state->interface && |
| 730 | chip->info->ops->port_set_link) |
| 731 | chip->info->ops->port_set_link(chip, port, LINK_UNFORCED); |
| 732 | |
| 733 | p->interface = state->interface; |
| 734 | |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 735 | err_unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 736 | mv88e6xxx_reg_unlock(chip); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 737 | |
| 738 | if (err && err != -EOPNOTSUPP) |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 739 | 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] | 740 | } |
| 741 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 742 | static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port, |
| 743 | unsigned int mode, |
| 744 | phy_interface_t interface) |
| 745 | { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 746 | struct mv88e6xxx_chip *chip = ds->priv; |
| 747 | const struct mv88e6xxx_ops *ops; |
| 748 | int err = 0; |
| 749 | |
| 750 | ops = chip->info->ops; |
| 751 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 752 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 34b5e6a | 2020-04-14 02:34:38 +0200 | [diff] [blame] | 753 | if ((!mv88e6xxx_port_ppu_updates(chip, port) || |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 754 | mode == MLO_AN_FIXED) && ops->port_sync_link) |
| 755 | err = ops->port_sync_link(chip, port, mode, false); |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 756 | mv88e6xxx_reg_unlock(chip); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 757 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 758 | if (err) |
| 759 | dev_err(chip->dev, |
| 760 | "p%d: failed to force MAC link down\n", port); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 761 | } |
| 762 | |
| 763 | static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port, |
| 764 | unsigned int mode, phy_interface_t interface, |
Russell King | 5b502a7 | 2020-02-26 10:23:46 +0000 | [diff] [blame] | 765 | struct phy_device *phydev, |
| 766 | int speed, int duplex, |
| 767 | bool tx_pause, bool rx_pause) |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 768 | { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 769 | struct mv88e6xxx_chip *chip = ds->priv; |
| 770 | const struct mv88e6xxx_ops *ops; |
| 771 | int err = 0; |
| 772 | |
| 773 | ops = chip->info->ops; |
| 774 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 775 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 34b5e6a | 2020-04-14 02:34:38 +0200 | [diff] [blame] | 776 | if (!mv88e6xxx_port_ppu_updates(chip, port) || mode == MLO_AN_FIXED) { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 777 | /* FIXME: for an automedia port, should we force the link |
| 778 | * down here - what if the link comes up due to "other" media |
| 779 | * while we're bringing the port up, how is the exclusivity |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 780 | * handled in the Marvell hardware? E.g. port 2 on 88E6390 |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 781 | * shared between internal PHY and Serdes. |
| 782 | */ |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 783 | err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed, |
| 784 | duplex); |
| 785 | if (err) |
| 786 | goto error; |
| 787 | |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 788 | if (ops->port_set_speed_duplex) { |
| 789 | err = ops->port_set_speed_duplex(chip, port, |
| 790 | speed, duplex); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 791 | if (err && err != -EOPNOTSUPP) |
| 792 | goto error; |
| 793 | } |
| 794 | |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 795 | if (ops->port_sync_link) |
| 796 | err = ops->port_sync_link(chip, port, mode, true); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 797 | } |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 798 | error: |
| 799 | mv88e6xxx_reg_unlock(chip); |
| 800 | |
| 801 | if (err && err != -EOPNOTSUPP) |
| 802 | dev_err(ds->dev, |
| 803 | "p%d: failed to configure MAC link up\n", port); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 804 | } |
| 805 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 806 | static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 807 | { |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 808 | if (!chip->info->ops->stats_snapshot) |
| 809 | return -EOPNOTSUPP; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 810 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 811 | return chip->info->ops->stats_snapshot(chip, port); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 812 | } |
| 813 | |
Andrew Lunn | e413e7e | 2015-04-02 04:06:38 +0200 | [diff] [blame] | 814 | static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = { |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 815 | { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, }, |
| 816 | { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, }, |
| 817 | { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, }, |
| 818 | { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, }, |
| 819 | { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, }, |
| 820 | { "in_pause", 4, 0x16, STATS_TYPE_BANK0, }, |
| 821 | { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, }, |
| 822 | { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, }, |
| 823 | { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, }, |
| 824 | { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, }, |
| 825 | { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, }, |
| 826 | { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, }, |
| 827 | { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, }, |
| 828 | { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, }, |
| 829 | { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, }, |
| 830 | { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, }, |
| 831 | { "out_pause", 4, 0x15, STATS_TYPE_BANK0, }, |
| 832 | { "excessive", 4, 0x11, STATS_TYPE_BANK0, }, |
| 833 | { "collisions", 4, 0x1e, STATS_TYPE_BANK0, }, |
| 834 | { "deferred", 4, 0x05, STATS_TYPE_BANK0, }, |
| 835 | { "single", 4, 0x14, STATS_TYPE_BANK0, }, |
| 836 | { "multiple", 4, 0x17, STATS_TYPE_BANK0, }, |
| 837 | { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, }, |
| 838 | { "late", 4, 0x1f, STATS_TYPE_BANK0, }, |
| 839 | { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, }, |
| 840 | { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, }, |
| 841 | { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, }, |
| 842 | { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, }, |
| 843 | { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, }, |
| 844 | { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, }, |
| 845 | { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, }, |
| 846 | { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, }, |
| 847 | { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, }, |
| 848 | { "in_discards", 4, 0x00, STATS_TYPE_BANK1, }, |
| 849 | { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, }, |
| 850 | { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, }, |
| 851 | { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, }, |
| 852 | { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, }, |
| 853 | { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, }, |
| 854 | { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, }, |
| 855 | { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, }, |
| 856 | { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, }, |
| 857 | { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, }, |
| 858 | { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, }, |
| 859 | { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, }, |
| 860 | { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, }, |
| 861 | { "in_management", 4, 0x0f, STATS_TYPE_BANK1, }, |
| 862 | { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, }, |
| 863 | { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, }, |
| 864 | { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, }, |
| 865 | { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, }, |
| 866 | { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, }, |
| 867 | { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, }, |
| 868 | { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, }, |
| 869 | { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, }, |
| 870 | { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, }, |
| 871 | { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, }, |
| 872 | { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, }, |
| 873 | { "out_management", 4, 0x1f, STATS_TYPE_BANK1, }, |
Andrew Lunn | e413e7e | 2015-04-02 04:06:38 +0200 | [diff] [blame] | 874 | }; |
| 875 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 876 | static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip, |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 877 | struct mv88e6xxx_hw_stat *s, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 878 | int port, u16 bank1_select, |
| 879 | u16 histogram) |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 880 | { |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 881 | u32 low; |
| 882 | u32 high = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 883 | u16 reg = 0; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 884 | int err; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 885 | u64 value; |
| 886 | |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 887 | switch (s->type) { |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 888 | case STATS_TYPE_PORT: |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 889 | err = mv88e6xxx_port_read(chip, port, s->reg, ®); |
| 890 | if (err) |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 891 | return U64_MAX; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 892 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 893 | low = reg; |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 894 | if (s->size == 4) { |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 895 | err = mv88e6xxx_port_read(chip, port, s->reg + 1, ®); |
| 896 | if (err) |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 897 | return U64_MAX; |
Rasmus Villemoes | 84b3fd1 | 2019-05-29 07:02:11 +0000 | [diff] [blame] | 898 | low |= ((u32)reg) << 16; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 899 | } |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 900 | break; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 901 | case STATS_TYPE_BANK1: |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 902 | reg = bank1_select; |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 903 | fallthrough; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 904 | case STATS_TYPE_BANK0: |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 905 | reg |= s->reg | histogram; |
Andrew Lunn | 7f9ef3a | 2016-11-21 23:27:05 +0100 | [diff] [blame] | 906 | mv88e6xxx_g1_stats_read(chip, reg, &low); |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 907 | if (s->size == 8) |
Andrew Lunn | 7f9ef3a | 2016-11-21 23:27:05 +0100 | [diff] [blame] | 908 | mv88e6xxx_g1_stats_read(chip, reg + 1, &high); |
Gustavo A. R. Silva | 9fc3e4d | 2017-05-11 22:11:29 -0500 | [diff] [blame] | 909 | break; |
| 910 | default: |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 911 | return U64_MAX; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 912 | } |
Andrew Lunn | 6e46e2d | 2019-02-28 18:14:03 +0100 | [diff] [blame] | 913 | value = (((u64)high) << 32) | low; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 914 | return value; |
| 915 | } |
| 916 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 917 | static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 918 | uint8_t *data, int types) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 919 | { |
| 920 | struct mv88e6xxx_hw_stat *stat; |
| 921 | int i, j; |
| 922 | |
| 923 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 924 | stat = &mv88e6xxx_hw_stats[i]; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 925 | if (stat->type & types) { |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 926 | memcpy(data + j * ETH_GSTRING_LEN, stat->string, |
| 927 | ETH_GSTRING_LEN); |
| 928 | j++; |
| 929 | } |
| 930 | } |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 931 | |
| 932 | return j; |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 933 | } |
| 934 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 935 | static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 936 | uint8_t *data) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 937 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 938 | return mv88e6xxx_stats_get_strings(chip, data, |
| 939 | STATS_TYPE_BANK0 | STATS_TYPE_PORT); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 940 | } |
| 941 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 942 | static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 943 | uint8_t *data) |
| 944 | { |
| 945 | return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0); |
| 946 | } |
| 947 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 948 | static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 949 | uint8_t *data) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 950 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 951 | return mv88e6xxx_stats_get_strings(chip, data, |
| 952 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 953 | } |
| 954 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 955 | static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = { |
| 956 | "atu_member_violation", |
| 957 | "atu_miss_violation", |
| 958 | "atu_full_violation", |
| 959 | "vtu_member_violation", |
| 960 | "vtu_miss_violation", |
| 961 | }; |
| 962 | |
| 963 | static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data) |
| 964 | { |
| 965 | unsigned int i; |
| 966 | |
| 967 | for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++) |
| 968 | strlcpy(data + i * ETH_GSTRING_LEN, |
| 969 | mv88e6xxx_atu_vtu_stats_strings[i], |
| 970 | ETH_GSTRING_LEN); |
| 971 | } |
| 972 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 973 | static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port, |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 974 | u32 stringset, uint8_t *data) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 975 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 976 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 977 | int count = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 978 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 979 | if (stringset != ETH_SS_STATS) |
| 980 | return; |
| 981 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 982 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 983 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 984 | if (chip->info->ops->stats_get_strings) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 985 | count = chip->info->ops->stats_get_strings(chip, data); |
| 986 | |
| 987 | if (chip->info->ops->serdes_get_strings) { |
| 988 | data += count * ETH_GSTRING_LEN; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 989 | count = chip->info->ops->serdes_get_strings(chip, port, data); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 990 | } |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 991 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 992 | data += count * ETH_GSTRING_LEN; |
| 993 | mv88e6xxx_atu_vtu_get_strings(data); |
| 994 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 995 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 996 | } |
| 997 | |
| 998 | static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip, |
| 999 | int types) |
| 1000 | { |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 1001 | struct mv88e6xxx_hw_stat *stat; |
| 1002 | int i, j; |
| 1003 | |
| 1004 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 1005 | stat = &mv88e6xxx_hw_stats[i]; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1006 | if (stat->type & types) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 1007 | j++; |
| 1008 | } |
| 1009 | return j; |
| 1010 | } |
| 1011 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1012 | static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 1013 | { |
| 1014 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 | |
| 1015 | STATS_TYPE_PORT); |
| 1016 | } |
| 1017 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 1018 | static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 1019 | { |
| 1020 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0); |
| 1021 | } |
| 1022 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1023 | static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 1024 | { |
| 1025 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 | |
| 1026 | STATS_TYPE_BANK1); |
| 1027 | } |
| 1028 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 1029 | 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] | 1030 | { |
| 1031 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1032 | int serdes_count = 0; |
| 1033 | int count = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1034 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 1035 | if (sset != ETH_SS_STATS) |
| 1036 | return 0; |
| 1037 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1038 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1039 | if (chip->info->ops->stats_get_sset_count) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1040 | count = chip->info->ops->stats_get_sset_count(chip); |
| 1041 | if (count < 0) |
| 1042 | goto out; |
| 1043 | |
| 1044 | if (chip->info->ops->serdes_get_sset_count) |
| 1045 | serdes_count = chip->info->ops->serdes_get_sset_count(chip, |
| 1046 | port); |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1047 | if (serdes_count < 0) { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1048 | count = serdes_count; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1049 | goto out; |
| 1050 | } |
| 1051 | count += serdes_count; |
| 1052 | count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); |
| 1053 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1054 | out: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1055 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1056 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1057 | return count; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1058 | } |
| 1059 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1060 | static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1061 | uint64_t *data, int types, |
| 1062 | u16 bank1_select, u16 histogram) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1063 | { |
| 1064 | struct mv88e6xxx_hw_stat *stat; |
| 1065 | int i, j; |
| 1066 | |
| 1067 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 1068 | stat = &mv88e6xxx_hw_stats[i]; |
| 1069 | if (stat->type & types) { |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1070 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1071 | data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port, |
| 1072 | bank1_select, |
| 1073 | histogram); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1074 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 1075 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1076 | j++; |
| 1077 | } |
| 1078 | } |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1079 | return j; |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1080 | } |
| 1081 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1082 | static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1083 | uint64_t *data) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1084 | { |
| 1085 | return mv88e6xxx_stats_get_stats(chip, port, data, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1086 | STATS_TYPE_BANK0 | STATS_TYPE_PORT, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1087 | 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1088 | } |
| 1089 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 1090 | static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1091 | uint64_t *data) |
| 1092 | { |
| 1093 | return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0, |
| 1094 | 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
| 1095 | } |
| 1096 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1097 | static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1098 | uint64_t *data) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1099 | { |
| 1100 | return mv88e6xxx_stats_get_stats(chip, port, data, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1101 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1102 | MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9, |
| 1103 | MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1104 | } |
| 1105 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1106 | static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1107 | uint64_t *data) |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1108 | { |
| 1109 | return mv88e6xxx_stats_get_stats(chip, port, data, |
| 1110 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1111 | MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10, |
| 1112 | 0); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1113 | } |
| 1114 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1115 | static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1116 | uint64_t *data) |
| 1117 | { |
| 1118 | *data++ = chip->ports[port].atu_member_violation; |
| 1119 | *data++ = chip->ports[port].atu_miss_violation; |
| 1120 | *data++ = chip->ports[port].atu_full_violation; |
| 1121 | *data++ = chip->ports[port].vtu_member_violation; |
| 1122 | *data++ = chip->ports[port].vtu_miss_violation; |
| 1123 | } |
| 1124 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1125 | static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1126 | uint64_t *data) |
| 1127 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1128 | int count = 0; |
| 1129 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1130 | if (chip->info->ops->stats_get_stats) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1131 | count = chip->info->ops->stats_get_stats(chip, port, data); |
| 1132 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1133 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1134 | if (chip->info->ops->serdes_get_stats) { |
| 1135 | data += count; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1136 | count = chip->info->ops->serdes_get_stats(chip, port, data); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1137 | } |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1138 | data += count; |
| 1139 | mv88e6xxx_atu_vtu_get_stats(chip, port, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1140 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1141 | } |
| 1142 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1143 | static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port, |
| 1144 | uint64_t *data) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1145 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1146 | struct mv88e6xxx_chip *chip = ds->priv; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1147 | int ret; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1148 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1149 | mv88e6xxx_reg_lock(chip); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1150 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 1151 | ret = mv88e6xxx_stats_snapshot(chip, port); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1152 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 1153 | |
| 1154 | if (ret < 0) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1155 | return; |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1156 | |
| 1157 | mv88e6xxx_get_stats(chip, port, data); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1158 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1159 | } |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 1160 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1161 | static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port) |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1162 | { |
Andrew Lunn | 0d30bbd | 2020-02-16 18:54:13 +0100 | [diff] [blame] | 1163 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1164 | int len; |
| 1165 | |
| 1166 | len = 32 * sizeof(u16); |
| 1167 | if (chip->info->ops->serdes_get_regs_len) |
| 1168 | len += chip->info->ops->serdes_get_regs_len(chip, port); |
| 1169 | |
| 1170 | return len; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1171 | } |
| 1172 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1173 | static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port, |
| 1174 | struct ethtool_regs *regs, void *_p) |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1175 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1176 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1177 | int err; |
| 1178 | u16 reg; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1179 | u16 *p = _p; |
| 1180 | int i; |
| 1181 | |
Vivien Didelot | a5f3932 | 2018-12-17 16:05:21 -0500 | [diff] [blame] | 1182 | regs->version = chip->info->prod_num; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1183 | |
| 1184 | memset(p, 0xff, 32 * sizeof(u16)); |
| 1185 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1186 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 2306251 | 2016-05-09 13:22:45 -0400 | [diff] [blame] | 1187 | |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1188 | for (i = 0; i < 32; i++) { |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1189 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1190 | err = mv88e6xxx_port_read(chip, port, i, ®); |
| 1191 | if (!err) |
| 1192 | p[i] = reg; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1193 | } |
Vivien Didelot | 2306251 | 2016-05-09 13:22:45 -0400 | [diff] [blame] | 1194 | |
Andrew Lunn | 0d30bbd | 2020-02-16 18:54:13 +0100 | [diff] [blame] | 1195 | if (chip->info->ops->serdes_get_regs) |
| 1196 | chip->info->ops->serdes_get_regs(chip, port, &p[i]); |
| 1197 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1198 | mv88e6xxx_reg_unlock(chip); |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1199 | } |
| 1200 | |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 1201 | static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port, |
| 1202 | struct ethtool_eee *e) |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1203 | { |
Vivien Didelot | 5480db6 | 2017-08-01 16:32:40 -0400 | [diff] [blame] | 1204 | /* Nothing to do on the port's MAC */ |
| 1205 | return 0; |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1206 | } |
| 1207 | |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 1208 | static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port, |
| 1209 | struct ethtool_eee *e) |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1210 | { |
Vivien Didelot | 5480db6 | 2017-08-01 16:32:40 -0400 | [diff] [blame] | 1211 | /* Nothing to do on the port's MAC */ |
| 1212 | return 0; |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1213 | } |
| 1214 | |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1215 | /* 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] | 1216 | 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] | 1217 | { |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1218 | struct dsa_switch *ds = chip->ds; |
| 1219 | struct dsa_switch_tree *dst = ds->dst; |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1220 | struct net_device *br; |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1221 | struct dsa_port *dp; |
| 1222 | bool found = false; |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1223 | u16 pvlan; |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1224 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1225 | /* dev is a physical switch */ |
| 1226 | if (dev <= dst->last_switch) { |
| 1227 | list_for_each_entry(dp, &dst->ports, list) { |
| 1228 | if (dp->ds->index == dev && dp->index == port) { |
| 1229 | /* dp might be a DSA link or a user port, so it |
| 1230 | * might or might not have a bridge_dev |
| 1231 | * pointer. Use the "found" variable for both |
| 1232 | * cases. |
| 1233 | */ |
| 1234 | br = dp->bridge_dev; |
| 1235 | found = true; |
| 1236 | break; |
| 1237 | } |
| 1238 | } |
| 1239 | /* dev is a virtual bridge */ |
| 1240 | } else { |
| 1241 | list_for_each_entry(dp, &dst->ports, list) { |
| 1242 | if (dp->bridge_num < 0) |
| 1243 | continue; |
| 1244 | |
| 1245 | if (dp->bridge_num + 1 + dst->last_switch != dev) |
| 1246 | continue; |
| 1247 | |
| 1248 | br = dp->bridge_dev; |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1249 | found = true; |
| 1250 | break; |
| 1251 | } |
| 1252 | } |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1253 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1254 | /* Prevent frames from unknown switch or virtual bridge */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1255 | if (!found) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1256 | return 0; |
| 1257 | |
| 1258 | /* Frames from DSA links and CPU ports can egress any local port */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1259 | 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] | 1260 | return mv88e6xxx_port_mask(chip); |
| 1261 | |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1262 | pvlan = 0; |
| 1263 | |
| 1264 | /* Frames from user ports can egress any local DSA links and CPU ports, |
| 1265 | * as well as any local member of their bridge group. |
| 1266 | */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1267 | list_for_each_entry(dp, &dst->ports, list) |
| 1268 | if (dp->ds == ds && |
| 1269 | (dp->type == DSA_PORT_TYPE_CPU || |
| 1270 | dp->type == DSA_PORT_TYPE_DSA || |
| 1271 | (br && dp->bridge_dev == br))) |
| 1272 | pvlan |= BIT(dp->index); |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1273 | |
| 1274 | return pvlan; |
| 1275 | } |
| 1276 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 1277 | static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1278 | { |
| 1279 | u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port); |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1280 | |
| 1281 | /* prevent frames from going back out of the port they came in on */ |
| 1282 | output_ports &= ~BIT(port); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1283 | |
Vivien Didelot | 5a7921f | 2016-11-04 03:23:28 +0100 | [diff] [blame] | 1284 | return mv88e6xxx_port_set_vlan_map(chip, port, output_ports); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1285 | } |
| 1286 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1287 | static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port, |
| 1288 | u8 state) |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1289 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1290 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 553eb54 | 2016-05-13 20:38:23 -0400 | [diff] [blame] | 1291 | int err; |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1292 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1293 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | f894c29 | 2017-06-08 18:34:10 -0400 | [diff] [blame] | 1294 | err = mv88e6xxx_port_set_state(chip, port, state); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1295 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 553eb54 | 2016-05-13 20:38:23 -0400 | [diff] [blame] | 1296 | |
| 1297 | if (err) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1298 | dev_err(ds->dev, "p%d: failed to update state\n", port); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1299 | } |
| 1300 | |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 1301 | static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip) |
| 1302 | { |
| 1303 | int err; |
| 1304 | |
| 1305 | if (chip->info->ops->ieee_pri_map) { |
| 1306 | err = chip->info->ops->ieee_pri_map(chip); |
| 1307 | if (err) |
| 1308 | return err; |
| 1309 | } |
| 1310 | |
| 1311 | if (chip->info->ops->ip_pri_map) { |
| 1312 | err = chip->info->ops->ip_pri_map(chip); |
| 1313 | if (err) |
| 1314 | return err; |
| 1315 | } |
| 1316 | |
| 1317 | return 0; |
| 1318 | } |
| 1319 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1320 | static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip) |
| 1321 | { |
Vivien Didelot | c5f5176 | 2019-10-30 22:09:13 -0400 | [diff] [blame] | 1322 | struct dsa_switch *ds = chip->ds; |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1323 | int target, port; |
| 1324 | int err; |
| 1325 | |
| 1326 | if (!chip->info->global2_addr) |
| 1327 | return 0; |
| 1328 | |
| 1329 | /* Initialize the routing port to the 32 possible target devices */ |
| 1330 | for (target = 0; target < 32; target++) { |
Vivien Didelot | c5f5176 | 2019-10-30 22:09:13 -0400 | [diff] [blame] | 1331 | port = dsa_routing_port(ds, target); |
| 1332 | if (port == ds->num_ports) |
| 1333 | port = 0x1f; |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1334 | |
| 1335 | err = mv88e6xxx_g2_device_mapping_write(chip, target, port); |
| 1336 | if (err) |
| 1337 | return err; |
| 1338 | } |
| 1339 | |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 1340 | if (chip->info->ops->set_cascade_port) { |
| 1341 | port = MV88E6XXX_CASCADE_PORT_MULTIPLE; |
| 1342 | err = chip->info->ops->set_cascade_port(chip, port); |
| 1343 | if (err) |
| 1344 | return err; |
| 1345 | } |
| 1346 | |
Vivien Didelot | 23c9891 | 2018-05-09 11:38:50 -0400 | [diff] [blame] | 1347 | err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index); |
| 1348 | if (err) |
| 1349 | return err; |
| 1350 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1351 | return 0; |
| 1352 | } |
| 1353 | |
Vivien Didelot | b28f872 | 2018-04-26 21:56:44 -0400 | [diff] [blame] | 1354 | static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip) |
| 1355 | { |
| 1356 | /* Clear all trunk masks and mapping */ |
| 1357 | if (chip->info->global2_addr) |
| 1358 | return mv88e6xxx_g2_trunk_clear(chip); |
| 1359 | |
| 1360 | return 0; |
| 1361 | } |
| 1362 | |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 1363 | static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip) |
| 1364 | { |
| 1365 | if (chip->info->ops->rmu_disable) |
| 1366 | return chip->info->ops->rmu_disable(chip); |
| 1367 | |
| 1368 | return 0; |
| 1369 | } |
| 1370 | |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 1371 | static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip) |
| 1372 | { |
| 1373 | if (chip->info->ops->pot_clear) |
| 1374 | return chip->info->ops->pot_clear(chip); |
| 1375 | |
| 1376 | return 0; |
| 1377 | } |
| 1378 | |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 1379 | static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip) |
| 1380 | { |
| 1381 | if (chip->info->ops->mgmt_rsvd2cpu) |
| 1382 | return chip->info->ops->mgmt_rsvd2cpu(chip); |
| 1383 | |
| 1384 | return 0; |
| 1385 | } |
| 1386 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 1387 | static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip) |
| 1388 | { |
Vivien Didelot | c3a7d4a | 2017-03-11 16:12:51 -0500 | [diff] [blame] | 1389 | int err; |
| 1390 | |
Vivien Didelot | daefc94 | 2017-03-11 16:12:54 -0500 | [diff] [blame] | 1391 | err = mv88e6xxx_g1_atu_flush(chip, 0, true); |
| 1392 | if (err) |
| 1393 | return err; |
| 1394 | |
Rasmus Villemoes | 49506a9 | 2020-12-10 12:06:44 +0100 | [diff] [blame] | 1395 | /* The chips that have a "learn2all" bit in Global1, ATU |
| 1396 | * Control are precisely those whose port registers have a |
| 1397 | * Message Port bit in Port Control 1 and hence implement |
| 1398 | * ->port_setup_message_port. |
| 1399 | */ |
| 1400 | if (chip->info->ops->port_setup_message_port) { |
| 1401 | err = mv88e6xxx_g1_atu_set_learn2all(chip, true); |
| 1402 | if (err) |
| 1403 | return err; |
| 1404 | } |
Vivien Didelot | c3a7d4a | 2017-03-11 16:12:51 -0500 | [diff] [blame] | 1405 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 1406 | return mv88e6xxx_g1_atu_set_age_time(chip, 300000); |
| 1407 | } |
| 1408 | |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 1409 | static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip) |
| 1410 | { |
| 1411 | int port; |
| 1412 | int err; |
| 1413 | |
| 1414 | if (!chip->info->ops->irl_init_all) |
| 1415 | return 0; |
| 1416 | |
| 1417 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 1418 | /* Disable ingress rate limiting by resetting all per port |
| 1419 | * ingress rate limit resources to their initial state. |
| 1420 | */ |
| 1421 | err = chip->info->ops->irl_init_all(chip, port); |
| 1422 | if (err) |
| 1423 | return err; |
| 1424 | } |
| 1425 | |
| 1426 | return 0; |
| 1427 | } |
| 1428 | |
Vivien Didelot | 04a69a1 | 2017-10-13 14:18:05 -0400 | [diff] [blame] | 1429 | static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip) |
| 1430 | { |
| 1431 | if (chip->info->ops->set_switch_mac) { |
| 1432 | u8 addr[ETH_ALEN]; |
| 1433 | |
| 1434 | eth_random_addr(addr); |
| 1435 | |
| 1436 | return chip->info->ops->set_switch_mac(chip, addr); |
| 1437 | } |
| 1438 | |
| 1439 | return 0; |
| 1440 | } |
| 1441 | |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1442 | static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port) |
| 1443 | { |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1444 | struct dsa_switch_tree *dst = chip->ds->dst; |
| 1445 | struct dsa_switch *ds; |
| 1446 | struct dsa_port *dp; |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1447 | u16 pvlan = 0; |
| 1448 | |
| 1449 | if (!mv88e6xxx_has_pvt(chip)) |
Vivien Didelot | d14939b | 2019-10-21 16:51:25 -0400 | [diff] [blame] | 1450 | return 0; |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1451 | |
| 1452 | /* Skip the local source device, which uses in-chip port VLAN */ |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1453 | if (dev != chip->ds->index) { |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 1454 | pvlan = mv88e6xxx_port_vlan(chip, dev, port); |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1455 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1456 | ds = dsa_switch_find(dst->index, dev); |
| 1457 | dp = ds ? dsa_to_port(ds, port) : NULL; |
| 1458 | if (dp && dp->lag_dev) { |
| 1459 | /* As the PVT is used to limit flooding of |
| 1460 | * FORWARD frames, which use the LAG ID as the |
| 1461 | * source port, we must translate dev/port to |
| 1462 | * the special "LAG device" in the PVT, using |
| 1463 | * the LAG ID as the port number. |
| 1464 | */ |
Tobias Waldekranz | 78e70db | 2021-04-21 14:04:52 +0200 | [diff] [blame] | 1465 | dev = MV88E6XXX_G2_PVT_ADDR_DEV_TRUNK; |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1466 | port = dsa_lag_id(dst, dp->lag_dev); |
| 1467 | } |
| 1468 | } |
| 1469 | |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1470 | return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan); |
| 1471 | } |
| 1472 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1473 | static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip) |
| 1474 | { |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1475 | int dev, port; |
| 1476 | int err; |
| 1477 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1478 | if (!mv88e6xxx_has_pvt(chip)) |
| 1479 | return 0; |
| 1480 | |
| 1481 | /* Clear 5 Bit Port for usage with Marvell Link Street devices: |
| 1482 | * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev. |
| 1483 | */ |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1484 | err = mv88e6xxx_g2_misc_4_bit_port(chip); |
| 1485 | if (err) |
| 1486 | return err; |
| 1487 | |
| 1488 | for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) { |
| 1489 | for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) { |
| 1490 | err = mv88e6xxx_pvt_map(chip, dev, port); |
| 1491 | if (err) |
| 1492 | return err; |
| 1493 | } |
| 1494 | } |
| 1495 | |
| 1496 | return 0; |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1497 | } |
| 1498 | |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1499 | static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port) |
| 1500 | { |
| 1501 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1502 | int err; |
| 1503 | |
Tobias Waldekranz | ffcec3f | 2021-03-18 20:25:34 +0100 | [diff] [blame] | 1504 | if (dsa_to_port(ds, port)->lag_dev) |
| 1505 | /* Hardware is incapable of fast-aging a LAG through a |
| 1506 | * regular ATU move operation. Until we have something |
| 1507 | * more fancy in place this is a no-op. |
| 1508 | */ |
| 1509 | return; |
| 1510 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1511 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 1512 | err = mv88e6xxx_g1_atu_remove(chip, 0, port, false); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1513 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1514 | |
| 1515 | if (err) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1516 | dev_err(ds->dev, "p%d: failed to flush ATU\n", port); |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1517 | } |
| 1518 | |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 1519 | static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip) |
| 1520 | { |
Tobias Waldekranz | e545f86 | 2020-11-10 19:57:20 +0100 | [diff] [blame] | 1521 | if (!mv88e6xxx_max_vid(chip)) |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 1522 | return 0; |
| 1523 | |
| 1524 | return mv88e6xxx_g1_vtu_flush(chip); |
| 1525 | } |
| 1526 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1527 | static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid, |
| 1528 | struct mv88e6xxx_vtu_entry *entry) |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1529 | { |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1530 | int err; |
| 1531 | |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1532 | if (!chip->info->ops->vtu_getnext) |
| 1533 | return -EOPNOTSUPP; |
| 1534 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1535 | entry->vid = vid ? vid - 1 : mv88e6xxx_max_vid(chip); |
| 1536 | entry->valid = false; |
| 1537 | |
| 1538 | err = chip->info->ops->vtu_getnext(chip, entry); |
| 1539 | |
| 1540 | if (entry->vid != vid) |
| 1541 | entry->valid = false; |
| 1542 | |
| 1543 | return err; |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1544 | } |
| 1545 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 1546 | static int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip, |
| 1547 | int (*cb)(struct mv88e6xxx_chip *chip, |
| 1548 | const struct mv88e6xxx_vtu_entry *entry, |
| 1549 | void *priv), |
| 1550 | void *priv) |
| 1551 | { |
| 1552 | struct mv88e6xxx_vtu_entry entry = { |
| 1553 | .vid = mv88e6xxx_max_vid(chip), |
| 1554 | .valid = false, |
| 1555 | }; |
| 1556 | int err; |
| 1557 | |
| 1558 | if (!chip->info->ops->vtu_getnext) |
| 1559 | return -EOPNOTSUPP; |
| 1560 | |
| 1561 | do { |
| 1562 | err = chip->info->ops->vtu_getnext(chip, &entry); |
| 1563 | if (err) |
| 1564 | return err; |
| 1565 | |
| 1566 | if (!entry.valid) |
| 1567 | break; |
| 1568 | |
| 1569 | err = cb(chip, &entry, priv); |
| 1570 | if (err) |
| 1571 | return err; |
| 1572 | } while (entry.vid < mv88e6xxx_max_vid(chip)); |
| 1573 | |
| 1574 | return 0; |
| 1575 | } |
| 1576 | |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 1577 | static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip, |
| 1578 | struct mv88e6xxx_vtu_entry *entry) |
| 1579 | { |
| 1580 | if (!chip->info->ops->vtu_loadpurge) |
| 1581 | return -EOPNOTSUPP; |
| 1582 | |
| 1583 | return chip->info->ops->vtu_loadpurge(chip, entry); |
| 1584 | } |
| 1585 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 1586 | static int mv88e6xxx_fid_map_vlan(struct mv88e6xxx_chip *chip, |
| 1587 | const struct mv88e6xxx_vtu_entry *entry, |
| 1588 | void *_fid_bitmap) |
| 1589 | { |
| 1590 | unsigned long *fid_bitmap = _fid_bitmap; |
| 1591 | |
| 1592 | set_bit(entry->fid, fid_bitmap); |
| 1593 | return 0; |
| 1594 | } |
| 1595 | |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1596 | int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap) |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1597 | { |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1598 | int i, err; |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1599 | u16 fid; |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1600 | |
| 1601 | bitmap_zero(fid_bitmap, MV88E6XXX_N_FID); |
| 1602 | |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1603 | /* Set every FID bit used by the (un)bridged ports */ |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 1604 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1605 | err = mv88e6xxx_port_get_fid(chip, i, &fid); |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1606 | if (err) |
| 1607 | return err; |
| 1608 | |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1609 | set_bit(fid, fid_bitmap); |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1610 | } |
| 1611 | |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1612 | /* Set every FID bit used by the VLAN entries */ |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 1613 | return mv88e6xxx_vtu_walk(chip, mv88e6xxx_fid_map_vlan, fid_bitmap); |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1614 | } |
| 1615 | |
| 1616 | static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid) |
| 1617 | { |
| 1618 | DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID); |
| 1619 | int err; |
| 1620 | |
| 1621 | err = mv88e6xxx_fid_map(chip, fid_bitmap); |
| 1622 | if (err) |
| 1623 | return err; |
| 1624 | |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1625 | /* The reset value 0x000 is used to indicate that multiple address |
| 1626 | * databases are not needed. Return the next positive available. |
| 1627 | */ |
| 1628 | *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1629 | if (unlikely(*fid >= mv88e6xxx_num_databases(chip))) |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1630 | return -ENOSPC; |
| 1631 | |
| 1632 | /* Clear the database */ |
Vivien Didelot | daefc94 | 2017-03-11 16:12:54 -0500 | [diff] [blame] | 1633 | return mv88e6xxx_g1_atu_flush(chip, *fid, true); |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1634 | } |
| 1635 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1636 | 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] | 1637 | u16 vid) |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1638 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1639 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 1640 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1641 | int i, err; |
| 1642 | |
Andrew Lunn | db06ae41 | 2017-09-25 23:32:20 +0200 | [diff] [blame] | 1643 | /* DSA and CPU ports have to be members of multiple vlans */ |
| 1644 | if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) |
| 1645 | return 0; |
| 1646 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1647 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1648 | if (err) |
| 1649 | return err; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1650 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1651 | if (!vlan.valid) |
| 1652 | return 0; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1653 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1654 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
| 1655 | if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i)) |
| 1656 | continue; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1657 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1658 | if (!dsa_to_port(ds, i)->slave) |
| 1659 | continue; |
Andrew Lunn | 66e2809 | 2016-12-11 21:07:19 +0100 | [diff] [blame] | 1660 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1661 | if (vlan.member[i] == |
| 1662 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) |
| 1663 | continue; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1664 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1665 | if (dsa_to_port(ds, i)->bridge_dev == |
| 1666 | dsa_to_port(ds, port)->bridge_dev) |
| 1667 | break; /* same bridge, check next VLAN */ |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1668 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1669 | if (!dsa_to_port(ds, i)->bridge_dev) |
| 1670 | continue; |
Andrew Lunn | 66e2809 | 2016-12-11 21:07:19 +0100 | [diff] [blame] | 1671 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1672 | dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n", |
| 1673 | port, vlan.vid, i, |
| 1674 | netdev_name(dsa_to_port(ds, i)->bridge_dev)); |
| 1675 | return -EOPNOTSUPP; |
| 1676 | } |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1677 | |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1678 | return 0; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1679 | } |
| 1680 | |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1681 | static int mv88e6xxx_port_commit_pvid(struct mv88e6xxx_chip *chip, int port) |
| 1682 | { |
| 1683 | struct dsa_port *dp = dsa_to_port(chip->ds, port); |
| 1684 | struct mv88e6xxx_port *p = &chip->ports[port]; |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 1685 | u16 pvid = MV88E6XXX_VID_STANDALONE; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1686 | bool drop_untagged = false; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1687 | int err; |
| 1688 | |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 1689 | if (dp->bridge_dev) { |
| 1690 | if (br_vlan_enabled(dp->bridge_dev)) { |
| 1691 | pvid = p->bridge_pvid.vid; |
| 1692 | drop_untagged = !p->bridge_pvid.valid; |
| 1693 | } else { |
| 1694 | pvid = MV88E6XXX_VID_BRIDGED; |
| 1695 | } |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1696 | } |
| 1697 | |
| 1698 | err = mv88e6xxx_port_set_pvid(chip, port, pvid); |
| 1699 | if (err) |
| 1700 | return err; |
| 1701 | |
| 1702 | return mv88e6xxx_port_drop_untagged(chip, port, drop_untagged); |
| 1703 | } |
| 1704 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1705 | static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port, |
Vladimir Oltean | 89153ed | 2021-02-13 22:43:19 +0200 | [diff] [blame] | 1706 | bool vlan_filtering, |
| 1707 | struct netlink_ext_ack *extack) |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1708 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1709 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 81c6edb | 2017-06-12 12:37:41 -0400 | [diff] [blame] | 1710 | u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE : |
| 1711 | MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1712 | int err; |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1713 | |
Vladimir Oltean | bae33f2 | 2021-01-09 02:01:50 +0200 | [diff] [blame] | 1714 | if (!mv88e6xxx_max_vid(chip)) |
| 1715 | return -EOPNOTSUPP; |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1716 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1717 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1718 | |
Vivien Didelot | 385a099 | 2016-11-04 03:23:31 +0100 | [diff] [blame] | 1719 | err = mv88e6xxx_port_set_8021q_mode(chip, port, mode); |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1720 | if (err) |
| 1721 | goto unlock; |
| 1722 | |
| 1723 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 1724 | if (err) |
| 1725 | goto unlock; |
| 1726 | |
| 1727 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1728 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1729 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1730 | return err; |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1731 | } |
| 1732 | |
Vivien Didelot | 57d3231 | 2016-06-20 13:13:58 -0400 | [diff] [blame] | 1733 | static int |
| 1734 | mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port, |
Vivien Didelot | 80e0236 | 2017-11-30 11:23:57 -0500 | [diff] [blame] | 1735 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1736 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1737 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1738 | int err; |
| 1739 | |
Tobias Waldekranz | e545f86 | 2020-11-10 19:57:20 +0100 | [diff] [blame] | 1740 | if (!mv88e6xxx_max_vid(chip)) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1741 | return -EOPNOTSUPP; |
| 1742 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1743 | /* If the requested port doesn't belong to the same bridge as the VLAN |
| 1744 | * members, do not support it (yet) and fallback to software VLAN. |
| 1745 | */ |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1746 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1747 | err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid); |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1748 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1749 | |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1750 | return err; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1751 | } |
| 1752 | |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1753 | static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port, |
| 1754 | const unsigned char *addr, u16 vid, |
| 1755 | u8 state) |
| 1756 | { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1757 | struct mv88e6xxx_atu_entry entry; |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1758 | struct mv88e6xxx_vtu_entry vlan; |
| 1759 | u16 fid; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1760 | int err; |
| 1761 | |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 1762 | /* Ports have two private address databases: one for when the port is |
| 1763 | * standalone and one for when the port is under a bridge and the |
| 1764 | * 802.1Q mode is disabled. When the port is standalone, DSA wants its |
| 1765 | * address database to remain 100% empty, so we never load an ATU entry |
| 1766 | * into a standalone port's database. Therefore, translate the null |
| 1767 | * VLAN ID into the port's database used for VLAN-unaware bridging. |
| 1768 | */ |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1769 | if (vid == 0) { |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 1770 | fid = MV88E6XXX_FID_BRIDGED; |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1771 | } else { |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1772 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1773 | if (err) |
| 1774 | return err; |
| 1775 | |
| 1776 | /* switchdev expects -EOPNOTSUPP to honor software VLANs */ |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1777 | if (!vlan.valid) |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1778 | return -EOPNOTSUPP; |
| 1779 | |
| 1780 | fid = vlan.fid; |
| 1781 | } |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1782 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1783 | entry.state = 0; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1784 | ether_addr_copy(entry.mac, addr); |
| 1785 | eth_addr_dec(entry.mac); |
| 1786 | |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1787 | err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry); |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1788 | if (err) |
| 1789 | return err; |
| 1790 | |
| 1791 | /* Initialize a fresh ATU entry if it isn't found */ |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1792 | if (!entry.state || !ether_addr_equal(entry.mac, addr)) { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1793 | memset(&entry, 0, sizeof(entry)); |
| 1794 | ether_addr_copy(entry.mac, addr); |
| 1795 | } |
| 1796 | |
| 1797 | /* Purge the ATU entry only if no port is using it anymore */ |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1798 | if (!state) { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1799 | entry.portvec &= ~BIT(port); |
| 1800 | if (!entry.portvec) |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1801 | entry.state = 0; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1802 | } else { |
DENG Qingfang | f72f2fb | 2021-01-30 21:43:34 +0800 | [diff] [blame] | 1803 | if (state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC) |
| 1804 | entry.portvec = BIT(port); |
| 1805 | else |
| 1806 | entry.portvec |= BIT(port); |
| 1807 | |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1808 | entry.state = state; |
| 1809 | } |
| 1810 | |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1811 | return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry); |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1812 | } |
| 1813 | |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 1814 | static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port, |
| 1815 | const struct mv88e6xxx_policy *policy) |
| 1816 | { |
| 1817 | enum mv88e6xxx_policy_mapping mapping = policy->mapping; |
| 1818 | enum mv88e6xxx_policy_action action = policy->action; |
| 1819 | const u8 *addr = policy->addr; |
| 1820 | u16 vid = policy->vid; |
| 1821 | u8 state; |
| 1822 | int err; |
| 1823 | int id; |
| 1824 | |
| 1825 | if (!chip->info->ops->port_set_policy) |
| 1826 | return -EOPNOTSUPP; |
| 1827 | |
| 1828 | switch (mapping) { |
| 1829 | case MV88E6XXX_POLICY_MAPPING_DA: |
| 1830 | case MV88E6XXX_POLICY_MAPPING_SA: |
| 1831 | if (action == MV88E6XXX_POLICY_ACTION_NORMAL) |
| 1832 | state = 0; /* Dissociate the port and address */ |
| 1833 | else if (action == MV88E6XXX_POLICY_ACTION_DISCARD && |
| 1834 | is_multicast_ether_addr(addr)) |
| 1835 | state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY; |
| 1836 | else if (action == MV88E6XXX_POLICY_ACTION_DISCARD && |
| 1837 | is_unicast_ether_addr(addr)) |
| 1838 | state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY; |
| 1839 | else |
| 1840 | return -EOPNOTSUPP; |
| 1841 | |
| 1842 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, |
| 1843 | state); |
| 1844 | if (err) |
| 1845 | return err; |
| 1846 | break; |
| 1847 | default: |
| 1848 | return -EOPNOTSUPP; |
| 1849 | } |
| 1850 | |
| 1851 | /* Skip the port's policy clearing if the mapping is still in use */ |
| 1852 | if (action == MV88E6XXX_POLICY_ACTION_NORMAL) |
| 1853 | idr_for_each_entry(&chip->policies, policy, id) |
| 1854 | if (policy->port == port && |
| 1855 | policy->mapping == mapping && |
| 1856 | policy->action != action) |
| 1857 | return 0; |
| 1858 | |
| 1859 | return chip->info->ops->port_set_policy(chip, port, mapping, action); |
| 1860 | } |
| 1861 | |
| 1862 | static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port, |
| 1863 | struct ethtool_rx_flow_spec *fs) |
| 1864 | { |
| 1865 | struct ethhdr *mac_entry = &fs->h_u.ether_spec; |
| 1866 | struct ethhdr *mac_mask = &fs->m_u.ether_spec; |
| 1867 | enum mv88e6xxx_policy_mapping mapping; |
| 1868 | enum mv88e6xxx_policy_action action; |
| 1869 | struct mv88e6xxx_policy *policy; |
| 1870 | u16 vid = 0; |
| 1871 | u8 *addr; |
| 1872 | int err; |
| 1873 | int id; |
| 1874 | |
| 1875 | if (fs->location != RX_CLS_LOC_ANY) |
| 1876 | return -EINVAL; |
| 1877 | |
| 1878 | if (fs->ring_cookie == RX_CLS_FLOW_DISC) |
| 1879 | action = MV88E6XXX_POLICY_ACTION_DISCARD; |
| 1880 | else |
| 1881 | return -EOPNOTSUPP; |
| 1882 | |
| 1883 | switch (fs->flow_type & ~FLOW_EXT) { |
| 1884 | case ETHER_FLOW: |
| 1885 | if (!is_zero_ether_addr(mac_mask->h_dest) && |
| 1886 | is_zero_ether_addr(mac_mask->h_source)) { |
| 1887 | mapping = MV88E6XXX_POLICY_MAPPING_DA; |
| 1888 | addr = mac_entry->h_dest; |
| 1889 | } else if (is_zero_ether_addr(mac_mask->h_dest) && |
| 1890 | !is_zero_ether_addr(mac_mask->h_source)) { |
| 1891 | mapping = MV88E6XXX_POLICY_MAPPING_SA; |
| 1892 | addr = mac_entry->h_source; |
| 1893 | } else { |
| 1894 | /* Cannot support DA and SA mapping in the same rule */ |
| 1895 | return -EOPNOTSUPP; |
| 1896 | } |
| 1897 | break; |
| 1898 | default: |
| 1899 | return -EOPNOTSUPP; |
| 1900 | } |
| 1901 | |
| 1902 | if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) { |
Andrew Lunn | 0484428 | 2020-07-05 21:38:08 +0200 | [diff] [blame] | 1903 | if (fs->m_ext.vlan_tci != htons(0xffff)) |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 1904 | return -EOPNOTSUPP; |
| 1905 | vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK; |
| 1906 | } |
| 1907 | |
| 1908 | idr_for_each_entry(&chip->policies, policy, id) { |
| 1909 | if (policy->port == port && policy->mapping == mapping && |
| 1910 | policy->action == action && policy->vid == vid && |
| 1911 | ether_addr_equal(policy->addr, addr)) |
| 1912 | return -EEXIST; |
| 1913 | } |
| 1914 | |
| 1915 | policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL); |
| 1916 | if (!policy) |
| 1917 | return -ENOMEM; |
| 1918 | |
| 1919 | fs->location = 0; |
| 1920 | err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff, |
| 1921 | GFP_KERNEL); |
| 1922 | if (err) { |
| 1923 | devm_kfree(chip->dev, policy); |
| 1924 | return err; |
| 1925 | } |
| 1926 | |
| 1927 | memcpy(&policy->fs, fs, sizeof(*fs)); |
| 1928 | ether_addr_copy(policy->addr, addr); |
| 1929 | policy->mapping = mapping; |
| 1930 | policy->action = action; |
| 1931 | policy->port = port; |
| 1932 | policy->vid = vid; |
| 1933 | |
| 1934 | err = mv88e6xxx_policy_apply(chip, port, policy); |
| 1935 | if (err) { |
| 1936 | idr_remove(&chip->policies, fs->location); |
| 1937 | devm_kfree(chip->dev, policy); |
| 1938 | return err; |
| 1939 | } |
| 1940 | |
| 1941 | return 0; |
| 1942 | } |
| 1943 | |
| 1944 | static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port, |
| 1945 | struct ethtool_rxnfc *rxnfc, u32 *rule_locs) |
| 1946 | { |
| 1947 | struct ethtool_rx_flow_spec *fs = &rxnfc->fs; |
| 1948 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1949 | struct mv88e6xxx_policy *policy; |
| 1950 | int err; |
| 1951 | int id; |
| 1952 | |
| 1953 | mv88e6xxx_reg_lock(chip); |
| 1954 | |
| 1955 | switch (rxnfc->cmd) { |
| 1956 | case ETHTOOL_GRXCLSRLCNT: |
| 1957 | rxnfc->data = 0; |
| 1958 | rxnfc->data |= RX_CLS_LOC_SPECIAL; |
| 1959 | rxnfc->rule_cnt = 0; |
| 1960 | idr_for_each_entry(&chip->policies, policy, id) |
| 1961 | if (policy->port == port) |
| 1962 | rxnfc->rule_cnt++; |
| 1963 | err = 0; |
| 1964 | break; |
| 1965 | case ETHTOOL_GRXCLSRULE: |
| 1966 | err = -ENOENT; |
| 1967 | policy = idr_find(&chip->policies, fs->location); |
| 1968 | if (policy) { |
| 1969 | memcpy(fs, &policy->fs, sizeof(*fs)); |
| 1970 | err = 0; |
| 1971 | } |
| 1972 | break; |
| 1973 | case ETHTOOL_GRXCLSRLALL: |
| 1974 | rxnfc->data = 0; |
| 1975 | rxnfc->rule_cnt = 0; |
| 1976 | idr_for_each_entry(&chip->policies, policy, id) |
| 1977 | if (policy->port == port) |
| 1978 | rule_locs[rxnfc->rule_cnt++] = id; |
| 1979 | err = 0; |
| 1980 | break; |
| 1981 | default: |
| 1982 | err = -EOPNOTSUPP; |
| 1983 | break; |
| 1984 | } |
| 1985 | |
| 1986 | mv88e6xxx_reg_unlock(chip); |
| 1987 | |
| 1988 | return err; |
| 1989 | } |
| 1990 | |
| 1991 | static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port, |
| 1992 | struct ethtool_rxnfc *rxnfc) |
| 1993 | { |
| 1994 | struct ethtool_rx_flow_spec *fs = &rxnfc->fs; |
| 1995 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1996 | struct mv88e6xxx_policy *policy; |
| 1997 | int err; |
| 1998 | |
| 1999 | mv88e6xxx_reg_lock(chip); |
| 2000 | |
| 2001 | switch (rxnfc->cmd) { |
| 2002 | case ETHTOOL_SRXCLSRLINS: |
| 2003 | err = mv88e6xxx_policy_insert(chip, port, fs); |
| 2004 | break; |
| 2005 | case ETHTOOL_SRXCLSRLDEL: |
| 2006 | err = -ENOENT; |
| 2007 | policy = idr_remove(&chip->policies, fs->location); |
| 2008 | if (policy) { |
| 2009 | policy->action = MV88E6XXX_POLICY_ACTION_NORMAL; |
| 2010 | err = mv88e6xxx_policy_apply(chip, port, policy); |
| 2011 | devm_kfree(chip->dev, policy); |
| 2012 | } |
| 2013 | break; |
| 2014 | default: |
| 2015 | err = -EOPNOTSUPP; |
| 2016 | break; |
| 2017 | } |
| 2018 | |
| 2019 | mv88e6xxx_reg_unlock(chip); |
| 2020 | |
| 2021 | return err; |
| 2022 | } |
| 2023 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2024 | static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port, |
| 2025 | u16 vid) |
| 2026 | { |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2027 | u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC; |
Tobias Waldekranz | 0806dd46 | 2021-03-18 20:25:37 +0100 | [diff] [blame] | 2028 | u8 broadcast[ETH_ALEN]; |
| 2029 | |
| 2030 | eth_broadcast_addr(broadcast); |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2031 | |
| 2032 | return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state); |
| 2033 | } |
| 2034 | |
| 2035 | static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid) |
| 2036 | { |
| 2037 | int port; |
| 2038 | int err; |
| 2039 | |
| 2040 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 2041 | struct dsa_port *dp = dsa_to_port(chip->ds, port); |
| 2042 | struct net_device *brport; |
| 2043 | |
| 2044 | if (dsa_is_unused_port(chip->ds, port)) |
| 2045 | continue; |
| 2046 | |
| 2047 | brport = dsa_port_to_bridge_port(dp); |
| 2048 | if (brport && !br_port_flag_is_set(brport, BR_BCAST_FLOOD)) |
| 2049 | /* Skip bridged user ports where broadcast |
| 2050 | * flooding is disabled. |
| 2051 | */ |
| 2052 | continue; |
| 2053 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2054 | err = mv88e6xxx_port_add_broadcast(chip, port, vid); |
| 2055 | if (err) |
| 2056 | return err; |
| 2057 | } |
| 2058 | |
| 2059 | return 0; |
| 2060 | } |
| 2061 | |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 2062 | struct mv88e6xxx_port_broadcast_sync_ctx { |
| 2063 | int port; |
| 2064 | bool flood; |
| 2065 | }; |
| 2066 | |
| 2067 | static int |
| 2068 | mv88e6xxx_port_broadcast_sync_vlan(struct mv88e6xxx_chip *chip, |
| 2069 | const struct mv88e6xxx_vtu_entry *vlan, |
| 2070 | void *_ctx) |
| 2071 | { |
| 2072 | struct mv88e6xxx_port_broadcast_sync_ctx *ctx = _ctx; |
| 2073 | u8 broadcast[ETH_ALEN]; |
| 2074 | u8 state; |
| 2075 | |
| 2076 | if (ctx->flood) |
| 2077 | state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC; |
| 2078 | else |
| 2079 | state = MV88E6XXX_G1_ATU_DATA_STATE_MC_UNUSED; |
| 2080 | |
| 2081 | eth_broadcast_addr(broadcast); |
| 2082 | |
| 2083 | return mv88e6xxx_port_db_load_purge(chip, ctx->port, broadcast, |
| 2084 | vlan->vid, state); |
| 2085 | } |
| 2086 | |
| 2087 | static int mv88e6xxx_port_broadcast_sync(struct mv88e6xxx_chip *chip, int port, |
| 2088 | bool flood) |
| 2089 | { |
| 2090 | struct mv88e6xxx_port_broadcast_sync_ctx ctx = { |
| 2091 | .port = port, |
| 2092 | .flood = flood, |
| 2093 | }; |
| 2094 | struct mv88e6xxx_vtu_entry vid0 = { |
| 2095 | .vid = 0, |
| 2096 | }; |
| 2097 | int err; |
| 2098 | |
| 2099 | /* Update the port's private database... */ |
| 2100 | err = mv88e6xxx_port_broadcast_sync_vlan(chip, &vid0, &ctx); |
| 2101 | if (err) |
| 2102 | return err; |
| 2103 | |
| 2104 | /* ...and the database for all VLANs. */ |
| 2105 | return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_broadcast_sync_vlan, |
| 2106 | &ctx); |
| 2107 | } |
| 2108 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2109 | static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port, |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2110 | u16 vid, u8 member, bool warn) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2111 | { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2112 | const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 2113 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2114 | int i, err; |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 2115 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2116 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2117 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2118 | return err; |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2119 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2120 | if (!vlan.valid) { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2121 | memset(&vlan, 0, sizeof(vlan)); |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 2122 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2123 | err = mv88e6xxx_atu_new(chip, &vlan.fid); |
| 2124 | if (err) |
| 2125 | return err; |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2126 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2127 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) |
| 2128 | if (i == port) |
| 2129 | vlan.member[i] = member; |
| 2130 | else |
| 2131 | vlan.member[i] = non_member; |
| 2132 | |
| 2133 | vlan.vid = vid; |
| 2134 | vlan.valid = true; |
| 2135 | |
| 2136 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
| 2137 | if (err) |
| 2138 | return err; |
| 2139 | |
| 2140 | err = mv88e6xxx_broadcast_setup(chip, vlan.vid); |
| 2141 | if (err) |
| 2142 | return err; |
| 2143 | } else if (vlan.member[port] != member) { |
| 2144 | vlan.member[port] = member; |
| 2145 | |
| 2146 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
| 2147 | if (err) |
| 2148 | return err; |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2149 | } else if (warn) { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2150 | dev_info(chip->dev, "p%d: already a member of VLAN %d\n", |
| 2151 | port, vid); |
| 2152 | } |
| 2153 | |
| 2154 | return 0; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2155 | } |
| 2156 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2157 | static int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, |
Vladimir Oltean | 31046a5 | 2021-02-13 22:43:18 +0200 | [diff] [blame] | 2158 | const struct switchdev_obj_port_vlan *vlan, |
| 2159 | struct netlink_ext_ack *extack) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2160 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2161 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2162 | bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; |
| 2163 | bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2164 | struct mv88e6xxx_port *p = &chip->ports[port]; |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2165 | bool warn; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2166 | u8 member; |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2167 | int err; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2168 | |
Eldar Gasanov | b8b79c4 | 2021-06-21 11:54:38 +0300 | [diff] [blame] | 2169 | if (!vlan->vid) |
| 2170 | return 0; |
| 2171 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2172 | err = mv88e6xxx_port_vlan_prepare(ds, port, vlan); |
| 2173 | if (err) |
| 2174 | return err; |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 2175 | |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2176 | 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] | 2177 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2178 | else if (untagged) |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2179 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2180 | else |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2181 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2182 | |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2183 | /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port |
| 2184 | * and then the CPU port. Do not warn for duplicates for the CPU port. |
| 2185 | */ |
| 2186 | warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port); |
| 2187 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2188 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2189 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2190 | err = mv88e6xxx_port_vlan_join(chip, port, vlan->vid, member, warn); |
| 2191 | if (err) { |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 2192 | dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port, |
| 2193 | vlan->vid, untagged ? 'u' : 't'); |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2194 | goto out; |
| 2195 | } |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2196 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2197 | if (pvid) { |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2198 | p->bridge_pvid.vid = vlan->vid; |
| 2199 | p->bridge_pvid.valid = true; |
| 2200 | |
| 2201 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 2202 | if (err) |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2203 | goto out; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2204 | } else if (vlan->vid && p->bridge_pvid.vid == vlan->vid) { |
| 2205 | /* The old pvid was reinstalled as a non-pvid VLAN */ |
| 2206 | p->bridge_pvid.valid = false; |
| 2207 | |
| 2208 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 2209 | if (err) |
| 2210 | goto out; |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2211 | } |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2212 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2213 | out: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2214 | mv88e6xxx_reg_unlock(chip); |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2215 | |
| 2216 | return err; |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 2217 | } |
| 2218 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2219 | static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip, |
| 2220 | int port, u16 vid) |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2221 | { |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 2222 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2223 | int i, err; |
| 2224 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2225 | if (!vid) |
Vladimir Oltean | c92c741 | 2021-07-22 16:05:51 +0300 | [diff] [blame] | 2226 | return 0; |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2227 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2228 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2229 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2230 | return err; |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2231 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2232 | /* If the VLAN doesn't exist in hardware or the port isn't a member, |
| 2233 | * tell switchdev that this VLAN is likely handled in software. |
| 2234 | */ |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2235 | if (!vlan.valid || |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2236 | vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) |
Vivien Didelot | 3c06f08 | 2016-02-05 14:04:39 -0500 | [diff] [blame] | 2237 | return -EOPNOTSUPP; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2238 | |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2239 | vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2240 | |
| 2241 | /* keep the VLAN unless all ports are excluded */ |
Vivien Didelot | f02bdff | 2015-10-11 18:08:36 -0400 | [diff] [blame] | 2242 | vlan.valid = false; |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 2243 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2244 | if (vlan.member[i] != |
| 2245 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) { |
Vivien Didelot | f02bdff | 2015-10-11 18:08:36 -0400 | [diff] [blame] | 2246 | vlan.valid = true; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2247 | break; |
| 2248 | } |
| 2249 | } |
| 2250 | |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2251 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2252 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2253 | return err; |
| 2254 | |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 2255 | return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2256 | } |
| 2257 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2258 | static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, |
| 2259 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2260 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2261 | struct mv88e6xxx_chip *chip = ds->priv; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2262 | struct mv88e6xxx_port *p = &chip->ports[port]; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2263 | int err = 0; |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 2264 | u16 pvid; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2265 | |
Tobias Waldekranz | e545f86 | 2020-11-10 19:57:20 +0100 | [diff] [blame] | 2266 | if (!mv88e6xxx_max_vid(chip)) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 2267 | return -EOPNOTSUPP; |
| 2268 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2269 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2270 | |
Vivien Didelot | 77064f3 | 2016-11-04 03:23:30 +0100 | [diff] [blame] | 2271 | err = mv88e6xxx_port_get_pvid(chip, port, &pvid); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2272 | if (err) |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2273 | goto unlock; |
| 2274 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 2275 | err = mv88e6xxx_port_vlan_leave(chip, port, vlan->vid); |
| 2276 | if (err) |
| 2277 | goto unlock; |
| 2278 | |
| 2279 | if (vlan->vid == pvid) { |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2280 | p->bridge_pvid.valid = false; |
| 2281 | |
| 2282 | err = mv88e6xxx_port_commit_pvid(chip, port); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2283 | if (err) |
| 2284 | goto unlock; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2285 | } |
| 2286 | |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2287 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2288 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2289 | |
| 2290 | return err; |
| 2291 | } |
| 2292 | |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2293 | static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port, |
| 2294 | const unsigned char *addr, u16 vid) |
Guenter Roeck | defb05b | 2015-03-26 18:36:38 -0700 | [diff] [blame] | 2295 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2296 | struct mv88e6xxx_chip *chip = ds->priv; |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2297 | int err; |
Vivien Didelot | 6630e23 | 2015-08-06 01:44:07 -0400 | [diff] [blame] | 2298 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2299 | mv88e6xxx_reg_lock(chip); |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2300 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, |
| 2301 | MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2302 | mv88e6xxx_reg_unlock(chip); |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2303 | |
| 2304 | return err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2305 | } |
| 2306 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2307 | static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port, |
Arkadi Sharshevsky | 6c2c1dc | 2017-08-06 16:15:39 +0300 | [diff] [blame] | 2308 | const unsigned char *addr, u16 vid) |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2309 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2310 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2311 | int err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2312 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2313 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2314 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2315 | mv88e6xxx_reg_unlock(chip); |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2316 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2317 | return err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2318 | } |
| 2319 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2320 | static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip, |
| 2321 | u16 fid, u16 vid, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2322 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2323 | { |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2324 | struct mv88e6xxx_atu_entry addr; |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2325 | bool is_static; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2326 | int err; |
| 2327 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2328 | addr.state = 0; |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2329 | eth_broadcast_addr(addr.mac); |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2330 | |
| 2331 | do { |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2332 | err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr); |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2333 | if (err) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2334 | return err; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2335 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2336 | if (!addr.state) |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2337 | break; |
| 2338 | |
Vivien Didelot | 01bd96c | 2017-03-11 16:12:57 -0500 | [diff] [blame] | 2339 | if (addr.trunk || (addr.portvec & BIT(port)) == 0) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2340 | continue; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2341 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2342 | if (!is_unicast_ether_addr(addr.mac)) |
| 2343 | continue; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2344 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2345 | is_static = (addr.state == |
| 2346 | MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); |
| 2347 | err = cb(addr.mac, vid, is_static, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2348 | if (err) |
| 2349 | return err; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2350 | } while (!is_broadcast_ether_addr(addr.mac)); |
| 2351 | |
| 2352 | return err; |
| 2353 | } |
| 2354 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 2355 | struct mv88e6xxx_port_db_dump_vlan_ctx { |
| 2356 | int port; |
| 2357 | dsa_fdb_dump_cb_t *cb; |
| 2358 | void *data; |
| 2359 | }; |
| 2360 | |
| 2361 | static int mv88e6xxx_port_db_dump_vlan(struct mv88e6xxx_chip *chip, |
| 2362 | const struct mv88e6xxx_vtu_entry *entry, |
| 2363 | void *_data) |
| 2364 | { |
| 2365 | struct mv88e6xxx_port_db_dump_vlan_ctx *ctx = _data; |
| 2366 | |
| 2367 | return mv88e6xxx_port_db_dump_fid(chip, entry->fid, entry->vid, |
| 2368 | ctx->port, ctx->cb, ctx->data); |
| 2369 | } |
| 2370 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2371 | static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2372 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2373 | { |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 2374 | struct mv88e6xxx_port_db_dump_vlan_ctx ctx = { |
| 2375 | .port = port, |
| 2376 | .cb = cb, |
| 2377 | .data = data, |
| 2378 | }; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2379 | u16 fid; |
| 2380 | int err; |
| 2381 | |
| 2382 | /* Dump port's default Filtering Information Database (VLAN ID 0) */ |
Vivien Didelot | b4e48c5 | 2016-11-04 03:23:29 +0100 | [diff] [blame] | 2383 | err = mv88e6xxx_port_get_fid(chip, port, &fid); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2384 | if (err) |
| 2385 | return err; |
| 2386 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2387 | err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2388 | if (err) |
| 2389 | return err; |
| 2390 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 2391 | return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_db_dump_vlan, &ctx); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2392 | } |
| 2393 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2394 | static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2395 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2396 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2397 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2398 | int err; |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2399 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2400 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2401 | err = mv88e6xxx_port_db_dump(chip, port, cb, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2402 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2403 | |
| 2404 | return err; |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2405 | } |
| 2406 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2407 | static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip, |
| 2408 | struct net_device *br) |
| 2409 | { |
Vivien Didelot | ef2025e | 2019-10-21 16:51:27 -0400 | [diff] [blame] | 2410 | struct dsa_switch *ds = chip->ds; |
| 2411 | struct dsa_switch_tree *dst = ds->dst; |
| 2412 | struct dsa_port *dp; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2413 | int err; |
| 2414 | |
Vivien Didelot | ef2025e | 2019-10-21 16:51:27 -0400 | [diff] [blame] | 2415 | list_for_each_entry(dp, &dst->ports, list) { |
| 2416 | if (dp->bridge_dev == br) { |
| 2417 | if (dp->ds == ds) { |
| 2418 | /* This is a local bridge group member, |
| 2419 | * remap its Port VLAN Map. |
| 2420 | */ |
| 2421 | err = mv88e6xxx_port_vlan_map(chip, dp->index); |
| 2422 | if (err) |
| 2423 | return err; |
| 2424 | } else { |
| 2425 | /* This is an external bridge group member, |
| 2426 | * remap its cross-chip Port VLAN Table entry. |
| 2427 | */ |
| 2428 | err = mv88e6xxx_pvt_map(chip, dp->ds->index, |
| 2429 | dp->index); |
Vivien Didelot | e96a6e0 | 2017-03-30 17:37:13 -0400 | [diff] [blame] | 2430 | if (err) |
| 2431 | return err; |
| 2432 | } |
| 2433 | } |
| 2434 | } |
| 2435 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2436 | return 0; |
| 2437 | } |
| 2438 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2439 | static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, |
Vivien Didelot | fae8a25 | 2017-01-27 15:29:42 -0500 | [diff] [blame] | 2440 | struct net_device *br) |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2441 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2442 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2443 | int err; |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2444 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2445 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2446 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2447 | err = mv88e6xxx_bridge_map(chip, br); |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2448 | if (err) |
| 2449 | goto unlock; |
| 2450 | |
| 2451 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 2452 | if (err) |
| 2453 | goto unlock; |
| 2454 | |
| 2455 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2456 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | a669275 | 2016-02-12 12:09:39 -0500 | [diff] [blame] | 2457 | |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2458 | return err; |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2459 | } |
| 2460 | |
Vivien Didelot | f123f2f | 2017-01-27 15:29:41 -0500 | [diff] [blame] | 2461 | static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port, |
| 2462 | struct net_device *br) |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2463 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2464 | struct mv88e6xxx_chip *chip = ds->priv; |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2465 | int err; |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2466 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2467 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2468 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2469 | if (mv88e6xxx_bridge_map(chip, br) || |
| 2470 | mv88e6xxx_port_vlan_map(chip, port)) |
| 2471 | dev_err(ds->dev, "failed to remap in-chip Port VLAN\n"); |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2472 | |
| 2473 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 2474 | if (err) |
| 2475 | dev_err(ds->dev, |
| 2476 | "port %d failed to restore standalone pvid: %pe\n", |
| 2477 | port, ERR_PTR(err)); |
| 2478 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2479 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 66d9cd0 | 2016-02-05 14:07:14 -0500 | [diff] [blame] | 2480 | } |
| 2481 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2482 | static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, |
| 2483 | int tree_index, int sw_index, |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2484 | int port, struct net_device *br) |
| 2485 | { |
| 2486 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2487 | int err; |
| 2488 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2489 | if (tree_index != ds->dst->index) |
| 2490 | return 0; |
| 2491 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2492 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2493 | err = mv88e6xxx_pvt_map(chip, sw_index, port); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2494 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2495 | |
| 2496 | return err; |
| 2497 | } |
| 2498 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2499 | static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, |
| 2500 | int tree_index, int sw_index, |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2501 | int port, struct net_device *br) |
| 2502 | { |
| 2503 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2504 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2505 | if (tree_index != ds->dst->index) |
| 2506 | return; |
| 2507 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2508 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2509 | if (mv88e6xxx_pvt_map(chip, sw_index, port)) |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2510 | dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2511 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2512 | } |
| 2513 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 2514 | /* Treat the software bridge as a virtual single-port switch behind the |
| 2515 | * CPU and map in the PVT. First dst->last_switch elements are taken by |
| 2516 | * physical switches, so start from beyond that range. |
| 2517 | */ |
| 2518 | static int mv88e6xxx_map_virtual_bridge_to_pvt(struct dsa_switch *ds, |
| 2519 | int bridge_num) |
| 2520 | { |
| 2521 | u8 dev = bridge_num + ds->dst->last_switch + 1; |
| 2522 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2523 | int err; |
| 2524 | |
| 2525 | mv88e6xxx_reg_lock(chip); |
| 2526 | err = mv88e6xxx_pvt_map(chip, dev, 0); |
| 2527 | mv88e6xxx_reg_unlock(chip); |
| 2528 | |
| 2529 | return err; |
| 2530 | } |
| 2531 | |
| 2532 | static int mv88e6xxx_bridge_tx_fwd_offload(struct dsa_switch *ds, int port, |
| 2533 | struct net_device *br, |
| 2534 | int bridge_num) |
| 2535 | { |
| 2536 | return mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge_num); |
| 2537 | } |
| 2538 | |
| 2539 | static void mv88e6xxx_bridge_tx_fwd_unoffload(struct dsa_switch *ds, int port, |
| 2540 | struct net_device *br, |
| 2541 | int bridge_num) |
| 2542 | { |
| 2543 | int err; |
| 2544 | |
| 2545 | err = mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge_num); |
| 2546 | if (err) { |
| 2547 | dev_err(ds->dev, "failed to remap cross-chip Port VLAN: %pe\n", |
| 2548 | ERR_PTR(err)); |
| 2549 | } |
| 2550 | } |
| 2551 | |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2552 | static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip) |
| 2553 | { |
| 2554 | if (chip->info->ops->reset) |
| 2555 | return chip->info->ops->reset(chip); |
| 2556 | |
| 2557 | return 0; |
| 2558 | } |
| 2559 | |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2560 | static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip) |
| 2561 | { |
| 2562 | struct gpio_desc *gpiod = chip->reset; |
| 2563 | |
| 2564 | /* If there is a GPIO connected to the reset pin, toggle it */ |
| 2565 | if (gpiod) { |
| 2566 | gpiod_set_value_cansleep(gpiod, 1); |
| 2567 | usleep_range(10000, 20000); |
| 2568 | gpiod_set_value_cansleep(gpiod, 0); |
| 2569 | usleep_range(10000, 20000); |
Andrew Lunn | a3dcb3e | 2020-11-16 08:43:01 -0800 | [diff] [blame] | 2570 | |
| 2571 | mv88e6xxx_g1_wait_eeprom_done(chip); |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2572 | } |
| 2573 | } |
| 2574 | |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2575 | static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip) |
| 2576 | { |
| 2577 | int i, err; |
| 2578 | |
| 2579 | /* Set all ports to the Disabled state */ |
| 2580 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
Vivien Didelot | f894c29 | 2017-06-08 18:34:10 -0400 | [diff] [blame] | 2581 | err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED); |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2582 | if (err) |
| 2583 | return err; |
| 2584 | } |
| 2585 | |
| 2586 | /* Wait for transmit queues to drain, |
| 2587 | * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps. |
| 2588 | */ |
| 2589 | usleep_range(2000, 4000); |
| 2590 | |
| 2591 | return 0; |
| 2592 | } |
| 2593 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2594 | static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2595 | { |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 2596 | int err; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2597 | |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2598 | err = mv88e6xxx_disable_ports(chip); |
| 2599 | if (err) |
| 2600 | return err; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2601 | |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2602 | mv88e6xxx_hardware_reset(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2603 | |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2604 | return mv88e6xxx_software_reset(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2605 | } |
| 2606 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2607 | static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2608 | enum mv88e6xxx_frame_mode frame, |
| 2609 | enum mv88e6xxx_egress_mode egress, u16 etype) |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2610 | { |
| 2611 | int err; |
| 2612 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2613 | if (!chip->info->ops->port_set_frame_mode) |
| 2614 | return -EOPNOTSUPP; |
| 2615 | |
| 2616 | err = mv88e6xxx_port_set_egress_mode(chip, port, egress); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2617 | if (err) |
| 2618 | return err; |
| 2619 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2620 | err = chip->info->ops->port_set_frame_mode(chip, port, frame); |
| 2621 | if (err) |
| 2622 | return err; |
| 2623 | |
| 2624 | if (chip->info->ops->port_set_ether_type) |
| 2625 | return chip->info->ops->port_set_ether_type(chip, port, etype); |
| 2626 | |
| 2627 | return 0; |
| 2628 | } |
| 2629 | |
| 2630 | static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port) |
| 2631 | { |
| 2632 | return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2633 | MV88E6XXX_EGRESS_MODE_UNMODIFIED, |
Vivien Didelot | b810959 | 2017-06-12 12:37:45 -0400 | [diff] [blame] | 2634 | MV88E6XXX_PORT_ETH_TYPE_DEFAULT); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2635 | } |
| 2636 | |
| 2637 | static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port) |
| 2638 | { |
| 2639 | return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2640 | MV88E6XXX_EGRESS_MODE_UNMODIFIED, |
Vivien Didelot | b810959 | 2017-06-12 12:37:45 -0400 | [diff] [blame] | 2641 | MV88E6XXX_PORT_ETH_TYPE_DEFAULT); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2642 | } |
| 2643 | |
| 2644 | static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port) |
| 2645 | { |
| 2646 | return mv88e6xxx_set_port_mode(chip, port, |
| 2647 | MV88E6XXX_FRAME_MODE_ETHERTYPE, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2648 | MV88E6XXX_EGRESS_MODE_ETHERTYPE, |
| 2649 | ETH_P_EDSA); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2650 | } |
| 2651 | |
| 2652 | static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port) |
| 2653 | { |
| 2654 | if (dsa_is_dsa_port(chip->ds, port)) |
| 2655 | return mv88e6xxx_set_port_mode_dsa(chip, port); |
| 2656 | |
Vivien Didelot | 2b3e989 | 2017-10-26 11:22:54 -0400 | [diff] [blame] | 2657 | if (dsa_is_user_port(chip->ds, port)) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2658 | return mv88e6xxx_set_port_mode_normal(chip, port); |
| 2659 | |
| 2660 | /* Setup CPU port mode depending on its supported tag format */ |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 2661 | if (chip->tag_protocol == DSA_TAG_PROTO_DSA) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2662 | return mv88e6xxx_set_port_mode_dsa(chip, port); |
| 2663 | |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 2664 | if (chip->tag_protocol == DSA_TAG_PROTO_EDSA) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2665 | return mv88e6xxx_set_port_mode_edsa(chip, port); |
| 2666 | |
| 2667 | return -EINVAL; |
| 2668 | } |
| 2669 | |
Vivien Didelot | ea698f4 | 2017-03-11 16:12:50 -0500 | [diff] [blame] | 2670 | static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port) |
| 2671 | { |
| 2672 | bool message = dsa_is_dsa_port(chip->ds, port); |
| 2673 | |
| 2674 | return mv88e6xxx_port_set_message_port(chip, port, message); |
| 2675 | } |
| 2676 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2677 | static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port) |
| 2678 | { |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2679 | int err; |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2680 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2681 | if (chip->info->ops->port_set_ucast_flood) { |
Tobias Waldekranz | 7b9f16f | 2021-03-18 20:25:38 +0100 | [diff] [blame] | 2682 | err = chip->info->ops->port_set_ucast_flood(chip, port, true); |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2683 | if (err) |
| 2684 | return err; |
| 2685 | } |
| 2686 | if (chip->info->ops->port_set_mcast_flood) { |
Tobias Waldekranz | 7b9f16f | 2021-03-18 20:25:38 +0100 | [diff] [blame] | 2687 | err = chip->info->ops->port_set_mcast_flood(chip, port, true); |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2688 | if (err) |
| 2689 | return err; |
| 2690 | } |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2691 | |
David S. Miller | 407308f | 2019-06-15 13:35:29 -0700 | [diff] [blame] | 2692 | return 0; |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2693 | } |
| 2694 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2695 | static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id) |
| 2696 | { |
| 2697 | struct mv88e6xxx_port *mvp = dev_id; |
| 2698 | struct mv88e6xxx_chip *chip = mvp->chip; |
| 2699 | irqreturn_t ret = IRQ_NONE; |
| 2700 | int port = mvp->port; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2701 | int lane; |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2702 | |
| 2703 | mv88e6xxx_reg_lock(chip); |
| 2704 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2705 | if (lane >= 0) |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2706 | ret = mv88e6xxx_serdes_irq_status(chip, port, lane); |
| 2707 | mv88e6xxx_reg_unlock(chip); |
| 2708 | |
| 2709 | return ret; |
| 2710 | } |
| 2711 | |
| 2712 | static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port, |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2713 | int lane) |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2714 | { |
| 2715 | struct mv88e6xxx_port *dev_id = &chip->ports[port]; |
| 2716 | unsigned int irq; |
| 2717 | int err; |
| 2718 | |
| 2719 | /* Nothing to request if this SERDES port has no IRQ */ |
| 2720 | irq = mv88e6xxx_serdes_irq_mapping(chip, port); |
| 2721 | if (!irq) |
| 2722 | return 0; |
| 2723 | |
Andrew Lunn | e6f2f6b | 2020-01-06 17:13:49 +0100 | [diff] [blame] | 2724 | snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name), |
| 2725 | "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port); |
| 2726 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2727 | /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */ |
| 2728 | mv88e6xxx_reg_unlock(chip); |
| 2729 | err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn, |
Andrew Lunn | e6f2f6b | 2020-01-06 17:13:49 +0100 | [diff] [blame] | 2730 | IRQF_ONESHOT, dev_id->serdes_irq_name, |
| 2731 | dev_id); |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2732 | mv88e6xxx_reg_lock(chip); |
| 2733 | if (err) |
| 2734 | return err; |
| 2735 | |
| 2736 | dev_id->serdes_irq = irq; |
| 2737 | |
| 2738 | return mv88e6xxx_serdes_irq_enable(chip, port, lane); |
| 2739 | } |
| 2740 | |
| 2741 | static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port, |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2742 | int lane) |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2743 | { |
| 2744 | struct mv88e6xxx_port *dev_id = &chip->ports[port]; |
| 2745 | unsigned int irq = dev_id->serdes_irq; |
| 2746 | int err; |
| 2747 | |
| 2748 | /* Nothing to free if no IRQ has been requested */ |
| 2749 | if (!irq) |
| 2750 | return 0; |
| 2751 | |
| 2752 | err = mv88e6xxx_serdes_irq_disable(chip, port, lane); |
| 2753 | |
| 2754 | /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */ |
| 2755 | mv88e6xxx_reg_unlock(chip); |
| 2756 | free_irq(irq, dev_id); |
| 2757 | mv88e6xxx_reg_lock(chip); |
| 2758 | |
| 2759 | dev_id->serdes_irq = 0; |
| 2760 | |
| 2761 | return err; |
| 2762 | } |
| 2763 | |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2764 | static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port, |
| 2765 | bool on) |
| 2766 | { |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2767 | int lane; |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2768 | int err; |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2769 | |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2770 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2771 | if (lane < 0) |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2772 | return 0; |
| 2773 | |
| 2774 | if (on) { |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2775 | err = mv88e6xxx_serdes_power_up(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2776 | if (err) |
| 2777 | return err; |
| 2778 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2779 | err = mv88e6xxx_serdes_irq_request(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2780 | } else { |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2781 | err = mv88e6xxx_serdes_irq_free(chip, port, lane); |
| 2782 | if (err) |
| 2783 | return err; |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2784 | |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2785 | err = mv88e6xxx_serdes_power_down(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2786 | } |
| 2787 | |
| 2788 | return err; |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2789 | } |
| 2790 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2791 | static int mv88e6xxx_set_egress_port(struct mv88e6xxx_chip *chip, |
| 2792 | enum mv88e6xxx_egress_direction direction, |
| 2793 | int port) |
| 2794 | { |
| 2795 | int err; |
| 2796 | |
| 2797 | if (!chip->info->ops->set_egress_port) |
| 2798 | return -EOPNOTSUPP; |
| 2799 | |
| 2800 | err = chip->info->ops->set_egress_port(chip, direction, port); |
| 2801 | if (err) |
| 2802 | return err; |
| 2803 | |
| 2804 | if (direction == MV88E6XXX_EGRESS_DIR_INGRESS) |
| 2805 | chip->ingress_dest_port = port; |
| 2806 | else |
| 2807 | chip->egress_dest_port = port; |
| 2808 | |
| 2809 | return 0; |
| 2810 | } |
| 2811 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2812 | static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port) |
| 2813 | { |
| 2814 | struct dsa_switch *ds = chip->ds; |
| 2815 | int upstream_port; |
| 2816 | int err; |
| 2817 | |
Vivien Didelot | 07073c7 | 2017-12-05 15:34:13 -0500 | [diff] [blame] | 2818 | upstream_port = dsa_upstream_port(ds, port); |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2819 | if (chip->info->ops->port_set_upstream_port) { |
| 2820 | err = chip->info->ops->port_set_upstream_port(chip, port, |
| 2821 | upstream_port); |
| 2822 | if (err) |
| 2823 | return err; |
| 2824 | } |
| 2825 | |
Vivien Didelot | 0ea54dd | 2017-12-05 15:34:11 -0500 | [diff] [blame] | 2826 | if (port == upstream_port) { |
| 2827 | if (chip->info->ops->set_cpu_port) { |
| 2828 | err = chip->info->ops->set_cpu_port(chip, |
| 2829 | upstream_port); |
| 2830 | if (err) |
| 2831 | return err; |
| 2832 | } |
| 2833 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2834 | err = mv88e6xxx_set_egress_port(chip, |
Iwan R Timmer | 5c74c54 | 2019-11-07 22:11:13 +0100 | [diff] [blame] | 2835 | MV88E6XXX_EGRESS_DIR_INGRESS, |
| 2836 | upstream_port); |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2837 | if (err && err != -EOPNOTSUPP) |
| 2838 | return err; |
Iwan R Timmer | 5c74c54 | 2019-11-07 22:11:13 +0100 | [diff] [blame] | 2839 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2840 | err = mv88e6xxx_set_egress_port(chip, |
Iwan R Timmer | 5c74c54 | 2019-11-07 22:11:13 +0100 | [diff] [blame] | 2841 | MV88E6XXX_EGRESS_DIR_EGRESS, |
| 2842 | upstream_port); |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2843 | if (err && err != -EOPNOTSUPP) |
| 2844 | return err; |
Vivien Didelot | 0ea54dd | 2017-12-05 15:34:11 -0500 | [diff] [blame] | 2845 | } |
| 2846 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2847 | return 0; |
| 2848 | } |
| 2849 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2850 | static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2851 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2852 | struct dsa_switch *ds = chip->ds; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2853 | int err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2854 | u16 reg; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2855 | |
Andrew Lunn | 7b89846 | 2018-08-09 15:38:47 +0200 | [diff] [blame] | 2856 | chip->ports[port].chip = chip; |
| 2857 | chip->ports[port].port = port; |
| 2858 | |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2859 | /* MAC Forcing register: don't force link, speed, duplex or flow control |
| 2860 | * state to any particular values on physical ports, but force the CPU |
| 2861 | * port and all DSA ports to their maximum bandwidth and full duplex. |
| 2862 | */ |
| 2863 | if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) |
| 2864 | err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP, |
| 2865 | SPEED_MAX, DUPLEX_FULL, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 2866 | PAUSE_OFF, |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2867 | PHY_INTERFACE_MODE_NA); |
| 2868 | else |
| 2869 | err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED, |
| 2870 | SPEED_UNFORCED, DUPLEX_UNFORCED, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 2871 | PAUSE_ON, |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2872 | PHY_INTERFACE_MODE_NA); |
| 2873 | if (err) |
| 2874 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2875 | |
| 2876 | /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock, |
| 2877 | * disable Header mode, enable IGMP/MLD snooping, disable VLAN |
| 2878 | * tunneling, determine priority by looking at 802.1p and IP |
| 2879 | * priority fields (IP prio has precedence), and set STP state |
| 2880 | * to Forwarding. |
| 2881 | * |
| 2882 | * If this is the CPU link, use DSA or EDSA tagging depending |
| 2883 | * on which tagging mode was configured. |
| 2884 | * |
| 2885 | * If this is a link to another switch, use DSA tagging mode. |
| 2886 | * |
| 2887 | * If this is the upstream port for this switch, enable |
| 2888 | * forwarding of unknown unicasts and multicasts. |
| 2889 | */ |
Vivien Didelot | a89b433be | 2017-06-12 12:37:37 -0400 | [diff] [blame] | 2890 | reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP | |
| 2891 | MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP | |
| 2892 | MV88E6XXX_PORT_CTL0_STATE_FORWARDING; |
| 2893 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2894 | if (err) |
| 2895 | return err; |
Andrew Lunn | 6083ce7 | 2015-08-17 23:52:52 +0200 | [diff] [blame] | 2896 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2897 | err = mv88e6xxx_setup_port_mode(chip, port); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2898 | if (err) |
| 2899 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2900 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2901 | err = mv88e6xxx_setup_egress_floods(chip, port); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2902 | if (err) |
| 2903 | return err; |
| 2904 | |
Andrew Lunn | b92ce2f | 2021-09-26 19:41:25 +0200 | [diff] [blame] | 2905 | /* Port Control 2: don't force a good FCS, set the MTU size to |
| 2906 | * 10222 bytes, disable 802.1q tags checking, don't discard tagged or |
Vivien Didelot | 8efdda4 | 2015-08-13 12:52:23 -0400 | [diff] [blame] | 2907 | * untagged frames on this port, do a destination address lookup on all |
| 2908 | * received packets as usual, disable ARP mirroring and don't send a |
| 2909 | * copy of all transmitted/received frames on this port to the CPU. |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2910 | */ |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2911 | err = mv88e6xxx_port_set_map_da(chip, port); |
| 2912 | if (err) |
| 2913 | return err; |
| 2914 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2915 | err = mv88e6xxx_setup_upstream_port(chip, port); |
| 2916 | if (err) |
| 2917 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2918 | |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2919 | err = mv88e6xxx_port_set_8021q_mode(chip, port, |
Vivien Didelot | 81c6edb | 2017-06-12 12:37:41 -0400 | [diff] [blame] | 2920 | MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED); |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2921 | if (err) |
| 2922 | return err; |
| 2923 | |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2924 | /* Associate MV88E6XXX_VID_BRIDGED with MV88E6XXX_FID_BRIDGED in the |
| 2925 | * ATU by virtue of the fact that mv88e6xxx_atu_new() will pick it as |
| 2926 | * the first free FID after MV88E6XXX_FID_STANDALONE. This will be used |
| 2927 | * as the private PVID on ports under a VLAN-unaware bridge. |
| 2928 | * Shared (DSA and CPU) ports must also be members of it, to translate |
| 2929 | * the VID from the DSA tag into MV88E6XXX_FID_BRIDGED, instead of |
| 2930 | * relying on their port default FID. |
| 2931 | */ |
| 2932 | err = mv88e6xxx_port_vlan_join(chip, port, MV88E6XXX_VID_BRIDGED, |
| 2933 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED, |
| 2934 | false); |
| 2935 | if (err) |
| 2936 | return err; |
| 2937 | |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2938 | if (chip->info->ops->port_set_jumbo_size) { |
Andrew Lunn | b92ce2f | 2021-09-26 19:41:25 +0200 | [diff] [blame] | 2939 | err = chip->info->ops->port_set_jumbo_size(chip, port, 10218); |
Andrew Lunn | 5f43666 | 2016-12-03 04:45:17 +0100 | [diff] [blame] | 2940 | if (err) |
| 2941 | return err; |
| 2942 | } |
| 2943 | |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 2944 | /* Port Association Vector: disable automatic address learning |
| 2945 | * on all user ports since they start out in standalone |
| 2946 | * mode. When joining a bridge, learning will be configured to |
| 2947 | * match the bridge port settings. Enable learning on all |
| 2948 | * DSA/CPU ports. NOTE: FROM_CPU frames always bypass the |
| 2949 | * learning process. |
| 2950 | * |
| 2951 | * Disable HoldAt1, IntOnAgeOut, LockedPort, IgnoreWrongData, |
| 2952 | * and RefreshLocked. I.e. setup standard automatic learning. |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2953 | */ |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 2954 | if (dsa_is_user_port(ds, port)) |
Vivien Didelot | 65fa402 | 2016-04-14 14:42:07 -0400 | [diff] [blame] | 2955 | reg = 0; |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 2956 | else |
| 2957 | reg = 1 << port; |
Andrew Lunn | 4c7ea3c | 2015-11-03 10:52:36 -0500 | [diff] [blame] | 2958 | |
Vivien Didelot | 2a4614e | 2017-06-12 12:37:43 -0400 | [diff] [blame] | 2959 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR, |
| 2960 | reg); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2961 | if (err) |
| 2962 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2963 | |
| 2964 | /* Egress rate control 2: disable egress rate control. */ |
Vivien Didelot | 2cb8cb1 | 2017-06-12 12:37:42 -0400 | [diff] [blame] | 2965 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2, |
| 2966 | 0x0000); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2967 | if (err) |
| 2968 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2969 | |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2970 | if (chip->info->ops->port_pause_limit) { |
| 2971 | err = chip->info->ops->port_pause_limit(chip, port, 0, 0); |
Andrew Lunn | b35d322a | 2016-12-03 04:45:19 +0100 | [diff] [blame] | 2972 | if (err) |
| 2973 | return err; |
| 2974 | } |
| 2975 | |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2976 | if (chip->info->ops->port_disable_learn_limit) { |
| 2977 | err = chip->info->ops->port_disable_learn_limit(chip, port); |
| 2978 | if (err) |
| 2979 | return err; |
| 2980 | } |
| 2981 | |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2982 | if (chip->info->ops->port_disable_pri_override) { |
| 2983 | err = chip->info->ops->port_disable_pri_override(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2984 | if (err) |
| 2985 | return err; |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2986 | } |
Andrew Lunn | 2bbb33b | 2016-08-22 16:01:02 +0200 | [diff] [blame] | 2987 | |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2988 | if (chip->info->ops->port_tag_remap) { |
| 2989 | err = chip->info->ops->port_tag_remap(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2990 | if (err) |
| 2991 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2992 | } |
| 2993 | |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2994 | if (chip->info->ops->port_egress_rate_limiting) { |
| 2995 | err = chip->info->ops->port_egress_rate_limiting(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2996 | if (err) |
| 2997 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2998 | } |
| 2999 | |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3000 | if (chip->info->ops->port_setup_message_port) { |
| 3001 | err = chip->info->ops->port_setup_message_port(chip, port); |
| 3002 | if (err) |
| 3003 | return err; |
| 3004 | } |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 3005 | |
Vivien Didelot | 207afda | 2016-04-14 14:42:09 -0400 | [diff] [blame] | 3006 | /* Port based VLAN map: give each port the same default address |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 3007 | * database, and allow bidirectional communication between the |
| 3008 | * CPU and DSA port(s), and the other ports. |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 3009 | */ |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 3010 | err = mv88e6xxx_port_set_fid(chip, port, MV88E6XXX_FID_STANDALONE); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 3011 | if (err) |
| 3012 | return err; |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 3013 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 3014 | err = mv88e6xxx_port_vlan_map(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 3015 | if (err) |
| 3016 | return err; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 3017 | |
| 3018 | /* Default VLAN ID and priority: don't set a default VLAN |
| 3019 | * ID, and set the default packet priority to zero. |
| 3020 | */ |
Vivien Didelot | b7929fb | 2017-06-12 12:37:40 -0400 | [diff] [blame] | 3021 | return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0); |
Andrew Lunn | dbde9e6 | 2015-05-06 01:09:48 +0200 | [diff] [blame] | 3022 | } |
| 3023 | |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 3024 | static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port) |
| 3025 | { |
| 3026 | struct mv88e6xxx_chip *chip = ds->priv; |
| 3027 | |
| 3028 | if (chip->info->ops->port_set_jumbo_size) |
Andrew Lunn | b9c587f | 2021-09-26 19:41:26 +0200 | [diff] [blame] | 3029 | return 10240 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3030 | else if (chip->info->ops->set_max_frame_size) |
Andrew Lunn | b9c587f | 2021-09-26 19:41:26 +0200 | [diff] [blame] | 3031 | return 1632 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; |
| 3032 | return 1522 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 3033 | } |
| 3034 | |
| 3035 | static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu) |
| 3036 | { |
| 3037 | struct mv88e6xxx_chip *chip = ds->priv; |
| 3038 | int ret = 0; |
| 3039 | |
Andrew Lunn | b9c587f | 2021-09-26 19:41:26 +0200 | [diff] [blame] | 3040 | if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) |
| 3041 | new_mtu += EDSA_HLEN; |
| 3042 | |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 3043 | mv88e6xxx_reg_lock(chip); |
| 3044 | if (chip->info->ops->port_set_jumbo_size) |
| 3045 | ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu); |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3046 | else if (chip->info->ops->set_max_frame_size) |
| 3047 | ret = chip->info->ops->set_max_frame_size(chip, new_mtu); |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 3048 | else |
| 3049 | if (new_mtu > 1522) |
| 3050 | ret = -EINVAL; |
| 3051 | mv88e6xxx_reg_unlock(chip); |
| 3052 | |
| 3053 | return ret; |
| 3054 | } |
| 3055 | |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3056 | static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port, |
| 3057 | struct phy_device *phydev) |
| 3058 | { |
| 3059 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 3060 | int err; |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3061 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3062 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 3063 | err = mv88e6xxx_serdes_power(chip, port, true); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3064 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3065 | |
| 3066 | return err; |
| 3067 | } |
| 3068 | |
Andrew Lunn | 75104db | 2019-02-24 20:44:43 +0100 | [diff] [blame] | 3069 | static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port) |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3070 | { |
| 3071 | struct mv88e6xxx_chip *chip = ds->priv; |
| 3072 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3073 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 3074 | if (mv88e6xxx_serdes_power(chip, port, false)) |
| 3075 | dev_err(chip->dev, "failed to power off SERDES\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3076 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3077 | } |
| 3078 | |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 3079 | static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds, |
| 3080 | unsigned int ageing_time) |
| 3081 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3082 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 3083 | int err; |
| 3084 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3085 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 720c634 | 2017-03-11 16:12:48 -0500 | [diff] [blame] | 3086 | err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3087 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 3088 | |
| 3089 | return err; |
| 3090 | } |
| 3091 | |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 3092 | static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 3093 | { |
| 3094 | int err; |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 3095 | |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3096 | /* Initialize the statistics unit */ |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 3097 | if (chip->info->ops->stats_set_histogram) { |
| 3098 | err = chip->info->ops->stats_set_histogram(chip); |
| 3099 | if (err) |
| 3100 | return err; |
| 3101 | } |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3102 | |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3103 | return mv88e6xxx_g1_stats_clear(chip); |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3104 | } |
| 3105 | |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3106 | /* Check if the errata has already been applied. */ |
| 3107 | static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip) |
| 3108 | { |
| 3109 | int port; |
| 3110 | int err; |
| 3111 | u16 val; |
| 3112 | |
| 3113 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Marek Behún | 6090701 | 2019-08-26 23:31:51 +0200 | [diff] [blame] | 3114 | err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val); |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3115 | if (err) { |
| 3116 | dev_err(chip->dev, |
| 3117 | "Error reading hidden register: %d\n", err); |
| 3118 | return false; |
| 3119 | } |
| 3120 | if (val != 0x01c0) |
| 3121 | return false; |
| 3122 | } |
| 3123 | |
| 3124 | return true; |
| 3125 | } |
| 3126 | |
| 3127 | /* The 6390 copper ports have an errata which require poking magic |
| 3128 | * values into undocumented hidden registers and then performing a |
| 3129 | * software reset. |
| 3130 | */ |
| 3131 | static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip) |
| 3132 | { |
| 3133 | int port; |
| 3134 | int err; |
| 3135 | |
| 3136 | if (mv88e6390_setup_errata_applied(chip)) |
| 3137 | return 0; |
| 3138 | |
| 3139 | /* Set the ports into blocking mode */ |
| 3140 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 3141 | err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED); |
| 3142 | if (err) |
| 3143 | return err; |
| 3144 | } |
| 3145 | |
| 3146 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Marek Behún | 6090701 | 2019-08-26 23:31:51 +0200 | [diff] [blame] | 3147 | err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0); |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3148 | if (err) |
| 3149 | return err; |
| 3150 | } |
| 3151 | |
| 3152 | return mv88e6xxx_software_reset(chip); |
| 3153 | } |
| 3154 | |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3155 | static void mv88e6xxx_teardown(struct dsa_switch *ds) |
| 3156 | { |
| 3157 | mv88e6xxx_teardown_devlink_params(ds); |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3158 | dsa_devlink_resources_unregister(ds); |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 3159 | mv88e6xxx_teardown_devlink_regions_global(ds); |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3160 | } |
| 3161 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3162 | static int mv88e6xxx_setup(struct dsa_switch *ds) |
Guenter Roeck | acdaffc | 2015-03-26 18:36:28 -0700 | [diff] [blame] | 3163 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3164 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3165 | u8 cmode; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3166 | int err; |
Vivien Didelot | a1a6a4d | 2016-05-09 13:22:56 -0400 | [diff] [blame] | 3167 | int i; |
| 3168 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3169 | chip->ds = ds; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3170 | ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3171 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 3172 | /* Since virtual bridges are mapped in the PVT, the number we support |
| 3173 | * depends on the physical switch topology. We need to let DSA figure |
| 3174 | * that out and therefore we cannot set this at dsa_register_switch() |
| 3175 | * time. |
| 3176 | */ |
| 3177 | if (mv88e6xxx_has_pvt(chip)) |
| 3178 | ds->num_fwd_offloading_bridges = MV88E6XXX_MAX_PVT_SWITCHES - |
| 3179 | ds->dst->last_switch - 1; |
| 3180 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3181 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3182 | |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3183 | if (chip->info->ops->setup_errata) { |
| 3184 | err = chip->info->ops->setup_errata(chip); |
| 3185 | if (err) |
| 3186 | goto unlock; |
| 3187 | } |
| 3188 | |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3189 | /* Cache the cmode of each port. */ |
| 3190 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
| 3191 | if (chip->info->ops->port_get_cmode) { |
| 3192 | err = chip->info->ops->port_get_cmode(chip, i, &cmode); |
| 3193 | if (err) |
Dan Carpenter | e29129f | 2018-08-14 12:09:05 +0300 | [diff] [blame] | 3194 | goto unlock; |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3195 | |
| 3196 | chip->ports[i].cmode = cmode; |
| 3197 | } |
| 3198 | } |
| 3199 | |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 3200 | err = mv88e6xxx_vtu_setup(chip); |
| 3201 | if (err) |
| 3202 | goto unlock; |
| 3203 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3204 | /* Setup Switch Port Registers */ |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 3205 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
Vivien Didelot | b759f52 | 2019-08-19 16:00:52 -0400 | [diff] [blame] | 3206 | if (dsa_is_unused_port(ds, i)) |
| 3207 | continue; |
| 3208 | |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 3209 | /* Prevent the use of an invalid port. */ |
Vivien Didelot | b759f52 | 2019-08-19 16:00:52 -0400 | [diff] [blame] | 3210 | if (mv88e6xxx_is_invalid_port(chip, i)) { |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 3211 | dev_err(chip->dev, "port %d is invalid\n", i); |
| 3212 | err = -EINVAL; |
| 3213 | goto unlock; |
| 3214 | } |
| 3215 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3216 | err = mv88e6xxx_setup_port(chip, i); |
| 3217 | if (err) |
| 3218 | goto unlock; |
| 3219 | } |
| 3220 | |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3221 | err = mv88e6xxx_irl_setup(chip); |
| 3222 | if (err) |
| 3223 | goto unlock; |
| 3224 | |
Vivien Didelot | 04a69a1 | 2017-10-13 14:18:05 -0400 | [diff] [blame] | 3225 | err = mv88e6xxx_mac_setup(chip); |
| 3226 | if (err) |
| 3227 | goto unlock; |
| 3228 | |
Vivien Didelot | 1b17aed | 2017-05-26 18:03:05 -0400 | [diff] [blame] | 3229 | err = mv88e6xxx_phy_setup(chip); |
| 3230 | if (err) |
| 3231 | goto unlock; |
| 3232 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 3233 | err = mv88e6xxx_pvt_setup(chip); |
| 3234 | if (err) |
| 3235 | goto unlock; |
| 3236 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 3237 | err = mv88e6xxx_atu_setup(chip); |
| 3238 | if (err) |
| 3239 | goto unlock; |
| 3240 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 3241 | err = mv88e6xxx_broadcast_setup(chip, 0); |
| 3242 | if (err) |
| 3243 | goto unlock; |
| 3244 | |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3245 | err = mv88e6xxx_pot_setup(chip); |
| 3246 | if (err) |
| 3247 | goto unlock; |
| 3248 | |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3249 | err = mv88e6xxx_rmu_setup(chip); |
| 3250 | if (err) |
| 3251 | goto unlock; |
| 3252 | |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3253 | err = mv88e6xxx_rsvd2cpu_setup(chip); |
| 3254 | if (err) |
| 3255 | goto unlock; |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 3256 | |
Vivien Didelot | b28f872 | 2018-04-26 21:56:44 -0400 | [diff] [blame] | 3257 | err = mv88e6xxx_trunk_setup(chip); |
| 3258 | if (err) |
| 3259 | goto unlock; |
| 3260 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 3261 | err = mv88e6xxx_devmap_setup(chip); |
| 3262 | if (err) |
| 3263 | goto unlock; |
| 3264 | |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3265 | err = mv88e6xxx_pri_setup(chip); |
| 3266 | if (err) |
| 3267 | goto unlock; |
| 3268 | |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 3269 | /* Setup PTP Hardware Clock and timestamping */ |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3270 | if (chip->info->ptp_support) { |
| 3271 | err = mv88e6xxx_ptp_setup(chip); |
| 3272 | if (err) |
| 3273 | goto unlock; |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 3274 | |
| 3275 | err = mv88e6xxx_hwtstamp_setup(chip); |
| 3276 | if (err) |
| 3277 | goto unlock; |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3278 | } |
| 3279 | |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 3280 | err = mv88e6xxx_stats_setup(chip); |
| 3281 | if (err) |
| 3282 | goto unlock; |
| 3283 | |
Vivien Didelot | 6b17e86 | 2015-08-13 12:52:18 -0400 | [diff] [blame] | 3284 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3285 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | db687a5 | 2015-06-20 21:31:29 +0200 | [diff] [blame] | 3286 | |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3287 | if (err) |
| 3288 | return err; |
| 3289 | |
| 3290 | /* Have to be called without holding the register lock, since |
| 3291 | * they take the devlink lock, and we later take the locks in |
| 3292 | * the reverse order when getting/setting parameters or |
| 3293 | * resource occupancy. |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3294 | */ |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3295 | err = mv88e6xxx_setup_devlink_resources(ds); |
| 3296 | if (err) |
| 3297 | return err; |
| 3298 | |
| 3299 | err = mv88e6xxx_setup_devlink_params(ds); |
| 3300 | if (err) |
Andrew Lunn | bfb2554 | 2020-09-18 21:11:07 +0200 | [diff] [blame] | 3301 | goto out_resources; |
| 3302 | |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 3303 | err = mv88e6xxx_setup_devlink_regions_global(ds); |
Andrew Lunn | bfb2554 | 2020-09-18 21:11:07 +0200 | [diff] [blame] | 3304 | if (err) |
| 3305 | goto out_params; |
| 3306 | |
| 3307 | return 0; |
| 3308 | |
| 3309 | out_params: |
| 3310 | mv88e6xxx_teardown_devlink_params(ds); |
| 3311 | out_resources: |
| 3312 | dsa_devlink_resources_unregister(ds); |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3313 | |
| 3314 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 3315 | } |
| 3316 | |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 3317 | static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port) |
| 3318 | { |
| 3319 | return mv88e6xxx_setup_devlink_regions_port(ds, port); |
| 3320 | } |
| 3321 | |
| 3322 | static void mv88e6xxx_port_teardown(struct dsa_switch *ds, int port) |
| 3323 | { |
| 3324 | mv88e6xxx_teardown_devlink_regions_port(ds, port); |
| 3325 | } |
| 3326 | |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3327 | /* prod_id for switch families which do not have a PHY model number */ |
| 3328 | static const u16 family_prod_id_table[] = { |
| 3329 | [MV88E6XXX_FAMILY_6341] = MV88E6XXX_PORT_SWITCH_ID_PROD_6341, |
| 3330 | [MV88E6XXX_FAMILY_6390] = MV88E6XXX_PORT_SWITCH_ID_PROD_6390, |
Marek Behún | c5d015b | 2021-04-20 09:54:02 +0200 | [diff] [blame] | 3331 | [MV88E6XXX_FAMILY_6393] = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X, |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3332 | }; |
| 3333 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3334 | 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] | 3335 | { |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3336 | struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; |
| 3337 | struct mv88e6xxx_chip *chip = mdio_bus->chip; |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3338 | u16 prod_id; |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3339 | u16 val; |
| 3340 | int err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3341 | |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3342 | if (!chip->info->ops->phy_read) |
| 3343 | return -EOPNOTSUPP; |
| 3344 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3345 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3346 | err = chip->info->ops->phy_read(chip, bus, phy, reg, &val); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3347 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3348 | |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3349 | /* Some internal PHYs don't have a model number. */ |
| 3350 | if (reg == MII_PHYSID2 && !(val & 0x3f0) && |
| 3351 | chip->info->family < ARRAY_SIZE(family_prod_id_table)) { |
| 3352 | prod_id = family_prod_id_table[chip->info->family]; |
| 3353 | if (prod_id) |
| 3354 | val |= prod_id >> 4; |
Andrew Lunn | da9f330 | 2017-02-01 03:40:05 +0100 | [diff] [blame] | 3355 | } |
| 3356 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3357 | return err ? err : val; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3358 | } |
| 3359 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3360 | 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] | 3361 | { |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3362 | struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; |
| 3363 | struct mv88e6xxx_chip *chip = mdio_bus->chip; |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3364 | int err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3365 | |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3366 | if (!chip->info->ops->phy_write) |
| 3367 | return -EOPNOTSUPP; |
| 3368 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3369 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3370 | err = chip->info->ops->phy_write(chip, bus, phy, reg, val); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3371 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3372 | |
| 3373 | return err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3374 | } |
| 3375 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3376 | static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip, |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3377 | struct device_node *np, |
| 3378 | bool external) |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3379 | { |
| 3380 | static int index; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3381 | struct mv88e6xxx_mdio_bus *mdio_bus; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3382 | struct mii_bus *bus; |
| 3383 | int err; |
| 3384 | |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3385 | if (external) { |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3386 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3387 | err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3388 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3389 | |
| 3390 | if (err) |
| 3391 | return err; |
| 3392 | } |
| 3393 | |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3394 | bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus)); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3395 | if (!bus) |
| 3396 | return -ENOMEM; |
| 3397 | |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3398 | mdio_bus = bus->priv; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3399 | mdio_bus->bus = bus; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3400 | mdio_bus->chip = chip; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3401 | INIT_LIST_HEAD(&mdio_bus->list); |
| 3402 | mdio_bus->external = external; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3403 | |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3404 | if (np) { |
| 3405 | bus->name = np->full_name; |
Rob Herring | f7ce910 | 2017-07-18 16:43:19 -0500 | [diff] [blame] | 3406 | snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3407 | } else { |
| 3408 | bus->name = "mv88e6xxx SMI"; |
| 3409 | snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++); |
| 3410 | } |
| 3411 | |
| 3412 | bus->read = mv88e6xxx_mdio_read; |
| 3413 | bus->write = mv88e6xxx_mdio_write; |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3414 | bus->parent = chip->dev; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3415 | |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3416 | if (!external) { |
| 3417 | err = mv88e6xxx_g2_irq_mdio_setup(chip, bus); |
| 3418 | if (err) |
| 3419 | return err; |
| 3420 | } |
| 3421 | |
Florian Fainelli | 00e798c | 2018-05-15 16:56:19 -0700 | [diff] [blame] | 3422 | err = of_mdiobus_register(bus, np); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3423 | if (err) { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3424 | dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err); |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3425 | mv88e6xxx_g2_irq_mdio_free(chip, bus); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3426 | return err; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3427 | } |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3428 | |
| 3429 | if (external) |
| 3430 | list_add_tail(&mdio_bus->list, &chip->mdios); |
| 3431 | else |
| 3432 | list_add(&mdio_bus->list, &chip->mdios); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3433 | |
| 3434 | return 0; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3435 | } |
| 3436 | |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3437 | static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip) |
| 3438 | |
| 3439 | { |
| 3440 | struct mv88e6xxx_mdio_bus *mdio_bus; |
| 3441 | struct mii_bus *bus; |
| 3442 | |
| 3443 | list_for_each_entry(mdio_bus, &chip->mdios, list) { |
| 3444 | bus = mdio_bus->bus; |
| 3445 | |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3446 | if (!mdio_bus->external) |
| 3447 | mv88e6xxx_g2_irq_mdio_free(chip, bus); |
| 3448 | |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3449 | mdiobus_unregister(bus); |
| 3450 | } |
| 3451 | } |
| 3452 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3453 | static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, |
| 3454 | struct device_node *np) |
| 3455 | { |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3456 | struct device_node *child; |
| 3457 | int err; |
| 3458 | |
| 3459 | /* Always register one mdio bus for the internal/default mdio |
| 3460 | * bus. This maybe represented in the device tree, but is |
| 3461 | * optional. |
| 3462 | */ |
| 3463 | child = of_get_child_by_name(np, "mdio"); |
| 3464 | err = mv88e6xxx_mdio_register(chip, child, false); |
| 3465 | if (err) |
| 3466 | return err; |
| 3467 | |
| 3468 | /* Walk the device tree, and see if there are any other nodes |
| 3469 | * which say they are compatible with the external mdio |
| 3470 | * bus. |
| 3471 | */ |
| 3472 | for_each_available_child_of_node(np, child) { |
Andrew Lunn | ceb96fa | 2020-09-01 04:32:57 +0200 | [diff] [blame] | 3473 | if (of_device_is_compatible( |
| 3474 | child, "marvell,mv88e6xxx-mdio-external")) { |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3475 | err = mv88e6xxx_mdio_register(chip, child, true); |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3476 | if (err) { |
| 3477 | mv88e6xxx_mdios_unregister(chip); |
Nishka Dasgupta | 78e4204 | 2019-07-23 16:13:07 +0530 | [diff] [blame] | 3478 | of_node_put(child); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3479 | return err; |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3480 | } |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3481 | } |
| 3482 | } |
| 3483 | |
| 3484 | return 0; |
| 3485 | } |
| 3486 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3487 | static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds) |
| 3488 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3489 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3490 | |
| 3491 | return chip->eeprom_len; |
| 3492 | } |
| 3493 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3494 | static int mv88e6xxx_get_eeprom(struct dsa_switch *ds, |
| 3495 | struct ethtool_eeprom *eeprom, u8 *data) |
| 3496 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3497 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3498 | int err; |
| 3499 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3500 | if (!chip->info->ops->get_eeprom) |
| 3501 | return -EOPNOTSUPP; |
| 3502 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3503 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3504 | err = chip->info->ops->get_eeprom(chip, eeprom, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3505 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3506 | |
| 3507 | if (err) |
| 3508 | return err; |
| 3509 | |
| 3510 | eeprom->magic = 0xc3ec4951; |
| 3511 | |
| 3512 | return 0; |
| 3513 | } |
| 3514 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3515 | static int mv88e6xxx_set_eeprom(struct dsa_switch *ds, |
| 3516 | struct ethtool_eeprom *eeprom, u8 *data) |
| 3517 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3518 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3519 | int err; |
| 3520 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3521 | if (!chip->info->ops->set_eeprom) |
| 3522 | return -EOPNOTSUPP; |
| 3523 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3524 | if (eeprom->magic != 0xc3ec4951) |
| 3525 | return -EINVAL; |
| 3526 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3527 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3528 | err = chip->info->ops->set_eeprom(chip, eeprom, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3529 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3530 | |
| 3531 | return err; |
| 3532 | } |
| 3533 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3534 | static const struct mv88e6xxx_ops mv88e6085_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3535 | /* MV88E6XXX_FAMILY_6097 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3536 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3537 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3538 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3539 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3540 | .phy_read = mv88e6185_phy_ppu_read, |
| 3541 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3542 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3543 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3544 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3545 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3546 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3547 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3548 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3549 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3550 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3551 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3552 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3553 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3554 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3555 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3556 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3557 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3558 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3559 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3560 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3561 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3562 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3563 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3564 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3565 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3566 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 3567 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3568 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3569 | .rmu_disable = mv88e6085_g1_rmu_disable, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3570 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3571 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3572 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3573 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3574 | }; |
| 3575 | |
| 3576 | static const struct mv88e6xxx_ops mv88e6095_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3577 | /* MV88E6XXX_FAMILY_6095 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3578 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3579 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3580 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3581 | .phy_read = mv88e6185_phy_ppu_read, |
| 3582 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3583 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3584 | .port_sync_link = mv88e6185_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3585 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3586 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3587 | .port_set_ucast_flood = mv88e6185_port_set_forward_unknown, |
| 3588 | .port_set_mcast_flood = mv88e6185_port_set_default_forward, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 3589 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3590 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3591 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3592 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3593 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3594 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3595 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3596 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3597 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Chris Packham | f5be107 | 2020-11-24 17:34:38 +1300 | [diff] [blame] | 3598 | .serdes_power = mv88e6185_serdes_power, |
| 3599 | .serdes_get_lane = mv88e6185_serdes_get_lane, |
| 3600 | .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3601 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 3602 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3603 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3604 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3605 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3606 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3607 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3608 | }; |
| 3609 | |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3610 | static const struct mv88e6xxx_ops mv88e6097_ops = { |
Stefan Eichenberger | 15da3cc | 2016-11-25 09:41:30 +0100 | [diff] [blame] | 3611 | /* MV88E6XXX_FAMILY_6097 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3612 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3613 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3614 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3615 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3616 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3617 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3618 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3619 | .port_sync_link = mv88e6185_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3620 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3621 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3622 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3623 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3624 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3625 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3626 | .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3627 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3628 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3629 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3630 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3631 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3632 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3633 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3634 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3635 | .stats_get_strings = mv88e6095_stats_get_strings, |
| 3636 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3637 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3638 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Volodymyr Bendiuga | 91eaa47 | 2017-02-14 11:29:30 +0100 | [diff] [blame] | 3639 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3640 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Chris Packham | f5be107 | 2020-11-24 17:34:38 +1300 | [diff] [blame] | 3641 | .serdes_power = mv88e6185_serdes_power, |
| 3642 | .serdes_get_lane = mv88e6185_serdes_get_lane, |
| 3643 | .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, |
Chris Packham | 5c19bc8 | 2020-11-24 17:34:39 +1300 | [diff] [blame] | 3644 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
| 3645 | .serdes_irq_enable = mv88e6097_serdes_irq_enable, |
| 3646 | .serdes_irq_status = mv88e6097_serdes_irq_status, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3647 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3648 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3649 | .rmu_disable = mv88e6085_g1_rmu_disable, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3650 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3651 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3652 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3653 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3654 | }; |
| 3655 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3656 | static const struct mv88e6xxx_ops mv88e6123_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3657 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3658 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3659 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3660 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3661 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | ec8378b | 2017-06-02 23:22:45 +0200 | [diff] [blame] | 3662 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3663 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3664 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3665 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3666 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3667 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3668 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3669 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3670 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3671 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3672 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3673 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 0ac64c3 | 2017-06-02 23:22:46 +0200 | [diff] [blame] | 3674 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3675 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3676 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3677 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3678 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3679 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3680 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3681 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3682 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3683 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3684 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3685 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3686 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3687 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3688 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3689 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3690 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3691 | }; |
| 3692 | |
| 3693 | static const struct mv88e6xxx_ops mv88e6131_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3694 | /* MV88E6XXX_FAMILY_6185 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3695 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3696 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3697 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3698 | .phy_read = mv88e6185_phy_ppu_read, |
| 3699 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3700 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3701 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3702 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3703 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3704 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3705 | .port_set_ucast_flood = mv88e6185_port_set_forward_unknown, |
| 3706 | .port_set_mcast_flood = mv88e6185_port_set_default_forward, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3707 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 3708 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3709 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3710 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3711 | .port_pause_limit = mv88e6097_port_pause_limit, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 3712 | .port_set_pause = mv88e6185_port_set_pause, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3713 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3714 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3715 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3716 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3717 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3718 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3719 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3720 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3721 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3722 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3723 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3724 | .ppu_enable = mv88e6185_g1_ppu_enable, |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 3725 | .set_cascade_port = mv88e6185_g1_set_cascade_port, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3726 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3727 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3728 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3729 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3730 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3731 | }; |
| 3732 | |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3733 | static const struct mv88e6xxx_ops mv88e6141_ops = { |
| 3734 | /* MV88E6XXX_FAMILY_6341 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3735 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3736 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3737 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3738 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3739 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 3740 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3741 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3742 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3743 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3744 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3745 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3746 | .port_set_speed_duplex = mv88e6341_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 3747 | .port_max_speed_mode = mv88e6341_port_max_speed_mode, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3748 | .port_tag_remap = mv88e6095_port_tag_remap, |
Marek Behún | 7da467d | 2021-07-01 00:22:26 +0200 | [diff] [blame] | 3749 | .port_set_policy = mv88e6352_port_set_policy, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3750 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3751 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3752 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3753 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3754 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3755 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3756 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3757 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 3758 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3759 | .port_get_cmode = mv88e6352_port_get_cmode, |
Marek Behún | 7a3007d | 2019-08-26 23:31:55 +0200 | [diff] [blame] | 3760 | .port_set_cmode = mv88e6341_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3761 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3762 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Marek Behún | 11527f3 | 2021-07-01 00:22:27 +0200 | [diff] [blame] | 3763 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3764 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3765 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 3766 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3767 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 3768 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3769 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 3770 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3771 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3772 | .reset = mv88e6352_g1_reset, |
Marek Behún | 3709488 | 2021-07-01 00:22:28 +0200 | [diff] [blame] | 3773 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Marek Behún | c07fff3 | 2021-07-01 00:22:29 +0200 | [diff] [blame] | 3774 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3775 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3776 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3777 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 3778 | .serdes_power = mv88e6390_serdes_power, |
| 3779 | .serdes_get_lane = mv88e6341_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 3780 | /* Check status register pause & lpa register */ |
| 3781 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 3782 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 3783 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 3784 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 3785 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 3786 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 3787 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3788 | .gpio_ops = &mv88e6352_gpio_ops, |
Marek Behún | a03b98d | 2021-07-01 00:22:30 +0200 | [diff] [blame] | 3789 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 3790 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 3791 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Marek Behún | 953b0dc | 2021-07-01 00:22:31 +0200 | [diff] [blame] | 3792 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 3793 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 3794 | .phylink_validate = mv88e6341_phylink_validate, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3795 | }; |
| 3796 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3797 | static const struct mv88e6xxx_ops mv88e6161_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3798 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3799 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3800 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3801 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3802 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | ec8378b | 2017-06-02 23:22:45 +0200 | [diff] [blame] | 3803 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3804 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3805 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3806 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3807 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3808 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3809 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3810 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3811 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3812 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3813 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3814 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3815 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3816 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3817 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3818 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a6da21b | 2019-03-01 23:43:39 +0100 | [diff] [blame] | 3819 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3820 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3821 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3822 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3823 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3824 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3825 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3826 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3827 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3828 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3829 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3830 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3831 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3832 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3833 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | a469a61 | 2018-07-18 22:38:21 +0200 | [diff] [blame] | 3834 | .avb_ops = &mv88e6165_avb_ops, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 3835 | .ptp_ops = &mv88e6165_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3836 | .phylink_validate = mv88e6185_phylink_validate, |
Andrew Lunn | fe23036 | 2021-09-26 19:41:24 +0200 | [diff] [blame] | 3837 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3838 | }; |
| 3839 | |
| 3840 | static const struct mv88e6xxx_ops mv88e6165_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3841 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3842 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3843 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3844 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3845 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | efb3e74 | 2017-01-24 14:53:47 +0100 | [diff] [blame] | 3846 | .phy_read = mv88e6165_phy_read, |
| 3847 | .phy_write = mv88e6165_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3848 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3849 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3850 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3851 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3852 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3853 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3854 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3855 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3856 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3857 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3858 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3859 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3860 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3861 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3862 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3863 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3864 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3865 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3866 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3867 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3868 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3869 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | a469a61 | 2018-07-18 22:38:21 +0200 | [diff] [blame] | 3870 | .avb_ops = &mv88e6165_avb_ops, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 3871 | .ptp_ops = &mv88e6165_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3872 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3873 | }; |
| 3874 | |
| 3875 | static const struct mv88e6xxx_ops mv88e6171_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3876 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3877 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3878 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3879 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3880 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3881 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3882 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3883 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3884 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 3885 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3886 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3887 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3888 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3889 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3890 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3891 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3892 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3893 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3894 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3895 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3896 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3897 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3898 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3899 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3900 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3901 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3902 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3903 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3904 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3905 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3906 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3907 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3908 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3909 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3910 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3911 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3912 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3913 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3914 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3915 | }; |
| 3916 | |
| 3917 | static const struct mv88e6xxx_ops mv88e6172_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3918 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3919 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3920 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3921 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3922 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 3923 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3924 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3925 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3926 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3927 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3928 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 3929 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3930 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3931 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 3932 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3933 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3934 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3935 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3936 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3937 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3938 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3939 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3940 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3941 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3942 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3943 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3944 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3945 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3946 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3947 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3948 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3949 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3950 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3951 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3952 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3953 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3954 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3955 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3956 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3957 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3958 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3959 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 3960 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 3961 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 3962 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 3963 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 3964 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 3965 | .serdes_power = mv88e6352_serdes_power, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 3966 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 3967 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3968 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3969 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3970 | }; |
| 3971 | |
| 3972 | static const struct mv88e6xxx_ops mv88e6175_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3973 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3974 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3975 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3976 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3977 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3978 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3979 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3980 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3981 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 3982 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3983 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3984 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3985 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3986 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3987 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3988 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3989 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3990 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3991 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3992 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3993 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3994 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3995 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3996 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3997 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3998 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3999 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4000 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4001 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4002 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4003 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4004 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4005 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4006 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4007 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4008 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4009 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4010 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4011 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4012 | }; |
| 4013 | |
| 4014 | static const struct mv88e6xxx_ops mv88e6176_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4015 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4016 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4017 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4018 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4019 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4020 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4021 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4022 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4023 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4024 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4025 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4026 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4027 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4028 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4029 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4030 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4031 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4032 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4033 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4034 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4035 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4036 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4037 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4038 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4039 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4040 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4041 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4042 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4043 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4044 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4045 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4046 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4047 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4048 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4049 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4050 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4051 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4052 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4053 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4054 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4055 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4056 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4057 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4058 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 4059 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 4060 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 4061 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4062 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4063 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4064 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4065 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4066 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4067 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4068 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4069 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4070 | }; |
| 4071 | |
| 4072 | static const struct mv88e6xxx_ops mv88e6185_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4073 | /* MV88E6XXX_FAMILY_6185 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4074 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4075 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4076 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 4077 | .phy_read = mv88e6185_phy_ppu_read, |
| 4078 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4079 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4080 | .port_sync_link = mv88e6185_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4081 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4082 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4083 | .port_set_ucast_flood = mv88e6185_port_set_forward_unknown, |
| 4084 | .port_set_mcast_flood = mv88e6185_port_set_default_forward, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4085 | .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 4086 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 4087 | .port_set_pause = mv88e6185_port_set_pause, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4088 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4089 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4090 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4091 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4092 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4093 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4094 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4095 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4096 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4097 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4098 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Chris Packham | f5be107 | 2020-11-24 17:34:38 +1300 | [diff] [blame] | 4099 | .serdes_power = mv88e6185_serdes_power, |
| 4100 | .serdes_get_lane = mv88e6185_serdes_get_lane, |
| 4101 | .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 4102 | .set_cascade_port = mv88e6185_g1_set_cascade_port, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 4103 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 4104 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4105 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4106 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4107 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4108 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 4109 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4110 | }; |
| 4111 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4112 | static const struct mv88e6xxx_ops mv88e6190_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4113 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4114 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4115 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4116 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4117 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4118 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4119 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4120 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4121 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4122 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4123 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4124 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4125 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4126 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4127 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4128 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4129 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4130 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4131 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Chris Packham | e8b34c6 | 2020-07-24 11:21:21 +1200 | [diff] [blame] | 4132 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4133 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4134 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4135 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4136 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4137 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4138 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4139 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4140 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4141 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4142 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4143 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4144 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4145 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4146 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4147 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4148 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4149 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4150 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4151 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4152 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4153 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4154 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4155 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4156 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4157 | /* Check status register pause & lpa register */ |
| 4158 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4159 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4160 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4161 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4162 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4163 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4164 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4165 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4166 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4167 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4168 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4169 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4170 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4171 | }; |
| 4172 | |
| 4173 | static const struct mv88e6xxx_ops mv88e6190x_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4174 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4175 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4176 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4177 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4178 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4179 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4180 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4181 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4182 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4183 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4184 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4185 | .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4186 | .port_max_speed_mode = mv88e6390x_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4187 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4188 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4189 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4190 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4191 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4192 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Chris Packham | e8b34c6 | 2020-07-24 11:21:21 +1200 | [diff] [blame] | 4193 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4194 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4195 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4196 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4197 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4198 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4199 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4200 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4201 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4202 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4203 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4204 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4205 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4206 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4207 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4208 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4209 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4210 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4211 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4212 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4213 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4214 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4215 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4216 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4217 | .serdes_get_lane = mv88e6390x_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4218 | /* Check status register pause & lpa register */ |
| 4219 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4220 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4221 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4222 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4223 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4224 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4225 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4226 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4227 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4228 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4229 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4230 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4231 | .phylink_validate = mv88e6390x_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4232 | }; |
| 4233 | |
| 4234 | static const struct mv88e6xxx_ops mv88e6191_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4235 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4236 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4237 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4238 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4239 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4240 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4241 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4242 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4243 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4244 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4245 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4246 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4247 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4248 | .port_tag_remap = mv88e6390_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4249 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4250 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4251 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4252 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4253 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4254 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4255 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4256 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4257 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4258 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4259 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4260 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4261 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4262 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4263 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4264 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4265 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4266 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4267 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4268 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4269 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4270 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4271 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4272 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4273 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4274 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4275 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4276 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4277 | /* Check status register pause & lpa register */ |
| 4278 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4279 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4280 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4281 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4282 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4283 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4284 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4285 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4286 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4287 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4288 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4289 | .avb_ops = &mv88e6390_avb_ops, |
| 4290 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4291 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4292 | }; |
| 4293 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4294 | static const struct mv88e6xxx_ops mv88e6240_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4295 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4296 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4297 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4298 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4299 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4300 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4301 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4302 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4303 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4304 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4305 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4306 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4307 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4308 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4309 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4310 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4311 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4312 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4313 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4314 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4315 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4316 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4317 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4318 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4319 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4320 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4321 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4322 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4323 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4324 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4325 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4326 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4327 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4328 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4329 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4330 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4331 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4332 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4333 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4334 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4335 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4336 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4337 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4338 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 4339 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 4340 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 4341 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4342 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4343 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4344 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4345 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4346 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4347 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4348 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4349 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4350 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4351 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4352 | }; |
| 4353 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4354 | static const struct mv88e6xxx_ops mv88e6250_ops = { |
| 4355 | /* MV88E6XXX_FAMILY_6250 */ |
| 4356 | .ieee_pri_map = mv88e6250_g1_ieee_pri_map, |
| 4357 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
| 4358 | .irl_init_all = mv88e6352_g2_irl_init_all, |
| 4359 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4360 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
| 4361 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4362 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4363 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4364 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4365 | .port_sync_link = mv88e6xxx_port_sync_link, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4366 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4367 | .port_set_speed_duplex = mv88e6250_port_set_speed_duplex, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4368 | .port_tag_remap = mv88e6095_port_tag_remap, |
| 4369 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4370 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4371 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4372 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
| 4373 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
| 4374 | .port_pause_limit = mv88e6097_port_pause_limit, |
| 4375 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4376 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
| 4377 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
| 4378 | .stats_get_sset_count = mv88e6250_stats_get_sset_count, |
| 4379 | .stats_get_strings = mv88e6250_stats_get_strings, |
| 4380 | .stats_get_stats = mv88e6250_stats_get_stats, |
| 4381 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4382 | .set_egress_port = mv88e6095_g1_set_egress_port, |
| 4383 | .watchdog_ops = &mv88e6250_watchdog_ops, |
| 4384 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
| 4385 | .pot_clear = mv88e6xxx_g2_pot_clear, |
| 4386 | .reset = mv88e6250_g1_reset, |
Rasmus Villemoes | 67c9ed1 | 2021-01-25 16:04:48 +0100 | [diff] [blame] | 4387 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Rasmus Villemoes | b28f3f3 | 2021-01-25 16:04:49 +0100 | [diff] [blame] | 4388 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 4389 | .avb_ops = &mv88e6352_avb_ops, |
| 4390 | .ptp_ops = &mv88e6250_ptp_ops, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4391 | .phylink_validate = mv88e6065_phylink_validate, |
| 4392 | }; |
| 4393 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4394 | static const struct mv88e6xxx_ops mv88e6290_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4395 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4396 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4397 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4398 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4399 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4400 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4401 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4402 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4403 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4404 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4405 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4406 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4407 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4408 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4409 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4410 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4411 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4412 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4413 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4414 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4415 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4416 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4417 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4418 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4419 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4420 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4421 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4422 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4423 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4424 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4425 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4426 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4427 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4428 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4429 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4430 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4431 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4432 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4433 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4434 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4435 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4436 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4437 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4438 | /* Check status register pause & lpa register */ |
| 4439 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4440 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4441 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4442 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4443 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4444 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4445 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4446 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4447 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4448 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4449 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4450 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4451 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4452 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4453 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4454 | }; |
| 4455 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4456 | static const struct mv88e6xxx_ops mv88e6320_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4457 | /* MV88E6XXX_FAMILY_6320 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4458 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4459 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4460 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4461 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4462 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4463 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4464 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4465 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4466 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4467 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4468 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4469 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4470 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4471 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4472 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4473 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4474 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4475 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4476 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4477 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4478 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4479 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4480 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4481 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4482 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4483 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4484 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4485 | .stats_get_stats = mv88e6320_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4486 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4487 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | 9c7f37e | 2018-12-19 18:28:54 +0100 | [diff] [blame] | 4488 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4489 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4490 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4491 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4492 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4493 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4494 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4495 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4496 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4497 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4498 | }; |
| 4499 | |
| 4500 | static const struct mv88e6xxx_ops mv88e6321_ops = { |
Vivien Didelot | bd80720 | 2017-07-17 13:03:37 -0400 | [diff] [blame] | 4501 | /* MV88E6XXX_FAMILY_6320 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4502 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4503 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4504 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4505 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4506 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4507 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4508 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4509 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4510 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4511 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4512 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4513 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4514 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4515 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4516 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4517 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4518 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4519 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4520 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4521 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4522 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4523 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4524 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4525 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4526 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4527 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4528 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4529 | .stats_get_stats = mv88e6320_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4530 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4531 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | 9c7f37e | 2018-12-19 18:28:54 +0100 | [diff] [blame] | 4532 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4533 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4534 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4535 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4536 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4537 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4538 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4539 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4540 | }; |
| 4541 | |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4542 | static const struct mv88e6xxx_ops mv88e6341_ops = { |
| 4543 | /* MV88E6XXX_FAMILY_6341 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4544 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4545 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4546 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4547 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4548 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 4549 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4550 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4551 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4552 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4553 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4554 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4555 | .port_set_speed_duplex = mv88e6341_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4556 | .port_max_speed_mode = mv88e6341_port_max_speed_mode, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4557 | .port_tag_remap = mv88e6095_port_tag_remap, |
Marek Behún | 7da467d | 2021-07-01 00:22:26 +0200 | [diff] [blame] | 4558 | .port_set_policy = mv88e6352_port_set_policy, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4559 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4560 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4561 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4562 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4563 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4564 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4565 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4566 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 4567 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4568 | .port_get_cmode = mv88e6352_port_get_cmode, |
Marek Behún | 7a3007d | 2019-08-26 23:31:55 +0200 | [diff] [blame] | 4569 | .port_set_cmode = mv88e6341_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4570 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4571 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Marek Behún | 11527f3 | 2021-07-01 00:22:27 +0200 | [diff] [blame] | 4572 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4573 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4574 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 4575 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4576 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4577 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4578 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 4579 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4580 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4581 | .reset = mv88e6352_g1_reset, |
Marek Behún | 3709488 | 2021-07-01 00:22:28 +0200 | [diff] [blame] | 4582 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Marek Behún | c07fff3 | 2021-07-01 00:22:29 +0200 | [diff] [blame] | 4583 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4584 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4585 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4586 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4587 | .serdes_power = mv88e6390_serdes_power, |
| 4588 | .serdes_get_lane = mv88e6341_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4589 | /* Check status register pause & lpa register */ |
| 4590 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4591 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4592 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4593 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4594 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4595 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4596 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4597 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4598 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4599 | .ptp_ops = &mv88e6352_ptp_ops, |
Marek Behún | a03b98d | 2021-07-01 00:22:30 +0200 | [diff] [blame] | 4600 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4601 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4602 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Marek Behún | 953b0dc | 2021-07-01 00:22:31 +0200 | [diff] [blame] | 4603 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4604 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 4605 | .phylink_validate = mv88e6341_phylink_validate, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4606 | }; |
| 4607 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4608 | static const struct mv88e6xxx_ops mv88e6350_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4609 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4610 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4611 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4612 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4613 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4614 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4615 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4616 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4617 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 4618 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4619 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4620 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4621 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4622 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4623 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4624 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4625 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4626 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4627 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4628 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4629 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4630 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4631 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4632 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4633 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4634 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4635 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4636 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4637 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4638 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4639 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4640 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4641 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4642 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4643 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4644 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4645 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4646 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4647 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4648 | }; |
| 4649 | |
| 4650 | static const struct mv88e6xxx_ops mv88e6351_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4651 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4652 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4653 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4654 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4655 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4656 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4657 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4658 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4659 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 4660 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4661 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4662 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4663 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4664 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4665 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4666 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4667 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4668 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4669 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4670 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4671 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4672 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4673 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4674 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4675 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4676 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4677 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4678 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4679 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4680 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4681 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4682 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4683 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4684 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4685 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4686 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4687 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4688 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4689 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4690 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4691 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4692 | }; |
| 4693 | |
| 4694 | static const struct mv88e6xxx_ops mv88e6352_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4695 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4696 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4697 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4698 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4699 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4700 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4701 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4702 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4703 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4704 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4705 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4706 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4707 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4708 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4709 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4710 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4711 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4712 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4713 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4714 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4715 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4716 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4717 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4718 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4719 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4720 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4721 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4722 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4723 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4724 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4725 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4726 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4727 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4728 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4729 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4730 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4731 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4732 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4733 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4734 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4735 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4736 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4737 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4738 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 4739 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 4740 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 4741 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4742 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4743 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4744 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4745 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4746 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4747 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4748 | .ptp_ops = &mv88e6352_ptp_ops, |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 4749 | .serdes_get_sset_count = mv88e6352_serdes_get_sset_count, |
| 4750 | .serdes_get_strings = mv88e6352_serdes_get_strings, |
| 4751 | .serdes_get_stats = mv88e6352_serdes_get_stats, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4752 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4753 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4754 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4755 | }; |
| 4756 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4757 | static const struct mv88e6xxx_ops mv88e6390_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4758 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4759 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4760 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4761 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4762 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4763 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4764 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4765 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4766 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4767 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4768 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4769 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4770 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4771 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4772 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4773 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4774 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4775 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4776 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4777 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4778 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4779 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4780 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4781 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4782 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4783 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4784 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4785 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4786 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4787 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4788 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4789 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4790 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4791 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4792 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4793 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4794 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4795 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4796 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4797 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4798 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4799 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4800 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4801 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4802 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4803 | /* Check status register pause & lpa register */ |
| 4804 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4805 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4806 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4807 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4808 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4809 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4810 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4811 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4812 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4813 | .ptp_ops = &mv88e6352_ptp_ops, |
Nikita Yushchenko | 0df9528 | 2019-12-25 08:22:38 +0300 | [diff] [blame] | 4814 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4815 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4816 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4817 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4818 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4819 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4820 | }; |
| 4821 | |
| 4822 | static const struct mv88e6xxx_ops mv88e6390x_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4823 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4824 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4825 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4826 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4827 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4828 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4829 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4830 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4831 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4832 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4833 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4834 | .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4835 | .port_max_speed_mode = mv88e6390x_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4836 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4837 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4838 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4839 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4840 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4841 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4842 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4843 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4844 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4845 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4846 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4847 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | b3dce4d | 2018-11-11 00:32:14 +0100 | [diff] [blame] | 4848 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4849 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4850 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4851 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4852 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4853 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4854 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4855 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4856 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4857 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4858 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4859 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4860 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4861 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4862 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4863 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4864 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4865 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4866 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4867 | .serdes_get_lane = mv88e6390x_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4868 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4869 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4870 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4871 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4872 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4873 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4874 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4875 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4876 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4877 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4878 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4879 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4880 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4881 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4882 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4883 | .phylink_validate = mv88e6390x_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4884 | }; |
| 4885 | |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 4886 | static const struct mv88e6xxx_ops mv88e6393x_ops = { |
| 4887 | /* MV88E6XXX_FAMILY_6393 */ |
| 4888 | .setup_errata = mv88e6393x_serdes_setup_errata, |
| 4889 | .irl_init_all = mv88e6390_g2_irl_init_all, |
| 4890 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4891 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 4892 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4893 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4894 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4895 | .port_set_link = mv88e6xxx_port_set_link, |
| 4896 | .port_sync_link = mv88e6xxx_port_sync_link, |
| 4897 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 4898 | .port_set_speed_duplex = mv88e6393x_port_set_speed_duplex, |
| 4899 | .port_max_speed_mode = mv88e6393x_port_max_speed_mode, |
| 4900 | .port_tag_remap = mv88e6390_port_tag_remap, |
Marek Behún | 6584b26 | 2021-03-17 14:46:43 +0100 | [diff] [blame] | 4901 | .port_set_policy = mv88e6393x_port_set_policy, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 4902 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
| 4903 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4904 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
| 4905 | .port_set_ether_type = mv88e6393x_port_set_ether_type, |
| 4906 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
| 4907 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
| 4908 | .port_pause_limit = mv88e6390_port_pause_limit, |
| 4909 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 4910 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
| 4911 | .port_get_cmode = mv88e6352_port_get_cmode, |
| 4912 | .port_set_cmode = mv88e6393x_port_set_cmode, |
| 4913 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
| 4914 | .port_set_upstream_port = mv88e6393x_port_set_upstream_port, |
| 4915 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
| 4916 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
| 4917 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4918 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 4919 | .stats_get_stats = mv88e6390_stats_get_stats, |
| 4920 | /* .set_cpu_port is missing because this family does not support a global |
| 4921 | * CPU port, only per port CPU port which is set via |
| 4922 | * .port_set_upstream_port method. |
| 4923 | */ |
| 4924 | .set_egress_port = mv88e6393x_set_egress_port, |
| 4925 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 4926 | .mgmt_rsvd2cpu = mv88e6393x_port_mgmt_rsvd2cpu, |
| 4927 | .pot_clear = mv88e6xxx_g2_pot_clear, |
| 4928 | .reset = mv88e6352_g1_reset, |
| 4929 | .rmu_disable = mv88e6390_g1_rmu_disable, |
| 4930 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4931 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
| 4932 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4933 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
| 4934 | .serdes_power = mv88e6393x_serdes_power, |
| 4935 | .serdes_get_lane = mv88e6393x_serdes_get_lane, |
| 4936 | .serdes_pcs_get_state = mv88e6393x_serdes_pcs_get_state, |
| 4937 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4938 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4939 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
| 4940 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
| 4941 | .serdes_irq_enable = mv88e6393x_serdes_irq_enable, |
| 4942 | .serdes_irq_status = mv88e6393x_serdes_irq_status, |
| 4943 | /* TODO: serdes stats */ |
| 4944 | .gpio_ops = &mv88e6352_gpio_ops, |
| 4945 | .avb_ops = &mv88e6390_avb_ops, |
| 4946 | .ptp_ops = &mv88e6352_ptp_ops, |
| 4947 | .phylink_validate = mv88e6393x_phylink_validate, |
| 4948 | }; |
| 4949 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4950 | static const struct mv88e6xxx_info mv88e6xxx_table[] = { |
| 4951 | [MV88E6085] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4952 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4953 | .family = MV88E6XXX_FAMILY_6097, |
| 4954 | .name = "Marvell 88E6085", |
| 4955 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4956 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4957 | .num_ports = 10, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4958 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4959 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4960 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4961 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4962 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4963 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4964 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4965 | .g1_irqs = 8, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4966 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4967 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4968 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4969 | .multi_chip = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4970 | .ops = &mv88e6085_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4971 | }, |
| 4972 | |
| 4973 | [MV88E6095] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4974 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4975 | .family = MV88E6XXX_FAMILY_6095, |
| 4976 | .name = "Marvell 88E6095/88E6095F", |
| 4977 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4978 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4979 | .num_ports = 11, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4980 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4981 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4982 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4983 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4984 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4985 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4986 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4987 | .g1_irqs = 8, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4988 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4989 | .multi_chip = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4990 | .ops = &mv88e6095_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4991 | }, |
| 4992 | |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4993 | [MV88E6097] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4994 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4995 | .family = MV88E6XXX_FAMILY_6097, |
| 4996 | .name = "Marvell 88E6097/88E6097F", |
| 4997 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4998 | .num_macs = 8192, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4999 | .num_ports = 11, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5000 | .num_internal_phys = 8, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5001 | .max_vid = 4095, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5002 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5003 | .phy_base_addr = 0x0, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5004 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5005 | .global2_addr = 0x1c, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5006 | .age_time_coeff = 15000, |
Stefan Eichenberger | c534178 | 2016-11-25 09:41:29 +0100 | [diff] [blame] | 5007 | .g1_irqs = 8, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5008 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5009 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5010 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5011 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5012 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5013 | .ops = &mv88e6097_ops, |
| 5014 | }, |
| 5015 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5016 | [MV88E6123] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5017 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5018 | .family = MV88E6XXX_FAMILY_6165, |
| 5019 | .name = "Marvell 88E6123", |
| 5020 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5021 | .num_macs = 1024, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5022 | .num_ports = 3, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5023 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5024 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5025 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5026 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5027 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5028 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5029 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5030 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5031 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5032 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5033 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5034 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5035 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5036 | .ops = &mv88e6123_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5037 | }, |
| 5038 | |
| 5039 | [MV88E6131] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5040 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5041 | .family = MV88E6XXX_FAMILY_6185, |
| 5042 | .name = "Marvell 88E6131", |
| 5043 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5044 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5045 | .num_ports = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5046 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5047 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5048 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5049 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5050 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5051 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5052 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5053 | .g1_irqs = 9, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5054 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5055 | .multi_chip = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5056 | .ops = &mv88e6131_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5057 | }, |
| 5058 | |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5059 | [MV88E6141] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5060 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5061 | .family = MV88E6XXX_FAMILY_6341, |
Uwe Kleine-König | 79a68b2 | 2018-03-20 10:44:40 +0100 | [diff] [blame] | 5062 | .name = "Marvell 88E6141", |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5063 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5064 | .num_macs = 2048, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5065 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5066 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5067 | .num_gpio = 11, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5068 | .max_vid = 4095, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5069 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5070 | .phy_base_addr = 0x10, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5071 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5072 | .global2_addr = 0x1c, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5073 | .age_time_coeff = 3750, |
| 5074 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | adfccf1 | 2018-03-17 20:32:03 +0100 | [diff] [blame] | 5075 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5076 | .g2_irqs = 10, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5077 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5078 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5079 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5080 | .ops = &mv88e6141_ops, |
| 5081 | }, |
| 5082 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5083 | [MV88E6161] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5084 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5085 | .family = MV88E6XXX_FAMILY_6165, |
| 5086 | .name = "Marvell 88E6161", |
| 5087 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5088 | .num_macs = 1024, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5089 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5090 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5091 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5092 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5093 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5094 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5095 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5096 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5097 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5098 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5099 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5100 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5101 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5102 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 5103 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5104 | .ops = &mv88e6161_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5105 | }, |
| 5106 | |
| 5107 | [MV88E6165] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5108 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5109 | .family = MV88E6XXX_FAMILY_6165, |
| 5110 | .name = "Marvell 88E6165", |
| 5111 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5112 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5113 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5114 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5115 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5116 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5117 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5118 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5119 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5120 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5121 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5122 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5123 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5124 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5125 | .multi_chip = true, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 5126 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5127 | .ops = &mv88e6165_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5128 | }, |
| 5129 | |
| 5130 | [MV88E6171] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5131 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5132 | .family = MV88E6XXX_FAMILY_6351, |
| 5133 | .name = "Marvell 88E6171", |
| 5134 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5135 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5136 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5137 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5138 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5139 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5140 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5141 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5142 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5143 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5144 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5145 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5146 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5147 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5148 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5149 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5150 | .ops = &mv88e6171_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5151 | }, |
| 5152 | |
| 5153 | [MV88E6172] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5154 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5155 | .family = MV88E6XXX_FAMILY_6352, |
| 5156 | .name = "Marvell 88E6172", |
| 5157 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5158 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5159 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5160 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5161 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5162 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5163 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5164 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5165 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5166 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5167 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5168 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5169 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5170 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5171 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5172 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5173 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5174 | .ops = &mv88e6172_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5175 | }, |
| 5176 | |
| 5177 | [MV88E6175] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5178 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5179 | .family = MV88E6XXX_FAMILY_6351, |
| 5180 | .name = "Marvell 88E6175", |
| 5181 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5182 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5183 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5184 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5185 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5186 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5187 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5188 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5189 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5190 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5191 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5192 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5193 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5194 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5195 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5196 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5197 | .ops = &mv88e6175_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5198 | }, |
| 5199 | |
| 5200 | [MV88E6176] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5201 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5202 | .family = MV88E6XXX_FAMILY_6352, |
| 5203 | .name = "Marvell 88E6176", |
| 5204 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5205 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5206 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5207 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5208 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5209 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5210 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5211 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5212 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5213 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5214 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5215 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5216 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5217 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5218 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5219 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5220 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5221 | .ops = &mv88e6176_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5222 | }, |
| 5223 | |
| 5224 | [MV88E6185] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5225 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5226 | .family = MV88E6XXX_FAMILY_6185, |
| 5227 | .name = "Marvell 88E6185", |
| 5228 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5229 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5230 | .num_ports = 10, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5231 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5232 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5233 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5234 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5235 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5236 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5237 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5238 | .g1_irqs = 8, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5239 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5240 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5241 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5242 | .ops = &mv88e6185_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5243 | }, |
| 5244 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5245 | [MV88E6190] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5246 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5247 | .family = MV88E6XXX_FAMILY_6390, |
| 5248 | .name = "Marvell 88E6190", |
| 5249 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5250 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5251 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5252 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5253 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5254 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5255 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5256 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5257 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5258 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5259 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5260 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5261 | .g2_irqs = 14, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5262 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5263 | .multi_chip = true, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5264 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5265 | .ops = &mv88e6190_ops, |
| 5266 | }, |
| 5267 | |
| 5268 | [MV88E6190X] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5269 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5270 | .family = MV88E6XXX_FAMILY_6390, |
| 5271 | .name = "Marvell 88E6190X", |
| 5272 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5273 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5274 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5275 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5276 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5277 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5278 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5279 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5280 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5281 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5282 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5283 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5284 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5285 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5286 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5287 | .multi_chip = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5288 | .ops = &mv88e6190x_ops, |
| 5289 | }, |
| 5290 | |
| 5291 | [MV88E6191] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5292 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5293 | .family = MV88E6XXX_FAMILY_6390, |
| 5294 | .name = "Marvell 88E6191", |
| 5295 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5296 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5297 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5298 | .num_internal_phys = 9, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5299 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5300 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5301 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5302 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5303 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5304 | .age_time_coeff = 3750, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5305 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5306 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5307 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5308 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5309 | .multi_chip = true, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5310 | .ptp_support = true, |
Vivien Didelot | 2cf4cefb | 2017-03-28 13:50:34 -0400 | [diff] [blame] | 5311 | .ops = &mv88e6191_ops, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5312 | }, |
| 5313 | |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5314 | [MV88E6191X] = { |
| 5315 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191X, |
| 5316 | .family = MV88E6XXX_FAMILY_6393, |
| 5317 | .name = "Marvell 88E6191X", |
| 5318 | .num_databases = 4096, |
| 5319 | .num_ports = 11, /* 10 + Z80 */ |
| 5320 | .num_internal_phys = 9, |
| 5321 | .max_vid = 8191, |
| 5322 | .port_base_addr = 0x0, |
| 5323 | .phy_base_addr = 0x0, |
| 5324 | .global1_addr = 0x1b, |
| 5325 | .global2_addr = 0x1c, |
| 5326 | .age_time_coeff = 3750, |
| 5327 | .g1_irqs = 10, |
| 5328 | .g2_irqs = 14, |
| 5329 | .atu_move_port_mask = 0x1f, |
| 5330 | .pvt = true, |
| 5331 | .multi_chip = true, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5332 | .ptp_support = true, |
| 5333 | .ops = &mv88e6393x_ops, |
| 5334 | }, |
| 5335 | |
| 5336 | [MV88E6193X] = { |
| 5337 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6193X, |
| 5338 | .family = MV88E6XXX_FAMILY_6393, |
| 5339 | .name = "Marvell 88E6193X", |
| 5340 | .num_databases = 4096, |
| 5341 | .num_ports = 11, /* 10 + Z80 */ |
| 5342 | .num_internal_phys = 9, |
| 5343 | .max_vid = 8191, |
| 5344 | .port_base_addr = 0x0, |
| 5345 | .phy_base_addr = 0x0, |
| 5346 | .global1_addr = 0x1b, |
| 5347 | .global2_addr = 0x1c, |
| 5348 | .age_time_coeff = 3750, |
| 5349 | .g1_irqs = 10, |
| 5350 | .g2_irqs = 14, |
| 5351 | .atu_move_port_mask = 0x1f, |
| 5352 | .pvt = true, |
| 5353 | .multi_chip = true, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5354 | .ptp_support = true, |
| 5355 | .ops = &mv88e6393x_ops, |
| 5356 | }, |
| 5357 | |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5358 | [MV88E6220] = { |
| 5359 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220, |
| 5360 | .family = MV88E6XXX_FAMILY_6250, |
| 5361 | .name = "Marvell 88E6220", |
| 5362 | .num_databases = 64, |
| 5363 | |
| 5364 | /* Ports 2-4 are not routed to pins |
| 5365 | * => usable ports 0, 1, 5, 6 |
| 5366 | */ |
| 5367 | .num_ports = 7, |
| 5368 | .num_internal_phys = 2, |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 5369 | .invalid_port_mask = BIT(2) | BIT(3) | BIT(4), |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5370 | .max_vid = 4095, |
| 5371 | .port_base_addr = 0x08, |
| 5372 | .phy_base_addr = 0x00, |
| 5373 | .global1_addr = 0x0f, |
| 5374 | .global2_addr = 0x07, |
| 5375 | .age_time_coeff = 15000, |
| 5376 | .g1_irqs = 9, |
| 5377 | .g2_irqs = 10, |
| 5378 | .atu_move_port_mask = 0xf, |
| 5379 | .dual_chip = true, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 5380 | .ptp_support = true, |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5381 | .ops = &mv88e6250_ops, |
| 5382 | }, |
| 5383 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5384 | [MV88E6240] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5385 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5386 | .family = MV88E6XXX_FAMILY_6352, |
| 5387 | .name = "Marvell 88E6240", |
| 5388 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5389 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5390 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5391 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5392 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5393 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5394 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5395 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5396 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5397 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5398 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5399 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5400 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5401 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5402 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5403 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5404 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5405 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5406 | .ops = &mv88e6240_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5407 | }, |
| 5408 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 5409 | [MV88E6250] = { |
| 5410 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250, |
| 5411 | .family = MV88E6XXX_FAMILY_6250, |
| 5412 | .name = "Marvell 88E6250", |
| 5413 | .num_databases = 64, |
| 5414 | .num_ports = 7, |
| 5415 | .num_internal_phys = 5, |
| 5416 | .max_vid = 4095, |
| 5417 | .port_base_addr = 0x08, |
| 5418 | .phy_base_addr = 0x00, |
| 5419 | .global1_addr = 0x0f, |
| 5420 | .global2_addr = 0x07, |
| 5421 | .age_time_coeff = 15000, |
| 5422 | .g1_irqs = 9, |
| 5423 | .g2_irqs = 10, |
| 5424 | .atu_move_port_mask = 0xf, |
| 5425 | .dual_chip = true, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 5426 | .ptp_support = true, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 5427 | .ops = &mv88e6250_ops, |
| 5428 | }, |
| 5429 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5430 | [MV88E6290] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5431 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5432 | .family = MV88E6XXX_FAMILY_6390, |
| 5433 | .name = "Marvell 88E6290", |
| 5434 | .num_databases = 4096, |
| 5435 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5436 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5437 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5438 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5439 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5440 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5441 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5442 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5443 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5444 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5445 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5446 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5447 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5448 | .multi_chip = true, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5449 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5450 | .ops = &mv88e6290_ops, |
| 5451 | }, |
| 5452 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5453 | [MV88E6320] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5454 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5455 | .family = MV88E6XXX_FAMILY_6320, |
| 5456 | .name = "Marvell 88E6320", |
| 5457 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5458 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5459 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5460 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5461 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5462 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5463 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5464 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5465 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5466 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5467 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5468 | .g1_irqs = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5469 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5470 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5471 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5472 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5473 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5474 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5475 | .ops = &mv88e6320_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5476 | }, |
| 5477 | |
| 5478 | [MV88E6321] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5479 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5480 | .family = MV88E6XXX_FAMILY_6320, |
| 5481 | .name = "Marvell 88E6321", |
| 5482 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5483 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5484 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5485 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5486 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5487 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5488 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5489 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5490 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5491 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5492 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5493 | .g1_irqs = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5494 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5495 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5496 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5497 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5498 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5499 | .ops = &mv88e6321_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5500 | }, |
| 5501 | |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5502 | [MV88E6341] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5503 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5504 | .family = MV88E6XXX_FAMILY_6341, |
| 5505 | .name = "Marvell 88E6341", |
| 5506 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5507 | .num_macs = 2048, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5508 | .num_internal_phys = 5, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5509 | .num_ports = 6, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5510 | .num_gpio = 11, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5511 | .max_vid = 4095, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5512 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5513 | .phy_base_addr = 0x10, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5514 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5515 | .global2_addr = 0x1c, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5516 | .age_time_coeff = 3750, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5517 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | adfccf1 | 2018-03-17 20:32:03 +0100 | [diff] [blame] | 5518 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5519 | .g2_irqs = 10, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5520 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5521 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5522 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5523 | .ptp_support = true, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5524 | .ops = &mv88e6341_ops, |
| 5525 | }, |
| 5526 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5527 | [MV88E6350] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5528 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5529 | .family = MV88E6XXX_FAMILY_6351, |
| 5530 | .name = "Marvell 88E6350", |
| 5531 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5532 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5533 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5534 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5535 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5536 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5537 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5538 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5539 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5540 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5541 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5542 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5543 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5544 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5545 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5546 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5547 | .ops = &mv88e6350_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5548 | }, |
| 5549 | |
| 5550 | [MV88E6351] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5551 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5552 | .family = MV88E6XXX_FAMILY_6351, |
| 5553 | .name = "Marvell 88E6351", |
| 5554 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5555 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5556 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5557 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5558 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5559 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5560 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5561 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5562 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5563 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5564 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5565 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5566 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5567 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5568 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5569 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5570 | .ops = &mv88e6351_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5571 | }, |
| 5572 | |
| 5573 | [MV88E6352] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5574 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5575 | .family = MV88E6XXX_FAMILY_6352, |
| 5576 | .name = "Marvell 88E6352", |
| 5577 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5578 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5579 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5580 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5581 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5582 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5583 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5584 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5585 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5586 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5587 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5588 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5589 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5590 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5591 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5592 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5593 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5594 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5595 | .ops = &mv88e6352_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5596 | }, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5597 | [MV88E6390] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5598 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5599 | .family = MV88E6XXX_FAMILY_6390, |
| 5600 | .name = "Marvell 88E6390", |
| 5601 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5602 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5603 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5604 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5605 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5606 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5607 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5608 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5609 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5610 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5611 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5612 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5613 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5614 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5615 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5616 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5617 | .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5618 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5619 | .ops = &mv88e6390_ops, |
| 5620 | }, |
| 5621 | [MV88E6390X] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5622 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5623 | .family = MV88E6XXX_FAMILY_6390, |
| 5624 | .name = "Marvell 88E6390X", |
| 5625 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5626 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5627 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5628 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5629 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5630 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5631 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5632 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5633 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5634 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5635 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5636 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5637 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5638 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5639 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5640 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5641 | .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5642 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5643 | .ops = &mv88e6390x_ops, |
| 5644 | }, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5645 | |
| 5646 | [MV88E6393X] = { |
| 5647 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X, |
| 5648 | .family = MV88E6XXX_FAMILY_6393, |
| 5649 | .name = "Marvell 88E6393X", |
| 5650 | .num_databases = 4096, |
| 5651 | .num_ports = 11, /* 10 + Z80 */ |
| 5652 | .num_internal_phys = 9, |
| 5653 | .max_vid = 8191, |
| 5654 | .port_base_addr = 0x0, |
| 5655 | .phy_base_addr = 0x0, |
| 5656 | .global1_addr = 0x1b, |
| 5657 | .global2_addr = 0x1c, |
| 5658 | .age_time_coeff = 3750, |
| 5659 | .g1_irqs = 10, |
| 5660 | .g2_irqs = 14, |
| 5661 | .atu_move_port_mask = 0x1f, |
| 5662 | .pvt = true, |
| 5663 | .multi_chip = true, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5664 | .ptp_support = true, |
| 5665 | .ops = &mv88e6393x_ops, |
| 5666 | }, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5667 | }; |
| 5668 | |
Vivien Didelot | 5f7c036 | 2016-06-20 13:14:04 -0400 | [diff] [blame] | 5669 | static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num) |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5670 | { |
Vivien Didelot | a439c06 | 2016-04-17 13:23:58 -0400 | [diff] [blame] | 5671 | int i; |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5672 | |
Vivien Didelot | 5f7c036 | 2016-06-20 13:14:04 -0400 | [diff] [blame] | 5673 | for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i) |
| 5674 | if (mv88e6xxx_table[i].prod_num == prod_num) |
| 5675 | return &mv88e6xxx_table[i]; |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5676 | |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5677 | return NULL; |
| 5678 | } |
| 5679 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5680 | static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip) |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5681 | { |
| 5682 | const struct mv88e6xxx_info *info; |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 5683 | unsigned int prod_num, rev; |
| 5684 | u16 id; |
| 5685 | int err; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5686 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5687 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5688 | err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5689 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 5690 | if (err) |
| 5691 | return err; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5692 | |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5693 | prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK; |
| 5694 | rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5695 | |
| 5696 | info = mv88e6xxx_lookup_info(prod_num); |
| 5697 | if (!info) |
| 5698 | return -ENODEV; |
| 5699 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 5700 | /* Update the compatible info with the probed one */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5701 | chip->info = info; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5702 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5703 | dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n", |
| 5704 | chip->info->prod_num, chip->info->name, rev); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5705 | |
| 5706 | return 0; |
| 5707 | } |
| 5708 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5709 | static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5710 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5711 | struct mv88e6xxx_chip *chip; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5712 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5713 | chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); |
| 5714 | if (!chip) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5715 | return NULL; |
| 5716 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5717 | chip->dev = dev; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5718 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5719 | mutex_init(&chip->reg_lock); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 5720 | INIT_LIST_HEAD(&chip->mdios); |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 5721 | idr_init(&chip->policies); |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5722 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5723 | return chip; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5724 | } |
| 5725 | |
Florian Fainelli | 5ed4e3e | 2017-11-10 15:22:52 -0800 | [diff] [blame] | 5726 | 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] | 5727 | int port, |
| 5728 | enum dsa_tag_protocol m) |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 5729 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5730 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 2bbb33b | 2016-08-22 16:01:02 +0200 | [diff] [blame] | 5731 | |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5732 | return chip->tag_protocol; |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 5733 | } |
| 5734 | |
Tobias Waldekranz | 9a99bef | 2021-04-20 20:53:08 +0200 | [diff] [blame] | 5735 | static int mv88e6xxx_change_tag_protocol(struct dsa_switch *ds, int port, |
| 5736 | enum dsa_tag_protocol proto) |
| 5737 | { |
| 5738 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5739 | enum dsa_tag_protocol old_protocol; |
| 5740 | int err; |
| 5741 | |
| 5742 | switch (proto) { |
| 5743 | case DSA_TAG_PROTO_EDSA: |
| 5744 | switch (chip->info->edsa_support) { |
| 5745 | case MV88E6XXX_EDSA_UNSUPPORTED: |
| 5746 | return -EPROTONOSUPPORT; |
| 5747 | case MV88E6XXX_EDSA_UNDOCUMENTED: |
| 5748 | dev_warn(chip->dev, "Relying on undocumented EDSA tagging behavior\n"); |
| 5749 | fallthrough; |
| 5750 | case MV88E6XXX_EDSA_SUPPORTED: |
| 5751 | break; |
| 5752 | } |
| 5753 | break; |
| 5754 | case DSA_TAG_PROTO_DSA: |
| 5755 | break; |
| 5756 | default: |
| 5757 | return -EPROTONOSUPPORT; |
| 5758 | } |
| 5759 | |
| 5760 | old_protocol = chip->tag_protocol; |
| 5761 | chip->tag_protocol = proto; |
| 5762 | |
| 5763 | mv88e6xxx_reg_lock(chip); |
| 5764 | err = mv88e6xxx_setup_port_mode(chip, port); |
| 5765 | mv88e6xxx_reg_unlock(chip); |
| 5766 | |
| 5767 | if (err) |
| 5768 | chip->tag_protocol = old_protocol; |
| 5769 | |
| 5770 | return err; |
| 5771 | } |
| 5772 | |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5773 | static int mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port, |
| 5774 | const struct switchdev_obj_port_mdb *mdb) |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5775 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5776 | struct mv88e6xxx_chip *chip = ds->priv; |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5777 | int err; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5778 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5779 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5780 | err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, |
| 5781 | MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5782 | mv88e6xxx_reg_unlock(chip); |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5783 | |
| 5784 | return err; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5785 | } |
| 5786 | |
| 5787 | static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port, |
| 5788 | const struct switchdev_obj_port_mdb *mdb) |
| 5789 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5790 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5791 | int err; |
| 5792 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5793 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 5794 | 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] | 5795 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5796 | |
| 5797 | return err; |
| 5798 | } |
| 5799 | |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5800 | static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port, |
| 5801 | struct dsa_mall_mirror_tc_entry *mirror, |
| 5802 | bool ingress) |
| 5803 | { |
| 5804 | enum mv88e6xxx_egress_direction direction = ingress ? |
| 5805 | MV88E6XXX_EGRESS_DIR_INGRESS : |
| 5806 | MV88E6XXX_EGRESS_DIR_EGRESS; |
| 5807 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5808 | bool other_mirrors = false; |
| 5809 | int i; |
| 5810 | int err; |
| 5811 | |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5812 | mutex_lock(&chip->reg_lock); |
| 5813 | if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) != |
| 5814 | mirror->to_local_port) { |
| 5815 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) |
| 5816 | other_mirrors |= ingress ? |
| 5817 | chip->ports[i].mirror_ingress : |
| 5818 | chip->ports[i].mirror_egress; |
| 5819 | |
| 5820 | /* Can't change egress port when other mirror is active */ |
| 5821 | if (other_mirrors) { |
| 5822 | err = -EBUSY; |
| 5823 | goto out; |
| 5824 | } |
| 5825 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 5826 | err = mv88e6xxx_set_egress_port(chip, direction, |
| 5827 | mirror->to_local_port); |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5828 | if (err) |
| 5829 | goto out; |
| 5830 | } |
| 5831 | |
| 5832 | err = mv88e6xxx_port_set_mirror(chip, port, direction, true); |
| 5833 | out: |
| 5834 | mutex_unlock(&chip->reg_lock); |
| 5835 | |
| 5836 | return err; |
| 5837 | } |
| 5838 | |
| 5839 | static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port, |
| 5840 | struct dsa_mall_mirror_tc_entry *mirror) |
| 5841 | { |
| 5842 | enum mv88e6xxx_egress_direction direction = mirror->ingress ? |
| 5843 | MV88E6XXX_EGRESS_DIR_INGRESS : |
| 5844 | MV88E6XXX_EGRESS_DIR_EGRESS; |
| 5845 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5846 | bool other_mirrors = false; |
| 5847 | int i; |
| 5848 | |
| 5849 | mutex_lock(&chip->reg_lock); |
| 5850 | if (mv88e6xxx_port_set_mirror(chip, port, direction, false)) |
| 5851 | dev_err(ds->dev, "p%d: failed to disable mirroring\n", port); |
| 5852 | |
| 5853 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) |
| 5854 | other_mirrors |= mirror->ingress ? |
| 5855 | chip->ports[i].mirror_ingress : |
| 5856 | chip->ports[i].mirror_egress; |
| 5857 | |
| 5858 | /* Reset egress port when no other mirror is active */ |
| 5859 | if (!other_mirrors) { |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 5860 | if (mv88e6xxx_set_egress_port(chip, direction, |
| 5861 | dsa_upstream_port(ds, port))) |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5862 | dev_err(ds->dev, "failed to set egress port\n"); |
| 5863 | } |
| 5864 | |
| 5865 | mutex_unlock(&chip->reg_lock); |
| 5866 | } |
| 5867 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5868 | static int mv88e6xxx_port_pre_bridge_flags(struct dsa_switch *ds, int port, |
| 5869 | struct switchdev_brport_flags flags, |
| 5870 | struct netlink_ext_ack *extack) |
| 5871 | { |
| 5872 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5873 | const struct mv88e6xxx_ops *ops; |
| 5874 | |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 5875 | if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | |
| 5876 | BR_BCAST_FLOOD)) |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5877 | return -EINVAL; |
| 5878 | |
| 5879 | ops = chip->info->ops; |
| 5880 | |
| 5881 | if ((flags.mask & BR_FLOOD) && !ops->port_set_ucast_flood) |
| 5882 | return -EINVAL; |
| 5883 | |
| 5884 | if ((flags.mask & BR_MCAST_FLOOD) && !ops->port_set_mcast_flood) |
| 5885 | return -EINVAL; |
| 5886 | |
| 5887 | return 0; |
| 5888 | } |
| 5889 | |
| 5890 | static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port, |
| 5891 | struct switchdev_brport_flags flags, |
| 5892 | struct netlink_ext_ack *extack) |
Russell King | 4f85901 | 2019-02-20 15:35:05 -0800 | [diff] [blame] | 5893 | { |
| 5894 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5895 | int err = -EOPNOTSUPP; |
| 5896 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5897 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5898 | |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 5899 | if (flags.mask & BR_LEARNING) { |
| 5900 | bool learning = !!(flags.val & BR_LEARNING); |
| 5901 | u16 pav = learning ? (1 << port) : 0; |
| 5902 | |
| 5903 | err = mv88e6xxx_port_set_assoc_vector(chip, port, pav); |
| 5904 | if (err) |
| 5905 | goto out; |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 5906 | } |
| 5907 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5908 | if (flags.mask & BR_FLOOD) { |
| 5909 | bool unicast = !!(flags.val & BR_FLOOD); |
| 5910 | |
| 5911 | err = chip->info->ops->port_set_ucast_flood(chip, port, |
| 5912 | unicast); |
| 5913 | if (err) |
| 5914 | goto out; |
| 5915 | } |
| 5916 | |
| 5917 | if (flags.mask & BR_MCAST_FLOOD) { |
| 5918 | bool multicast = !!(flags.val & BR_MCAST_FLOOD); |
| 5919 | |
| 5920 | err = chip->info->ops->port_set_mcast_flood(chip, port, |
| 5921 | multicast); |
| 5922 | if (err) |
| 5923 | goto out; |
| 5924 | } |
| 5925 | |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 5926 | if (flags.mask & BR_BCAST_FLOOD) { |
| 5927 | bool broadcast = !!(flags.val & BR_BCAST_FLOOD); |
| 5928 | |
| 5929 | err = mv88e6xxx_port_broadcast_sync(chip, port, broadcast); |
| 5930 | if (err) |
| 5931 | goto out; |
| 5932 | } |
| 5933 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5934 | out: |
| 5935 | mv88e6xxx_reg_unlock(chip); |
| 5936 | |
| 5937 | return err; |
| 5938 | } |
| 5939 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 5940 | static bool mv88e6xxx_lag_can_offload(struct dsa_switch *ds, |
| 5941 | struct net_device *lag, |
| 5942 | struct netdev_lag_upper_info *info) |
| 5943 | { |
Tobias Waldekranz | b80dc51 | 2021-01-15 13:52:59 +0100 | [diff] [blame] | 5944 | struct mv88e6xxx_chip *chip = ds->priv; |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 5945 | struct dsa_port *dp; |
| 5946 | int id, members = 0; |
| 5947 | |
Tobias Waldekranz | b80dc51 | 2021-01-15 13:52:59 +0100 | [diff] [blame] | 5948 | if (!mv88e6xxx_has_lag(chip)) |
| 5949 | return false; |
| 5950 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 5951 | id = dsa_lag_id(ds->dst, lag); |
| 5952 | if (id < 0 || id >= ds->num_lag_ids) |
| 5953 | return false; |
| 5954 | |
| 5955 | dsa_lag_foreach_port(dp, ds->dst, lag) |
| 5956 | /* Includes the port joining the LAG */ |
| 5957 | members++; |
| 5958 | |
| 5959 | if (members > 8) |
| 5960 | return false; |
| 5961 | |
| 5962 | /* We could potentially relax this to include active |
| 5963 | * backup in the future. |
| 5964 | */ |
| 5965 | if (info->tx_type != NETDEV_LAG_TX_TYPE_HASH) |
| 5966 | return false; |
| 5967 | |
| 5968 | /* Ideally we would also validate that the hash type matches |
| 5969 | * the hardware. Alas, this is always set to unknown on team |
| 5970 | * interfaces. |
| 5971 | */ |
| 5972 | return true; |
| 5973 | } |
| 5974 | |
| 5975 | static int mv88e6xxx_lag_sync_map(struct dsa_switch *ds, struct net_device *lag) |
| 5976 | { |
| 5977 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5978 | struct dsa_port *dp; |
| 5979 | u16 map = 0; |
| 5980 | int id; |
| 5981 | |
| 5982 | id = dsa_lag_id(ds->dst, lag); |
| 5983 | |
| 5984 | /* Build the map of all ports to distribute flows destined for |
| 5985 | * this LAG. This can be either a local user port, or a DSA |
| 5986 | * port if the LAG port is on a remote chip. |
| 5987 | */ |
| 5988 | dsa_lag_foreach_port(dp, ds->dst, lag) |
| 5989 | map |= BIT(dsa_towards_port(ds, dp->ds->index, dp->index)); |
| 5990 | |
| 5991 | return mv88e6xxx_g2_trunk_mapping_write(chip, id, map); |
| 5992 | } |
| 5993 | |
| 5994 | static const u8 mv88e6xxx_lag_mask_table[8][8] = { |
| 5995 | /* Row number corresponds to the number of active members in a |
| 5996 | * LAG. Each column states which of the eight hash buckets are |
| 5997 | * mapped to the column:th port in the LAG. |
| 5998 | * |
| 5999 | * Example: In a LAG with three active ports, the second port |
| 6000 | * ([2][1]) would be selected for traffic mapped to buckets |
| 6001 | * 3,4,5 (0x38). |
| 6002 | */ |
| 6003 | { 0xff, 0, 0, 0, 0, 0, 0, 0 }, |
| 6004 | { 0x0f, 0xf0, 0, 0, 0, 0, 0, 0 }, |
| 6005 | { 0x07, 0x38, 0xc0, 0, 0, 0, 0, 0 }, |
| 6006 | { 0x03, 0x0c, 0x30, 0xc0, 0, 0, 0, 0 }, |
| 6007 | { 0x03, 0x0c, 0x30, 0x40, 0x80, 0, 0, 0 }, |
| 6008 | { 0x03, 0x0c, 0x10, 0x20, 0x40, 0x80, 0, 0 }, |
| 6009 | { 0x03, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0 }, |
| 6010 | { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, |
| 6011 | }; |
| 6012 | |
| 6013 | static void mv88e6xxx_lag_set_port_mask(u16 *mask, int port, |
| 6014 | int num_tx, int nth) |
| 6015 | { |
| 6016 | u8 active = 0; |
| 6017 | int i; |
| 6018 | |
| 6019 | num_tx = num_tx <= 8 ? num_tx : 8; |
| 6020 | if (nth < num_tx) |
| 6021 | active = mv88e6xxx_lag_mask_table[num_tx - 1][nth]; |
| 6022 | |
| 6023 | for (i = 0; i < 8; i++) { |
| 6024 | if (BIT(i) & active) |
| 6025 | mask[i] |= BIT(port); |
| 6026 | } |
| 6027 | } |
| 6028 | |
| 6029 | static int mv88e6xxx_lag_sync_masks(struct dsa_switch *ds) |
| 6030 | { |
| 6031 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6032 | unsigned int id, num_tx; |
| 6033 | struct net_device *lag; |
| 6034 | struct dsa_port *dp; |
| 6035 | int i, err, nth; |
| 6036 | u16 mask[8]; |
| 6037 | u16 ivec; |
| 6038 | |
| 6039 | /* Assume no port is a member of any LAG. */ |
| 6040 | ivec = BIT(mv88e6xxx_num_ports(chip)) - 1; |
| 6041 | |
| 6042 | /* Disable all masks for ports that _are_ members of a LAG. */ |
| 6043 | list_for_each_entry(dp, &ds->dst->ports, list) { |
| 6044 | if (!dp->lag_dev || dp->ds != ds) |
| 6045 | continue; |
| 6046 | |
| 6047 | ivec &= ~BIT(dp->index); |
| 6048 | } |
| 6049 | |
| 6050 | for (i = 0; i < 8; i++) |
| 6051 | mask[i] = ivec; |
| 6052 | |
| 6053 | /* Enable the correct subset of masks for all LAG ports that |
| 6054 | * are in the Tx set. |
| 6055 | */ |
| 6056 | dsa_lags_foreach_id(id, ds->dst) { |
| 6057 | lag = dsa_lag_dev(ds->dst, id); |
| 6058 | if (!lag) |
| 6059 | continue; |
| 6060 | |
| 6061 | num_tx = 0; |
| 6062 | dsa_lag_foreach_port(dp, ds->dst, lag) { |
| 6063 | if (dp->lag_tx_enabled) |
| 6064 | num_tx++; |
| 6065 | } |
| 6066 | |
| 6067 | if (!num_tx) |
| 6068 | continue; |
| 6069 | |
| 6070 | nth = 0; |
| 6071 | dsa_lag_foreach_port(dp, ds->dst, lag) { |
| 6072 | if (!dp->lag_tx_enabled) |
| 6073 | continue; |
| 6074 | |
| 6075 | if (dp->ds == ds) |
| 6076 | mv88e6xxx_lag_set_port_mask(mask, dp->index, |
| 6077 | num_tx, nth); |
| 6078 | |
| 6079 | nth++; |
| 6080 | } |
| 6081 | } |
| 6082 | |
| 6083 | for (i = 0; i < 8; i++) { |
| 6084 | err = mv88e6xxx_g2_trunk_mask_write(chip, i, true, mask[i]); |
| 6085 | if (err) |
| 6086 | return err; |
| 6087 | } |
| 6088 | |
| 6089 | return 0; |
| 6090 | } |
| 6091 | |
| 6092 | static int mv88e6xxx_lag_sync_masks_map(struct dsa_switch *ds, |
| 6093 | struct net_device *lag) |
| 6094 | { |
| 6095 | int err; |
| 6096 | |
| 6097 | err = mv88e6xxx_lag_sync_masks(ds); |
| 6098 | |
| 6099 | if (!err) |
| 6100 | err = mv88e6xxx_lag_sync_map(ds, lag); |
| 6101 | |
| 6102 | return err; |
| 6103 | } |
| 6104 | |
| 6105 | static int mv88e6xxx_port_lag_change(struct dsa_switch *ds, int port) |
| 6106 | { |
| 6107 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6108 | int err; |
| 6109 | |
| 6110 | mv88e6xxx_reg_lock(chip); |
| 6111 | err = mv88e6xxx_lag_sync_masks(ds); |
| 6112 | mv88e6xxx_reg_unlock(chip); |
| 6113 | return err; |
| 6114 | } |
| 6115 | |
| 6116 | static int mv88e6xxx_port_lag_join(struct dsa_switch *ds, int port, |
| 6117 | struct net_device *lag, |
| 6118 | struct netdev_lag_upper_info *info) |
| 6119 | { |
| 6120 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6121 | int err, id; |
| 6122 | |
| 6123 | if (!mv88e6xxx_lag_can_offload(ds, lag, info)) |
| 6124 | return -EOPNOTSUPP; |
| 6125 | |
| 6126 | id = dsa_lag_id(ds->dst, lag); |
| 6127 | |
| 6128 | mv88e6xxx_reg_lock(chip); |
| 6129 | |
| 6130 | err = mv88e6xxx_port_set_trunk(chip, port, true, id); |
| 6131 | if (err) |
| 6132 | goto err_unlock; |
| 6133 | |
| 6134 | err = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6135 | if (err) |
| 6136 | goto err_clear_trunk; |
| 6137 | |
| 6138 | mv88e6xxx_reg_unlock(chip); |
| 6139 | return 0; |
| 6140 | |
| 6141 | err_clear_trunk: |
| 6142 | mv88e6xxx_port_set_trunk(chip, port, false, 0); |
| 6143 | err_unlock: |
| 6144 | mv88e6xxx_reg_unlock(chip); |
| 6145 | return err; |
| 6146 | } |
| 6147 | |
| 6148 | static int mv88e6xxx_port_lag_leave(struct dsa_switch *ds, int port, |
| 6149 | struct net_device *lag) |
| 6150 | { |
| 6151 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6152 | int err_sync, err_trunk; |
| 6153 | |
| 6154 | mv88e6xxx_reg_lock(chip); |
| 6155 | err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6156 | err_trunk = mv88e6xxx_port_set_trunk(chip, port, false, 0); |
| 6157 | mv88e6xxx_reg_unlock(chip); |
| 6158 | return err_sync ? : err_trunk; |
| 6159 | } |
| 6160 | |
| 6161 | static int mv88e6xxx_crosschip_lag_change(struct dsa_switch *ds, int sw_index, |
| 6162 | int port) |
| 6163 | { |
| 6164 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6165 | int err; |
| 6166 | |
| 6167 | mv88e6xxx_reg_lock(chip); |
| 6168 | err = mv88e6xxx_lag_sync_masks(ds); |
| 6169 | mv88e6xxx_reg_unlock(chip); |
| 6170 | return err; |
| 6171 | } |
| 6172 | |
| 6173 | static int mv88e6xxx_crosschip_lag_join(struct dsa_switch *ds, int sw_index, |
| 6174 | int port, struct net_device *lag, |
| 6175 | struct netdev_lag_upper_info *info) |
| 6176 | { |
| 6177 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6178 | int err; |
| 6179 | |
| 6180 | if (!mv88e6xxx_lag_can_offload(ds, lag, info)) |
| 6181 | return -EOPNOTSUPP; |
| 6182 | |
| 6183 | mv88e6xxx_reg_lock(chip); |
| 6184 | |
| 6185 | err = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6186 | if (err) |
| 6187 | goto unlock; |
| 6188 | |
| 6189 | err = mv88e6xxx_pvt_map(chip, sw_index, port); |
| 6190 | |
| 6191 | unlock: |
| 6192 | mv88e6xxx_reg_unlock(chip); |
| 6193 | return err; |
| 6194 | } |
| 6195 | |
| 6196 | static int mv88e6xxx_crosschip_lag_leave(struct dsa_switch *ds, int sw_index, |
| 6197 | int port, struct net_device *lag) |
| 6198 | { |
| 6199 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6200 | int err_sync, err_pvt; |
| 6201 | |
| 6202 | mv88e6xxx_reg_lock(chip); |
| 6203 | err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6204 | err_pvt = mv88e6xxx_pvt_map(chip, sw_index, port); |
| 6205 | mv88e6xxx_reg_unlock(chip); |
| 6206 | return err_sync ? : err_pvt; |
| 6207 | } |
| 6208 | |
Florian Fainelli | a82f67a | 2017-01-08 14:52:08 -0800 | [diff] [blame] | 6209 | static const struct dsa_switch_ops mv88e6xxx_switch_ops = { |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 6210 | .get_tag_protocol = mv88e6xxx_get_tag_protocol, |
Tobias Waldekranz | 9a99bef | 2021-04-20 20:53:08 +0200 | [diff] [blame] | 6211 | .change_tag_protocol = mv88e6xxx_change_tag_protocol, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6212 | .setup = mv88e6xxx_setup, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 6213 | .teardown = mv88e6xxx_teardown, |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 6214 | .port_setup = mv88e6xxx_port_setup, |
| 6215 | .port_teardown = mv88e6xxx_port_teardown, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 6216 | .phylink_validate = mv88e6xxx_validate, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 6217 | .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 6218 | .phylink_mac_config = mv88e6xxx_mac_config, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 6219 | .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 6220 | .phylink_mac_link_down = mv88e6xxx_mac_link_down, |
| 6221 | .phylink_mac_link_up = mv88e6xxx_mac_link_up, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6222 | .get_strings = mv88e6xxx_get_strings, |
| 6223 | .get_ethtool_stats = mv88e6xxx_get_ethtool_stats, |
| 6224 | .get_sset_count = mv88e6xxx_get_sset_count, |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 6225 | .port_enable = mv88e6xxx_port_enable, |
| 6226 | .port_disable = mv88e6xxx_port_disable, |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 6227 | .port_max_mtu = mv88e6xxx_get_max_mtu, |
| 6228 | .port_change_mtu = mv88e6xxx_change_mtu, |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 6229 | .get_mac_eee = mv88e6xxx_get_mac_eee, |
| 6230 | .set_mac_eee = mv88e6xxx_set_mac_eee, |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 6231 | .get_eeprom_len = mv88e6xxx_get_eeprom_len, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6232 | .get_eeprom = mv88e6xxx_get_eeprom, |
| 6233 | .set_eeprom = mv88e6xxx_set_eeprom, |
| 6234 | .get_regs_len = mv88e6xxx_get_regs_len, |
| 6235 | .get_regs = mv88e6xxx_get_regs, |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 6236 | .get_rxnfc = mv88e6xxx_get_rxnfc, |
| 6237 | .set_rxnfc = mv88e6xxx_set_rxnfc, |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 6238 | .set_ageing_time = mv88e6xxx_set_ageing_time, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6239 | .port_bridge_join = mv88e6xxx_port_bridge_join, |
| 6240 | .port_bridge_leave = mv88e6xxx_port_bridge_leave, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 6241 | .port_pre_bridge_flags = mv88e6xxx_port_pre_bridge_flags, |
| 6242 | .port_bridge_flags = mv88e6xxx_port_bridge_flags, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6243 | .port_stp_state_set = mv88e6xxx_port_stp_state_set, |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 6244 | .port_fast_age = mv88e6xxx_port_fast_age, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6245 | .port_vlan_filtering = mv88e6xxx_port_vlan_filtering, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6246 | .port_vlan_add = mv88e6xxx_port_vlan_add, |
| 6247 | .port_vlan_del = mv88e6xxx_port_vlan_del, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6248 | .port_fdb_add = mv88e6xxx_port_fdb_add, |
| 6249 | .port_fdb_del = mv88e6xxx_port_fdb_del, |
| 6250 | .port_fdb_dump = mv88e6xxx_port_fdb_dump, |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 6251 | .port_mdb_add = mv88e6xxx_port_mdb_add, |
| 6252 | .port_mdb_del = mv88e6xxx_port_mdb_del, |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 6253 | .port_mirror_add = mv88e6xxx_port_mirror_add, |
| 6254 | .port_mirror_del = mv88e6xxx_port_mirror_del, |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 6255 | .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join, |
| 6256 | .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave, |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 6257 | .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set, |
| 6258 | .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get, |
| 6259 | .port_txtstamp = mv88e6xxx_port_txtstamp, |
| 6260 | .port_rxtstamp = mv88e6xxx_port_rxtstamp, |
| 6261 | .get_ts_info = mv88e6xxx_get_ts_info, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 6262 | .devlink_param_get = mv88e6xxx_devlink_param_get, |
| 6263 | .devlink_param_set = mv88e6xxx_devlink_param_set, |
Andrew Lunn | 9315730 | 2020-09-18 21:11:09 +0200 | [diff] [blame] | 6264 | .devlink_info_get = mv88e6xxx_devlink_info_get, |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 6265 | .port_lag_change = mv88e6xxx_port_lag_change, |
| 6266 | .port_lag_join = mv88e6xxx_port_lag_join, |
| 6267 | .port_lag_leave = mv88e6xxx_port_lag_leave, |
| 6268 | .crosschip_lag_change = mv88e6xxx_crosschip_lag_change, |
| 6269 | .crosschip_lag_join = mv88e6xxx_crosschip_lag_join, |
| 6270 | .crosschip_lag_leave = mv88e6xxx_crosschip_lag_leave, |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 6271 | .port_bridge_tx_fwd_offload = mv88e6xxx_bridge_tx_fwd_offload, |
| 6272 | .port_bridge_tx_fwd_unoffload = mv88e6xxx_bridge_tx_fwd_unoffload, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6273 | }; |
| 6274 | |
Florian Fainelli | 55ed0ce | 2017-01-26 10:45:51 -0800 | [diff] [blame] | 6275 | static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip) |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6276 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6277 | struct device *dev = chip->dev; |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6278 | struct dsa_switch *ds; |
| 6279 | |
Vivien Didelot | 7e99e34 | 2019-10-21 16:51:30 -0400 | [diff] [blame] | 6280 | ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6281 | if (!ds) |
| 6282 | return -ENOMEM; |
| 6283 | |
Vivien Didelot | 7e99e34 | 2019-10-21 16:51:30 -0400 | [diff] [blame] | 6284 | ds->dev = dev; |
| 6285 | ds->num_ports = mv88e6xxx_num_ports(chip); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6286 | ds->priv = chip; |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6287 | ds->dev = dev; |
Vivien Didelot | 9d490b4 | 2016-08-23 12:38:56 -0400 | [diff] [blame] | 6288 | ds->ops = &mv88e6xxx_switch_ops; |
Vivien Didelot | 9ff74f2 | 2017-03-15 15:53:50 -0400 | [diff] [blame] | 6289 | ds->ageing_time_min = chip->info->age_time_coeff; |
| 6290 | ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX; |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6291 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 6292 | /* Some chips support up to 32, but that requires enabling the |
| 6293 | * 5-bit port mode, which we do not support. 640k^W16 ought to |
| 6294 | * be enough for anyone. |
| 6295 | */ |
Tobias Waldekranz | b80dc51 | 2021-01-15 13:52:59 +0100 | [diff] [blame] | 6296 | ds->num_lag_ids = mv88e6xxx_has_lag(chip) ? 16 : 0; |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 6297 | |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6298 | dev_set_drvdata(dev, ds); |
| 6299 | |
Vivien Didelot | 23c9ee4 | 2017-05-26 18:12:51 -0400 | [diff] [blame] | 6300 | return dsa_register_switch(ds); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6301 | } |
| 6302 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6303 | static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip) |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6304 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6305 | dsa_unregister_switch(chip->ds); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6306 | } |
| 6307 | |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6308 | static const void *pdata_device_get_match_data(struct device *dev) |
| 6309 | { |
| 6310 | const struct of_device_id *matches = dev->driver->of_match_table; |
| 6311 | const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data; |
| 6312 | |
| 6313 | for (; matches->name[0] || matches->type[0] || matches->compatible[0]; |
| 6314 | matches++) { |
| 6315 | if (!strcmp(pdata->compatible, matches->compatible)) |
| 6316 | return matches->data; |
| 6317 | } |
| 6318 | return NULL; |
| 6319 | } |
| 6320 | |
Miquel Raynal | bcd3d9d | 2019-02-05 12:07:28 +0100 | [diff] [blame] | 6321 | /* There is no suspend to RAM support at DSA level yet, the switch configuration |
| 6322 | * would be lost after a power cycle so prevent it to be suspended. |
| 6323 | */ |
| 6324 | static int __maybe_unused mv88e6xxx_suspend(struct device *dev) |
| 6325 | { |
| 6326 | return -EOPNOTSUPP; |
| 6327 | } |
| 6328 | |
| 6329 | static int __maybe_unused mv88e6xxx_resume(struct device *dev) |
| 6330 | { |
| 6331 | return 0; |
| 6332 | } |
| 6333 | |
| 6334 | static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume); |
| 6335 | |
Vivien Didelot | 57d3231 | 2016-06-20 13:13:58 -0400 | [diff] [blame] | 6336 | static int mv88e6xxx_probe(struct mdio_device *mdiodev) |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6337 | { |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6338 | struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data; |
David S. Miller | 7ddae24 | 2018-05-20 19:04:24 -0400 | [diff] [blame] | 6339 | const struct mv88e6xxx_info *compat_info = NULL; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6340 | struct device *dev = &mdiodev->dev; |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 6341 | struct device_node *np = dev->of_node; |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6342 | struct mv88e6xxx_chip *chip; |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6343 | int port; |
Andrew Lunn | 52638f7 | 2016-05-10 23:27:22 +0200 | [diff] [blame] | 6344 | int err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6345 | |
Andrew Lunn | 7bb8c99 | 2018-05-31 00:15:42 +0200 | [diff] [blame] | 6346 | if (!np && !pdata) |
| 6347 | return -EINVAL; |
| 6348 | |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6349 | if (np) |
| 6350 | compat_info = of_device_get_match_data(dev); |
| 6351 | |
| 6352 | if (pdata) { |
| 6353 | compat_info = pdata_device_get_match_data(dev); |
| 6354 | |
| 6355 | if (!pdata->netdev) |
| 6356 | return -EINVAL; |
| 6357 | |
| 6358 | for (port = 0; port < DSA_MAX_PORTS; port++) { |
| 6359 | if (!(pdata->enabled_ports & (1 << port))) |
| 6360 | continue; |
| 6361 | if (strcmp(pdata->cd.port_names[port], "cpu")) |
| 6362 | continue; |
| 6363 | pdata->cd.netdev[port] = &pdata->netdev->dev; |
| 6364 | break; |
| 6365 | } |
| 6366 | } |
| 6367 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 6368 | if (!compat_info) |
| 6369 | return -EINVAL; |
| 6370 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6371 | chip = mv88e6xxx_alloc_chip(dev); |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6372 | if (!chip) { |
| 6373 | err = -ENOMEM; |
| 6374 | goto out; |
| 6375 | } |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6376 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6377 | chip->info = compat_info; |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 6378 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6379 | err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr); |
Vivien Didelot | 4a70c4a | 2016-06-20 13:14:07 -0400 | [diff] [blame] | 6380 | if (err) |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6381 | goto out; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6382 | |
Andrew Lunn | b4308f0 | 2016-11-21 23:26:55 +0100 | [diff] [blame] | 6383 | chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6384 | if (IS_ERR(chip->reset)) { |
| 6385 | err = PTR_ERR(chip->reset); |
| 6386 | goto out; |
| 6387 | } |
Baruch Siach | 7b75e49 | 2019-06-27 21:17:39 +0300 | [diff] [blame] | 6388 | if (chip->reset) |
| 6389 | usleep_range(1000, 2000); |
Andrew Lunn | b4308f0 | 2016-11-21 23:26:55 +0100 | [diff] [blame] | 6390 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6391 | err = mv88e6xxx_detect(chip); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 6392 | if (err) |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6393 | goto out; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6394 | |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 6395 | if (chip->info->edsa_support == MV88E6XXX_EDSA_SUPPORTED) |
| 6396 | chip->tag_protocol = DSA_TAG_PROTO_EDSA; |
| 6397 | else |
| 6398 | chip->tag_protocol = DSA_TAG_PROTO_DSA; |
| 6399 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 6400 | mv88e6xxx_phy_init(chip); |
| 6401 | |
Andrew Lunn | 00baabe | 2018-05-19 22:31:35 +0200 | [diff] [blame] | 6402 | if (chip->info->ops->get_eeprom) { |
| 6403 | if (np) |
| 6404 | of_property_read_u32(np, "eeprom-length", |
| 6405 | &chip->eeprom_len); |
| 6406 | else |
| 6407 | chip->eeprom_len = pdata->eeprom_len; |
| 6408 | } |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 6409 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6410 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6411 | err = mv88e6xxx_switch_reset(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6412 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 6413 | if (err) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6414 | goto out; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 6415 | |
Andrew Lunn | a27415d | 2019-05-01 00:10:50 +0200 | [diff] [blame] | 6416 | if (np) { |
| 6417 | chip->irq = of_irq_get(np, 0); |
| 6418 | if (chip->irq == -EPROBE_DEFER) { |
| 6419 | err = chip->irq; |
| 6420 | goto out; |
| 6421 | } |
Andrew Lunn | 83c0afa | 2016-06-04 21:17:07 +0200 | [diff] [blame] | 6422 | } |
| 6423 | |
Andrew Lunn | a27415d | 2019-05-01 00:10:50 +0200 | [diff] [blame] | 6424 | if (pdata) |
| 6425 | chip->irq = pdata->irq; |
| 6426 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6427 | /* 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] | 6428 | * the PHYs will link their interrupts to these interrupt |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6429 | * controllers |
| 6430 | */ |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6431 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6432 | if (chip->irq > 0) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6433 | err = mv88e6xxx_g1_irq_setup(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6434 | else |
| 6435 | err = mv88e6xxx_irq_poll_setup(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6436 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6437 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6438 | if (err) |
| 6439 | goto out; |
| 6440 | |
| 6441 | if (chip->info->g2_irqs > 0) { |
| 6442 | err = mv88e6xxx_g2_irq_setup(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6443 | if (err) |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6444 | goto out_g1_irq; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6445 | } |
| 6446 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6447 | err = mv88e6xxx_g1_atu_prob_irq_setup(chip); |
| 6448 | if (err) |
| 6449 | goto out_g2_irq; |
| 6450 | |
| 6451 | err = mv88e6xxx_g1_vtu_prob_irq_setup(chip); |
| 6452 | if (err) |
| 6453 | goto out_g1_atu_prob_irq; |
| 6454 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 6455 | err = mv88e6xxx_mdios_register(chip, np); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6456 | if (err) |
Andrew Lunn | 62eb116 | 2018-01-14 02:32:45 +0100 | [diff] [blame] | 6457 | goto out_g1_vtu_prob_irq; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6458 | |
Florian Fainelli | 55ed0ce | 2017-01-26 10:45:51 -0800 | [diff] [blame] | 6459 | err = mv88e6xxx_register_switch(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6460 | if (err) |
| 6461 | goto out_mdio; |
| 6462 | |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6463 | return 0; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6464 | |
| 6465 | out_mdio: |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 6466 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | 62eb116 | 2018-01-14 02:32:45 +0100 | [diff] [blame] | 6467 | out_g1_vtu_prob_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6468 | mv88e6xxx_g1_vtu_prob_irq_free(chip); |
Andrew Lunn | 0977644 | 2018-01-14 02:32:44 +0100 | [diff] [blame] | 6469 | out_g1_atu_prob_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6470 | mv88e6xxx_g1_atu_prob_irq_free(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6471 | out_g2_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6472 | if (chip->info->g2_irqs > 0) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6473 | mv88e6xxx_g2_irq_free(chip); |
| 6474 | out_g1_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6475 | if (chip->irq > 0) |
Andrew Lunn | 46712644 | 2016-11-20 20:14:15 +0100 | [diff] [blame] | 6476 | mv88e6xxx_g1_irq_free(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6477 | else |
| 6478 | mv88e6xxx_irq_poll_free(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6479 | out: |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6480 | if (pdata) |
| 6481 | dev_put(pdata->netdev); |
| 6482 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6483 | return err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6484 | } |
| 6485 | |
| 6486 | static void mv88e6xxx_remove(struct mdio_device *mdiodev) |
| 6487 | { |
| 6488 | struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev); |
Vladimir Oltean | 0650bf5 | 2021-09-17 16:34:33 +0300 | [diff] [blame] | 6489 | struct mv88e6xxx_chip *chip; |
| 6490 | |
| 6491 | if (!ds) |
| 6492 | return; |
| 6493 | |
| 6494 | chip = ds->priv; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6495 | |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 6496 | if (chip->info->ptp_support) { |
| 6497 | mv88e6xxx_hwtstamp_free(chip); |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 6498 | mv88e6xxx_ptp_free(chip); |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 6499 | } |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 6500 | |
Andrew Lunn | 930188c | 2016-08-22 16:01:03 +0200 | [diff] [blame] | 6501 | mv88e6xxx_phy_destroy(chip); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6502 | mv88e6xxx_unregister_switch(chip); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 6503 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6504 | |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 6505 | mv88e6xxx_g1_vtu_prob_irq_free(chip); |
| 6506 | mv88e6xxx_g1_atu_prob_irq_free(chip); |
| 6507 | |
| 6508 | if (chip->info->g2_irqs > 0) |
| 6509 | mv88e6xxx_g2_irq_free(chip); |
| 6510 | |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 6511 | if (chip->irq > 0) |
Andrew Lunn | 46712644 | 2016-11-20 20:14:15 +0100 | [diff] [blame] | 6512 | mv88e6xxx_g1_irq_free(chip); |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 6513 | else |
| 6514 | mv88e6xxx_irq_poll_free(chip); |
Vladimir Oltean | 0650bf5 | 2021-09-17 16:34:33 +0300 | [diff] [blame] | 6515 | |
| 6516 | dev_set_drvdata(&mdiodev->dev, NULL); |
| 6517 | } |
| 6518 | |
| 6519 | static void mv88e6xxx_shutdown(struct mdio_device *mdiodev) |
| 6520 | { |
| 6521 | struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev); |
| 6522 | |
| 6523 | if (!ds) |
| 6524 | return; |
| 6525 | |
| 6526 | dsa_switch_shutdown(ds); |
| 6527 | |
| 6528 | dev_set_drvdata(&mdiodev->dev, NULL); |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6529 | } |
| 6530 | |
| 6531 | static const struct of_device_id mv88e6xxx_of_match[] = { |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 6532 | { |
| 6533 | .compatible = "marvell,mv88e6085", |
| 6534 | .data = &mv88e6xxx_table[MV88E6085], |
| 6535 | }, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 6536 | { |
| 6537 | .compatible = "marvell,mv88e6190", |
| 6538 | .data = &mv88e6xxx_table[MV88E6190], |
| 6539 | }, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 6540 | { |
| 6541 | .compatible = "marvell,mv88e6250", |
| 6542 | .data = &mv88e6xxx_table[MV88E6250], |
| 6543 | }, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6544 | { /* sentinel */ }, |
| 6545 | }; |
| 6546 | |
| 6547 | MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match); |
| 6548 | |
| 6549 | static struct mdio_driver mv88e6xxx_driver = { |
| 6550 | .probe = mv88e6xxx_probe, |
| 6551 | .remove = mv88e6xxx_remove, |
Vladimir Oltean | 0650bf5 | 2021-09-17 16:34:33 +0300 | [diff] [blame] | 6552 | .shutdown = mv88e6xxx_shutdown, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6553 | .mdiodrv.driver = { |
| 6554 | .name = "mv88e6085", |
| 6555 | .of_match_table = mv88e6xxx_of_match, |
Miquel Raynal | bcd3d9d | 2019-02-05 12:07:28 +0100 | [diff] [blame] | 6556 | .pm = &mv88e6xxx_pm_ops, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6557 | }, |
| 6558 | }; |
| 6559 | |
Andrew Lunn | 7324d50 | 2019-04-27 19:19:10 +0200 | [diff] [blame] | 6560 | mdio_module_driver(mv88e6xxx_driver); |
Ben Hutchings | 3d825ed | 2011-11-25 14:37:16 +0000 | [diff] [blame] | 6561 | |
| 6562 | MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); |
| 6563 | MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips"); |
| 6564 | MODULE_LICENSE("GPL"); |