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> |
Guenter Roeck | defb05b | 2015-03-26 18:36:38 -0700 | [diff] [blame] | 15 | #include <linux/etherdevice.h> |
Andrew Lunn | dea8702 | 2015-08-31 15:56:47 +0200 | [diff] [blame] | 16 | #include <linux/ethtool.h> |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 17 | #include <linux/if_bridge.h> |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 18 | #include <linux/interrupt.h> |
| 19 | #include <linux/irq.h> |
| 20 | #include <linux/irqdomain.h> |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 21 | #include <linux/jiffies.h> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 22 | #include <linux/list.h> |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 23 | #include <linux/mdio.h> |
Paul Gortmaker | 2bbba27 | 2012-01-24 10:41:40 +0000 | [diff] [blame] | 24 | #include <linux/module.h> |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 25 | #include <linux/of_device.h> |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 26 | #include <linux/of_irq.h> |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 27 | #include <linux/of_mdio.h> |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 28 | #include <linux/platform_data/mv88e6xxx.h> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 29 | #include <linux/netdevice.h> |
Andrew Lunn | c8c1b39a | 2015-11-20 03:56:24 +0100 | [diff] [blame] | 30 | #include <linux/gpio/consumer.h> |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 31 | #include <linux/phylink.h> |
Ben Hutchings | c8f0b86 | 2011-11-27 17:06:08 +0000 | [diff] [blame] | 32 | #include <net/dsa.h> |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 33 | |
Vivien Didelot | 4d5f2ba7 | 2017-06-02 17:06:15 -0400 | [diff] [blame] | 34 | #include "chip.h" |
Andrew Lunn | 9dd43aa | 2020-09-18 21:11:05 +0200 | [diff] [blame] | 35 | #include "devlink.h" |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 36 | #include "global1.h" |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 37 | #include "global2.h" |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 38 | #include "hwtstamp.h" |
Andrew Lunn | 10fa5bf | 2017-05-26 01:03:20 +0200 | [diff] [blame] | 39 | #include "phy.h" |
Vivien Didelot | 18abed2 | 2016-11-04 03:23:26 +0100 | [diff] [blame] | 40 | #include "port.h" |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 41 | #include "ptp.h" |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 42 | #include "serdes.h" |
Vivien Didelot | e7ba0fa | 2019-05-03 19:28:22 -0400 | [diff] [blame] | 43 | #include "smi.h" |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 44 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 45 | static void assert_reg_lock(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 3996a4f | 2015-10-30 18:56:45 -0400 | [diff] [blame] | 46 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 47 | if (unlikely(!mutex_is_locked(&chip->reg_lock))) { |
| 48 | dev_err(chip->dev, "Switch registers lock not held!\n"); |
Vivien Didelot | 3996a4f | 2015-10-30 18:56:45 -0400 | [diff] [blame] | 49 | dump_stack(); |
| 50 | } |
| 51 | } |
| 52 | |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 53 | 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] | 54 | { |
| 55 | int err; |
| 56 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 57 | assert_reg_lock(chip); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 58 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 59 | err = mv88e6xxx_smi_read(chip, addr, reg, val); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 60 | if (err) |
| 61 | return err; |
| 62 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 63 | 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] | 64 | addr, reg, *val); |
| 65 | |
| 66 | return 0; |
| 67 | } |
| 68 | |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 69 | 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] | 70 | { |
| 71 | int err; |
| 72 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 73 | assert_reg_lock(chip); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 74 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 75 | err = mv88e6xxx_smi_write(chip, addr, reg, val); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 76 | if (err) |
| 77 | return err; |
| 78 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 79 | 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] | 80 | addr, reg, val); |
| 81 | |
| 82 | return 0; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 83 | } |
| 84 | |
Vivien Didelot | 683f224 | 2019-08-09 18:47:54 -0400 | [diff] [blame] | 85 | int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg, |
| 86 | u16 mask, u16 val) |
| 87 | { |
| 88 | u16 data; |
| 89 | int err; |
| 90 | int i; |
| 91 | |
| 92 | /* There's no bus specific operation to wait for a mask */ |
| 93 | for (i = 0; i < 16; i++) { |
| 94 | err = mv88e6xxx_read(chip, addr, reg, &data); |
| 95 | if (err) |
| 96 | return err; |
| 97 | |
| 98 | if ((data & mask) == val) |
| 99 | return 0; |
| 100 | |
| 101 | usleep_range(1000, 2000); |
| 102 | } |
| 103 | |
| 104 | dev_err(chip->dev, "Timeout while waiting for switch\n"); |
| 105 | return -ETIMEDOUT; |
| 106 | } |
| 107 | |
Vivien Didelot | 19fb7f6 | 2019-08-09 18:47:55 -0400 | [diff] [blame] | 108 | int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg, |
| 109 | int bit, int val) |
| 110 | { |
| 111 | return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit), |
| 112 | val ? BIT(bit) : 0x0000); |
| 113 | } |
| 114 | |
Andrew Lunn | 10fa5bf | 2017-05-26 01:03:20 +0200 | [diff] [blame] | 115 | struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip) |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 116 | { |
| 117 | struct mv88e6xxx_mdio_bus *mdio_bus; |
| 118 | |
| 119 | mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus, |
| 120 | list); |
| 121 | if (!mdio_bus) |
| 122 | return NULL; |
| 123 | |
| 124 | return mdio_bus->bus; |
| 125 | } |
| 126 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 127 | static void mv88e6xxx_g1_irq_mask(struct irq_data *d) |
| 128 | { |
| 129 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 130 | unsigned int n = d->hwirq; |
| 131 | |
| 132 | chip->g1_irq.masked |= (1 << n); |
| 133 | } |
| 134 | |
| 135 | static void mv88e6xxx_g1_irq_unmask(struct irq_data *d) |
| 136 | { |
| 137 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 138 | unsigned int n = d->hwirq; |
| 139 | |
| 140 | chip->g1_irq.masked &= ~(1 << n); |
| 141 | } |
| 142 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 143 | static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 144 | { |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 145 | unsigned int nhandled = 0; |
| 146 | unsigned int sub_irq; |
| 147 | unsigned int n; |
| 148 | u16 reg; |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 149 | u16 ctl1; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 150 | int err; |
| 151 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 152 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 8246692 | 2017-06-15 12:13:59 -0400 | [diff] [blame] | 153 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 154 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 155 | |
| 156 | if (err) |
| 157 | goto out; |
| 158 | |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 159 | do { |
| 160 | for (n = 0; n < chip->g1_irq.nirqs; ++n) { |
| 161 | if (reg & (1 << n)) { |
| 162 | sub_irq = irq_find_mapping(chip->g1_irq.domain, |
| 163 | n); |
| 164 | handle_nested_irq(sub_irq); |
| 165 | ++nhandled; |
| 166 | } |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 167 | } |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 168 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 169 | mv88e6xxx_reg_lock(chip); |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 170 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1); |
| 171 | if (err) |
| 172 | goto unlock; |
| 173 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); |
| 174 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 175 | mv88e6xxx_reg_unlock(chip); |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 176 | if (err) |
| 177 | goto out; |
| 178 | ctl1 &= GENMASK(chip->g1_irq.nirqs, 0); |
| 179 | } while (reg & ctl1); |
| 180 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 181 | out: |
| 182 | return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE); |
| 183 | } |
| 184 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 185 | static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id) |
| 186 | { |
| 187 | struct mv88e6xxx_chip *chip = dev_id; |
| 188 | |
| 189 | return mv88e6xxx_g1_irq_thread_work(chip); |
| 190 | } |
| 191 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 192 | static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d) |
| 193 | { |
| 194 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 195 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 196 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d) |
| 200 | { |
| 201 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 202 | u16 mask = GENMASK(chip->g1_irq.nirqs, 0); |
| 203 | u16 reg; |
| 204 | int err; |
| 205 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 206 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, ®); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 207 | if (err) |
| 208 | goto out; |
| 209 | |
| 210 | reg &= ~mask; |
| 211 | reg |= (~chip->g1_irq.masked & mask); |
| 212 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 213 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 214 | if (err) |
| 215 | goto out; |
| 216 | |
| 217 | out: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 218 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 219 | } |
| 220 | |
Bhumika Goyal | 6eb15e2 | 2017-08-19 16:25:52 +0530 | [diff] [blame] | 221 | static const struct irq_chip mv88e6xxx_g1_irq_chip = { |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 222 | .name = "mv88e6xxx-g1", |
| 223 | .irq_mask = mv88e6xxx_g1_irq_mask, |
| 224 | .irq_unmask = mv88e6xxx_g1_irq_unmask, |
| 225 | .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock, |
| 226 | .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock, |
| 227 | }; |
| 228 | |
| 229 | static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d, |
| 230 | unsigned int irq, |
| 231 | irq_hw_number_t hwirq) |
| 232 | { |
| 233 | struct mv88e6xxx_chip *chip = d->host_data; |
| 234 | |
| 235 | irq_set_chip_data(irq, d->host_data); |
| 236 | irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq); |
| 237 | irq_set_noprobe(irq); |
| 238 | |
| 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = { |
| 243 | .map = mv88e6xxx_g1_irq_domain_map, |
| 244 | .xlate = irq_domain_xlate_twocell, |
| 245 | }; |
| 246 | |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 247 | /* To be called with reg_lock held */ |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 248 | static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 249 | { |
| 250 | int irq, virq; |
Andrew Lunn | 3460a57 | 2016-11-20 20:14:16 +0100 | [diff] [blame] | 251 | u16 mask; |
| 252 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 253 | mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask); |
Andrew Lunn | 3d5fdba | 2017-12-07 01:05:56 +0100 | [diff] [blame] | 254 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 255 | mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | 3460a57 | 2016-11-20 20:14:16 +0100 | [diff] [blame] | 256 | |
Andreas Färber | 5edef2f | 2016-11-27 23:26:28 +0100 | [diff] [blame] | 257 | for (irq = 0; irq < chip->g1_irq.nirqs; irq++) { |
Andrew Lunn | a3db3d3 | 2016-11-20 20:14:14 +0100 | [diff] [blame] | 258 | virq = irq_find_mapping(chip->g1_irq.domain, irq); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 259 | irq_dispose_mapping(virq); |
| 260 | } |
| 261 | |
Andrew Lunn | a3db3d3 | 2016-11-20 20:14:14 +0100 | [diff] [blame] | 262 | irq_domain_remove(chip->g1_irq.domain); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 263 | } |
| 264 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 265 | static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip) |
| 266 | { |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 267 | /* |
| 268 | * free_irq must be called without reg_lock taken because the irq |
| 269 | * handler takes this lock, too. |
| 270 | */ |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 271 | free_irq(chip->irq, chip); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 272 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 273 | mv88e6xxx_reg_lock(chip); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 274 | mv88e6xxx_g1_irq_free_common(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 275 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 279 | { |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 280 | int err, irq, virq; |
| 281 | u16 reg, mask; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 282 | |
| 283 | chip->g1_irq.nirqs = chip->info->g1_irqs; |
| 284 | chip->g1_irq.domain = irq_domain_add_simple( |
| 285 | NULL, chip->g1_irq.nirqs, 0, |
| 286 | &mv88e6xxx_g1_irq_domain_ops, chip); |
| 287 | if (!chip->g1_irq.domain) |
| 288 | return -ENOMEM; |
| 289 | |
| 290 | for (irq = 0; irq < chip->g1_irq.nirqs; irq++) |
| 291 | irq_create_mapping(chip->g1_irq.domain, irq); |
| 292 | |
| 293 | chip->g1_irq.chip = mv88e6xxx_g1_irq_chip; |
| 294 | chip->g1_irq.masked = ~0; |
| 295 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 296 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 297 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 298 | goto out_mapping; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 299 | |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 300 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 301 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 302 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 303 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 304 | goto out_disable; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 305 | |
| 306 | /* Reading the interrupt status clears (most of) them */ |
Vivien Didelot | 8246692 | 2017-06-15 12:13:59 -0400 | [diff] [blame] | 307 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 308 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 309 | goto out_disable; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 310 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 311 | return 0; |
| 312 | |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 313 | out_disable: |
Andrew Lunn | 3d5fdba | 2017-12-07 01:05:56 +0100 | [diff] [blame] | 314 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 315 | mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 316 | |
| 317 | out_mapping: |
| 318 | for (irq = 0; irq < 16; irq++) { |
| 319 | virq = irq_find_mapping(chip->g1_irq.domain, irq); |
| 320 | irq_dispose_mapping(virq); |
| 321 | } |
| 322 | |
| 323 | irq_domain_remove(chip->g1_irq.domain); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 324 | |
| 325 | return err; |
| 326 | } |
| 327 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 328 | static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip) |
| 329 | { |
Andrew Lunn | f6d9758 | 2019-02-23 17:43:56 +0100 | [diff] [blame] | 330 | static struct lock_class_key lock_key; |
| 331 | static struct lock_class_key request_key; |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 332 | int err; |
| 333 | |
| 334 | err = mv88e6xxx_g1_irq_setup_common(chip); |
| 335 | if (err) |
| 336 | return err; |
| 337 | |
Andrew Lunn | f6d9758 | 2019-02-23 17:43:56 +0100 | [diff] [blame] | 338 | /* These lock classes tells lockdep that global 1 irqs are in |
| 339 | * a different category than their parent GPIO, so it won't |
| 340 | * report false recursion. |
| 341 | */ |
| 342 | irq_set_lockdep_class(chip->irq, &lock_key, &request_key); |
| 343 | |
Andrew Lunn | 3095383 | 2020-01-06 17:13:48 +0100 | [diff] [blame] | 344 | snprintf(chip->irq_name, sizeof(chip->irq_name), |
| 345 | "mv88e6xxx-%s", dev_name(chip->dev)); |
| 346 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 347 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 348 | err = request_threaded_irq(chip->irq, NULL, |
| 349 | mv88e6xxx_g1_irq_thread_fn, |
Marek Behún | 0340376 | 2018-08-30 02:13:50 +0200 | [diff] [blame] | 350 | IRQF_ONESHOT | IRQF_SHARED, |
Andrew Lunn | 3095383 | 2020-01-06 17:13:48 +0100 | [diff] [blame] | 351 | chip->irq_name, chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 352 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 353 | if (err) |
| 354 | mv88e6xxx_g1_irq_free_common(chip); |
| 355 | |
| 356 | return err; |
| 357 | } |
| 358 | |
| 359 | static void mv88e6xxx_irq_poll(struct kthread_work *work) |
| 360 | { |
| 361 | struct mv88e6xxx_chip *chip = container_of(work, |
| 362 | struct mv88e6xxx_chip, |
| 363 | irq_poll_work.work); |
| 364 | mv88e6xxx_g1_irq_thread_work(chip); |
| 365 | |
| 366 | kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work, |
| 367 | msecs_to_jiffies(100)); |
| 368 | } |
| 369 | |
| 370 | static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip) |
| 371 | { |
| 372 | int err; |
| 373 | |
| 374 | err = mv88e6xxx_g1_irq_setup_common(chip); |
| 375 | if (err) |
| 376 | return err; |
| 377 | |
| 378 | kthread_init_delayed_work(&chip->irq_poll_work, |
| 379 | mv88e6xxx_irq_poll); |
| 380 | |
Florian Fainelli | 3f8b869 | 2019-02-21 20:09:27 -0800 | [diff] [blame] | 381 | chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev)); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 382 | if (IS_ERR(chip->kworker)) |
| 383 | return PTR_ERR(chip->kworker); |
| 384 | |
| 385 | kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work, |
| 386 | msecs_to_jiffies(100)); |
| 387 | |
| 388 | return 0; |
| 389 | } |
| 390 | |
| 391 | static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip) |
| 392 | { |
| 393 | kthread_cancel_delayed_work_sync(&chip->irq_poll_work); |
| 394 | kthread_destroy_worker(chip->kworker); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 395 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 396 | mv88e6xxx_reg_lock(chip); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 397 | mv88e6xxx_g1_irq_free_common(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 398 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 399 | } |
| 400 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 401 | static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip, |
| 402 | int port, phy_interface_t interface) |
| 403 | { |
| 404 | int err; |
| 405 | |
| 406 | if (chip->info->ops->port_set_rgmii_delay) { |
| 407 | err = chip->info->ops->port_set_rgmii_delay(chip, port, |
| 408 | interface); |
| 409 | if (err && err != -EOPNOTSUPP) |
| 410 | return err; |
| 411 | } |
| 412 | |
| 413 | if (chip->info->ops->port_set_cmode) { |
| 414 | err = chip->info->ops->port_set_cmode(chip, port, |
| 415 | interface); |
| 416 | if (err && err != -EOPNOTSUPP) |
| 417 | return err; |
| 418 | } |
| 419 | |
| 420 | return 0; |
| 421 | } |
| 422 | |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 423 | static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, |
| 424 | int link, int speed, int duplex, int pause, |
| 425 | phy_interface_t mode) |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 426 | { |
| 427 | int err; |
| 428 | |
| 429 | if (!chip->info->ops->port_set_link) |
| 430 | return 0; |
| 431 | |
| 432 | /* 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] | 433 | err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 434 | if (err) |
| 435 | return err; |
| 436 | |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 437 | if (chip->info->ops->port_set_speed_duplex) { |
| 438 | err = chip->info->ops->port_set_speed_duplex(chip, port, |
| 439 | speed, duplex); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 440 | if (err && err != -EOPNOTSUPP) |
| 441 | goto restore_link; |
| 442 | } |
| 443 | |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 444 | if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode) |
| 445 | mode = chip->info->ops->port_max_speed_mode(port); |
| 446 | |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 447 | if (chip->info->ops->port_set_pause) { |
| 448 | err = chip->info->ops->port_set_pause(chip, port, pause); |
| 449 | if (err) |
| 450 | goto restore_link; |
| 451 | } |
| 452 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 453 | err = mv88e6xxx_port_config_interface(chip, port, mode); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 454 | restore_link: |
| 455 | if (chip->info->ops->port_set_link(chip, port, link)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 456 | 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] | 457 | |
| 458 | return err; |
| 459 | } |
| 460 | |
Marek Vasut | d700ec4 | 2018-09-12 00:15:24 +0200 | [diff] [blame] | 461 | static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port) |
| 462 | { |
| 463 | struct mv88e6xxx_chip *chip = ds->priv; |
| 464 | |
| 465 | return port < chip->info->num_internal_phys; |
| 466 | } |
| 467 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 468 | static int mv88e6xxx_port_ppu_updates(struct mv88e6xxx_chip *chip, int port) |
| 469 | { |
| 470 | u16 reg; |
| 471 | int err; |
| 472 | |
| 473 | err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, ®); |
| 474 | if (err) { |
| 475 | dev_err(chip->dev, |
| 476 | "p%d: %s: failed to read port status\n", |
| 477 | port, __func__); |
| 478 | return err; |
| 479 | } |
| 480 | |
| 481 | return !!(reg & MV88E6XXX_PORT_STS_PHY_DETECT); |
| 482 | } |
| 483 | |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 484 | static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port, |
| 485 | struct phylink_link_state *state) |
| 486 | { |
| 487 | struct mv88e6xxx_chip *chip = ds->priv; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 488 | int lane; |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 489 | int err; |
| 490 | |
| 491 | mv88e6xxx_reg_lock(chip); |
| 492 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 493 | if (lane >= 0 && chip->info->ops->serdes_pcs_get_state) |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 494 | err = chip->info->ops->serdes_pcs_get_state(chip, port, lane, |
| 495 | state); |
| 496 | else |
| 497 | err = -EOPNOTSUPP; |
| 498 | mv88e6xxx_reg_unlock(chip); |
| 499 | |
| 500 | return err; |
| 501 | } |
| 502 | |
| 503 | static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port, |
| 504 | unsigned int mode, |
| 505 | phy_interface_t interface, |
| 506 | const unsigned long *advertise) |
| 507 | { |
| 508 | const struct mv88e6xxx_ops *ops = chip->info->ops; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 509 | int lane; |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 510 | |
| 511 | if (ops->serdes_pcs_config) { |
| 512 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 513 | if (lane >= 0) |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 514 | return ops->serdes_pcs_config(chip, port, lane, mode, |
| 515 | interface, advertise); |
| 516 | } |
| 517 | |
| 518 | return 0; |
| 519 | } |
| 520 | |
| 521 | static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port) |
| 522 | { |
| 523 | struct mv88e6xxx_chip *chip = ds->priv; |
| 524 | const struct mv88e6xxx_ops *ops; |
| 525 | int err = 0; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 526 | int lane; |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 527 | |
| 528 | ops = chip->info->ops; |
| 529 | |
| 530 | if (ops->serdes_pcs_an_restart) { |
| 531 | mv88e6xxx_reg_lock(chip); |
| 532 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 533 | if (lane >= 0) |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 534 | err = ops->serdes_pcs_an_restart(chip, port, lane); |
| 535 | mv88e6xxx_reg_unlock(chip); |
| 536 | |
| 537 | if (err) |
| 538 | dev_err(ds->dev, "p%d: failed to restart AN\n", port); |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port, |
| 543 | unsigned int mode, |
| 544 | int speed, int duplex) |
| 545 | { |
| 546 | const struct mv88e6xxx_ops *ops = chip->info->ops; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 547 | int lane; |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 548 | |
| 549 | if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) { |
| 550 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 551 | if (lane >= 0) |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 552 | return ops->serdes_pcs_link_up(chip, port, lane, |
| 553 | speed, duplex); |
| 554 | } |
| 555 | |
| 556 | return 0; |
| 557 | } |
| 558 | |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 559 | static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 560 | unsigned long *mask, |
| 561 | struct phylink_link_state *state) |
| 562 | { |
| 563 | if (!phy_interface_mode_is_8023z(state->interface)) { |
| 564 | /* 10M and 100M are only supported in non-802.3z mode */ |
| 565 | phylink_set(mask, 10baseT_Half); |
| 566 | phylink_set(mask, 10baseT_Full); |
| 567 | phylink_set(mask, 100baseT_Half); |
| 568 | phylink_set(mask, 100baseT_Full); |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 573 | unsigned long *mask, |
| 574 | struct phylink_link_state *state) |
| 575 | { |
| 576 | /* FIXME: if the port is in 1000Base-X mode, then it only supports |
| 577 | * 1000M FD speeds. In this case, CMODE will indicate 5. |
| 578 | */ |
| 579 | phylink_set(mask, 1000baseT_Full); |
| 580 | phylink_set(mask, 1000baseX_Full); |
| 581 | |
| 582 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 583 | } |
| 584 | |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 585 | static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 586 | unsigned long *mask, |
| 587 | struct phylink_link_state *state) |
| 588 | { |
| 589 | if (port >= 5) |
| 590 | phylink_set(mask, 2500baseX_Full); |
| 591 | |
| 592 | /* No ethtool bits for 200Mbps */ |
| 593 | phylink_set(mask, 1000baseT_Full); |
| 594 | phylink_set(mask, 1000baseX_Full); |
| 595 | |
| 596 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 597 | } |
| 598 | |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 599 | static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 600 | unsigned long *mask, |
| 601 | struct phylink_link_state *state) |
| 602 | { |
| 603 | /* No ethtool bits for 200Mbps */ |
| 604 | phylink_set(mask, 1000baseT_Full); |
| 605 | phylink_set(mask, 1000baseX_Full); |
| 606 | |
| 607 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 608 | } |
| 609 | |
| 610 | static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 611 | unsigned long *mask, |
| 612 | struct phylink_link_state *state) |
| 613 | { |
Andrew Lunn | ec26016 | 2019-02-08 22:25:44 +0100 | [diff] [blame] | 614 | if (port >= 9) { |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 615 | phylink_set(mask, 2500baseX_Full); |
Andrew Lunn | ec26016 | 2019-02-08 22:25:44 +0100 | [diff] [blame] | 616 | phylink_set(mask, 2500baseT_Full); |
| 617 | } |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 618 | |
| 619 | /* No ethtool bits for 200Mbps */ |
| 620 | phylink_set(mask, 1000baseT_Full); |
| 621 | phylink_set(mask, 1000baseX_Full); |
| 622 | |
| 623 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 624 | } |
| 625 | |
| 626 | static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 627 | unsigned long *mask, |
| 628 | struct phylink_link_state *state) |
| 629 | { |
| 630 | if (port >= 9) { |
| 631 | phylink_set(mask, 10000baseT_Full); |
| 632 | phylink_set(mask, 10000baseKR_Full); |
| 633 | } |
| 634 | |
| 635 | mv88e6390_phylink_validate(chip, port, mask, state); |
| 636 | } |
| 637 | |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 638 | static void mv88e6393x_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 639 | unsigned long *mask, |
| 640 | struct phylink_link_state *state) |
| 641 | { |
| 642 | if (port == 0 || port == 9 || port == 10) { |
| 643 | phylink_set(mask, 10000baseT_Full); |
| 644 | phylink_set(mask, 10000baseKR_Full); |
| 645 | phylink_set(mask, 10000baseCR_Full); |
| 646 | phylink_set(mask, 10000baseSR_Full); |
| 647 | phylink_set(mask, 10000baseLR_Full); |
| 648 | phylink_set(mask, 10000baseLRM_Full); |
| 649 | phylink_set(mask, 10000baseER_Full); |
| 650 | phylink_set(mask, 5000baseT_Full); |
| 651 | phylink_set(mask, 2500baseX_Full); |
| 652 | phylink_set(mask, 2500baseT_Full); |
| 653 | } |
| 654 | |
| 655 | phylink_set(mask, 1000baseT_Full); |
| 656 | phylink_set(mask, 1000baseX_Full); |
| 657 | |
| 658 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 659 | } |
| 660 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 661 | static void mv88e6xxx_validate(struct dsa_switch *ds, int port, |
| 662 | unsigned long *supported, |
| 663 | struct phylink_link_state *state) |
| 664 | { |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 665 | __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; |
| 666 | struct mv88e6xxx_chip *chip = ds->priv; |
| 667 | |
| 668 | /* Allow all the expected bits */ |
| 669 | phylink_set(mask, Autoneg); |
| 670 | phylink_set(mask, Pause); |
| 671 | phylink_set_port_modes(mask); |
| 672 | |
| 673 | if (chip->info->ops->phylink_validate) |
| 674 | chip->info->ops->phylink_validate(chip, port, mask, state); |
| 675 | |
| 676 | bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); |
| 677 | bitmap_and(state->advertising, state->advertising, mask, |
| 678 | __ETHTOOL_LINK_MODE_MASK_NBITS); |
| 679 | |
| 680 | /* We can only operate at 2500BaseX or 1000BaseX. If requested |
| 681 | * to advertise both, only report advertising at 2500BaseX. |
| 682 | */ |
| 683 | phylink_helper_basex_speed(state); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 684 | } |
| 685 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 686 | static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port, |
| 687 | unsigned int mode, |
| 688 | const struct phylink_link_state *state) |
| 689 | { |
| 690 | struct mv88e6xxx_chip *chip = ds->priv; |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 691 | struct mv88e6xxx_port *p; |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 692 | int err; |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 693 | |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 694 | p = &chip->ports[port]; |
| 695 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 696 | /* FIXME: is this the correct test? If we're in fixed mode on an |
| 697 | * internal port, why should we process this any different from |
| 698 | * PHY mode? On the other hand, the port may be automedia between |
| 699 | * an internal PHY and the serdes... |
| 700 | */ |
Marek Vasut | d700ec4 | 2018-09-12 00:15:24 +0200 | [diff] [blame] | 701 | if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port)) |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 702 | return; |
| 703 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 704 | mv88e6xxx_reg_lock(chip); |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 705 | /* In inband mode, the link may come up at any time while the link |
| 706 | * is not forced down. Force the link down while we reconfigure the |
| 707 | * interface mode. |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 708 | */ |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 709 | if (mode == MLO_AN_INBAND && p->interface != state->interface && |
| 710 | chip->info->ops->port_set_link) |
| 711 | chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN); |
| 712 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 713 | err = mv88e6xxx_port_config_interface(chip, port, state->interface); |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 714 | if (err && err != -EOPNOTSUPP) |
| 715 | goto err_unlock; |
| 716 | |
| 717 | err = mv88e6xxx_serdes_pcs_config(chip, port, mode, state->interface, |
| 718 | state->advertising); |
| 719 | /* FIXME: we should restart negotiation if something changed - which |
| 720 | * is something we get if we convert to using phylinks PCS operations. |
| 721 | */ |
| 722 | if (err > 0) |
| 723 | err = 0; |
| 724 | |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 725 | /* Undo the forced down state above after completing configuration |
| 726 | * irrespective of its state on entry, which allows the link to come up. |
| 727 | */ |
| 728 | if (mode == MLO_AN_INBAND && p->interface != state->interface && |
| 729 | chip->info->ops->port_set_link) |
| 730 | chip->info->ops->port_set_link(chip, port, LINK_UNFORCED); |
| 731 | |
| 732 | p->interface = state->interface; |
| 733 | |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 734 | err_unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 735 | mv88e6xxx_reg_unlock(chip); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 736 | |
| 737 | if (err && err != -EOPNOTSUPP) |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 738 | 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] | 739 | } |
| 740 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 741 | static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port, |
| 742 | unsigned int mode, |
| 743 | phy_interface_t interface) |
| 744 | { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 745 | struct mv88e6xxx_chip *chip = ds->priv; |
| 746 | const struct mv88e6xxx_ops *ops; |
| 747 | int err = 0; |
| 748 | |
| 749 | ops = chip->info->ops; |
| 750 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 751 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 34b5e6a | 2020-04-14 02:34:38 +0200 | [diff] [blame] | 752 | if ((!mv88e6xxx_port_ppu_updates(chip, port) || |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 753 | mode == MLO_AN_FIXED) && ops->port_sync_link) |
| 754 | err = ops->port_sync_link(chip, port, mode, false); |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 755 | mv88e6xxx_reg_unlock(chip); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 756 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 757 | if (err) |
| 758 | dev_err(chip->dev, |
| 759 | "p%d: failed to force MAC link down\n", port); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 760 | } |
| 761 | |
| 762 | static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port, |
| 763 | unsigned int mode, phy_interface_t interface, |
Russell King | 5b502a7 | 2020-02-26 10:23:46 +0000 | [diff] [blame] | 764 | struct phy_device *phydev, |
| 765 | int speed, int duplex, |
| 766 | bool tx_pause, bool rx_pause) |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 767 | { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 768 | struct mv88e6xxx_chip *chip = ds->priv; |
| 769 | const struct mv88e6xxx_ops *ops; |
| 770 | int err = 0; |
| 771 | |
| 772 | ops = chip->info->ops; |
| 773 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 774 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 34b5e6a | 2020-04-14 02:34:38 +0200 | [diff] [blame] | 775 | if (!mv88e6xxx_port_ppu_updates(chip, port) || mode == MLO_AN_FIXED) { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 776 | /* FIXME: for an automedia port, should we force the link |
| 777 | * down here - what if the link comes up due to "other" media |
| 778 | * while we're bringing the port up, how is the exclusivity |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 779 | * handled in the Marvell hardware? E.g. port 2 on 88E6390 |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 780 | * shared between internal PHY and Serdes. |
| 781 | */ |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 782 | err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed, |
| 783 | duplex); |
| 784 | if (err) |
| 785 | goto error; |
| 786 | |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 787 | if (ops->port_set_speed_duplex) { |
| 788 | err = ops->port_set_speed_duplex(chip, port, |
| 789 | speed, duplex); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 790 | if (err && err != -EOPNOTSUPP) |
| 791 | goto error; |
| 792 | } |
| 793 | |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 794 | if (ops->port_sync_link) |
| 795 | err = ops->port_sync_link(chip, port, mode, true); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 796 | } |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 797 | error: |
| 798 | mv88e6xxx_reg_unlock(chip); |
| 799 | |
| 800 | if (err && err != -EOPNOTSUPP) |
| 801 | dev_err(ds->dev, |
| 802 | "p%d: failed to configure MAC link up\n", port); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 803 | } |
| 804 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 805 | static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 806 | { |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 807 | if (!chip->info->ops->stats_snapshot) |
| 808 | return -EOPNOTSUPP; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 809 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 810 | return chip->info->ops->stats_snapshot(chip, port); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 811 | } |
| 812 | |
Andrew Lunn | e413e7e | 2015-04-02 04:06:38 +0200 | [diff] [blame] | 813 | static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = { |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 814 | { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, }, |
| 815 | { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, }, |
| 816 | { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, }, |
| 817 | { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, }, |
| 818 | { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, }, |
| 819 | { "in_pause", 4, 0x16, STATS_TYPE_BANK0, }, |
| 820 | { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, }, |
| 821 | { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, }, |
| 822 | { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, }, |
| 823 | { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, }, |
| 824 | { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, }, |
| 825 | { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, }, |
| 826 | { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, }, |
| 827 | { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, }, |
| 828 | { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, }, |
| 829 | { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, }, |
| 830 | { "out_pause", 4, 0x15, STATS_TYPE_BANK0, }, |
| 831 | { "excessive", 4, 0x11, STATS_TYPE_BANK0, }, |
| 832 | { "collisions", 4, 0x1e, STATS_TYPE_BANK0, }, |
| 833 | { "deferred", 4, 0x05, STATS_TYPE_BANK0, }, |
| 834 | { "single", 4, 0x14, STATS_TYPE_BANK0, }, |
| 835 | { "multiple", 4, 0x17, STATS_TYPE_BANK0, }, |
| 836 | { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, }, |
| 837 | { "late", 4, 0x1f, STATS_TYPE_BANK0, }, |
| 838 | { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, }, |
| 839 | { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, }, |
| 840 | { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, }, |
| 841 | { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, }, |
| 842 | { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, }, |
| 843 | { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, }, |
| 844 | { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, }, |
| 845 | { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, }, |
| 846 | { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, }, |
| 847 | { "in_discards", 4, 0x00, STATS_TYPE_BANK1, }, |
| 848 | { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, }, |
| 849 | { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, }, |
| 850 | { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, }, |
| 851 | { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, }, |
| 852 | { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, }, |
| 853 | { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, }, |
| 854 | { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, }, |
| 855 | { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, }, |
| 856 | { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, }, |
| 857 | { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, }, |
| 858 | { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, }, |
| 859 | { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, }, |
| 860 | { "in_management", 4, 0x0f, STATS_TYPE_BANK1, }, |
| 861 | { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, }, |
| 862 | { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, }, |
| 863 | { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, }, |
| 864 | { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, }, |
| 865 | { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, }, |
| 866 | { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, }, |
| 867 | { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, }, |
| 868 | { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, }, |
| 869 | { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, }, |
| 870 | { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, }, |
| 871 | { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, }, |
| 872 | { "out_management", 4, 0x1f, STATS_TYPE_BANK1, }, |
Andrew Lunn | e413e7e | 2015-04-02 04:06:38 +0200 | [diff] [blame] | 873 | }; |
| 874 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 875 | static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip, |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 876 | struct mv88e6xxx_hw_stat *s, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 877 | int port, u16 bank1_select, |
| 878 | u16 histogram) |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 879 | { |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 880 | u32 low; |
| 881 | u32 high = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 882 | u16 reg = 0; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 883 | int err; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 884 | u64 value; |
| 885 | |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 886 | switch (s->type) { |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 887 | case STATS_TYPE_PORT: |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 888 | err = mv88e6xxx_port_read(chip, port, s->reg, ®); |
| 889 | if (err) |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 890 | return U64_MAX; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 891 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 892 | low = reg; |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 893 | if (s->size == 4) { |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 894 | err = mv88e6xxx_port_read(chip, port, s->reg + 1, ®); |
| 895 | if (err) |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 896 | return U64_MAX; |
Rasmus Villemoes | 84b3fd1 | 2019-05-29 07:02:11 +0000 | [diff] [blame] | 897 | low |= ((u32)reg) << 16; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 898 | } |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 899 | break; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 900 | case STATS_TYPE_BANK1: |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 901 | reg = bank1_select; |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 902 | fallthrough; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 903 | case STATS_TYPE_BANK0: |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 904 | reg |= s->reg | histogram; |
Andrew Lunn | 7f9ef3a | 2016-11-21 23:27:05 +0100 | [diff] [blame] | 905 | mv88e6xxx_g1_stats_read(chip, reg, &low); |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 906 | if (s->size == 8) |
Andrew Lunn | 7f9ef3a | 2016-11-21 23:27:05 +0100 | [diff] [blame] | 907 | mv88e6xxx_g1_stats_read(chip, reg + 1, &high); |
Gustavo A. R. Silva | 9fc3e4d | 2017-05-11 22:11:29 -0500 | [diff] [blame] | 908 | break; |
| 909 | default: |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 910 | return U64_MAX; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 911 | } |
Andrew Lunn | 6e46e2d | 2019-02-28 18:14:03 +0100 | [diff] [blame] | 912 | value = (((u64)high) << 32) | low; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 913 | return value; |
| 914 | } |
| 915 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 916 | static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 917 | uint8_t *data, int types) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 918 | { |
| 919 | struct mv88e6xxx_hw_stat *stat; |
| 920 | int i, j; |
| 921 | |
| 922 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 923 | stat = &mv88e6xxx_hw_stats[i]; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 924 | if (stat->type & types) { |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 925 | memcpy(data + j * ETH_GSTRING_LEN, stat->string, |
| 926 | ETH_GSTRING_LEN); |
| 927 | j++; |
| 928 | } |
| 929 | } |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 930 | |
| 931 | return j; |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 932 | } |
| 933 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 934 | static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 935 | uint8_t *data) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 936 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 937 | return mv88e6xxx_stats_get_strings(chip, data, |
| 938 | STATS_TYPE_BANK0 | STATS_TYPE_PORT); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 939 | } |
| 940 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 941 | static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 942 | uint8_t *data) |
| 943 | { |
| 944 | return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0); |
| 945 | } |
| 946 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 947 | static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 948 | uint8_t *data) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 949 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 950 | return mv88e6xxx_stats_get_strings(chip, data, |
| 951 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 952 | } |
| 953 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 954 | static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = { |
| 955 | "atu_member_violation", |
| 956 | "atu_miss_violation", |
| 957 | "atu_full_violation", |
| 958 | "vtu_member_violation", |
| 959 | "vtu_miss_violation", |
| 960 | }; |
| 961 | |
| 962 | static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data) |
| 963 | { |
| 964 | unsigned int i; |
| 965 | |
| 966 | for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++) |
| 967 | strlcpy(data + i * ETH_GSTRING_LEN, |
| 968 | mv88e6xxx_atu_vtu_stats_strings[i], |
| 969 | ETH_GSTRING_LEN); |
| 970 | } |
| 971 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 972 | static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port, |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 973 | u32 stringset, uint8_t *data) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 974 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 975 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 976 | int count = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 977 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 978 | if (stringset != ETH_SS_STATS) |
| 979 | return; |
| 980 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 981 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 982 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 983 | if (chip->info->ops->stats_get_strings) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 984 | count = chip->info->ops->stats_get_strings(chip, data); |
| 985 | |
| 986 | if (chip->info->ops->serdes_get_strings) { |
| 987 | data += count * ETH_GSTRING_LEN; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 988 | count = chip->info->ops->serdes_get_strings(chip, port, data); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 989 | } |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 990 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 991 | data += count * ETH_GSTRING_LEN; |
| 992 | mv88e6xxx_atu_vtu_get_strings(data); |
| 993 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 994 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 995 | } |
| 996 | |
| 997 | static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip, |
| 998 | int types) |
| 999 | { |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 1000 | struct mv88e6xxx_hw_stat *stat; |
| 1001 | int i, j; |
| 1002 | |
| 1003 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 1004 | stat = &mv88e6xxx_hw_stats[i]; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1005 | if (stat->type & types) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 1006 | j++; |
| 1007 | } |
| 1008 | return j; |
| 1009 | } |
| 1010 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1011 | static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 1012 | { |
| 1013 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 | |
| 1014 | STATS_TYPE_PORT); |
| 1015 | } |
| 1016 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 1017 | static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 1018 | { |
| 1019 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0); |
| 1020 | } |
| 1021 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1022 | static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 1023 | { |
| 1024 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 | |
| 1025 | STATS_TYPE_BANK1); |
| 1026 | } |
| 1027 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 1028 | 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] | 1029 | { |
| 1030 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1031 | int serdes_count = 0; |
| 1032 | int count = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1033 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 1034 | if (sset != ETH_SS_STATS) |
| 1035 | return 0; |
| 1036 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1037 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1038 | if (chip->info->ops->stats_get_sset_count) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1039 | count = chip->info->ops->stats_get_sset_count(chip); |
| 1040 | if (count < 0) |
| 1041 | goto out; |
| 1042 | |
| 1043 | if (chip->info->ops->serdes_get_sset_count) |
| 1044 | serdes_count = chip->info->ops->serdes_get_sset_count(chip, |
| 1045 | port); |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1046 | if (serdes_count < 0) { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1047 | count = serdes_count; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1048 | goto out; |
| 1049 | } |
| 1050 | count += serdes_count; |
| 1051 | count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); |
| 1052 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1053 | out: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1054 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1055 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1056 | return count; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1057 | } |
| 1058 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1059 | static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1060 | uint64_t *data, int types, |
| 1061 | u16 bank1_select, u16 histogram) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1062 | { |
| 1063 | struct mv88e6xxx_hw_stat *stat; |
| 1064 | int i, j; |
| 1065 | |
| 1066 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 1067 | stat = &mv88e6xxx_hw_stats[i]; |
| 1068 | if (stat->type & types) { |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1069 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1070 | data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port, |
| 1071 | bank1_select, |
| 1072 | histogram); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1073 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 1074 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1075 | j++; |
| 1076 | } |
| 1077 | } |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1078 | return j; |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1079 | } |
| 1080 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1081 | static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1082 | uint64_t *data) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1083 | { |
| 1084 | return mv88e6xxx_stats_get_stats(chip, port, data, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1085 | STATS_TYPE_BANK0 | STATS_TYPE_PORT, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1086 | 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1087 | } |
| 1088 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 1089 | static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1090 | uint64_t *data) |
| 1091 | { |
| 1092 | return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0, |
| 1093 | 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
| 1094 | } |
| 1095 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1096 | static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1097 | uint64_t *data) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1098 | { |
| 1099 | return mv88e6xxx_stats_get_stats(chip, port, data, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1100 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1101 | MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9, |
| 1102 | MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1103 | } |
| 1104 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1105 | static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1106 | uint64_t *data) |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1107 | { |
| 1108 | return mv88e6xxx_stats_get_stats(chip, port, data, |
| 1109 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1110 | MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10, |
| 1111 | 0); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1112 | } |
| 1113 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1114 | static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1115 | uint64_t *data) |
| 1116 | { |
| 1117 | *data++ = chip->ports[port].atu_member_violation; |
| 1118 | *data++ = chip->ports[port].atu_miss_violation; |
| 1119 | *data++ = chip->ports[port].atu_full_violation; |
| 1120 | *data++ = chip->ports[port].vtu_member_violation; |
| 1121 | *data++ = chip->ports[port].vtu_miss_violation; |
| 1122 | } |
| 1123 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1124 | static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1125 | uint64_t *data) |
| 1126 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1127 | int count = 0; |
| 1128 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1129 | if (chip->info->ops->stats_get_stats) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1130 | count = chip->info->ops->stats_get_stats(chip, port, data); |
| 1131 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1132 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1133 | if (chip->info->ops->serdes_get_stats) { |
| 1134 | data += count; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1135 | count = chip->info->ops->serdes_get_stats(chip, port, data); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1136 | } |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1137 | data += count; |
| 1138 | mv88e6xxx_atu_vtu_get_stats(chip, port, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1139 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1140 | } |
| 1141 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1142 | static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port, |
| 1143 | uint64_t *data) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1144 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1145 | struct mv88e6xxx_chip *chip = ds->priv; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1146 | int ret; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1147 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1148 | mv88e6xxx_reg_lock(chip); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1149 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 1150 | ret = mv88e6xxx_stats_snapshot(chip, port); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1151 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 1152 | |
| 1153 | if (ret < 0) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1154 | return; |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1155 | |
| 1156 | mv88e6xxx_get_stats(chip, port, data); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1157 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1158 | } |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 1159 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1160 | static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port) |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1161 | { |
Andrew Lunn | 0d30bbd | 2020-02-16 18:54:13 +0100 | [diff] [blame] | 1162 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1163 | int len; |
| 1164 | |
| 1165 | len = 32 * sizeof(u16); |
| 1166 | if (chip->info->ops->serdes_get_regs_len) |
| 1167 | len += chip->info->ops->serdes_get_regs_len(chip, port); |
| 1168 | |
| 1169 | return len; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1170 | } |
| 1171 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1172 | static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port, |
| 1173 | struct ethtool_regs *regs, void *_p) |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1174 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1175 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1176 | int err; |
| 1177 | u16 reg; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1178 | u16 *p = _p; |
| 1179 | int i; |
| 1180 | |
Vivien Didelot | a5f3932 | 2018-12-17 16:05:21 -0500 | [diff] [blame] | 1181 | regs->version = chip->info->prod_num; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1182 | |
| 1183 | memset(p, 0xff, 32 * sizeof(u16)); |
| 1184 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1185 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 2306251 | 2016-05-09 13:22:45 -0400 | [diff] [blame] | 1186 | |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1187 | for (i = 0; i < 32; i++) { |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1188 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1189 | err = mv88e6xxx_port_read(chip, port, i, ®); |
| 1190 | if (!err) |
| 1191 | p[i] = reg; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1192 | } |
Vivien Didelot | 2306251 | 2016-05-09 13:22:45 -0400 | [diff] [blame] | 1193 | |
Andrew Lunn | 0d30bbd | 2020-02-16 18:54:13 +0100 | [diff] [blame] | 1194 | if (chip->info->ops->serdes_get_regs) |
| 1195 | chip->info->ops->serdes_get_regs(chip, port, &p[i]); |
| 1196 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1197 | mv88e6xxx_reg_unlock(chip); |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1198 | } |
| 1199 | |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 1200 | static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port, |
| 1201 | struct ethtool_eee *e) |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1202 | { |
Vivien Didelot | 5480db6 | 2017-08-01 16:32:40 -0400 | [diff] [blame] | 1203 | /* Nothing to do on the port's MAC */ |
| 1204 | return 0; |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1205 | } |
| 1206 | |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 1207 | static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port, |
| 1208 | struct ethtool_eee *e) |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1209 | { |
Vivien Didelot | 5480db6 | 2017-08-01 16:32:40 -0400 | [diff] [blame] | 1210 | /* Nothing to do on the port's MAC */ |
| 1211 | return 0; |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1212 | } |
| 1213 | |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1214 | /* 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] | 1215 | 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] | 1216 | { |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1217 | struct dsa_switch *ds = chip->ds; |
| 1218 | struct dsa_switch_tree *dst = ds->dst; |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1219 | struct net_device *br; |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1220 | struct dsa_port *dp; |
| 1221 | bool found = false; |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1222 | u16 pvlan; |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1223 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1224 | /* dev is a physical switch */ |
| 1225 | if (dev <= dst->last_switch) { |
| 1226 | list_for_each_entry(dp, &dst->ports, list) { |
| 1227 | if (dp->ds->index == dev && dp->index == port) { |
| 1228 | /* dp might be a DSA link or a user port, so it |
| 1229 | * might or might not have a bridge_dev |
| 1230 | * pointer. Use the "found" variable for both |
| 1231 | * cases. |
| 1232 | */ |
| 1233 | br = dp->bridge_dev; |
| 1234 | found = true; |
| 1235 | break; |
| 1236 | } |
| 1237 | } |
| 1238 | /* dev is a virtual bridge */ |
| 1239 | } else { |
| 1240 | list_for_each_entry(dp, &dst->ports, list) { |
| 1241 | if (dp->bridge_num < 0) |
| 1242 | continue; |
| 1243 | |
| 1244 | if (dp->bridge_num + 1 + dst->last_switch != dev) |
| 1245 | continue; |
| 1246 | |
| 1247 | br = dp->bridge_dev; |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1248 | found = true; |
| 1249 | break; |
| 1250 | } |
| 1251 | } |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1252 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1253 | /* Prevent frames from unknown switch or virtual bridge */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1254 | if (!found) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1255 | return 0; |
| 1256 | |
| 1257 | /* Frames from DSA links and CPU ports can egress any local port */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1258 | 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] | 1259 | return mv88e6xxx_port_mask(chip); |
| 1260 | |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1261 | pvlan = 0; |
| 1262 | |
| 1263 | /* Frames from user ports can egress any local DSA links and CPU ports, |
| 1264 | * as well as any local member of their bridge group. |
| 1265 | */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1266 | list_for_each_entry(dp, &dst->ports, list) |
| 1267 | if (dp->ds == ds && |
| 1268 | (dp->type == DSA_PORT_TYPE_CPU || |
| 1269 | dp->type == DSA_PORT_TYPE_DSA || |
| 1270 | (br && dp->bridge_dev == br))) |
| 1271 | pvlan |= BIT(dp->index); |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1272 | |
| 1273 | return pvlan; |
| 1274 | } |
| 1275 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 1276 | static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1277 | { |
| 1278 | u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port); |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1279 | |
| 1280 | /* prevent frames from going back out of the port they came in on */ |
| 1281 | output_ports &= ~BIT(port); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1282 | |
Vivien Didelot | 5a7921f | 2016-11-04 03:23:28 +0100 | [diff] [blame] | 1283 | return mv88e6xxx_port_set_vlan_map(chip, port, output_ports); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1284 | } |
| 1285 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1286 | static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port, |
| 1287 | u8 state) |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1288 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1289 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 553eb54 | 2016-05-13 20:38:23 -0400 | [diff] [blame] | 1290 | int err; |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1291 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1292 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | f894c29 | 2017-06-08 18:34:10 -0400 | [diff] [blame] | 1293 | err = mv88e6xxx_port_set_state(chip, port, state); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1294 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 553eb54 | 2016-05-13 20:38:23 -0400 | [diff] [blame] | 1295 | |
| 1296 | if (err) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1297 | dev_err(ds->dev, "p%d: failed to update state\n", port); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1298 | } |
| 1299 | |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 1300 | static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip) |
| 1301 | { |
| 1302 | int err; |
| 1303 | |
| 1304 | if (chip->info->ops->ieee_pri_map) { |
| 1305 | err = chip->info->ops->ieee_pri_map(chip); |
| 1306 | if (err) |
| 1307 | return err; |
| 1308 | } |
| 1309 | |
| 1310 | if (chip->info->ops->ip_pri_map) { |
| 1311 | err = chip->info->ops->ip_pri_map(chip); |
| 1312 | if (err) |
| 1313 | return err; |
| 1314 | } |
| 1315 | |
| 1316 | return 0; |
| 1317 | } |
| 1318 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1319 | static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip) |
| 1320 | { |
Vivien Didelot | c5f5176 | 2019-10-30 22:09:13 -0400 | [diff] [blame] | 1321 | struct dsa_switch *ds = chip->ds; |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1322 | int target, port; |
| 1323 | int err; |
| 1324 | |
| 1325 | if (!chip->info->global2_addr) |
| 1326 | return 0; |
| 1327 | |
| 1328 | /* Initialize the routing port to the 32 possible target devices */ |
| 1329 | for (target = 0; target < 32; target++) { |
Vivien Didelot | c5f5176 | 2019-10-30 22:09:13 -0400 | [diff] [blame] | 1330 | port = dsa_routing_port(ds, target); |
| 1331 | if (port == ds->num_ports) |
| 1332 | port = 0x1f; |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1333 | |
| 1334 | err = mv88e6xxx_g2_device_mapping_write(chip, target, port); |
| 1335 | if (err) |
| 1336 | return err; |
| 1337 | } |
| 1338 | |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 1339 | if (chip->info->ops->set_cascade_port) { |
| 1340 | port = MV88E6XXX_CASCADE_PORT_MULTIPLE; |
| 1341 | err = chip->info->ops->set_cascade_port(chip, port); |
| 1342 | if (err) |
| 1343 | return err; |
| 1344 | } |
| 1345 | |
Vivien Didelot | 23c9891 | 2018-05-09 11:38:50 -0400 | [diff] [blame] | 1346 | err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index); |
| 1347 | if (err) |
| 1348 | return err; |
| 1349 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1350 | return 0; |
| 1351 | } |
| 1352 | |
Vivien Didelot | b28f872 | 2018-04-26 21:56:44 -0400 | [diff] [blame] | 1353 | static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip) |
| 1354 | { |
| 1355 | /* Clear all trunk masks and mapping */ |
| 1356 | if (chip->info->global2_addr) |
| 1357 | return mv88e6xxx_g2_trunk_clear(chip); |
| 1358 | |
| 1359 | return 0; |
| 1360 | } |
| 1361 | |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 1362 | static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip) |
| 1363 | { |
| 1364 | if (chip->info->ops->rmu_disable) |
| 1365 | return chip->info->ops->rmu_disable(chip); |
| 1366 | |
| 1367 | return 0; |
| 1368 | } |
| 1369 | |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 1370 | static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip) |
| 1371 | { |
| 1372 | if (chip->info->ops->pot_clear) |
| 1373 | return chip->info->ops->pot_clear(chip); |
| 1374 | |
| 1375 | return 0; |
| 1376 | } |
| 1377 | |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 1378 | static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip) |
| 1379 | { |
| 1380 | if (chip->info->ops->mgmt_rsvd2cpu) |
| 1381 | return chip->info->ops->mgmt_rsvd2cpu(chip); |
| 1382 | |
| 1383 | return 0; |
| 1384 | } |
| 1385 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 1386 | static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip) |
| 1387 | { |
Vivien Didelot | c3a7d4a | 2017-03-11 16:12:51 -0500 | [diff] [blame] | 1388 | int err; |
| 1389 | |
Vivien Didelot | daefc94 | 2017-03-11 16:12:54 -0500 | [diff] [blame] | 1390 | err = mv88e6xxx_g1_atu_flush(chip, 0, true); |
| 1391 | if (err) |
| 1392 | return err; |
| 1393 | |
Rasmus Villemoes | 49506a9 | 2020-12-10 12:06:44 +0100 | [diff] [blame] | 1394 | /* The chips that have a "learn2all" bit in Global1, ATU |
| 1395 | * Control are precisely those whose port registers have a |
| 1396 | * Message Port bit in Port Control 1 and hence implement |
| 1397 | * ->port_setup_message_port. |
| 1398 | */ |
| 1399 | if (chip->info->ops->port_setup_message_port) { |
| 1400 | err = mv88e6xxx_g1_atu_set_learn2all(chip, true); |
| 1401 | if (err) |
| 1402 | return err; |
| 1403 | } |
Vivien Didelot | c3a7d4a | 2017-03-11 16:12:51 -0500 | [diff] [blame] | 1404 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 1405 | return mv88e6xxx_g1_atu_set_age_time(chip, 300000); |
| 1406 | } |
| 1407 | |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 1408 | static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip) |
| 1409 | { |
| 1410 | int port; |
| 1411 | int err; |
| 1412 | |
| 1413 | if (!chip->info->ops->irl_init_all) |
| 1414 | return 0; |
| 1415 | |
| 1416 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 1417 | /* Disable ingress rate limiting by resetting all per port |
| 1418 | * ingress rate limit resources to their initial state. |
| 1419 | */ |
| 1420 | err = chip->info->ops->irl_init_all(chip, port); |
| 1421 | if (err) |
| 1422 | return err; |
| 1423 | } |
| 1424 | |
| 1425 | return 0; |
| 1426 | } |
| 1427 | |
Vivien Didelot | 04a69a1 | 2017-10-13 14:18:05 -0400 | [diff] [blame] | 1428 | static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip) |
| 1429 | { |
| 1430 | if (chip->info->ops->set_switch_mac) { |
| 1431 | u8 addr[ETH_ALEN]; |
| 1432 | |
| 1433 | eth_random_addr(addr); |
| 1434 | |
| 1435 | return chip->info->ops->set_switch_mac(chip, addr); |
| 1436 | } |
| 1437 | |
| 1438 | return 0; |
| 1439 | } |
| 1440 | |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1441 | static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port) |
| 1442 | { |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1443 | struct dsa_switch_tree *dst = chip->ds->dst; |
| 1444 | struct dsa_switch *ds; |
| 1445 | struct dsa_port *dp; |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1446 | u16 pvlan = 0; |
| 1447 | |
| 1448 | if (!mv88e6xxx_has_pvt(chip)) |
Vivien Didelot | d14939b | 2019-10-21 16:51:25 -0400 | [diff] [blame] | 1449 | return 0; |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1450 | |
| 1451 | /* Skip the local source device, which uses in-chip port VLAN */ |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1452 | if (dev != chip->ds->index) { |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 1453 | pvlan = mv88e6xxx_port_vlan(chip, dev, port); |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1454 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1455 | ds = dsa_switch_find(dst->index, dev); |
| 1456 | dp = ds ? dsa_to_port(ds, port) : NULL; |
| 1457 | if (dp && dp->lag_dev) { |
| 1458 | /* As the PVT is used to limit flooding of |
| 1459 | * FORWARD frames, which use the LAG ID as the |
| 1460 | * source port, we must translate dev/port to |
| 1461 | * the special "LAG device" in the PVT, using |
| 1462 | * the LAG ID as the port number. |
| 1463 | */ |
Tobias Waldekranz | 78e70db | 2021-04-21 14:04:52 +0200 | [diff] [blame] | 1464 | dev = MV88E6XXX_G2_PVT_ADDR_DEV_TRUNK; |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1465 | port = dsa_lag_id(dst, dp->lag_dev); |
| 1466 | } |
| 1467 | } |
| 1468 | |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1469 | return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan); |
| 1470 | } |
| 1471 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1472 | static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip) |
| 1473 | { |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1474 | int dev, port; |
| 1475 | int err; |
| 1476 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1477 | if (!mv88e6xxx_has_pvt(chip)) |
| 1478 | return 0; |
| 1479 | |
| 1480 | /* Clear 5 Bit Port for usage with Marvell Link Street devices: |
| 1481 | * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev. |
| 1482 | */ |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1483 | err = mv88e6xxx_g2_misc_4_bit_port(chip); |
| 1484 | if (err) |
| 1485 | return err; |
| 1486 | |
| 1487 | for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) { |
| 1488 | for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) { |
| 1489 | err = mv88e6xxx_pvt_map(chip, dev, port); |
| 1490 | if (err) |
| 1491 | return err; |
| 1492 | } |
| 1493 | } |
| 1494 | |
| 1495 | return 0; |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1496 | } |
| 1497 | |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1498 | static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port) |
| 1499 | { |
| 1500 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1501 | int err; |
| 1502 | |
Tobias Waldekranz | ffcec3f | 2021-03-18 20:25:34 +0100 | [diff] [blame] | 1503 | if (dsa_to_port(ds, port)->lag_dev) |
| 1504 | /* Hardware is incapable of fast-aging a LAG through a |
| 1505 | * regular ATU move operation. Until we have something |
| 1506 | * more fancy in place this is a no-op. |
| 1507 | */ |
| 1508 | return; |
| 1509 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1510 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 1511 | err = mv88e6xxx_g1_atu_remove(chip, 0, port, false); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1512 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1513 | |
| 1514 | if (err) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1515 | dev_err(ds->dev, "p%d: failed to flush ATU\n", port); |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1516 | } |
| 1517 | |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 1518 | static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip) |
| 1519 | { |
Tobias Waldekranz | e545f86 | 2020-11-10 19:57:20 +0100 | [diff] [blame] | 1520 | if (!mv88e6xxx_max_vid(chip)) |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 1521 | return 0; |
| 1522 | |
| 1523 | return mv88e6xxx_g1_vtu_flush(chip); |
| 1524 | } |
| 1525 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1526 | static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid, |
| 1527 | struct mv88e6xxx_vtu_entry *entry) |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1528 | { |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1529 | int err; |
| 1530 | |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1531 | if (!chip->info->ops->vtu_getnext) |
| 1532 | return -EOPNOTSUPP; |
| 1533 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1534 | entry->vid = vid ? vid - 1 : mv88e6xxx_max_vid(chip); |
| 1535 | entry->valid = false; |
| 1536 | |
| 1537 | err = chip->info->ops->vtu_getnext(chip, entry); |
| 1538 | |
| 1539 | if (entry->vid != vid) |
| 1540 | entry->valid = false; |
| 1541 | |
| 1542 | return err; |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1543 | } |
| 1544 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 1545 | static int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip, |
| 1546 | int (*cb)(struct mv88e6xxx_chip *chip, |
| 1547 | const struct mv88e6xxx_vtu_entry *entry, |
| 1548 | void *priv), |
| 1549 | void *priv) |
| 1550 | { |
| 1551 | struct mv88e6xxx_vtu_entry entry = { |
| 1552 | .vid = mv88e6xxx_max_vid(chip), |
| 1553 | .valid = false, |
| 1554 | }; |
| 1555 | int err; |
| 1556 | |
| 1557 | if (!chip->info->ops->vtu_getnext) |
| 1558 | return -EOPNOTSUPP; |
| 1559 | |
| 1560 | do { |
| 1561 | err = chip->info->ops->vtu_getnext(chip, &entry); |
| 1562 | if (err) |
| 1563 | return err; |
| 1564 | |
| 1565 | if (!entry.valid) |
| 1566 | break; |
| 1567 | |
| 1568 | err = cb(chip, &entry, priv); |
| 1569 | if (err) |
| 1570 | return err; |
| 1571 | } while (entry.vid < mv88e6xxx_max_vid(chip)); |
| 1572 | |
| 1573 | return 0; |
| 1574 | } |
| 1575 | |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 1576 | static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip, |
| 1577 | struct mv88e6xxx_vtu_entry *entry) |
| 1578 | { |
| 1579 | if (!chip->info->ops->vtu_loadpurge) |
| 1580 | return -EOPNOTSUPP; |
| 1581 | |
| 1582 | return chip->info->ops->vtu_loadpurge(chip, entry); |
| 1583 | } |
| 1584 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 1585 | static int mv88e6xxx_fid_map_vlan(struct mv88e6xxx_chip *chip, |
| 1586 | const struct mv88e6xxx_vtu_entry *entry, |
| 1587 | void *_fid_bitmap) |
| 1588 | { |
| 1589 | unsigned long *fid_bitmap = _fid_bitmap; |
| 1590 | |
| 1591 | set_bit(entry->fid, fid_bitmap); |
| 1592 | return 0; |
| 1593 | } |
| 1594 | |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1595 | int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap) |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1596 | { |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1597 | int i, err; |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1598 | u16 fid; |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1599 | |
| 1600 | bitmap_zero(fid_bitmap, MV88E6XXX_N_FID); |
| 1601 | |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1602 | /* Set every FID bit used by the (un)bridged ports */ |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 1603 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1604 | err = mv88e6xxx_port_get_fid(chip, i, &fid); |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1605 | if (err) |
| 1606 | return err; |
| 1607 | |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1608 | set_bit(fid, fid_bitmap); |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1609 | } |
| 1610 | |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1611 | /* Set every FID bit used by the VLAN entries */ |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 1612 | return mv88e6xxx_vtu_walk(chip, mv88e6xxx_fid_map_vlan, fid_bitmap); |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1613 | } |
| 1614 | |
| 1615 | static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid) |
| 1616 | { |
| 1617 | DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID); |
| 1618 | int err; |
| 1619 | |
| 1620 | err = mv88e6xxx_fid_map(chip, fid_bitmap); |
| 1621 | if (err) |
| 1622 | return err; |
| 1623 | |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1624 | /* The reset value 0x000 is used to indicate that multiple address |
| 1625 | * databases are not needed. Return the next positive available. |
| 1626 | */ |
| 1627 | *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1628 | if (unlikely(*fid >= mv88e6xxx_num_databases(chip))) |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1629 | return -ENOSPC; |
| 1630 | |
| 1631 | /* Clear the database */ |
Vivien Didelot | daefc94 | 2017-03-11 16:12:54 -0500 | [diff] [blame] | 1632 | return mv88e6xxx_g1_atu_flush(chip, *fid, true); |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1633 | } |
| 1634 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1635 | 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] | 1636 | u16 vid) |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1637 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1638 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 1639 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1640 | int i, err; |
| 1641 | |
Andrew Lunn | db06ae41 | 2017-09-25 23:32:20 +0200 | [diff] [blame] | 1642 | /* DSA and CPU ports have to be members of multiple vlans */ |
| 1643 | if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) |
| 1644 | return 0; |
| 1645 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1646 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1647 | if (err) |
| 1648 | return err; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1649 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1650 | if (!vlan.valid) |
| 1651 | return 0; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1652 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1653 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
| 1654 | if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i)) |
| 1655 | continue; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1656 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1657 | if (!dsa_to_port(ds, i)->slave) |
| 1658 | continue; |
Andrew Lunn | 66e2809 | 2016-12-11 21:07:19 +0100 | [diff] [blame] | 1659 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1660 | if (vlan.member[i] == |
| 1661 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) |
| 1662 | continue; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1663 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1664 | if (dsa_to_port(ds, i)->bridge_dev == |
| 1665 | dsa_to_port(ds, port)->bridge_dev) |
| 1666 | break; /* same bridge, check next VLAN */ |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1667 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1668 | if (!dsa_to_port(ds, i)->bridge_dev) |
| 1669 | continue; |
Andrew Lunn | 66e2809 | 2016-12-11 21:07:19 +0100 | [diff] [blame] | 1670 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1671 | dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n", |
| 1672 | port, vlan.vid, i, |
| 1673 | netdev_name(dsa_to_port(ds, i)->bridge_dev)); |
| 1674 | return -EOPNOTSUPP; |
| 1675 | } |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1676 | |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1677 | return 0; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1678 | } |
| 1679 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1680 | static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port, |
Vladimir Oltean | 89153ed | 2021-02-13 22:43:19 +0200 | [diff] [blame] | 1681 | bool vlan_filtering, |
| 1682 | struct netlink_ext_ack *extack) |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1683 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1684 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 81c6edb | 2017-06-12 12:37:41 -0400 | [diff] [blame] | 1685 | u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE : |
| 1686 | MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1687 | int err; |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1688 | |
Vladimir Oltean | bae33f2 | 2021-01-09 02:01:50 +0200 | [diff] [blame] | 1689 | if (!mv88e6xxx_max_vid(chip)) |
| 1690 | return -EOPNOTSUPP; |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1691 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1692 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 385a099 | 2016-11-04 03:23:31 +0100 | [diff] [blame] | 1693 | err = mv88e6xxx_port_set_8021q_mode(chip, port, mode); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1694 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1695 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1696 | return err; |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1697 | } |
| 1698 | |
Vivien Didelot | 57d3231 | 2016-06-20 13:13:58 -0400 | [diff] [blame] | 1699 | static int |
| 1700 | mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port, |
Vivien Didelot | 80e0236 | 2017-11-30 11:23:57 -0500 | [diff] [blame] | 1701 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1702 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1703 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1704 | int err; |
| 1705 | |
Tobias Waldekranz | e545f86 | 2020-11-10 19:57:20 +0100 | [diff] [blame] | 1706 | if (!mv88e6xxx_max_vid(chip)) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1707 | return -EOPNOTSUPP; |
| 1708 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1709 | /* If the requested port doesn't belong to the same bridge as the VLAN |
| 1710 | * members, do not support it (yet) and fallback to software VLAN. |
| 1711 | */ |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1712 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1713 | err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid); |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1714 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1715 | |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1716 | return err; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1717 | } |
| 1718 | |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1719 | static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port, |
| 1720 | const unsigned char *addr, u16 vid, |
| 1721 | u8 state) |
| 1722 | { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1723 | struct mv88e6xxx_atu_entry entry; |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1724 | struct mv88e6xxx_vtu_entry vlan; |
| 1725 | u16 fid; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1726 | int err; |
| 1727 | |
| 1728 | /* Null VLAN ID corresponds to the port private database */ |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1729 | if (vid == 0) { |
| 1730 | err = mv88e6xxx_port_get_fid(chip, port, &fid); |
| 1731 | if (err) |
| 1732 | return err; |
| 1733 | } else { |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1734 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1735 | if (err) |
| 1736 | return err; |
| 1737 | |
| 1738 | /* switchdev expects -EOPNOTSUPP to honor software VLANs */ |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1739 | if (!vlan.valid) |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1740 | return -EOPNOTSUPP; |
| 1741 | |
| 1742 | fid = vlan.fid; |
| 1743 | } |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1744 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1745 | entry.state = 0; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1746 | ether_addr_copy(entry.mac, addr); |
| 1747 | eth_addr_dec(entry.mac); |
| 1748 | |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1749 | err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry); |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1750 | if (err) |
| 1751 | return err; |
| 1752 | |
| 1753 | /* Initialize a fresh ATU entry if it isn't found */ |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1754 | if (!entry.state || !ether_addr_equal(entry.mac, addr)) { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1755 | memset(&entry, 0, sizeof(entry)); |
| 1756 | ether_addr_copy(entry.mac, addr); |
| 1757 | } |
| 1758 | |
| 1759 | /* Purge the ATU entry only if no port is using it anymore */ |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1760 | if (!state) { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1761 | entry.portvec &= ~BIT(port); |
| 1762 | if (!entry.portvec) |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1763 | entry.state = 0; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1764 | } else { |
DENG Qingfang | f72f2fb | 2021-01-30 21:43:34 +0800 | [diff] [blame] | 1765 | if (state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC) |
| 1766 | entry.portvec = BIT(port); |
| 1767 | else |
| 1768 | entry.portvec |= BIT(port); |
| 1769 | |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1770 | entry.state = state; |
| 1771 | } |
| 1772 | |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1773 | return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry); |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1774 | } |
| 1775 | |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 1776 | static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port, |
| 1777 | const struct mv88e6xxx_policy *policy) |
| 1778 | { |
| 1779 | enum mv88e6xxx_policy_mapping mapping = policy->mapping; |
| 1780 | enum mv88e6xxx_policy_action action = policy->action; |
| 1781 | const u8 *addr = policy->addr; |
| 1782 | u16 vid = policy->vid; |
| 1783 | u8 state; |
| 1784 | int err; |
| 1785 | int id; |
| 1786 | |
| 1787 | if (!chip->info->ops->port_set_policy) |
| 1788 | return -EOPNOTSUPP; |
| 1789 | |
| 1790 | switch (mapping) { |
| 1791 | case MV88E6XXX_POLICY_MAPPING_DA: |
| 1792 | case MV88E6XXX_POLICY_MAPPING_SA: |
| 1793 | if (action == MV88E6XXX_POLICY_ACTION_NORMAL) |
| 1794 | state = 0; /* Dissociate the port and address */ |
| 1795 | else if (action == MV88E6XXX_POLICY_ACTION_DISCARD && |
| 1796 | is_multicast_ether_addr(addr)) |
| 1797 | state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY; |
| 1798 | else if (action == MV88E6XXX_POLICY_ACTION_DISCARD && |
| 1799 | is_unicast_ether_addr(addr)) |
| 1800 | state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY; |
| 1801 | else |
| 1802 | return -EOPNOTSUPP; |
| 1803 | |
| 1804 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, |
| 1805 | state); |
| 1806 | if (err) |
| 1807 | return err; |
| 1808 | break; |
| 1809 | default: |
| 1810 | return -EOPNOTSUPP; |
| 1811 | } |
| 1812 | |
| 1813 | /* Skip the port's policy clearing if the mapping is still in use */ |
| 1814 | if (action == MV88E6XXX_POLICY_ACTION_NORMAL) |
| 1815 | idr_for_each_entry(&chip->policies, policy, id) |
| 1816 | if (policy->port == port && |
| 1817 | policy->mapping == mapping && |
| 1818 | policy->action != action) |
| 1819 | return 0; |
| 1820 | |
| 1821 | return chip->info->ops->port_set_policy(chip, port, mapping, action); |
| 1822 | } |
| 1823 | |
| 1824 | static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port, |
| 1825 | struct ethtool_rx_flow_spec *fs) |
| 1826 | { |
| 1827 | struct ethhdr *mac_entry = &fs->h_u.ether_spec; |
| 1828 | struct ethhdr *mac_mask = &fs->m_u.ether_spec; |
| 1829 | enum mv88e6xxx_policy_mapping mapping; |
| 1830 | enum mv88e6xxx_policy_action action; |
| 1831 | struct mv88e6xxx_policy *policy; |
| 1832 | u16 vid = 0; |
| 1833 | u8 *addr; |
| 1834 | int err; |
| 1835 | int id; |
| 1836 | |
| 1837 | if (fs->location != RX_CLS_LOC_ANY) |
| 1838 | return -EINVAL; |
| 1839 | |
| 1840 | if (fs->ring_cookie == RX_CLS_FLOW_DISC) |
| 1841 | action = MV88E6XXX_POLICY_ACTION_DISCARD; |
| 1842 | else |
| 1843 | return -EOPNOTSUPP; |
| 1844 | |
| 1845 | switch (fs->flow_type & ~FLOW_EXT) { |
| 1846 | case ETHER_FLOW: |
| 1847 | if (!is_zero_ether_addr(mac_mask->h_dest) && |
| 1848 | is_zero_ether_addr(mac_mask->h_source)) { |
| 1849 | mapping = MV88E6XXX_POLICY_MAPPING_DA; |
| 1850 | addr = mac_entry->h_dest; |
| 1851 | } else if (is_zero_ether_addr(mac_mask->h_dest) && |
| 1852 | !is_zero_ether_addr(mac_mask->h_source)) { |
| 1853 | mapping = MV88E6XXX_POLICY_MAPPING_SA; |
| 1854 | addr = mac_entry->h_source; |
| 1855 | } else { |
| 1856 | /* Cannot support DA and SA mapping in the same rule */ |
| 1857 | return -EOPNOTSUPP; |
| 1858 | } |
| 1859 | break; |
| 1860 | default: |
| 1861 | return -EOPNOTSUPP; |
| 1862 | } |
| 1863 | |
| 1864 | if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) { |
Andrew Lunn | 0484428 | 2020-07-05 21:38:08 +0200 | [diff] [blame] | 1865 | if (fs->m_ext.vlan_tci != htons(0xffff)) |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 1866 | return -EOPNOTSUPP; |
| 1867 | vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK; |
| 1868 | } |
| 1869 | |
| 1870 | idr_for_each_entry(&chip->policies, policy, id) { |
| 1871 | if (policy->port == port && policy->mapping == mapping && |
| 1872 | policy->action == action && policy->vid == vid && |
| 1873 | ether_addr_equal(policy->addr, addr)) |
| 1874 | return -EEXIST; |
| 1875 | } |
| 1876 | |
| 1877 | policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL); |
| 1878 | if (!policy) |
| 1879 | return -ENOMEM; |
| 1880 | |
| 1881 | fs->location = 0; |
| 1882 | err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff, |
| 1883 | GFP_KERNEL); |
| 1884 | if (err) { |
| 1885 | devm_kfree(chip->dev, policy); |
| 1886 | return err; |
| 1887 | } |
| 1888 | |
| 1889 | memcpy(&policy->fs, fs, sizeof(*fs)); |
| 1890 | ether_addr_copy(policy->addr, addr); |
| 1891 | policy->mapping = mapping; |
| 1892 | policy->action = action; |
| 1893 | policy->port = port; |
| 1894 | policy->vid = vid; |
| 1895 | |
| 1896 | err = mv88e6xxx_policy_apply(chip, port, policy); |
| 1897 | if (err) { |
| 1898 | idr_remove(&chip->policies, fs->location); |
| 1899 | devm_kfree(chip->dev, policy); |
| 1900 | return err; |
| 1901 | } |
| 1902 | |
| 1903 | return 0; |
| 1904 | } |
| 1905 | |
| 1906 | static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port, |
| 1907 | struct ethtool_rxnfc *rxnfc, u32 *rule_locs) |
| 1908 | { |
| 1909 | struct ethtool_rx_flow_spec *fs = &rxnfc->fs; |
| 1910 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1911 | struct mv88e6xxx_policy *policy; |
| 1912 | int err; |
| 1913 | int id; |
| 1914 | |
| 1915 | mv88e6xxx_reg_lock(chip); |
| 1916 | |
| 1917 | switch (rxnfc->cmd) { |
| 1918 | case ETHTOOL_GRXCLSRLCNT: |
| 1919 | rxnfc->data = 0; |
| 1920 | rxnfc->data |= RX_CLS_LOC_SPECIAL; |
| 1921 | rxnfc->rule_cnt = 0; |
| 1922 | idr_for_each_entry(&chip->policies, policy, id) |
| 1923 | if (policy->port == port) |
| 1924 | rxnfc->rule_cnt++; |
| 1925 | err = 0; |
| 1926 | break; |
| 1927 | case ETHTOOL_GRXCLSRULE: |
| 1928 | err = -ENOENT; |
| 1929 | policy = idr_find(&chip->policies, fs->location); |
| 1930 | if (policy) { |
| 1931 | memcpy(fs, &policy->fs, sizeof(*fs)); |
| 1932 | err = 0; |
| 1933 | } |
| 1934 | break; |
| 1935 | case ETHTOOL_GRXCLSRLALL: |
| 1936 | rxnfc->data = 0; |
| 1937 | rxnfc->rule_cnt = 0; |
| 1938 | idr_for_each_entry(&chip->policies, policy, id) |
| 1939 | if (policy->port == port) |
| 1940 | rule_locs[rxnfc->rule_cnt++] = id; |
| 1941 | err = 0; |
| 1942 | break; |
| 1943 | default: |
| 1944 | err = -EOPNOTSUPP; |
| 1945 | break; |
| 1946 | } |
| 1947 | |
| 1948 | mv88e6xxx_reg_unlock(chip); |
| 1949 | |
| 1950 | return err; |
| 1951 | } |
| 1952 | |
| 1953 | static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port, |
| 1954 | struct ethtool_rxnfc *rxnfc) |
| 1955 | { |
| 1956 | struct ethtool_rx_flow_spec *fs = &rxnfc->fs; |
| 1957 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1958 | struct mv88e6xxx_policy *policy; |
| 1959 | int err; |
| 1960 | |
| 1961 | mv88e6xxx_reg_lock(chip); |
| 1962 | |
| 1963 | switch (rxnfc->cmd) { |
| 1964 | case ETHTOOL_SRXCLSRLINS: |
| 1965 | err = mv88e6xxx_policy_insert(chip, port, fs); |
| 1966 | break; |
| 1967 | case ETHTOOL_SRXCLSRLDEL: |
| 1968 | err = -ENOENT; |
| 1969 | policy = idr_remove(&chip->policies, fs->location); |
| 1970 | if (policy) { |
| 1971 | policy->action = MV88E6XXX_POLICY_ACTION_NORMAL; |
| 1972 | err = mv88e6xxx_policy_apply(chip, port, policy); |
| 1973 | devm_kfree(chip->dev, policy); |
| 1974 | } |
| 1975 | break; |
| 1976 | default: |
| 1977 | err = -EOPNOTSUPP; |
| 1978 | break; |
| 1979 | } |
| 1980 | |
| 1981 | mv88e6xxx_reg_unlock(chip); |
| 1982 | |
| 1983 | return err; |
| 1984 | } |
| 1985 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 1986 | static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port, |
| 1987 | u16 vid) |
| 1988 | { |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 1989 | u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC; |
Tobias Waldekranz | 0806dd46 | 2021-03-18 20:25:37 +0100 | [diff] [blame] | 1990 | u8 broadcast[ETH_ALEN]; |
| 1991 | |
| 1992 | eth_broadcast_addr(broadcast); |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 1993 | |
| 1994 | return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state); |
| 1995 | } |
| 1996 | |
| 1997 | static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid) |
| 1998 | { |
| 1999 | int port; |
| 2000 | int err; |
| 2001 | |
| 2002 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 2003 | struct dsa_port *dp = dsa_to_port(chip->ds, port); |
| 2004 | struct net_device *brport; |
| 2005 | |
| 2006 | if (dsa_is_unused_port(chip->ds, port)) |
| 2007 | continue; |
| 2008 | |
| 2009 | brport = dsa_port_to_bridge_port(dp); |
| 2010 | if (brport && !br_port_flag_is_set(brport, BR_BCAST_FLOOD)) |
| 2011 | /* Skip bridged user ports where broadcast |
| 2012 | * flooding is disabled. |
| 2013 | */ |
| 2014 | continue; |
| 2015 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2016 | err = mv88e6xxx_port_add_broadcast(chip, port, vid); |
| 2017 | if (err) |
| 2018 | return err; |
| 2019 | } |
| 2020 | |
| 2021 | return 0; |
| 2022 | } |
| 2023 | |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 2024 | struct mv88e6xxx_port_broadcast_sync_ctx { |
| 2025 | int port; |
| 2026 | bool flood; |
| 2027 | }; |
| 2028 | |
| 2029 | static int |
| 2030 | mv88e6xxx_port_broadcast_sync_vlan(struct mv88e6xxx_chip *chip, |
| 2031 | const struct mv88e6xxx_vtu_entry *vlan, |
| 2032 | void *_ctx) |
| 2033 | { |
| 2034 | struct mv88e6xxx_port_broadcast_sync_ctx *ctx = _ctx; |
| 2035 | u8 broadcast[ETH_ALEN]; |
| 2036 | u8 state; |
| 2037 | |
| 2038 | if (ctx->flood) |
| 2039 | state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC; |
| 2040 | else |
| 2041 | state = MV88E6XXX_G1_ATU_DATA_STATE_MC_UNUSED; |
| 2042 | |
| 2043 | eth_broadcast_addr(broadcast); |
| 2044 | |
| 2045 | return mv88e6xxx_port_db_load_purge(chip, ctx->port, broadcast, |
| 2046 | vlan->vid, state); |
| 2047 | } |
| 2048 | |
| 2049 | static int mv88e6xxx_port_broadcast_sync(struct mv88e6xxx_chip *chip, int port, |
| 2050 | bool flood) |
| 2051 | { |
| 2052 | struct mv88e6xxx_port_broadcast_sync_ctx ctx = { |
| 2053 | .port = port, |
| 2054 | .flood = flood, |
| 2055 | }; |
| 2056 | struct mv88e6xxx_vtu_entry vid0 = { |
| 2057 | .vid = 0, |
| 2058 | }; |
| 2059 | int err; |
| 2060 | |
| 2061 | /* Update the port's private database... */ |
| 2062 | err = mv88e6xxx_port_broadcast_sync_vlan(chip, &vid0, &ctx); |
| 2063 | if (err) |
| 2064 | return err; |
| 2065 | |
| 2066 | /* ...and the database for all VLANs. */ |
| 2067 | return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_broadcast_sync_vlan, |
| 2068 | &ctx); |
| 2069 | } |
| 2070 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2071 | static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port, |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2072 | u16 vid, u8 member, bool warn) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2073 | { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2074 | const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 2075 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2076 | int i, err; |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 2077 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2078 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2079 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2080 | return err; |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2081 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2082 | if (!vlan.valid) { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2083 | memset(&vlan, 0, sizeof(vlan)); |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 2084 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2085 | err = mv88e6xxx_atu_new(chip, &vlan.fid); |
| 2086 | if (err) |
| 2087 | return err; |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2088 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2089 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) |
| 2090 | if (i == port) |
| 2091 | vlan.member[i] = member; |
| 2092 | else |
| 2093 | vlan.member[i] = non_member; |
| 2094 | |
| 2095 | vlan.vid = vid; |
| 2096 | vlan.valid = true; |
| 2097 | |
| 2098 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
| 2099 | if (err) |
| 2100 | return err; |
| 2101 | |
| 2102 | err = mv88e6xxx_broadcast_setup(chip, vlan.vid); |
| 2103 | if (err) |
| 2104 | return err; |
| 2105 | } else if (vlan.member[port] != member) { |
| 2106 | vlan.member[port] = member; |
| 2107 | |
| 2108 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
| 2109 | if (err) |
| 2110 | return err; |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2111 | } else if (warn) { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2112 | dev_info(chip->dev, "p%d: already a member of VLAN %d\n", |
| 2113 | port, vid); |
| 2114 | } |
| 2115 | |
| 2116 | return 0; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2117 | } |
| 2118 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2119 | static int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, |
Vladimir Oltean | 31046a5 | 2021-02-13 22:43:18 +0200 | [diff] [blame] | 2120 | const struct switchdev_obj_port_vlan *vlan, |
| 2121 | struct netlink_ext_ack *extack) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2122 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2123 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2124 | bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; |
| 2125 | bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2126 | bool warn; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2127 | u8 member; |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2128 | int err; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2129 | |
Eldar Gasanov | b8b79c4 | 2021-06-21 11:54:38 +0300 | [diff] [blame] | 2130 | if (!vlan->vid) |
| 2131 | return 0; |
| 2132 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2133 | err = mv88e6xxx_port_vlan_prepare(ds, port, vlan); |
| 2134 | if (err) |
| 2135 | return err; |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 2136 | |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2137 | 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] | 2138 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2139 | else if (untagged) |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2140 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2141 | else |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2142 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2143 | |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2144 | /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port |
| 2145 | * and then the CPU port. Do not warn for duplicates for the CPU port. |
| 2146 | */ |
| 2147 | warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port); |
| 2148 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2149 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2150 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2151 | err = mv88e6xxx_port_vlan_join(chip, port, vlan->vid, member, warn); |
| 2152 | if (err) { |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 2153 | dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port, |
| 2154 | vlan->vid, untagged ? 'u' : 't'); |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2155 | goto out; |
| 2156 | } |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2157 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2158 | if (pvid) { |
| 2159 | err = mv88e6xxx_port_set_pvid(chip, port, vlan->vid); |
| 2160 | if (err) { |
| 2161 | dev_err(ds->dev, "p%d: failed to set PVID %d\n", |
| 2162 | port, vlan->vid); |
| 2163 | goto out; |
| 2164 | } |
| 2165 | } |
| 2166 | out: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2167 | mv88e6xxx_reg_unlock(chip); |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2168 | |
| 2169 | return err; |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 2170 | } |
| 2171 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2172 | static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip, |
| 2173 | int port, u16 vid) |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2174 | { |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 2175 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2176 | int i, err; |
| 2177 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2178 | if (!vid) |
Vladimir Oltean | c92c741 | 2021-07-22 16:05:51 +0300 | [diff] [blame] | 2179 | return 0; |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2180 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2181 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2182 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2183 | return err; |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2184 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2185 | /* If the VLAN doesn't exist in hardware or the port isn't a member, |
| 2186 | * tell switchdev that this VLAN is likely handled in software. |
| 2187 | */ |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2188 | if (!vlan.valid || |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2189 | vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) |
Vivien Didelot | 3c06f08 | 2016-02-05 14:04:39 -0500 | [diff] [blame] | 2190 | return -EOPNOTSUPP; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2191 | |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2192 | vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2193 | |
| 2194 | /* keep the VLAN unless all ports are excluded */ |
Vivien Didelot | f02bdff | 2015-10-11 18:08:36 -0400 | [diff] [blame] | 2195 | vlan.valid = false; |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 2196 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2197 | if (vlan.member[i] != |
| 2198 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) { |
Vivien Didelot | f02bdff | 2015-10-11 18:08:36 -0400 | [diff] [blame] | 2199 | vlan.valid = true; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2200 | break; |
| 2201 | } |
| 2202 | } |
| 2203 | |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2204 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2205 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2206 | return err; |
| 2207 | |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 2208 | return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2209 | } |
| 2210 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2211 | static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, |
| 2212 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2213 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2214 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2215 | int err = 0; |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 2216 | u16 pvid; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2217 | |
Tobias Waldekranz | e545f86 | 2020-11-10 19:57:20 +0100 | [diff] [blame] | 2218 | if (!mv88e6xxx_max_vid(chip)) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 2219 | return -EOPNOTSUPP; |
| 2220 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2221 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2222 | |
Vivien Didelot | 77064f3 | 2016-11-04 03:23:30 +0100 | [diff] [blame] | 2223 | err = mv88e6xxx_port_get_pvid(chip, port, &pvid); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2224 | if (err) |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2225 | goto unlock; |
| 2226 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 2227 | err = mv88e6xxx_port_vlan_leave(chip, port, vlan->vid); |
| 2228 | if (err) |
| 2229 | goto unlock; |
| 2230 | |
| 2231 | if (vlan->vid == pvid) { |
| 2232 | err = mv88e6xxx_port_set_pvid(chip, port, 0); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2233 | if (err) |
| 2234 | goto unlock; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2235 | } |
| 2236 | |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2237 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2238 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2239 | |
| 2240 | return err; |
| 2241 | } |
| 2242 | |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2243 | static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port, |
| 2244 | const unsigned char *addr, u16 vid) |
Guenter Roeck | defb05b | 2015-03-26 18:36:38 -0700 | [diff] [blame] | 2245 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2246 | struct mv88e6xxx_chip *chip = ds->priv; |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2247 | int err; |
Vivien Didelot | 6630e23 | 2015-08-06 01:44:07 -0400 | [diff] [blame] | 2248 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2249 | mv88e6xxx_reg_lock(chip); |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2250 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, |
| 2251 | MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2252 | mv88e6xxx_reg_unlock(chip); |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2253 | |
| 2254 | return err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2255 | } |
| 2256 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2257 | static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port, |
Arkadi Sharshevsky | 6c2c1dc | 2017-08-06 16:15:39 +0300 | [diff] [blame] | 2258 | const unsigned char *addr, u16 vid) |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2259 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2260 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2261 | int err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2262 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2263 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2264 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2265 | mv88e6xxx_reg_unlock(chip); |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2266 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2267 | return err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2268 | } |
| 2269 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2270 | static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip, |
| 2271 | u16 fid, u16 vid, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2272 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2273 | { |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2274 | struct mv88e6xxx_atu_entry addr; |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2275 | bool is_static; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2276 | int err; |
| 2277 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2278 | addr.state = 0; |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2279 | eth_broadcast_addr(addr.mac); |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2280 | |
| 2281 | do { |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2282 | err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr); |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2283 | if (err) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2284 | return err; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2285 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2286 | if (!addr.state) |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2287 | break; |
| 2288 | |
Vivien Didelot | 01bd96c | 2017-03-11 16:12:57 -0500 | [diff] [blame] | 2289 | if (addr.trunk || (addr.portvec & BIT(port)) == 0) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2290 | continue; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2291 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2292 | if (!is_unicast_ether_addr(addr.mac)) |
| 2293 | continue; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2294 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2295 | is_static = (addr.state == |
| 2296 | MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); |
| 2297 | err = cb(addr.mac, vid, is_static, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2298 | if (err) |
| 2299 | return err; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2300 | } while (!is_broadcast_ether_addr(addr.mac)); |
| 2301 | |
| 2302 | return err; |
| 2303 | } |
| 2304 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 2305 | struct mv88e6xxx_port_db_dump_vlan_ctx { |
| 2306 | int port; |
| 2307 | dsa_fdb_dump_cb_t *cb; |
| 2308 | void *data; |
| 2309 | }; |
| 2310 | |
| 2311 | static int mv88e6xxx_port_db_dump_vlan(struct mv88e6xxx_chip *chip, |
| 2312 | const struct mv88e6xxx_vtu_entry *entry, |
| 2313 | void *_data) |
| 2314 | { |
| 2315 | struct mv88e6xxx_port_db_dump_vlan_ctx *ctx = _data; |
| 2316 | |
| 2317 | return mv88e6xxx_port_db_dump_fid(chip, entry->fid, entry->vid, |
| 2318 | ctx->port, ctx->cb, ctx->data); |
| 2319 | } |
| 2320 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2321 | static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, 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 | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2323 | { |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 2324 | struct mv88e6xxx_port_db_dump_vlan_ctx ctx = { |
| 2325 | .port = port, |
| 2326 | .cb = cb, |
| 2327 | .data = data, |
| 2328 | }; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2329 | u16 fid; |
| 2330 | int err; |
| 2331 | |
| 2332 | /* Dump port's default Filtering Information Database (VLAN ID 0) */ |
Vivien Didelot | b4e48c5 | 2016-11-04 03:23:29 +0100 | [diff] [blame] | 2333 | err = mv88e6xxx_port_get_fid(chip, port, &fid); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2334 | if (err) |
| 2335 | return err; |
| 2336 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2337 | err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2338 | if (err) |
| 2339 | return err; |
| 2340 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 2341 | return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_db_dump_vlan, &ctx); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2342 | } |
| 2343 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2344 | static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2345 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2346 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2347 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2348 | int err; |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2349 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2350 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2351 | err = mv88e6xxx_port_db_dump(chip, port, cb, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2352 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2353 | |
| 2354 | return err; |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2355 | } |
| 2356 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2357 | static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip, |
| 2358 | struct net_device *br) |
| 2359 | { |
Vivien Didelot | ef2025e | 2019-10-21 16:51:27 -0400 | [diff] [blame] | 2360 | struct dsa_switch *ds = chip->ds; |
| 2361 | struct dsa_switch_tree *dst = ds->dst; |
| 2362 | struct dsa_port *dp; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2363 | int err; |
| 2364 | |
Vivien Didelot | ef2025e | 2019-10-21 16:51:27 -0400 | [diff] [blame] | 2365 | list_for_each_entry(dp, &dst->ports, list) { |
| 2366 | if (dp->bridge_dev == br) { |
| 2367 | if (dp->ds == ds) { |
| 2368 | /* This is a local bridge group member, |
| 2369 | * remap its Port VLAN Map. |
| 2370 | */ |
| 2371 | err = mv88e6xxx_port_vlan_map(chip, dp->index); |
| 2372 | if (err) |
| 2373 | return err; |
| 2374 | } else { |
| 2375 | /* This is an external bridge group member, |
| 2376 | * remap its cross-chip Port VLAN Table entry. |
| 2377 | */ |
| 2378 | err = mv88e6xxx_pvt_map(chip, dp->ds->index, |
| 2379 | dp->index); |
Vivien Didelot | e96a6e0 | 2017-03-30 17:37:13 -0400 | [diff] [blame] | 2380 | if (err) |
| 2381 | return err; |
| 2382 | } |
| 2383 | } |
| 2384 | } |
| 2385 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2386 | return 0; |
| 2387 | } |
| 2388 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2389 | static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, |
Vivien Didelot | fae8a25 | 2017-01-27 15:29:42 -0500 | [diff] [blame] | 2390 | struct net_device *br) |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2391 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2392 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2393 | int err; |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2394 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2395 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2396 | err = mv88e6xxx_bridge_map(chip, br); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2397 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | a669275 | 2016-02-12 12:09:39 -0500 | [diff] [blame] | 2398 | |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2399 | return err; |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2400 | } |
| 2401 | |
Vivien Didelot | f123f2f | 2017-01-27 15:29:41 -0500 | [diff] [blame] | 2402 | static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port, |
| 2403 | struct net_device *br) |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2404 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2405 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2406 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2407 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2408 | if (mv88e6xxx_bridge_map(chip, br) || |
| 2409 | mv88e6xxx_port_vlan_map(chip, port)) |
| 2410 | dev_err(ds->dev, "failed to remap in-chip Port VLAN\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2411 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 66d9cd0 | 2016-02-05 14:07:14 -0500 | [diff] [blame] | 2412 | } |
| 2413 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2414 | static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, |
| 2415 | int tree_index, int sw_index, |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2416 | int port, struct net_device *br) |
| 2417 | { |
| 2418 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2419 | int err; |
| 2420 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2421 | if (tree_index != ds->dst->index) |
| 2422 | return 0; |
| 2423 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2424 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2425 | err = mv88e6xxx_pvt_map(chip, sw_index, port); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2426 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2427 | |
| 2428 | return err; |
| 2429 | } |
| 2430 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2431 | static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, |
| 2432 | int tree_index, int sw_index, |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2433 | int port, struct net_device *br) |
| 2434 | { |
| 2435 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2436 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2437 | if (tree_index != ds->dst->index) |
| 2438 | return; |
| 2439 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2440 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2441 | if (mv88e6xxx_pvt_map(chip, sw_index, port)) |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2442 | dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2443 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2444 | } |
| 2445 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 2446 | /* Treat the software bridge as a virtual single-port switch behind the |
| 2447 | * CPU and map in the PVT. First dst->last_switch elements are taken by |
| 2448 | * physical switches, so start from beyond that range. |
| 2449 | */ |
| 2450 | static int mv88e6xxx_map_virtual_bridge_to_pvt(struct dsa_switch *ds, |
| 2451 | int bridge_num) |
| 2452 | { |
| 2453 | u8 dev = bridge_num + ds->dst->last_switch + 1; |
| 2454 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2455 | int err; |
| 2456 | |
| 2457 | mv88e6xxx_reg_lock(chip); |
| 2458 | err = mv88e6xxx_pvt_map(chip, dev, 0); |
| 2459 | mv88e6xxx_reg_unlock(chip); |
| 2460 | |
| 2461 | return err; |
| 2462 | } |
| 2463 | |
| 2464 | static int mv88e6xxx_bridge_tx_fwd_offload(struct dsa_switch *ds, int port, |
| 2465 | struct net_device *br, |
| 2466 | int bridge_num) |
| 2467 | { |
| 2468 | return mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge_num); |
| 2469 | } |
| 2470 | |
| 2471 | static void mv88e6xxx_bridge_tx_fwd_unoffload(struct dsa_switch *ds, int port, |
| 2472 | struct net_device *br, |
| 2473 | int bridge_num) |
| 2474 | { |
| 2475 | int err; |
| 2476 | |
| 2477 | err = mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge_num); |
| 2478 | if (err) { |
| 2479 | dev_err(ds->dev, "failed to remap cross-chip Port VLAN: %pe\n", |
| 2480 | ERR_PTR(err)); |
| 2481 | } |
| 2482 | } |
| 2483 | |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2484 | static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip) |
| 2485 | { |
| 2486 | if (chip->info->ops->reset) |
| 2487 | return chip->info->ops->reset(chip); |
| 2488 | |
| 2489 | return 0; |
| 2490 | } |
| 2491 | |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2492 | static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip) |
| 2493 | { |
| 2494 | struct gpio_desc *gpiod = chip->reset; |
| 2495 | |
| 2496 | /* If there is a GPIO connected to the reset pin, toggle it */ |
| 2497 | if (gpiod) { |
| 2498 | gpiod_set_value_cansleep(gpiod, 1); |
| 2499 | usleep_range(10000, 20000); |
| 2500 | gpiod_set_value_cansleep(gpiod, 0); |
| 2501 | usleep_range(10000, 20000); |
Andrew Lunn | a3dcb3e | 2020-11-16 08:43:01 -0800 | [diff] [blame] | 2502 | |
| 2503 | mv88e6xxx_g1_wait_eeprom_done(chip); |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2504 | } |
| 2505 | } |
| 2506 | |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2507 | static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip) |
| 2508 | { |
| 2509 | int i, err; |
| 2510 | |
| 2511 | /* Set all ports to the Disabled state */ |
| 2512 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
Vivien Didelot | f894c29 | 2017-06-08 18:34:10 -0400 | [diff] [blame] | 2513 | err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED); |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2514 | if (err) |
| 2515 | return err; |
| 2516 | } |
| 2517 | |
| 2518 | /* Wait for transmit queues to drain, |
| 2519 | * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps. |
| 2520 | */ |
| 2521 | usleep_range(2000, 4000); |
| 2522 | |
| 2523 | return 0; |
| 2524 | } |
| 2525 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2526 | static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2527 | { |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 2528 | int err; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2529 | |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2530 | err = mv88e6xxx_disable_ports(chip); |
| 2531 | if (err) |
| 2532 | return err; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2533 | |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2534 | mv88e6xxx_hardware_reset(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2535 | |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2536 | return mv88e6xxx_software_reset(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2537 | } |
| 2538 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2539 | static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2540 | enum mv88e6xxx_frame_mode frame, |
| 2541 | enum mv88e6xxx_egress_mode egress, u16 etype) |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2542 | { |
| 2543 | int err; |
| 2544 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2545 | if (!chip->info->ops->port_set_frame_mode) |
| 2546 | return -EOPNOTSUPP; |
| 2547 | |
| 2548 | err = mv88e6xxx_port_set_egress_mode(chip, port, egress); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2549 | if (err) |
| 2550 | return err; |
| 2551 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2552 | err = chip->info->ops->port_set_frame_mode(chip, port, frame); |
| 2553 | if (err) |
| 2554 | return err; |
| 2555 | |
| 2556 | if (chip->info->ops->port_set_ether_type) |
| 2557 | return chip->info->ops->port_set_ether_type(chip, port, etype); |
| 2558 | |
| 2559 | return 0; |
| 2560 | } |
| 2561 | |
| 2562 | static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port) |
| 2563 | { |
| 2564 | return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2565 | MV88E6XXX_EGRESS_MODE_UNMODIFIED, |
Vivien Didelot | b810959 | 2017-06-12 12:37:45 -0400 | [diff] [blame] | 2566 | MV88E6XXX_PORT_ETH_TYPE_DEFAULT); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2567 | } |
| 2568 | |
| 2569 | static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port) |
| 2570 | { |
| 2571 | return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2572 | MV88E6XXX_EGRESS_MODE_UNMODIFIED, |
Vivien Didelot | b810959 | 2017-06-12 12:37:45 -0400 | [diff] [blame] | 2573 | MV88E6XXX_PORT_ETH_TYPE_DEFAULT); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2574 | } |
| 2575 | |
| 2576 | static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port) |
| 2577 | { |
| 2578 | return mv88e6xxx_set_port_mode(chip, port, |
| 2579 | MV88E6XXX_FRAME_MODE_ETHERTYPE, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2580 | MV88E6XXX_EGRESS_MODE_ETHERTYPE, |
| 2581 | ETH_P_EDSA); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2582 | } |
| 2583 | |
| 2584 | static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port) |
| 2585 | { |
| 2586 | if (dsa_is_dsa_port(chip->ds, port)) |
| 2587 | return mv88e6xxx_set_port_mode_dsa(chip, port); |
| 2588 | |
Vivien Didelot | 2b3e989 | 2017-10-26 11:22:54 -0400 | [diff] [blame] | 2589 | if (dsa_is_user_port(chip->ds, port)) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2590 | return mv88e6xxx_set_port_mode_normal(chip, port); |
| 2591 | |
| 2592 | /* Setup CPU port mode depending on its supported tag format */ |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 2593 | if (chip->tag_protocol == DSA_TAG_PROTO_DSA) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2594 | return mv88e6xxx_set_port_mode_dsa(chip, port); |
| 2595 | |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 2596 | if (chip->tag_protocol == DSA_TAG_PROTO_EDSA) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2597 | return mv88e6xxx_set_port_mode_edsa(chip, port); |
| 2598 | |
| 2599 | return -EINVAL; |
| 2600 | } |
| 2601 | |
Vivien Didelot | ea698f4 | 2017-03-11 16:12:50 -0500 | [diff] [blame] | 2602 | static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port) |
| 2603 | { |
| 2604 | bool message = dsa_is_dsa_port(chip->ds, port); |
| 2605 | |
| 2606 | return mv88e6xxx_port_set_message_port(chip, port, message); |
| 2607 | } |
| 2608 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2609 | static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port) |
| 2610 | { |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2611 | int err; |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2612 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2613 | if (chip->info->ops->port_set_ucast_flood) { |
Tobias Waldekranz | 7b9f16f | 2021-03-18 20:25:38 +0100 | [diff] [blame] | 2614 | err = chip->info->ops->port_set_ucast_flood(chip, port, true); |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2615 | if (err) |
| 2616 | return err; |
| 2617 | } |
| 2618 | if (chip->info->ops->port_set_mcast_flood) { |
Tobias Waldekranz | 7b9f16f | 2021-03-18 20:25:38 +0100 | [diff] [blame] | 2619 | err = chip->info->ops->port_set_mcast_flood(chip, port, true); |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2620 | if (err) |
| 2621 | return err; |
| 2622 | } |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2623 | |
David S. Miller | 407308f | 2019-06-15 13:35:29 -0700 | [diff] [blame] | 2624 | return 0; |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2625 | } |
| 2626 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2627 | static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id) |
| 2628 | { |
| 2629 | struct mv88e6xxx_port *mvp = dev_id; |
| 2630 | struct mv88e6xxx_chip *chip = mvp->chip; |
| 2631 | irqreturn_t ret = IRQ_NONE; |
| 2632 | int port = mvp->port; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2633 | int lane; |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2634 | |
| 2635 | mv88e6xxx_reg_lock(chip); |
| 2636 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2637 | if (lane >= 0) |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2638 | ret = mv88e6xxx_serdes_irq_status(chip, port, lane); |
| 2639 | mv88e6xxx_reg_unlock(chip); |
| 2640 | |
| 2641 | return ret; |
| 2642 | } |
| 2643 | |
| 2644 | static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port, |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2645 | int lane) |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2646 | { |
| 2647 | struct mv88e6xxx_port *dev_id = &chip->ports[port]; |
| 2648 | unsigned int irq; |
| 2649 | int err; |
| 2650 | |
| 2651 | /* Nothing to request if this SERDES port has no IRQ */ |
| 2652 | irq = mv88e6xxx_serdes_irq_mapping(chip, port); |
| 2653 | if (!irq) |
| 2654 | return 0; |
| 2655 | |
Andrew Lunn | e6f2f6b | 2020-01-06 17:13:49 +0100 | [diff] [blame] | 2656 | snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name), |
| 2657 | "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port); |
| 2658 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2659 | /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */ |
| 2660 | mv88e6xxx_reg_unlock(chip); |
| 2661 | err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn, |
Andrew Lunn | e6f2f6b | 2020-01-06 17:13:49 +0100 | [diff] [blame] | 2662 | IRQF_ONESHOT, dev_id->serdes_irq_name, |
| 2663 | dev_id); |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2664 | mv88e6xxx_reg_lock(chip); |
| 2665 | if (err) |
| 2666 | return err; |
| 2667 | |
| 2668 | dev_id->serdes_irq = irq; |
| 2669 | |
| 2670 | return mv88e6xxx_serdes_irq_enable(chip, port, lane); |
| 2671 | } |
| 2672 | |
| 2673 | static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port, |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2674 | int lane) |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2675 | { |
| 2676 | struct mv88e6xxx_port *dev_id = &chip->ports[port]; |
| 2677 | unsigned int irq = dev_id->serdes_irq; |
| 2678 | int err; |
| 2679 | |
| 2680 | /* Nothing to free if no IRQ has been requested */ |
| 2681 | if (!irq) |
| 2682 | return 0; |
| 2683 | |
| 2684 | err = mv88e6xxx_serdes_irq_disable(chip, port, lane); |
| 2685 | |
| 2686 | /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */ |
| 2687 | mv88e6xxx_reg_unlock(chip); |
| 2688 | free_irq(irq, dev_id); |
| 2689 | mv88e6xxx_reg_lock(chip); |
| 2690 | |
| 2691 | dev_id->serdes_irq = 0; |
| 2692 | |
| 2693 | return err; |
| 2694 | } |
| 2695 | |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2696 | static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port, |
| 2697 | bool on) |
| 2698 | { |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2699 | int lane; |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2700 | int err; |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2701 | |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2702 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2703 | if (lane < 0) |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2704 | return 0; |
| 2705 | |
| 2706 | if (on) { |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2707 | err = mv88e6xxx_serdes_power_up(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2708 | if (err) |
| 2709 | return err; |
| 2710 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2711 | err = mv88e6xxx_serdes_irq_request(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2712 | } else { |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2713 | err = mv88e6xxx_serdes_irq_free(chip, port, lane); |
| 2714 | if (err) |
| 2715 | return err; |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2716 | |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2717 | err = mv88e6xxx_serdes_power_down(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2718 | } |
| 2719 | |
| 2720 | return err; |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2721 | } |
| 2722 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2723 | static int mv88e6xxx_set_egress_port(struct mv88e6xxx_chip *chip, |
| 2724 | enum mv88e6xxx_egress_direction direction, |
| 2725 | int port) |
| 2726 | { |
| 2727 | int err; |
| 2728 | |
| 2729 | if (!chip->info->ops->set_egress_port) |
| 2730 | return -EOPNOTSUPP; |
| 2731 | |
| 2732 | err = chip->info->ops->set_egress_port(chip, direction, port); |
| 2733 | if (err) |
| 2734 | return err; |
| 2735 | |
| 2736 | if (direction == MV88E6XXX_EGRESS_DIR_INGRESS) |
| 2737 | chip->ingress_dest_port = port; |
| 2738 | else |
| 2739 | chip->egress_dest_port = port; |
| 2740 | |
| 2741 | return 0; |
| 2742 | } |
| 2743 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2744 | static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port) |
| 2745 | { |
| 2746 | struct dsa_switch *ds = chip->ds; |
| 2747 | int upstream_port; |
| 2748 | int err; |
| 2749 | |
Vivien Didelot | 07073c7 | 2017-12-05 15:34:13 -0500 | [diff] [blame] | 2750 | upstream_port = dsa_upstream_port(ds, port); |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2751 | if (chip->info->ops->port_set_upstream_port) { |
| 2752 | err = chip->info->ops->port_set_upstream_port(chip, port, |
| 2753 | upstream_port); |
| 2754 | if (err) |
| 2755 | return err; |
| 2756 | } |
| 2757 | |
Vivien Didelot | 0ea54dd | 2017-12-05 15:34:11 -0500 | [diff] [blame] | 2758 | if (port == upstream_port) { |
| 2759 | if (chip->info->ops->set_cpu_port) { |
| 2760 | err = chip->info->ops->set_cpu_port(chip, |
| 2761 | upstream_port); |
| 2762 | if (err) |
| 2763 | return err; |
| 2764 | } |
| 2765 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2766 | err = mv88e6xxx_set_egress_port(chip, |
Iwan R Timmer | 5c74c54 | 2019-11-07 22:11:13 +0100 | [diff] [blame] | 2767 | MV88E6XXX_EGRESS_DIR_INGRESS, |
| 2768 | upstream_port); |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2769 | if (err && err != -EOPNOTSUPP) |
| 2770 | return err; |
Iwan R Timmer | 5c74c54 | 2019-11-07 22:11:13 +0100 | [diff] [blame] | 2771 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2772 | err = mv88e6xxx_set_egress_port(chip, |
Iwan R Timmer | 5c74c54 | 2019-11-07 22:11:13 +0100 | [diff] [blame] | 2773 | MV88E6XXX_EGRESS_DIR_EGRESS, |
| 2774 | upstream_port); |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2775 | if (err && err != -EOPNOTSUPP) |
| 2776 | return err; |
Vivien Didelot | 0ea54dd | 2017-12-05 15:34:11 -0500 | [diff] [blame] | 2777 | } |
| 2778 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2779 | return 0; |
| 2780 | } |
| 2781 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2782 | static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2783 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2784 | struct dsa_switch *ds = chip->ds; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2785 | int err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2786 | u16 reg; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2787 | |
Andrew Lunn | 7b89846 | 2018-08-09 15:38:47 +0200 | [diff] [blame] | 2788 | chip->ports[port].chip = chip; |
| 2789 | chip->ports[port].port = port; |
| 2790 | |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2791 | /* MAC Forcing register: don't force link, speed, duplex or flow control |
| 2792 | * state to any particular values on physical ports, but force the CPU |
| 2793 | * port and all DSA ports to their maximum bandwidth and full duplex. |
| 2794 | */ |
| 2795 | if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) |
| 2796 | err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP, |
| 2797 | SPEED_MAX, DUPLEX_FULL, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 2798 | PAUSE_OFF, |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2799 | PHY_INTERFACE_MODE_NA); |
| 2800 | else |
| 2801 | err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED, |
| 2802 | SPEED_UNFORCED, DUPLEX_UNFORCED, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 2803 | PAUSE_ON, |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2804 | PHY_INTERFACE_MODE_NA); |
| 2805 | if (err) |
| 2806 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2807 | |
| 2808 | /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock, |
| 2809 | * disable Header mode, enable IGMP/MLD snooping, disable VLAN |
| 2810 | * tunneling, determine priority by looking at 802.1p and IP |
| 2811 | * priority fields (IP prio has precedence), and set STP state |
| 2812 | * to Forwarding. |
| 2813 | * |
| 2814 | * If this is the CPU link, use DSA or EDSA tagging depending |
| 2815 | * on which tagging mode was configured. |
| 2816 | * |
| 2817 | * If this is a link to another switch, use DSA tagging mode. |
| 2818 | * |
| 2819 | * If this is the upstream port for this switch, enable |
| 2820 | * forwarding of unknown unicasts and multicasts. |
| 2821 | */ |
Vivien Didelot | a89b433be | 2017-06-12 12:37:37 -0400 | [diff] [blame] | 2822 | reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP | |
| 2823 | MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP | |
| 2824 | MV88E6XXX_PORT_CTL0_STATE_FORWARDING; |
| 2825 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2826 | if (err) |
| 2827 | return err; |
Andrew Lunn | 6083ce7 | 2015-08-17 23:52:52 +0200 | [diff] [blame] | 2828 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2829 | err = mv88e6xxx_setup_port_mode(chip, port); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2830 | if (err) |
| 2831 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2832 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2833 | err = mv88e6xxx_setup_egress_floods(chip, port); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2834 | if (err) |
| 2835 | return err; |
| 2836 | |
Vivien Didelot | 8efdda4 | 2015-08-13 12:52:23 -0400 | [diff] [blame] | 2837 | /* Port Control 2: don't force a good FCS, set the maximum frame size to |
Vivien Didelot | 46fbe5e | 2016-02-26 13:16:07 -0500 | [diff] [blame] | 2838 | * 10240 bytes, disable 802.1q tags checking, don't discard tagged or |
Vivien Didelot | 8efdda4 | 2015-08-13 12:52:23 -0400 | [diff] [blame] | 2839 | * untagged frames on this port, do a destination address lookup on all |
| 2840 | * received packets as usual, disable ARP mirroring and don't send a |
| 2841 | * copy of all transmitted/received frames on this port to the CPU. |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2842 | */ |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2843 | err = mv88e6xxx_port_set_map_da(chip, port); |
| 2844 | if (err) |
| 2845 | return err; |
| 2846 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2847 | err = mv88e6xxx_setup_upstream_port(chip, port); |
| 2848 | if (err) |
| 2849 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2850 | |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2851 | err = mv88e6xxx_port_set_8021q_mode(chip, port, |
Vivien Didelot | 81c6edb | 2017-06-12 12:37:41 -0400 | [diff] [blame] | 2852 | MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED); |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2853 | if (err) |
| 2854 | return err; |
| 2855 | |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2856 | if (chip->info->ops->port_set_jumbo_size) { |
| 2857 | err = chip->info->ops->port_set_jumbo_size(chip, port, 10240); |
Andrew Lunn | 5f43666 | 2016-12-03 04:45:17 +0100 | [diff] [blame] | 2858 | if (err) |
| 2859 | return err; |
| 2860 | } |
| 2861 | |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 2862 | /* Port Association Vector: disable automatic address learning |
| 2863 | * on all user ports since they start out in standalone |
| 2864 | * mode. When joining a bridge, learning will be configured to |
| 2865 | * match the bridge port settings. Enable learning on all |
| 2866 | * DSA/CPU ports. NOTE: FROM_CPU frames always bypass the |
| 2867 | * learning process. |
| 2868 | * |
| 2869 | * Disable HoldAt1, IntOnAgeOut, LockedPort, IgnoreWrongData, |
| 2870 | * and RefreshLocked. I.e. setup standard automatic learning. |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2871 | */ |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 2872 | if (dsa_is_user_port(ds, port)) |
Vivien Didelot | 65fa402 | 2016-04-14 14:42:07 -0400 | [diff] [blame] | 2873 | reg = 0; |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 2874 | else |
| 2875 | reg = 1 << port; |
Andrew Lunn | 4c7ea3c | 2015-11-03 10:52:36 -0500 | [diff] [blame] | 2876 | |
Vivien Didelot | 2a4614e | 2017-06-12 12:37:43 -0400 | [diff] [blame] | 2877 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR, |
| 2878 | reg); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2879 | if (err) |
| 2880 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2881 | |
| 2882 | /* Egress rate control 2: disable egress rate control. */ |
Vivien Didelot | 2cb8cb1 | 2017-06-12 12:37:42 -0400 | [diff] [blame] | 2883 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2, |
| 2884 | 0x0000); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2885 | if (err) |
| 2886 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2887 | |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2888 | if (chip->info->ops->port_pause_limit) { |
| 2889 | err = chip->info->ops->port_pause_limit(chip, port, 0, 0); |
Andrew Lunn | b35d322a | 2016-12-03 04:45:19 +0100 | [diff] [blame] | 2890 | if (err) |
| 2891 | return err; |
| 2892 | } |
| 2893 | |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2894 | if (chip->info->ops->port_disable_learn_limit) { |
| 2895 | err = chip->info->ops->port_disable_learn_limit(chip, port); |
| 2896 | if (err) |
| 2897 | return err; |
| 2898 | } |
| 2899 | |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2900 | if (chip->info->ops->port_disable_pri_override) { |
| 2901 | err = chip->info->ops->port_disable_pri_override(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2902 | if (err) |
| 2903 | return err; |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2904 | } |
Andrew Lunn | 2bbb33b | 2016-08-22 16:01:02 +0200 | [diff] [blame] | 2905 | |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2906 | if (chip->info->ops->port_tag_remap) { |
| 2907 | err = chip->info->ops->port_tag_remap(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2908 | if (err) |
| 2909 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2910 | } |
| 2911 | |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2912 | if (chip->info->ops->port_egress_rate_limiting) { |
| 2913 | err = chip->info->ops->port_egress_rate_limiting(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2914 | if (err) |
| 2915 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2916 | } |
| 2917 | |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 2918 | if (chip->info->ops->port_setup_message_port) { |
| 2919 | err = chip->info->ops->port_setup_message_port(chip, port); |
| 2920 | if (err) |
| 2921 | return err; |
| 2922 | } |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2923 | |
Vivien Didelot | 207afda | 2016-04-14 14:42:09 -0400 | [diff] [blame] | 2924 | /* Port based VLAN map: give each port the same default address |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 2925 | * database, and allow bidirectional communication between the |
| 2926 | * CPU and DSA port(s), and the other ports. |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2927 | */ |
Vivien Didelot | b4e48c5 | 2016-11-04 03:23:29 +0100 | [diff] [blame] | 2928 | err = mv88e6xxx_port_set_fid(chip, port, 0); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2929 | if (err) |
| 2930 | return err; |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 2931 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2932 | err = mv88e6xxx_port_vlan_map(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2933 | if (err) |
| 2934 | return err; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2935 | |
| 2936 | /* Default VLAN ID and priority: don't set a default VLAN |
| 2937 | * ID, and set the default packet priority to zero. |
| 2938 | */ |
Vivien Didelot | b7929fb | 2017-06-12 12:37:40 -0400 | [diff] [blame] | 2939 | return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0); |
Andrew Lunn | dbde9e6 | 2015-05-06 01:09:48 +0200 | [diff] [blame] | 2940 | } |
| 2941 | |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 2942 | static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port) |
| 2943 | { |
| 2944 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2945 | |
| 2946 | if (chip->info->ops->port_set_jumbo_size) |
| 2947 | return 10240; |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 2948 | else if (chip->info->ops->set_max_frame_size) |
| 2949 | return 1632; |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 2950 | return 1522; |
| 2951 | } |
| 2952 | |
| 2953 | static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu) |
| 2954 | { |
| 2955 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2956 | int ret = 0; |
| 2957 | |
| 2958 | mv88e6xxx_reg_lock(chip); |
| 2959 | if (chip->info->ops->port_set_jumbo_size) |
| 2960 | ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu); |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 2961 | else if (chip->info->ops->set_max_frame_size) |
| 2962 | ret = chip->info->ops->set_max_frame_size(chip, new_mtu); |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 2963 | else |
| 2964 | if (new_mtu > 1522) |
| 2965 | ret = -EINVAL; |
| 2966 | mv88e6xxx_reg_unlock(chip); |
| 2967 | |
| 2968 | return ret; |
| 2969 | } |
| 2970 | |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2971 | static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port, |
| 2972 | struct phy_device *phydev) |
| 2973 | { |
| 2974 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 2975 | int err; |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2976 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2977 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 2978 | err = mv88e6xxx_serdes_power(chip, port, true); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2979 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2980 | |
| 2981 | return err; |
| 2982 | } |
| 2983 | |
Andrew Lunn | 75104db | 2019-02-24 20:44:43 +0100 | [diff] [blame] | 2984 | static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port) |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2985 | { |
| 2986 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2987 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2988 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 2989 | if (mv88e6xxx_serdes_power(chip, port, false)) |
| 2990 | dev_err(chip->dev, "failed to power off SERDES\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2991 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2992 | } |
| 2993 | |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 2994 | static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds, |
| 2995 | unsigned int ageing_time) |
| 2996 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2997 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 2998 | int err; |
| 2999 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3000 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 720c634 | 2017-03-11 16:12:48 -0500 | [diff] [blame] | 3001 | err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3002 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 3003 | |
| 3004 | return err; |
| 3005 | } |
| 3006 | |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 3007 | static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 3008 | { |
| 3009 | int err; |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 3010 | |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3011 | /* Initialize the statistics unit */ |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 3012 | if (chip->info->ops->stats_set_histogram) { |
| 3013 | err = chip->info->ops->stats_set_histogram(chip); |
| 3014 | if (err) |
| 3015 | return err; |
| 3016 | } |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3017 | |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3018 | return mv88e6xxx_g1_stats_clear(chip); |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3019 | } |
| 3020 | |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3021 | /* Check if the errata has already been applied. */ |
| 3022 | static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip) |
| 3023 | { |
| 3024 | int port; |
| 3025 | int err; |
| 3026 | u16 val; |
| 3027 | |
| 3028 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Marek Behún | 6090701 | 2019-08-26 23:31:51 +0200 | [diff] [blame] | 3029 | err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val); |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3030 | if (err) { |
| 3031 | dev_err(chip->dev, |
| 3032 | "Error reading hidden register: %d\n", err); |
| 3033 | return false; |
| 3034 | } |
| 3035 | if (val != 0x01c0) |
| 3036 | return false; |
| 3037 | } |
| 3038 | |
| 3039 | return true; |
| 3040 | } |
| 3041 | |
| 3042 | /* The 6390 copper ports have an errata which require poking magic |
| 3043 | * values into undocumented hidden registers and then performing a |
| 3044 | * software reset. |
| 3045 | */ |
| 3046 | static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip) |
| 3047 | { |
| 3048 | int port; |
| 3049 | int err; |
| 3050 | |
| 3051 | if (mv88e6390_setup_errata_applied(chip)) |
| 3052 | return 0; |
| 3053 | |
| 3054 | /* Set the ports into blocking mode */ |
| 3055 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 3056 | err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED); |
| 3057 | if (err) |
| 3058 | return err; |
| 3059 | } |
| 3060 | |
| 3061 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Marek Behún | 6090701 | 2019-08-26 23:31:51 +0200 | [diff] [blame] | 3062 | err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0); |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3063 | if (err) |
| 3064 | return err; |
| 3065 | } |
| 3066 | |
| 3067 | return mv88e6xxx_software_reset(chip); |
| 3068 | } |
| 3069 | |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3070 | static void mv88e6xxx_teardown(struct dsa_switch *ds) |
| 3071 | { |
| 3072 | mv88e6xxx_teardown_devlink_params(ds); |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3073 | dsa_devlink_resources_unregister(ds); |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 3074 | mv88e6xxx_teardown_devlink_regions_global(ds); |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3075 | } |
| 3076 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3077 | static int mv88e6xxx_setup(struct dsa_switch *ds) |
Guenter Roeck | acdaffc | 2015-03-26 18:36:28 -0700 | [diff] [blame] | 3078 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3079 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3080 | u8 cmode; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3081 | int err; |
Vivien Didelot | a1a6a4d | 2016-05-09 13:22:56 -0400 | [diff] [blame] | 3082 | int i; |
| 3083 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3084 | chip->ds = ds; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3085 | ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3086 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 3087 | /* Since virtual bridges are mapped in the PVT, the number we support |
| 3088 | * depends on the physical switch topology. We need to let DSA figure |
| 3089 | * that out and therefore we cannot set this at dsa_register_switch() |
| 3090 | * time. |
| 3091 | */ |
| 3092 | if (mv88e6xxx_has_pvt(chip)) |
| 3093 | ds->num_fwd_offloading_bridges = MV88E6XXX_MAX_PVT_SWITCHES - |
| 3094 | ds->dst->last_switch - 1; |
| 3095 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3096 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3097 | |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3098 | if (chip->info->ops->setup_errata) { |
| 3099 | err = chip->info->ops->setup_errata(chip); |
| 3100 | if (err) |
| 3101 | goto unlock; |
| 3102 | } |
| 3103 | |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3104 | /* Cache the cmode of each port. */ |
| 3105 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
| 3106 | if (chip->info->ops->port_get_cmode) { |
| 3107 | err = chip->info->ops->port_get_cmode(chip, i, &cmode); |
| 3108 | if (err) |
Dan Carpenter | e29129f | 2018-08-14 12:09:05 +0300 | [diff] [blame] | 3109 | goto unlock; |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3110 | |
| 3111 | chip->ports[i].cmode = cmode; |
| 3112 | } |
| 3113 | } |
| 3114 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3115 | /* Setup Switch Port Registers */ |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 3116 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
Vivien Didelot | b759f52 | 2019-08-19 16:00:52 -0400 | [diff] [blame] | 3117 | if (dsa_is_unused_port(ds, i)) |
| 3118 | continue; |
| 3119 | |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 3120 | /* Prevent the use of an invalid port. */ |
Vivien Didelot | b759f52 | 2019-08-19 16:00:52 -0400 | [diff] [blame] | 3121 | if (mv88e6xxx_is_invalid_port(chip, i)) { |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 3122 | dev_err(chip->dev, "port %d is invalid\n", i); |
| 3123 | err = -EINVAL; |
| 3124 | goto unlock; |
| 3125 | } |
| 3126 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3127 | err = mv88e6xxx_setup_port(chip, i); |
| 3128 | if (err) |
| 3129 | goto unlock; |
| 3130 | } |
| 3131 | |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3132 | err = mv88e6xxx_irl_setup(chip); |
| 3133 | if (err) |
| 3134 | goto unlock; |
| 3135 | |
Vivien Didelot | 04a69a1 | 2017-10-13 14:18:05 -0400 | [diff] [blame] | 3136 | err = mv88e6xxx_mac_setup(chip); |
| 3137 | if (err) |
| 3138 | goto unlock; |
| 3139 | |
Vivien Didelot | 1b17aed | 2017-05-26 18:03:05 -0400 | [diff] [blame] | 3140 | err = mv88e6xxx_phy_setup(chip); |
| 3141 | if (err) |
| 3142 | goto unlock; |
| 3143 | |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 3144 | err = mv88e6xxx_vtu_setup(chip); |
| 3145 | if (err) |
| 3146 | goto unlock; |
| 3147 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 3148 | err = mv88e6xxx_pvt_setup(chip); |
| 3149 | if (err) |
| 3150 | goto unlock; |
| 3151 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 3152 | err = mv88e6xxx_atu_setup(chip); |
| 3153 | if (err) |
| 3154 | goto unlock; |
| 3155 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 3156 | err = mv88e6xxx_broadcast_setup(chip, 0); |
| 3157 | if (err) |
| 3158 | goto unlock; |
| 3159 | |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3160 | err = mv88e6xxx_pot_setup(chip); |
| 3161 | if (err) |
| 3162 | goto unlock; |
| 3163 | |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3164 | err = mv88e6xxx_rmu_setup(chip); |
| 3165 | if (err) |
| 3166 | goto unlock; |
| 3167 | |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3168 | err = mv88e6xxx_rsvd2cpu_setup(chip); |
| 3169 | if (err) |
| 3170 | goto unlock; |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 3171 | |
Vivien Didelot | b28f872 | 2018-04-26 21:56:44 -0400 | [diff] [blame] | 3172 | err = mv88e6xxx_trunk_setup(chip); |
| 3173 | if (err) |
| 3174 | goto unlock; |
| 3175 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 3176 | err = mv88e6xxx_devmap_setup(chip); |
| 3177 | if (err) |
| 3178 | goto unlock; |
| 3179 | |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3180 | err = mv88e6xxx_pri_setup(chip); |
| 3181 | if (err) |
| 3182 | goto unlock; |
| 3183 | |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 3184 | /* Setup PTP Hardware Clock and timestamping */ |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3185 | if (chip->info->ptp_support) { |
| 3186 | err = mv88e6xxx_ptp_setup(chip); |
| 3187 | if (err) |
| 3188 | goto unlock; |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 3189 | |
| 3190 | err = mv88e6xxx_hwtstamp_setup(chip); |
| 3191 | if (err) |
| 3192 | goto unlock; |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3193 | } |
| 3194 | |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 3195 | err = mv88e6xxx_stats_setup(chip); |
| 3196 | if (err) |
| 3197 | goto unlock; |
| 3198 | |
Vivien Didelot | 6b17e86 | 2015-08-13 12:52:18 -0400 | [diff] [blame] | 3199 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3200 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | db687a5 | 2015-06-20 21:31:29 +0200 | [diff] [blame] | 3201 | |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3202 | if (err) |
| 3203 | return err; |
| 3204 | |
| 3205 | /* Have to be called without holding the register lock, since |
| 3206 | * they take the devlink lock, and we later take the locks in |
| 3207 | * the reverse order when getting/setting parameters or |
| 3208 | * resource occupancy. |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3209 | */ |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3210 | err = mv88e6xxx_setup_devlink_resources(ds); |
| 3211 | if (err) |
| 3212 | return err; |
| 3213 | |
| 3214 | err = mv88e6xxx_setup_devlink_params(ds); |
| 3215 | if (err) |
Andrew Lunn | bfb2554 | 2020-09-18 21:11:07 +0200 | [diff] [blame] | 3216 | goto out_resources; |
| 3217 | |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 3218 | err = mv88e6xxx_setup_devlink_regions_global(ds); |
Andrew Lunn | bfb2554 | 2020-09-18 21:11:07 +0200 | [diff] [blame] | 3219 | if (err) |
| 3220 | goto out_params; |
| 3221 | |
| 3222 | return 0; |
| 3223 | |
| 3224 | out_params: |
| 3225 | mv88e6xxx_teardown_devlink_params(ds); |
| 3226 | out_resources: |
| 3227 | dsa_devlink_resources_unregister(ds); |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3228 | |
| 3229 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 3230 | } |
| 3231 | |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 3232 | static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port) |
| 3233 | { |
| 3234 | return mv88e6xxx_setup_devlink_regions_port(ds, port); |
| 3235 | } |
| 3236 | |
| 3237 | static void mv88e6xxx_port_teardown(struct dsa_switch *ds, int port) |
| 3238 | { |
| 3239 | mv88e6xxx_teardown_devlink_regions_port(ds, port); |
| 3240 | } |
| 3241 | |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3242 | /* prod_id for switch families which do not have a PHY model number */ |
| 3243 | static const u16 family_prod_id_table[] = { |
| 3244 | [MV88E6XXX_FAMILY_6341] = MV88E6XXX_PORT_SWITCH_ID_PROD_6341, |
| 3245 | [MV88E6XXX_FAMILY_6390] = MV88E6XXX_PORT_SWITCH_ID_PROD_6390, |
Marek Behún | c5d015b | 2021-04-20 09:54:02 +0200 | [diff] [blame] | 3246 | [MV88E6XXX_FAMILY_6393] = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X, |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3247 | }; |
| 3248 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3249 | 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] | 3250 | { |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3251 | struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; |
| 3252 | struct mv88e6xxx_chip *chip = mdio_bus->chip; |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3253 | u16 prod_id; |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3254 | u16 val; |
| 3255 | int err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3256 | |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3257 | if (!chip->info->ops->phy_read) |
| 3258 | return -EOPNOTSUPP; |
| 3259 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3260 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3261 | err = chip->info->ops->phy_read(chip, bus, phy, reg, &val); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3262 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3263 | |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3264 | /* Some internal PHYs don't have a model number. */ |
| 3265 | if (reg == MII_PHYSID2 && !(val & 0x3f0) && |
| 3266 | chip->info->family < ARRAY_SIZE(family_prod_id_table)) { |
| 3267 | prod_id = family_prod_id_table[chip->info->family]; |
| 3268 | if (prod_id) |
| 3269 | val |= prod_id >> 4; |
Andrew Lunn | da9f330 | 2017-02-01 03:40:05 +0100 | [diff] [blame] | 3270 | } |
| 3271 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3272 | return err ? err : val; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3273 | } |
| 3274 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3275 | 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] | 3276 | { |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3277 | struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; |
| 3278 | struct mv88e6xxx_chip *chip = mdio_bus->chip; |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3279 | int err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3280 | |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3281 | if (!chip->info->ops->phy_write) |
| 3282 | return -EOPNOTSUPP; |
| 3283 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3284 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3285 | err = chip->info->ops->phy_write(chip, bus, phy, reg, val); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3286 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3287 | |
| 3288 | return err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3289 | } |
| 3290 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3291 | static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip, |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3292 | struct device_node *np, |
| 3293 | bool external) |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3294 | { |
| 3295 | static int index; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3296 | struct mv88e6xxx_mdio_bus *mdio_bus; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3297 | struct mii_bus *bus; |
| 3298 | int err; |
| 3299 | |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3300 | if (external) { |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3301 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3302 | err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3303 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3304 | |
| 3305 | if (err) |
| 3306 | return err; |
| 3307 | } |
| 3308 | |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3309 | bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus)); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3310 | if (!bus) |
| 3311 | return -ENOMEM; |
| 3312 | |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3313 | mdio_bus = bus->priv; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3314 | mdio_bus->bus = bus; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3315 | mdio_bus->chip = chip; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3316 | INIT_LIST_HEAD(&mdio_bus->list); |
| 3317 | mdio_bus->external = external; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3318 | |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3319 | if (np) { |
| 3320 | bus->name = np->full_name; |
Rob Herring | f7ce910 | 2017-07-18 16:43:19 -0500 | [diff] [blame] | 3321 | snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3322 | } else { |
| 3323 | bus->name = "mv88e6xxx SMI"; |
| 3324 | snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++); |
| 3325 | } |
| 3326 | |
| 3327 | bus->read = mv88e6xxx_mdio_read; |
| 3328 | bus->write = mv88e6xxx_mdio_write; |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3329 | bus->parent = chip->dev; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3330 | |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3331 | if (!external) { |
| 3332 | err = mv88e6xxx_g2_irq_mdio_setup(chip, bus); |
| 3333 | if (err) |
| 3334 | return err; |
| 3335 | } |
| 3336 | |
Florian Fainelli | 00e798c | 2018-05-15 16:56:19 -0700 | [diff] [blame] | 3337 | err = of_mdiobus_register(bus, np); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3338 | if (err) { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3339 | dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err); |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3340 | mv88e6xxx_g2_irq_mdio_free(chip, bus); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3341 | return err; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3342 | } |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3343 | |
| 3344 | if (external) |
| 3345 | list_add_tail(&mdio_bus->list, &chip->mdios); |
| 3346 | else |
| 3347 | list_add(&mdio_bus->list, &chip->mdios); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3348 | |
| 3349 | return 0; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3350 | } |
| 3351 | |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3352 | static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip) |
| 3353 | |
| 3354 | { |
| 3355 | struct mv88e6xxx_mdio_bus *mdio_bus; |
| 3356 | struct mii_bus *bus; |
| 3357 | |
| 3358 | list_for_each_entry(mdio_bus, &chip->mdios, list) { |
| 3359 | bus = mdio_bus->bus; |
| 3360 | |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3361 | if (!mdio_bus->external) |
| 3362 | mv88e6xxx_g2_irq_mdio_free(chip, bus); |
| 3363 | |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3364 | mdiobus_unregister(bus); |
| 3365 | } |
| 3366 | } |
| 3367 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3368 | static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, |
| 3369 | struct device_node *np) |
| 3370 | { |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3371 | struct device_node *child; |
| 3372 | int err; |
| 3373 | |
| 3374 | /* Always register one mdio bus for the internal/default mdio |
| 3375 | * bus. This maybe represented in the device tree, but is |
| 3376 | * optional. |
| 3377 | */ |
| 3378 | child = of_get_child_by_name(np, "mdio"); |
| 3379 | err = mv88e6xxx_mdio_register(chip, child, false); |
| 3380 | if (err) |
| 3381 | return err; |
| 3382 | |
| 3383 | /* Walk the device tree, and see if there are any other nodes |
| 3384 | * which say they are compatible with the external mdio |
| 3385 | * bus. |
| 3386 | */ |
| 3387 | for_each_available_child_of_node(np, child) { |
Andrew Lunn | ceb96fa | 2020-09-01 04:32:57 +0200 | [diff] [blame] | 3388 | if (of_device_is_compatible( |
| 3389 | child, "marvell,mv88e6xxx-mdio-external")) { |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3390 | err = mv88e6xxx_mdio_register(chip, child, true); |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3391 | if (err) { |
| 3392 | mv88e6xxx_mdios_unregister(chip); |
Nishka Dasgupta | 78e4204 | 2019-07-23 16:13:07 +0530 | [diff] [blame] | 3393 | of_node_put(child); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3394 | return err; |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3395 | } |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3396 | } |
| 3397 | } |
| 3398 | |
| 3399 | return 0; |
| 3400 | } |
| 3401 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3402 | static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds) |
| 3403 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3404 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3405 | |
| 3406 | return chip->eeprom_len; |
| 3407 | } |
| 3408 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3409 | static int mv88e6xxx_get_eeprom(struct dsa_switch *ds, |
| 3410 | struct ethtool_eeprom *eeprom, u8 *data) |
| 3411 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3412 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3413 | int err; |
| 3414 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3415 | if (!chip->info->ops->get_eeprom) |
| 3416 | return -EOPNOTSUPP; |
| 3417 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3418 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3419 | err = chip->info->ops->get_eeprom(chip, eeprom, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3420 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3421 | |
| 3422 | if (err) |
| 3423 | return err; |
| 3424 | |
| 3425 | eeprom->magic = 0xc3ec4951; |
| 3426 | |
| 3427 | return 0; |
| 3428 | } |
| 3429 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3430 | static int mv88e6xxx_set_eeprom(struct dsa_switch *ds, |
| 3431 | struct ethtool_eeprom *eeprom, u8 *data) |
| 3432 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3433 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3434 | int err; |
| 3435 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3436 | if (!chip->info->ops->set_eeprom) |
| 3437 | return -EOPNOTSUPP; |
| 3438 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3439 | if (eeprom->magic != 0xc3ec4951) |
| 3440 | return -EINVAL; |
| 3441 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3442 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3443 | err = chip->info->ops->set_eeprom(chip, eeprom, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3444 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3445 | |
| 3446 | return err; |
| 3447 | } |
| 3448 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3449 | static const struct mv88e6xxx_ops mv88e6085_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3450 | /* MV88E6XXX_FAMILY_6097 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3451 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3452 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3453 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3454 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3455 | .phy_read = mv88e6185_phy_ppu_read, |
| 3456 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3457 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3458 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3459 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3460 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3461 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3462 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3463 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3464 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3465 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3466 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3467 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3468 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3469 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3470 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3471 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3472 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3473 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3474 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3475 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3476 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3477 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3478 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3479 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3480 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3481 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 3482 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3483 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3484 | .rmu_disable = mv88e6085_g1_rmu_disable, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3485 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3486 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3487 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3488 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3489 | }; |
| 3490 | |
| 3491 | static const struct mv88e6xxx_ops mv88e6095_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3492 | /* MV88E6XXX_FAMILY_6095 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3493 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3494 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3495 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3496 | .phy_read = mv88e6185_phy_ppu_read, |
| 3497 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3498 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3499 | .port_sync_link = mv88e6185_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3500 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3501 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3502 | .port_set_ucast_flood = mv88e6185_port_set_forward_unknown, |
| 3503 | .port_set_mcast_flood = mv88e6185_port_set_default_forward, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 3504 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3505 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3506 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3507 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3508 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3509 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3510 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3511 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3512 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Chris Packham | f5be107 | 2020-11-24 17:34:38 +1300 | [diff] [blame] | 3513 | .serdes_power = mv88e6185_serdes_power, |
| 3514 | .serdes_get_lane = mv88e6185_serdes_get_lane, |
| 3515 | .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3516 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 3517 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3518 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3519 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3520 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3521 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3522 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3523 | }; |
| 3524 | |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3525 | static const struct mv88e6xxx_ops mv88e6097_ops = { |
Stefan Eichenberger | 15da3cc | 2016-11-25 09:41:30 +0100 | [diff] [blame] | 3526 | /* MV88E6XXX_FAMILY_6097 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3527 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3528 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3529 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3530 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3531 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3532 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3533 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3534 | .port_sync_link = mv88e6185_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3535 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3536 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3537 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3538 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3539 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3540 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3541 | .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3542 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3543 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3544 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3545 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3546 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3547 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3548 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3549 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3550 | .stats_get_strings = mv88e6095_stats_get_strings, |
| 3551 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3552 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3553 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Volodymyr Bendiuga | 91eaa47 | 2017-02-14 11:29:30 +0100 | [diff] [blame] | 3554 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3555 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Chris Packham | f5be107 | 2020-11-24 17:34:38 +1300 | [diff] [blame] | 3556 | .serdes_power = mv88e6185_serdes_power, |
| 3557 | .serdes_get_lane = mv88e6185_serdes_get_lane, |
| 3558 | .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, |
Chris Packham | 5c19bc8 | 2020-11-24 17:34:39 +1300 | [diff] [blame] | 3559 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
| 3560 | .serdes_irq_enable = mv88e6097_serdes_irq_enable, |
| 3561 | .serdes_irq_status = mv88e6097_serdes_irq_status, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3562 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3563 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3564 | .rmu_disable = mv88e6085_g1_rmu_disable, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3565 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3566 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3567 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3568 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3569 | }; |
| 3570 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3571 | static const struct mv88e6xxx_ops mv88e6123_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3572 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3573 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3574 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3575 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3576 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | ec8378b | 2017-06-02 23:22:45 +0200 | [diff] [blame] | 3577 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3578 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3579 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3580 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3581 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3582 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3583 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3584 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3585 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3586 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3587 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3588 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 0ac64c3 | 2017-06-02 23:22:46 +0200 | [diff] [blame] | 3589 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3590 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3591 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3592 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3593 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3594 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3595 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3596 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3597 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3598 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3599 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3600 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3601 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3602 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3603 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3604 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3605 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3606 | }; |
| 3607 | |
| 3608 | static const struct mv88e6xxx_ops mv88e6131_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3609 | /* MV88E6XXX_FAMILY_6185 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3610 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3611 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3612 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3613 | .phy_read = mv88e6185_phy_ppu_read, |
| 3614 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3615 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3616 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3617 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3618 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3619 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3620 | .port_set_ucast_flood = mv88e6185_port_set_forward_unknown, |
| 3621 | .port_set_mcast_flood = mv88e6185_port_set_default_forward, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3622 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 3623 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3624 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3625 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3626 | .port_pause_limit = mv88e6097_port_pause_limit, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 3627 | .port_set_pause = mv88e6185_port_set_pause, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3628 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3629 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3630 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3631 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3632 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3633 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3634 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3635 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3636 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3637 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3638 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3639 | .ppu_enable = mv88e6185_g1_ppu_enable, |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 3640 | .set_cascade_port = mv88e6185_g1_set_cascade_port, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3641 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3642 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3643 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3644 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3645 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3646 | }; |
| 3647 | |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3648 | static const struct mv88e6xxx_ops mv88e6141_ops = { |
| 3649 | /* MV88E6XXX_FAMILY_6341 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3650 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3651 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3652 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3653 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3654 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 3655 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3656 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3657 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3658 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3659 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3660 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3661 | .port_set_speed_duplex = mv88e6341_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 3662 | .port_max_speed_mode = mv88e6341_port_max_speed_mode, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3663 | .port_tag_remap = mv88e6095_port_tag_remap, |
Marek Behún | 7da467d | 2021-07-01 00:22:26 +0200 | [diff] [blame] | 3664 | .port_set_policy = mv88e6352_port_set_policy, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3665 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3666 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3667 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3668 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3669 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3670 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3671 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3672 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 3673 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3674 | .port_get_cmode = mv88e6352_port_get_cmode, |
Marek Behún | 7a3007d | 2019-08-26 23:31:55 +0200 | [diff] [blame] | 3675 | .port_set_cmode = mv88e6341_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3676 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3677 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Marek Behún | 11527f3 | 2021-07-01 00:22:27 +0200 | [diff] [blame] | 3678 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3679 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3680 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 3681 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3682 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 3683 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3684 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 3685 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3686 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3687 | .reset = mv88e6352_g1_reset, |
Marek Behún | 3709488 | 2021-07-01 00:22:28 +0200 | [diff] [blame] | 3688 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Marek Behún | c07fff3 | 2021-07-01 00:22:29 +0200 | [diff] [blame] | 3689 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3690 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3691 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3692 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 3693 | .serdes_power = mv88e6390_serdes_power, |
| 3694 | .serdes_get_lane = mv88e6341_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 3695 | /* Check status register pause & lpa register */ |
| 3696 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 3697 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 3698 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 3699 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 3700 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 3701 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 3702 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3703 | .gpio_ops = &mv88e6352_gpio_ops, |
Marek Behún | a03b98d | 2021-07-01 00:22:30 +0200 | [diff] [blame] | 3704 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 3705 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 3706 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Marek Behún | 953b0dc | 2021-07-01 00:22:31 +0200 | [diff] [blame] | 3707 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 3708 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 3709 | .phylink_validate = mv88e6341_phylink_validate, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3710 | }; |
| 3711 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3712 | static const struct mv88e6xxx_ops mv88e6161_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3713 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3714 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3715 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3716 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3717 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | ec8378b | 2017-06-02 23:22:45 +0200 | [diff] [blame] | 3718 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3719 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3720 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3721 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3722 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3723 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3724 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3725 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3726 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3727 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3728 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3729 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3730 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3731 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3732 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3733 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a6da21b | 2019-03-01 23:43:39 +0100 | [diff] [blame] | 3734 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3735 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3736 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3737 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3738 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3739 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3740 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3741 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3742 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3743 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3744 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3745 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3746 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3747 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3748 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | a469a61 | 2018-07-18 22:38:21 +0200 | [diff] [blame] | 3749 | .avb_ops = &mv88e6165_avb_ops, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 3750 | .ptp_ops = &mv88e6165_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3751 | .phylink_validate = mv88e6185_phylink_validate, |
Andrew Lunn | fe23036 | 2021-09-26 19:41:24 +0200 | [diff] [blame^] | 3752 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3753 | }; |
| 3754 | |
| 3755 | static const struct mv88e6xxx_ops mv88e6165_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3756 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3757 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3758 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3759 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3760 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | efb3e74 | 2017-01-24 14:53:47 +0100 | [diff] [blame] | 3761 | .phy_read = mv88e6165_phy_read, |
| 3762 | .phy_write = mv88e6165_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3763 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3764 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3765 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3766 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3767 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3768 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3769 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3770 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3771 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3772 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3773 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3774 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3775 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3776 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3777 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3778 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3779 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3780 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3781 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3782 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3783 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3784 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | a469a61 | 2018-07-18 22:38:21 +0200 | [diff] [blame] | 3785 | .avb_ops = &mv88e6165_avb_ops, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 3786 | .ptp_ops = &mv88e6165_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3787 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3788 | }; |
| 3789 | |
| 3790 | static const struct mv88e6xxx_ops mv88e6171_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3791 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3792 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3793 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3794 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3795 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3796 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3797 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3798 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3799 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 3800 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3801 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3802 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3803 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3804 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3805 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3806 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3807 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3808 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3809 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3810 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3811 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3812 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3813 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3814 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3815 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3816 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3817 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3818 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3819 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3820 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3821 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3822 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3823 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3824 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3825 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3826 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3827 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3828 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3829 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3830 | }; |
| 3831 | |
| 3832 | static const struct mv88e6xxx_ops mv88e6172_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3833 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3834 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3835 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3836 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3837 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 3838 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3839 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3840 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3841 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3842 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3843 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 3844 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3845 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3846 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 3847 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3848 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3849 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3850 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3851 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3852 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3853 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3854 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3855 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3856 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3857 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3858 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3859 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3860 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3861 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3862 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3863 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3864 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3865 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3866 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3867 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3868 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3869 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3870 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3871 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3872 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3873 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3874 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 3875 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 3876 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 3877 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 3878 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 3879 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 3880 | .serdes_power = mv88e6352_serdes_power, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 3881 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 3882 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3883 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3884 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3885 | }; |
| 3886 | |
| 3887 | static const struct mv88e6xxx_ops mv88e6175_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3888 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3889 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3890 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3891 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3892 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3893 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3894 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3895 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3896 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 3897 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3898 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3899 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3900 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3901 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3902 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3903 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3904 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3905 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3906 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3907 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3908 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3909 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3910 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3911 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3912 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3913 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3914 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3915 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3916 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3917 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3918 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3919 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3920 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3921 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3922 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3923 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3924 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3925 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3926 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3927 | }; |
| 3928 | |
| 3929 | static const struct mv88e6xxx_ops mv88e6176_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3930 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3931 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3932 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3933 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3934 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 3935 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3936 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3937 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3938 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3939 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3940 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 3941 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3942 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3943 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 3944 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3945 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3946 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3947 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3948 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3949 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3950 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3951 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3952 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3953 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3954 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3955 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3956 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3957 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3958 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3959 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3960 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3961 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3962 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3963 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3964 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3965 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3966 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3967 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3968 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3969 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3970 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3971 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 3972 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 3973 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 3974 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 3975 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 3976 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 3977 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 3978 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 3979 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 3980 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 3981 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 3982 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3983 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3984 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3985 | }; |
| 3986 | |
| 3987 | static const struct mv88e6xxx_ops mv88e6185_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3988 | /* MV88E6XXX_FAMILY_6185 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3989 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3990 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3991 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3992 | .phy_read = mv88e6185_phy_ppu_read, |
| 3993 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3994 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3995 | .port_sync_link = mv88e6185_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3996 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3997 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3998 | .port_set_ucast_flood = mv88e6185_port_set_forward_unknown, |
| 3999 | .port_set_mcast_flood = mv88e6185_port_set_default_forward, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4000 | .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 4001 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 4002 | .port_set_pause = mv88e6185_port_set_pause, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4003 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4004 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4005 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4006 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4007 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4008 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4009 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4010 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4011 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4012 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4013 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Chris Packham | f5be107 | 2020-11-24 17:34:38 +1300 | [diff] [blame] | 4014 | .serdes_power = mv88e6185_serdes_power, |
| 4015 | .serdes_get_lane = mv88e6185_serdes_get_lane, |
| 4016 | .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 4017 | .set_cascade_port = mv88e6185_g1_set_cascade_port, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 4018 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 4019 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4020 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4021 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4022 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4023 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 4024 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4025 | }; |
| 4026 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4027 | static const struct mv88e6xxx_ops mv88e6190_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4028 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4029 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4030 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4031 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4032 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4033 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4034 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4035 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4036 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4037 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4038 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4039 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4040 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4041 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4042 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4043 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4044 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4045 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4046 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Chris Packham | e8b34c6 | 2020-07-24 11:21:21 +1200 | [diff] [blame] | 4047 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4048 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4049 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4050 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4051 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4052 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4053 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4054 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4055 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4056 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4057 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4058 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4059 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4060 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4061 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4062 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4063 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4064 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4065 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4066 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4067 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4068 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4069 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4070 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4071 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4072 | /* Check status register pause & lpa register */ |
| 4073 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4074 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4075 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4076 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4077 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4078 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4079 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4080 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4081 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4082 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4083 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4084 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4085 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4086 | }; |
| 4087 | |
| 4088 | static const struct mv88e6xxx_ops mv88e6190x_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4089 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4090 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4091 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4092 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4093 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4094 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4095 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4096 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4097 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4098 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4099 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4100 | .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4101 | .port_max_speed_mode = mv88e6390x_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4102 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4103 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4104 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4105 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4106 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4107 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Chris Packham | e8b34c6 | 2020-07-24 11:21:21 +1200 | [diff] [blame] | 4108 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4109 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4110 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4111 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4112 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4113 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4114 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4115 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4116 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4117 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4118 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4119 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4120 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4121 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4122 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4123 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4124 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4125 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4126 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4127 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4128 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4129 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4130 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4131 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4132 | .serdes_get_lane = mv88e6390x_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4133 | /* Check status register pause & lpa register */ |
| 4134 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4135 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4136 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4137 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4138 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4139 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4140 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4141 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4142 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4143 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4144 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4145 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4146 | .phylink_validate = mv88e6390x_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4147 | }; |
| 4148 | |
| 4149 | static const struct mv88e6xxx_ops mv88e6191_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4150 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4151 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4152 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4153 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4154 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4155 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4156 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4157 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4158 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4159 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4160 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4161 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4162 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4163 | .port_tag_remap = mv88e6390_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4164 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4165 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4166 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4167 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4168 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4169 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4170 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4171 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4172 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4173 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4174 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4175 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4176 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4177 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4178 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4179 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4180 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4181 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4182 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4183 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4184 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4185 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4186 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4187 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4188 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4189 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4190 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4191 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4192 | /* Check status register pause & lpa register */ |
| 4193 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4194 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4195 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4196 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4197 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4198 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4199 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4200 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4201 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4202 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4203 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4204 | .avb_ops = &mv88e6390_avb_ops, |
| 4205 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4206 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4207 | }; |
| 4208 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4209 | static const struct mv88e6xxx_ops mv88e6240_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4210 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4211 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4212 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4213 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4214 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4215 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4216 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4217 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4218 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4219 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4220 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4221 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4222 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4223 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4224 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4225 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4226 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4227 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4228 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4229 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4230 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4231 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4232 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4233 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4234 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4235 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4236 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4237 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4238 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4239 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4240 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4241 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4242 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4243 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4244 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4245 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4246 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4247 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4248 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4249 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4250 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4251 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4252 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4253 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 4254 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 4255 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 4256 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4257 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4258 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4259 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4260 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4261 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4262 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4263 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4264 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4265 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4266 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4267 | }; |
| 4268 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4269 | static const struct mv88e6xxx_ops mv88e6250_ops = { |
| 4270 | /* MV88E6XXX_FAMILY_6250 */ |
| 4271 | .ieee_pri_map = mv88e6250_g1_ieee_pri_map, |
| 4272 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
| 4273 | .irl_init_all = mv88e6352_g2_irl_init_all, |
| 4274 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4275 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
| 4276 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4277 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4278 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4279 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4280 | .port_sync_link = mv88e6xxx_port_sync_link, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4281 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4282 | .port_set_speed_duplex = mv88e6250_port_set_speed_duplex, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4283 | .port_tag_remap = mv88e6095_port_tag_remap, |
| 4284 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4285 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4286 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4287 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
| 4288 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
| 4289 | .port_pause_limit = mv88e6097_port_pause_limit, |
| 4290 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4291 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
| 4292 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
| 4293 | .stats_get_sset_count = mv88e6250_stats_get_sset_count, |
| 4294 | .stats_get_strings = mv88e6250_stats_get_strings, |
| 4295 | .stats_get_stats = mv88e6250_stats_get_stats, |
| 4296 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4297 | .set_egress_port = mv88e6095_g1_set_egress_port, |
| 4298 | .watchdog_ops = &mv88e6250_watchdog_ops, |
| 4299 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
| 4300 | .pot_clear = mv88e6xxx_g2_pot_clear, |
| 4301 | .reset = mv88e6250_g1_reset, |
Rasmus Villemoes | 67c9ed1 | 2021-01-25 16:04:48 +0100 | [diff] [blame] | 4302 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Rasmus Villemoes | b28f3f3 | 2021-01-25 16:04:49 +0100 | [diff] [blame] | 4303 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 4304 | .avb_ops = &mv88e6352_avb_ops, |
| 4305 | .ptp_ops = &mv88e6250_ptp_ops, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4306 | .phylink_validate = mv88e6065_phylink_validate, |
| 4307 | }; |
| 4308 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4309 | static const struct mv88e6xxx_ops mv88e6290_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4310 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4311 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4312 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4313 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4314 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4315 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4316 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4317 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4318 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4319 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4320 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4321 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4322 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4323 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4324 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4325 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4326 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4327 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4328 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4329 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4330 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4331 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4332 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4333 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4334 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4335 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4336 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4337 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4338 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4339 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4340 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4341 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4342 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4343 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4344 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4345 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4346 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4347 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4348 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4349 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4350 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4351 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4352 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4353 | /* Check status register pause & lpa register */ |
| 4354 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4355 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4356 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4357 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4358 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4359 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4360 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4361 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4362 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4363 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4364 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4365 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4366 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4367 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4368 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4369 | }; |
| 4370 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4371 | static const struct mv88e6xxx_ops mv88e6320_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4372 | /* MV88E6XXX_FAMILY_6320 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4373 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4374 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4375 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4376 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4377 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4378 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4379 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4380 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4381 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4382 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4383 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4384 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4385 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4386 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4387 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4388 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4389 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4390 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4391 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4392 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4393 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4394 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4395 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4396 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4397 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4398 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4399 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4400 | .stats_get_stats = mv88e6320_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4401 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4402 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | 9c7f37e | 2018-12-19 18:28:54 +0100 | [diff] [blame] | 4403 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4404 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4405 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4406 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4407 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4408 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4409 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4410 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4411 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4412 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4413 | }; |
| 4414 | |
| 4415 | static const struct mv88e6xxx_ops mv88e6321_ops = { |
Vivien Didelot | bd80720 | 2017-07-17 13:03:37 -0400 | [diff] [blame] | 4416 | /* MV88E6XXX_FAMILY_6320 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4417 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4418 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4419 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4420 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4421 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4422 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4423 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4424 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4425 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4426 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4427 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4428 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4429 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4430 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4431 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4432 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4433 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4434 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4435 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4436 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4437 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4438 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4439 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4440 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4441 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4442 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4443 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4444 | .stats_get_stats = mv88e6320_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4445 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4446 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | 9c7f37e | 2018-12-19 18:28:54 +0100 | [diff] [blame] | 4447 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4448 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4449 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4450 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4451 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4452 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4453 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4454 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4455 | }; |
| 4456 | |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4457 | static const struct mv88e6xxx_ops mv88e6341_ops = { |
| 4458 | /* MV88E6XXX_FAMILY_6341 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4459 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4460 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4461 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4462 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4463 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 4464 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4465 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4466 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4467 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4468 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4469 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4470 | .port_set_speed_duplex = mv88e6341_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4471 | .port_max_speed_mode = mv88e6341_port_max_speed_mode, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4472 | .port_tag_remap = mv88e6095_port_tag_remap, |
Marek Behún | 7da467d | 2021-07-01 00:22:26 +0200 | [diff] [blame] | 4473 | .port_set_policy = mv88e6352_port_set_policy, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4474 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4475 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4476 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4477 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4478 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4479 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4480 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4481 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 4482 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4483 | .port_get_cmode = mv88e6352_port_get_cmode, |
Marek Behún | 7a3007d | 2019-08-26 23:31:55 +0200 | [diff] [blame] | 4484 | .port_set_cmode = mv88e6341_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4485 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4486 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Marek Behún | 11527f3 | 2021-07-01 00:22:27 +0200 | [diff] [blame] | 4487 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4488 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4489 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 4490 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4491 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4492 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4493 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 4494 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4495 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4496 | .reset = mv88e6352_g1_reset, |
Marek Behún | 3709488 | 2021-07-01 00:22:28 +0200 | [diff] [blame] | 4497 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Marek Behún | c07fff3 | 2021-07-01 00:22:29 +0200 | [diff] [blame] | 4498 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4499 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4500 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4501 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4502 | .serdes_power = mv88e6390_serdes_power, |
| 4503 | .serdes_get_lane = mv88e6341_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4504 | /* Check status register pause & lpa register */ |
| 4505 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4506 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4507 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4508 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4509 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4510 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4511 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4512 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4513 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4514 | .ptp_ops = &mv88e6352_ptp_ops, |
Marek Behún | a03b98d | 2021-07-01 00:22:30 +0200 | [diff] [blame] | 4515 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4516 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4517 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Marek Behún | 953b0dc | 2021-07-01 00:22:31 +0200 | [diff] [blame] | 4518 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4519 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 4520 | .phylink_validate = mv88e6341_phylink_validate, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4521 | }; |
| 4522 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4523 | static const struct mv88e6xxx_ops mv88e6350_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4524 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4525 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4526 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4527 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4528 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4529 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4530 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4531 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4532 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 4533 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4534 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4535 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4536 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4537 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4538 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4539 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4540 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4541 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4542 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4543 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4544 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4545 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4546 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4547 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4548 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4549 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4550 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4551 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4552 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4553 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4554 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4555 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4556 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4557 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4558 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4559 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4560 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4561 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4562 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4563 | }; |
| 4564 | |
| 4565 | static const struct mv88e6xxx_ops mv88e6351_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4566 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4567 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4568 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4569 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4570 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4571 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4572 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4573 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4574 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 4575 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4576 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4577 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4578 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4579 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4580 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4581 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4582 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4583 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4584 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4585 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4586 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4587 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4588 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4589 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4590 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4591 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4592 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4593 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4594 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4595 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4596 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4597 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4598 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4599 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4600 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4601 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4602 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4603 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4604 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4605 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4606 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4607 | }; |
| 4608 | |
| 4609 | static const struct mv88e6xxx_ops mv88e6352_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4610 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4611 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4612 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4613 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4614 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4615 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4616 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4617 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4618 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4619 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4620 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4621 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4622 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4623 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4624 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4625 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4626 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4627 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4628 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4629 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4630 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4631 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4632 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4633 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4634 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4635 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4636 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4637 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4638 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4639 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4640 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4641 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4642 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4643 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4644 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4645 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4646 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4647 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4648 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4649 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4650 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4651 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4652 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4653 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 4654 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 4655 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 4656 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4657 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4658 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4659 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4660 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4661 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4662 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4663 | .ptp_ops = &mv88e6352_ptp_ops, |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 4664 | .serdes_get_sset_count = mv88e6352_serdes_get_sset_count, |
| 4665 | .serdes_get_strings = mv88e6352_serdes_get_strings, |
| 4666 | .serdes_get_stats = mv88e6352_serdes_get_stats, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4667 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4668 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4669 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4670 | }; |
| 4671 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4672 | static const struct mv88e6xxx_ops mv88e6390_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4673 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4674 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4675 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4676 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4677 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4678 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4679 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4680 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4681 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4682 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4683 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4684 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4685 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4686 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4687 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4688 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4689 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4690 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4691 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4692 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4693 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4694 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4695 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4696 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4697 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4698 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4699 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4700 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4701 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4702 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4703 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4704 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4705 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4706 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4707 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4708 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4709 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4710 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4711 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4712 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4713 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4714 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4715 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4716 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4717 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4718 | /* Check status register pause & lpa register */ |
| 4719 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4720 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4721 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4722 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4723 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4724 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4725 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4726 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4727 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4728 | .ptp_ops = &mv88e6352_ptp_ops, |
Nikita Yushchenko | 0df9528 | 2019-12-25 08:22:38 +0300 | [diff] [blame] | 4729 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4730 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4731 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4732 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4733 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4734 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4735 | }; |
| 4736 | |
| 4737 | static const struct mv88e6xxx_ops mv88e6390x_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4738 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4739 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4740 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4741 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4742 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4743 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4744 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4745 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4746 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4747 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4748 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4749 | .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4750 | .port_max_speed_mode = mv88e6390x_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4751 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4752 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4753 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4754 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4755 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4756 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4757 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4758 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4759 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4760 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4761 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4762 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | b3dce4d | 2018-11-11 00:32:14 +0100 | [diff] [blame] | 4763 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4764 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4765 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4766 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4767 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4768 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4769 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4770 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4771 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4772 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4773 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4774 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4775 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4776 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4777 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4778 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4779 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4780 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4781 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4782 | .serdes_get_lane = mv88e6390x_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4783 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4784 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4785 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4786 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4787 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4788 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4789 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4790 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4791 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4792 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4793 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4794 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4795 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4796 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4797 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4798 | .phylink_validate = mv88e6390x_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4799 | }; |
| 4800 | |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 4801 | static const struct mv88e6xxx_ops mv88e6393x_ops = { |
| 4802 | /* MV88E6XXX_FAMILY_6393 */ |
| 4803 | .setup_errata = mv88e6393x_serdes_setup_errata, |
| 4804 | .irl_init_all = mv88e6390_g2_irl_init_all, |
| 4805 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4806 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 4807 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4808 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4809 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4810 | .port_set_link = mv88e6xxx_port_set_link, |
| 4811 | .port_sync_link = mv88e6xxx_port_sync_link, |
| 4812 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 4813 | .port_set_speed_duplex = mv88e6393x_port_set_speed_duplex, |
| 4814 | .port_max_speed_mode = mv88e6393x_port_max_speed_mode, |
| 4815 | .port_tag_remap = mv88e6390_port_tag_remap, |
Marek Behún | 6584b26 | 2021-03-17 14:46:43 +0100 | [diff] [blame] | 4816 | .port_set_policy = mv88e6393x_port_set_policy, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 4817 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
| 4818 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4819 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
| 4820 | .port_set_ether_type = mv88e6393x_port_set_ether_type, |
| 4821 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
| 4822 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
| 4823 | .port_pause_limit = mv88e6390_port_pause_limit, |
| 4824 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 4825 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
| 4826 | .port_get_cmode = mv88e6352_port_get_cmode, |
| 4827 | .port_set_cmode = mv88e6393x_port_set_cmode, |
| 4828 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
| 4829 | .port_set_upstream_port = mv88e6393x_port_set_upstream_port, |
| 4830 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
| 4831 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
| 4832 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4833 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 4834 | .stats_get_stats = mv88e6390_stats_get_stats, |
| 4835 | /* .set_cpu_port is missing because this family does not support a global |
| 4836 | * CPU port, only per port CPU port which is set via |
| 4837 | * .port_set_upstream_port method. |
| 4838 | */ |
| 4839 | .set_egress_port = mv88e6393x_set_egress_port, |
| 4840 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 4841 | .mgmt_rsvd2cpu = mv88e6393x_port_mgmt_rsvd2cpu, |
| 4842 | .pot_clear = mv88e6xxx_g2_pot_clear, |
| 4843 | .reset = mv88e6352_g1_reset, |
| 4844 | .rmu_disable = mv88e6390_g1_rmu_disable, |
| 4845 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4846 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
| 4847 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4848 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
| 4849 | .serdes_power = mv88e6393x_serdes_power, |
| 4850 | .serdes_get_lane = mv88e6393x_serdes_get_lane, |
| 4851 | .serdes_pcs_get_state = mv88e6393x_serdes_pcs_get_state, |
| 4852 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4853 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4854 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
| 4855 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
| 4856 | .serdes_irq_enable = mv88e6393x_serdes_irq_enable, |
| 4857 | .serdes_irq_status = mv88e6393x_serdes_irq_status, |
| 4858 | /* TODO: serdes stats */ |
| 4859 | .gpio_ops = &mv88e6352_gpio_ops, |
| 4860 | .avb_ops = &mv88e6390_avb_ops, |
| 4861 | .ptp_ops = &mv88e6352_ptp_ops, |
| 4862 | .phylink_validate = mv88e6393x_phylink_validate, |
| 4863 | }; |
| 4864 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4865 | static const struct mv88e6xxx_info mv88e6xxx_table[] = { |
| 4866 | [MV88E6085] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4867 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4868 | .family = MV88E6XXX_FAMILY_6097, |
| 4869 | .name = "Marvell 88E6085", |
| 4870 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4871 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4872 | .num_ports = 10, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4873 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4874 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4875 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4876 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4877 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4878 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4879 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4880 | .g1_irqs = 8, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4881 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4882 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4883 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4884 | .multi_chip = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4885 | .ops = &mv88e6085_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4886 | }, |
| 4887 | |
| 4888 | [MV88E6095] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4889 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4890 | .family = MV88E6XXX_FAMILY_6095, |
| 4891 | .name = "Marvell 88E6095/88E6095F", |
| 4892 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4893 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4894 | .num_ports = 11, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4895 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4896 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4897 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4898 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4899 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4900 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4901 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4902 | .g1_irqs = 8, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4903 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4904 | .multi_chip = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4905 | .ops = &mv88e6095_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4906 | }, |
| 4907 | |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4908 | [MV88E6097] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4909 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4910 | .family = MV88E6XXX_FAMILY_6097, |
| 4911 | .name = "Marvell 88E6097/88E6097F", |
| 4912 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4913 | .num_macs = 8192, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4914 | .num_ports = 11, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4915 | .num_internal_phys = 8, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4916 | .max_vid = 4095, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4917 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4918 | .phy_base_addr = 0x0, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4919 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4920 | .global2_addr = 0x1c, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4921 | .age_time_coeff = 15000, |
Stefan Eichenberger | c534178 | 2016-11-25 09:41:29 +0100 | [diff] [blame] | 4922 | .g1_irqs = 8, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4923 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4924 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4925 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4926 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 4927 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4928 | .ops = &mv88e6097_ops, |
| 4929 | }, |
| 4930 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4931 | [MV88E6123] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4932 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4933 | .family = MV88E6XXX_FAMILY_6165, |
| 4934 | .name = "Marvell 88E6123", |
| 4935 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4936 | .num_macs = 1024, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4937 | .num_ports = 3, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4938 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4939 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4940 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4941 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4942 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4943 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4944 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4945 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4946 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4947 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4948 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4949 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 4950 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4951 | .ops = &mv88e6123_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4952 | }, |
| 4953 | |
| 4954 | [MV88E6131] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4955 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4956 | .family = MV88E6XXX_FAMILY_6185, |
| 4957 | .name = "Marvell 88E6131", |
| 4958 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4959 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4960 | .num_ports = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4961 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4962 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4963 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4964 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4965 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4966 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4967 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4968 | .g1_irqs = 9, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4969 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4970 | .multi_chip = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4971 | .ops = &mv88e6131_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4972 | }, |
| 4973 | |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4974 | [MV88E6141] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4975 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4976 | .family = MV88E6XXX_FAMILY_6341, |
Uwe Kleine-König | 79a68b2 | 2018-03-20 10:44:40 +0100 | [diff] [blame] | 4977 | .name = "Marvell 88E6141", |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4978 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4979 | .num_macs = 2048, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4980 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4981 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4982 | .num_gpio = 11, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4983 | .max_vid = 4095, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4984 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4985 | .phy_base_addr = 0x10, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4986 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4987 | .global2_addr = 0x1c, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4988 | .age_time_coeff = 3750, |
| 4989 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | adfccf1 | 2018-03-17 20:32:03 +0100 | [diff] [blame] | 4990 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4991 | .g2_irqs = 10, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4992 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4993 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 4994 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4995 | .ops = &mv88e6141_ops, |
| 4996 | }, |
| 4997 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4998 | [MV88E6161] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4999 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5000 | .family = MV88E6XXX_FAMILY_6165, |
| 5001 | .name = "Marvell 88E6161", |
| 5002 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5003 | .num_macs = 1024, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5004 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5005 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5006 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5007 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5008 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5009 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5010 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5011 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5012 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5013 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5014 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5015 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5016 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5017 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 5018 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5019 | .ops = &mv88e6161_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5020 | }, |
| 5021 | |
| 5022 | [MV88E6165] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5023 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5024 | .family = MV88E6XXX_FAMILY_6165, |
| 5025 | .name = "Marvell 88E6165", |
| 5026 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5027 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5028 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5029 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5030 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5031 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5032 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5033 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5034 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5035 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5036 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5037 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5038 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5039 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5040 | .multi_chip = true, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 5041 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5042 | .ops = &mv88e6165_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5043 | }, |
| 5044 | |
| 5045 | [MV88E6171] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5046 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5047 | .family = MV88E6XXX_FAMILY_6351, |
| 5048 | .name = "Marvell 88E6171", |
| 5049 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5050 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5051 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5052 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5053 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5054 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5055 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5056 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5057 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5058 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5059 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5060 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5061 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5062 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5063 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5064 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5065 | .ops = &mv88e6171_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5066 | }, |
| 5067 | |
| 5068 | [MV88E6172] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5069 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5070 | .family = MV88E6XXX_FAMILY_6352, |
| 5071 | .name = "Marvell 88E6172", |
| 5072 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5073 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5074 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5075 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5076 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5077 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5078 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5079 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5080 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5081 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5082 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5083 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5084 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5085 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5086 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5087 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5088 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5089 | .ops = &mv88e6172_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5090 | }, |
| 5091 | |
| 5092 | [MV88E6175] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5093 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5094 | .family = MV88E6XXX_FAMILY_6351, |
| 5095 | .name = "Marvell 88E6175", |
| 5096 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5097 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5098 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5099 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5100 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5101 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5102 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5103 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5104 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5105 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5106 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5107 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5108 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5109 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5110 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5111 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5112 | .ops = &mv88e6175_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5113 | }, |
| 5114 | |
| 5115 | [MV88E6176] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5116 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5117 | .family = MV88E6XXX_FAMILY_6352, |
| 5118 | .name = "Marvell 88E6176", |
| 5119 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5120 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5121 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5122 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5123 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5124 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5125 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5126 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5127 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5128 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5129 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5130 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5131 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5132 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5133 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5134 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5135 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5136 | .ops = &mv88e6176_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5137 | }, |
| 5138 | |
| 5139 | [MV88E6185] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5140 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5141 | .family = MV88E6XXX_FAMILY_6185, |
| 5142 | .name = "Marvell 88E6185", |
| 5143 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5144 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5145 | .num_ports = 10, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5146 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5147 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5148 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5149 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5150 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5151 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5152 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5153 | .g1_irqs = 8, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5154 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5155 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5156 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5157 | .ops = &mv88e6185_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5158 | }, |
| 5159 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5160 | [MV88E6190] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5161 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5162 | .family = MV88E6XXX_FAMILY_6390, |
| 5163 | .name = "Marvell 88E6190", |
| 5164 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5165 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5166 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5167 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5168 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5169 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5170 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5171 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5172 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5173 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5174 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5175 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5176 | .g2_irqs = 14, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5177 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5178 | .multi_chip = true, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5179 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5180 | .ops = &mv88e6190_ops, |
| 5181 | }, |
| 5182 | |
| 5183 | [MV88E6190X] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5184 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5185 | .family = MV88E6XXX_FAMILY_6390, |
| 5186 | .name = "Marvell 88E6190X", |
| 5187 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5188 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5189 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5190 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5191 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5192 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5193 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5194 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5195 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5196 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5197 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5198 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5199 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5200 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5201 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5202 | .multi_chip = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5203 | .ops = &mv88e6190x_ops, |
| 5204 | }, |
| 5205 | |
| 5206 | [MV88E6191] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5207 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5208 | .family = MV88E6XXX_FAMILY_6390, |
| 5209 | .name = "Marvell 88E6191", |
| 5210 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5211 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5212 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5213 | .num_internal_phys = 9, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5214 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5215 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5216 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5217 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5218 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5219 | .age_time_coeff = 3750, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5220 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5221 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5222 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5223 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5224 | .multi_chip = true, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5225 | .ptp_support = true, |
Vivien Didelot | 2cf4cefb | 2017-03-28 13:50:34 -0400 | [diff] [blame] | 5226 | .ops = &mv88e6191_ops, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5227 | }, |
| 5228 | |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5229 | [MV88E6191X] = { |
| 5230 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191X, |
| 5231 | .family = MV88E6XXX_FAMILY_6393, |
| 5232 | .name = "Marvell 88E6191X", |
| 5233 | .num_databases = 4096, |
| 5234 | .num_ports = 11, /* 10 + Z80 */ |
| 5235 | .num_internal_phys = 9, |
| 5236 | .max_vid = 8191, |
| 5237 | .port_base_addr = 0x0, |
| 5238 | .phy_base_addr = 0x0, |
| 5239 | .global1_addr = 0x1b, |
| 5240 | .global2_addr = 0x1c, |
| 5241 | .age_time_coeff = 3750, |
| 5242 | .g1_irqs = 10, |
| 5243 | .g2_irqs = 14, |
| 5244 | .atu_move_port_mask = 0x1f, |
| 5245 | .pvt = true, |
| 5246 | .multi_chip = true, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5247 | .ptp_support = true, |
| 5248 | .ops = &mv88e6393x_ops, |
| 5249 | }, |
| 5250 | |
| 5251 | [MV88E6193X] = { |
| 5252 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6193X, |
| 5253 | .family = MV88E6XXX_FAMILY_6393, |
| 5254 | .name = "Marvell 88E6193X", |
| 5255 | .num_databases = 4096, |
| 5256 | .num_ports = 11, /* 10 + Z80 */ |
| 5257 | .num_internal_phys = 9, |
| 5258 | .max_vid = 8191, |
| 5259 | .port_base_addr = 0x0, |
| 5260 | .phy_base_addr = 0x0, |
| 5261 | .global1_addr = 0x1b, |
| 5262 | .global2_addr = 0x1c, |
| 5263 | .age_time_coeff = 3750, |
| 5264 | .g1_irqs = 10, |
| 5265 | .g2_irqs = 14, |
| 5266 | .atu_move_port_mask = 0x1f, |
| 5267 | .pvt = true, |
| 5268 | .multi_chip = true, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5269 | .ptp_support = true, |
| 5270 | .ops = &mv88e6393x_ops, |
| 5271 | }, |
| 5272 | |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5273 | [MV88E6220] = { |
| 5274 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220, |
| 5275 | .family = MV88E6XXX_FAMILY_6250, |
| 5276 | .name = "Marvell 88E6220", |
| 5277 | .num_databases = 64, |
| 5278 | |
| 5279 | /* Ports 2-4 are not routed to pins |
| 5280 | * => usable ports 0, 1, 5, 6 |
| 5281 | */ |
| 5282 | .num_ports = 7, |
| 5283 | .num_internal_phys = 2, |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 5284 | .invalid_port_mask = BIT(2) | BIT(3) | BIT(4), |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5285 | .max_vid = 4095, |
| 5286 | .port_base_addr = 0x08, |
| 5287 | .phy_base_addr = 0x00, |
| 5288 | .global1_addr = 0x0f, |
| 5289 | .global2_addr = 0x07, |
| 5290 | .age_time_coeff = 15000, |
| 5291 | .g1_irqs = 9, |
| 5292 | .g2_irqs = 10, |
| 5293 | .atu_move_port_mask = 0xf, |
| 5294 | .dual_chip = true, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 5295 | .ptp_support = true, |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5296 | .ops = &mv88e6250_ops, |
| 5297 | }, |
| 5298 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5299 | [MV88E6240] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5300 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5301 | .family = MV88E6XXX_FAMILY_6352, |
| 5302 | .name = "Marvell 88E6240", |
| 5303 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5304 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5305 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5306 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5307 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5308 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5309 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5310 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5311 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5312 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5313 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5314 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5315 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5316 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5317 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5318 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5319 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5320 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5321 | .ops = &mv88e6240_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5322 | }, |
| 5323 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 5324 | [MV88E6250] = { |
| 5325 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250, |
| 5326 | .family = MV88E6XXX_FAMILY_6250, |
| 5327 | .name = "Marvell 88E6250", |
| 5328 | .num_databases = 64, |
| 5329 | .num_ports = 7, |
| 5330 | .num_internal_phys = 5, |
| 5331 | .max_vid = 4095, |
| 5332 | .port_base_addr = 0x08, |
| 5333 | .phy_base_addr = 0x00, |
| 5334 | .global1_addr = 0x0f, |
| 5335 | .global2_addr = 0x07, |
| 5336 | .age_time_coeff = 15000, |
| 5337 | .g1_irqs = 9, |
| 5338 | .g2_irqs = 10, |
| 5339 | .atu_move_port_mask = 0xf, |
| 5340 | .dual_chip = true, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 5341 | .ptp_support = true, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 5342 | .ops = &mv88e6250_ops, |
| 5343 | }, |
| 5344 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5345 | [MV88E6290] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5346 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5347 | .family = MV88E6XXX_FAMILY_6390, |
| 5348 | .name = "Marvell 88E6290", |
| 5349 | .num_databases = 4096, |
| 5350 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5351 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5352 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5353 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5354 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5355 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5356 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5357 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5358 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5359 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5360 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5361 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5362 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5363 | .multi_chip = true, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5364 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5365 | .ops = &mv88e6290_ops, |
| 5366 | }, |
| 5367 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5368 | [MV88E6320] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5369 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5370 | .family = MV88E6XXX_FAMILY_6320, |
| 5371 | .name = "Marvell 88E6320", |
| 5372 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5373 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5374 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5375 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5376 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5377 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5378 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5379 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5380 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5381 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5382 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5383 | .g1_irqs = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5384 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5385 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5386 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5387 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5388 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5389 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5390 | .ops = &mv88e6320_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5391 | }, |
| 5392 | |
| 5393 | [MV88E6321] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5394 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5395 | .family = MV88E6XXX_FAMILY_6320, |
| 5396 | .name = "Marvell 88E6321", |
| 5397 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5398 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5399 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5400 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5401 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5402 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5403 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5404 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5405 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5406 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5407 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5408 | .g1_irqs = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5409 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5410 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5411 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5412 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5413 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5414 | .ops = &mv88e6321_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5415 | }, |
| 5416 | |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5417 | [MV88E6341] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5418 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5419 | .family = MV88E6XXX_FAMILY_6341, |
| 5420 | .name = "Marvell 88E6341", |
| 5421 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5422 | .num_macs = 2048, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5423 | .num_internal_phys = 5, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5424 | .num_ports = 6, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5425 | .num_gpio = 11, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5426 | .max_vid = 4095, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5427 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5428 | .phy_base_addr = 0x10, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5429 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5430 | .global2_addr = 0x1c, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5431 | .age_time_coeff = 3750, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5432 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | adfccf1 | 2018-03-17 20:32:03 +0100 | [diff] [blame] | 5433 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5434 | .g2_irqs = 10, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5435 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5436 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5437 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5438 | .ptp_support = true, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5439 | .ops = &mv88e6341_ops, |
| 5440 | }, |
| 5441 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5442 | [MV88E6350] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5443 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5444 | .family = MV88E6XXX_FAMILY_6351, |
| 5445 | .name = "Marvell 88E6350", |
| 5446 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5447 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5448 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5449 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5450 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5451 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5452 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5453 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5454 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5455 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5456 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5457 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5458 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5459 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5460 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5461 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5462 | .ops = &mv88e6350_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5463 | }, |
| 5464 | |
| 5465 | [MV88E6351] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5466 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5467 | .family = MV88E6XXX_FAMILY_6351, |
| 5468 | .name = "Marvell 88E6351", |
| 5469 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5470 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5471 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5472 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5473 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5474 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5475 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5476 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5477 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5478 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5479 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5480 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5481 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5482 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5483 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5484 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5485 | .ops = &mv88e6351_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5486 | }, |
| 5487 | |
| 5488 | [MV88E6352] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5489 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5490 | .family = MV88E6XXX_FAMILY_6352, |
| 5491 | .name = "Marvell 88E6352", |
| 5492 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5493 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5494 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5495 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5496 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5497 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5498 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5499 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5500 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5501 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5502 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5503 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5504 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5505 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5506 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5507 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5508 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5509 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5510 | .ops = &mv88e6352_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5511 | }, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5512 | [MV88E6390] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5513 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5514 | .family = MV88E6XXX_FAMILY_6390, |
| 5515 | .name = "Marvell 88E6390", |
| 5516 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5517 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5518 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5519 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5520 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5521 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5522 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5523 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5524 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5525 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5526 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5527 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5528 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5529 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5530 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5531 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5532 | .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5533 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5534 | .ops = &mv88e6390_ops, |
| 5535 | }, |
| 5536 | [MV88E6390X] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5537 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5538 | .family = MV88E6XXX_FAMILY_6390, |
| 5539 | .name = "Marvell 88E6390X", |
| 5540 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5541 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5542 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5543 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5544 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5545 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5546 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5547 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5548 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5549 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5550 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5551 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5552 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5553 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5554 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5555 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5556 | .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5557 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5558 | .ops = &mv88e6390x_ops, |
| 5559 | }, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5560 | |
| 5561 | [MV88E6393X] = { |
| 5562 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X, |
| 5563 | .family = MV88E6XXX_FAMILY_6393, |
| 5564 | .name = "Marvell 88E6393X", |
| 5565 | .num_databases = 4096, |
| 5566 | .num_ports = 11, /* 10 + Z80 */ |
| 5567 | .num_internal_phys = 9, |
| 5568 | .max_vid = 8191, |
| 5569 | .port_base_addr = 0x0, |
| 5570 | .phy_base_addr = 0x0, |
| 5571 | .global1_addr = 0x1b, |
| 5572 | .global2_addr = 0x1c, |
| 5573 | .age_time_coeff = 3750, |
| 5574 | .g1_irqs = 10, |
| 5575 | .g2_irqs = 14, |
| 5576 | .atu_move_port_mask = 0x1f, |
| 5577 | .pvt = true, |
| 5578 | .multi_chip = true, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5579 | .ptp_support = true, |
| 5580 | .ops = &mv88e6393x_ops, |
| 5581 | }, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5582 | }; |
| 5583 | |
Vivien Didelot | 5f7c036 | 2016-06-20 13:14:04 -0400 | [diff] [blame] | 5584 | static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num) |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5585 | { |
Vivien Didelot | a439c06 | 2016-04-17 13:23:58 -0400 | [diff] [blame] | 5586 | int i; |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5587 | |
Vivien Didelot | 5f7c036 | 2016-06-20 13:14:04 -0400 | [diff] [blame] | 5588 | for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i) |
| 5589 | if (mv88e6xxx_table[i].prod_num == prod_num) |
| 5590 | return &mv88e6xxx_table[i]; |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5591 | |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5592 | return NULL; |
| 5593 | } |
| 5594 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5595 | static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip) |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5596 | { |
| 5597 | const struct mv88e6xxx_info *info; |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 5598 | unsigned int prod_num, rev; |
| 5599 | u16 id; |
| 5600 | int err; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5601 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5602 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5603 | err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5604 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 5605 | if (err) |
| 5606 | return err; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5607 | |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5608 | prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK; |
| 5609 | rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5610 | |
| 5611 | info = mv88e6xxx_lookup_info(prod_num); |
| 5612 | if (!info) |
| 5613 | return -ENODEV; |
| 5614 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 5615 | /* Update the compatible info with the probed one */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5616 | chip->info = info; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5617 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5618 | dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n", |
| 5619 | chip->info->prod_num, chip->info->name, rev); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5620 | |
| 5621 | return 0; |
| 5622 | } |
| 5623 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5624 | static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5625 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5626 | struct mv88e6xxx_chip *chip; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5627 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5628 | chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); |
| 5629 | if (!chip) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5630 | return NULL; |
| 5631 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5632 | chip->dev = dev; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5633 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5634 | mutex_init(&chip->reg_lock); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 5635 | INIT_LIST_HEAD(&chip->mdios); |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 5636 | idr_init(&chip->policies); |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5637 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5638 | return chip; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5639 | } |
| 5640 | |
Florian Fainelli | 5ed4e3e | 2017-11-10 15:22:52 -0800 | [diff] [blame] | 5641 | 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] | 5642 | int port, |
| 5643 | enum dsa_tag_protocol m) |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 5644 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5645 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 2bbb33b | 2016-08-22 16:01:02 +0200 | [diff] [blame] | 5646 | |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5647 | return chip->tag_protocol; |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 5648 | } |
| 5649 | |
Tobias Waldekranz | 9a99bef | 2021-04-20 20:53:08 +0200 | [diff] [blame] | 5650 | static int mv88e6xxx_change_tag_protocol(struct dsa_switch *ds, int port, |
| 5651 | enum dsa_tag_protocol proto) |
| 5652 | { |
| 5653 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5654 | enum dsa_tag_protocol old_protocol; |
| 5655 | int err; |
| 5656 | |
| 5657 | switch (proto) { |
| 5658 | case DSA_TAG_PROTO_EDSA: |
| 5659 | switch (chip->info->edsa_support) { |
| 5660 | case MV88E6XXX_EDSA_UNSUPPORTED: |
| 5661 | return -EPROTONOSUPPORT; |
| 5662 | case MV88E6XXX_EDSA_UNDOCUMENTED: |
| 5663 | dev_warn(chip->dev, "Relying on undocumented EDSA tagging behavior\n"); |
| 5664 | fallthrough; |
| 5665 | case MV88E6XXX_EDSA_SUPPORTED: |
| 5666 | break; |
| 5667 | } |
| 5668 | break; |
| 5669 | case DSA_TAG_PROTO_DSA: |
| 5670 | break; |
| 5671 | default: |
| 5672 | return -EPROTONOSUPPORT; |
| 5673 | } |
| 5674 | |
| 5675 | old_protocol = chip->tag_protocol; |
| 5676 | chip->tag_protocol = proto; |
| 5677 | |
| 5678 | mv88e6xxx_reg_lock(chip); |
| 5679 | err = mv88e6xxx_setup_port_mode(chip, port); |
| 5680 | mv88e6xxx_reg_unlock(chip); |
| 5681 | |
| 5682 | if (err) |
| 5683 | chip->tag_protocol = old_protocol; |
| 5684 | |
| 5685 | return err; |
| 5686 | } |
| 5687 | |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5688 | static int mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port, |
| 5689 | const struct switchdev_obj_port_mdb *mdb) |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5690 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5691 | struct mv88e6xxx_chip *chip = ds->priv; |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5692 | int err; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5693 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5694 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5695 | err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, |
| 5696 | MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5697 | mv88e6xxx_reg_unlock(chip); |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5698 | |
| 5699 | return err; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5700 | } |
| 5701 | |
| 5702 | static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port, |
| 5703 | const struct switchdev_obj_port_mdb *mdb) |
| 5704 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5705 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5706 | int err; |
| 5707 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5708 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 5709 | 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] | 5710 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5711 | |
| 5712 | return err; |
| 5713 | } |
| 5714 | |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5715 | static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port, |
| 5716 | struct dsa_mall_mirror_tc_entry *mirror, |
| 5717 | bool ingress) |
| 5718 | { |
| 5719 | enum mv88e6xxx_egress_direction direction = ingress ? |
| 5720 | MV88E6XXX_EGRESS_DIR_INGRESS : |
| 5721 | MV88E6XXX_EGRESS_DIR_EGRESS; |
| 5722 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5723 | bool other_mirrors = false; |
| 5724 | int i; |
| 5725 | int err; |
| 5726 | |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5727 | mutex_lock(&chip->reg_lock); |
| 5728 | if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) != |
| 5729 | mirror->to_local_port) { |
| 5730 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) |
| 5731 | other_mirrors |= ingress ? |
| 5732 | chip->ports[i].mirror_ingress : |
| 5733 | chip->ports[i].mirror_egress; |
| 5734 | |
| 5735 | /* Can't change egress port when other mirror is active */ |
| 5736 | if (other_mirrors) { |
| 5737 | err = -EBUSY; |
| 5738 | goto out; |
| 5739 | } |
| 5740 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 5741 | err = mv88e6xxx_set_egress_port(chip, direction, |
| 5742 | mirror->to_local_port); |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5743 | if (err) |
| 5744 | goto out; |
| 5745 | } |
| 5746 | |
| 5747 | err = mv88e6xxx_port_set_mirror(chip, port, direction, true); |
| 5748 | out: |
| 5749 | mutex_unlock(&chip->reg_lock); |
| 5750 | |
| 5751 | return err; |
| 5752 | } |
| 5753 | |
| 5754 | static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port, |
| 5755 | struct dsa_mall_mirror_tc_entry *mirror) |
| 5756 | { |
| 5757 | enum mv88e6xxx_egress_direction direction = mirror->ingress ? |
| 5758 | MV88E6XXX_EGRESS_DIR_INGRESS : |
| 5759 | MV88E6XXX_EGRESS_DIR_EGRESS; |
| 5760 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5761 | bool other_mirrors = false; |
| 5762 | int i; |
| 5763 | |
| 5764 | mutex_lock(&chip->reg_lock); |
| 5765 | if (mv88e6xxx_port_set_mirror(chip, port, direction, false)) |
| 5766 | dev_err(ds->dev, "p%d: failed to disable mirroring\n", port); |
| 5767 | |
| 5768 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) |
| 5769 | other_mirrors |= mirror->ingress ? |
| 5770 | chip->ports[i].mirror_ingress : |
| 5771 | chip->ports[i].mirror_egress; |
| 5772 | |
| 5773 | /* Reset egress port when no other mirror is active */ |
| 5774 | if (!other_mirrors) { |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 5775 | if (mv88e6xxx_set_egress_port(chip, direction, |
| 5776 | dsa_upstream_port(ds, port))) |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5777 | dev_err(ds->dev, "failed to set egress port\n"); |
| 5778 | } |
| 5779 | |
| 5780 | mutex_unlock(&chip->reg_lock); |
| 5781 | } |
| 5782 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5783 | static int mv88e6xxx_port_pre_bridge_flags(struct dsa_switch *ds, int port, |
| 5784 | struct switchdev_brport_flags flags, |
| 5785 | struct netlink_ext_ack *extack) |
| 5786 | { |
| 5787 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5788 | const struct mv88e6xxx_ops *ops; |
| 5789 | |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 5790 | if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | |
| 5791 | BR_BCAST_FLOOD)) |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5792 | return -EINVAL; |
| 5793 | |
| 5794 | ops = chip->info->ops; |
| 5795 | |
| 5796 | if ((flags.mask & BR_FLOOD) && !ops->port_set_ucast_flood) |
| 5797 | return -EINVAL; |
| 5798 | |
| 5799 | if ((flags.mask & BR_MCAST_FLOOD) && !ops->port_set_mcast_flood) |
| 5800 | return -EINVAL; |
| 5801 | |
| 5802 | return 0; |
| 5803 | } |
| 5804 | |
| 5805 | static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port, |
| 5806 | struct switchdev_brport_flags flags, |
| 5807 | struct netlink_ext_ack *extack) |
Russell King | 4f85901 | 2019-02-20 15:35:05 -0800 | [diff] [blame] | 5808 | { |
| 5809 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5810 | int err = -EOPNOTSUPP; |
| 5811 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5812 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5813 | |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 5814 | if (flags.mask & BR_LEARNING) { |
| 5815 | bool learning = !!(flags.val & BR_LEARNING); |
| 5816 | u16 pav = learning ? (1 << port) : 0; |
| 5817 | |
| 5818 | err = mv88e6xxx_port_set_assoc_vector(chip, port, pav); |
| 5819 | if (err) |
| 5820 | goto out; |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 5821 | } |
| 5822 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5823 | if (flags.mask & BR_FLOOD) { |
| 5824 | bool unicast = !!(flags.val & BR_FLOOD); |
| 5825 | |
| 5826 | err = chip->info->ops->port_set_ucast_flood(chip, port, |
| 5827 | unicast); |
| 5828 | if (err) |
| 5829 | goto out; |
| 5830 | } |
| 5831 | |
| 5832 | if (flags.mask & BR_MCAST_FLOOD) { |
| 5833 | bool multicast = !!(flags.val & BR_MCAST_FLOOD); |
| 5834 | |
| 5835 | err = chip->info->ops->port_set_mcast_flood(chip, port, |
| 5836 | multicast); |
| 5837 | if (err) |
| 5838 | goto out; |
| 5839 | } |
| 5840 | |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 5841 | if (flags.mask & BR_BCAST_FLOOD) { |
| 5842 | bool broadcast = !!(flags.val & BR_BCAST_FLOOD); |
| 5843 | |
| 5844 | err = mv88e6xxx_port_broadcast_sync(chip, port, broadcast); |
| 5845 | if (err) |
| 5846 | goto out; |
| 5847 | } |
| 5848 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5849 | out: |
| 5850 | mv88e6xxx_reg_unlock(chip); |
| 5851 | |
| 5852 | return err; |
| 5853 | } |
| 5854 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 5855 | static bool mv88e6xxx_lag_can_offload(struct dsa_switch *ds, |
| 5856 | struct net_device *lag, |
| 5857 | struct netdev_lag_upper_info *info) |
| 5858 | { |
Tobias Waldekranz | b80dc51 | 2021-01-15 13:52:59 +0100 | [diff] [blame] | 5859 | struct mv88e6xxx_chip *chip = ds->priv; |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 5860 | struct dsa_port *dp; |
| 5861 | int id, members = 0; |
| 5862 | |
Tobias Waldekranz | b80dc51 | 2021-01-15 13:52:59 +0100 | [diff] [blame] | 5863 | if (!mv88e6xxx_has_lag(chip)) |
| 5864 | return false; |
| 5865 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 5866 | id = dsa_lag_id(ds->dst, lag); |
| 5867 | if (id < 0 || id >= ds->num_lag_ids) |
| 5868 | return false; |
| 5869 | |
| 5870 | dsa_lag_foreach_port(dp, ds->dst, lag) |
| 5871 | /* Includes the port joining the LAG */ |
| 5872 | members++; |
| 5873 | |
| 5874 | if (members > 8) |
| 5875 | return false; |
| 5876 | |
| 5877 | /* We could potentially relax this to include active |
| 5878 | * backup in the future. |
| 5879 | */ |
| 5880 | if (info->tx_type != NETDEV_LAG_TX_TYPE_HASH) |
| 5881 | return false; |
| 5882 | |
| 5883 | /* Ideally we would also validate that the hash type matches |
| 5884 | * the hardware. Alas, this is always set to unknown on team |
| 5885 | * interfaces. |
| 5886 | */ |
| 5887 | return true; |
| 5888 | } |
| 5889 | |
| 5890 | static int mv88e6xxx_lag_sync_map(struct dsa_switch *ds, struct net_device *lag) |
| 5891 | { |
| 5892 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5893 | struct dsa_port *dp; |
| 5894 | u16 map = 0; |
| 5895 | int id; |
| 5896 | |
| 5897 | id = dsa_lag_id(ds->dst, lag); |
| 5898 | |
| 5899 | /* Build the map of all ports to distribute flows destined for |
| 5900 | * this LAG. This can be either a local user port, or a DSA |
| 5901 | * port if the LAG port is on a remote chip. |
| 5902 | */ |
| 5903 | dsa_lag_foreach_port(dp, ds->dst, lag) |
| 5904 | map |= BIT(dsa_towards_port(ds, dp->ds->index, dp->index)); |
| 5905 | |
| 5906 | return mv88e6xxx_g2_trunk_mapping_write(chip, id, map); |
| 5907 | } |
| 5908 | |
| 5909 | static const u8 mv88e6xxx_lag_mask_table[8][8] = { |
| 5910 | /* Row number corresponds to the number of active members in a |
| 5911 | * LAG. Each column states which of the eight hash buckets are |
| 5912 | * mapped to the column:th port in the LAG. |
| 5913 | * |
| 5914 | * Example: In a LAG with three active ports, the second port |
| 5915 | * ([2][1]) would be selected for traffic mapped to buckets |
| 5916 | * 3,4,5 (0x38). |
| 5917 | */ |
| 5918 | { 0xff, 0, 0, 0, 0, 0, 0, 0 }, |
| 5919 | { 0x0f, 0xf0, 0, 0, 0, 0, 0, 0 }, |
| 5920 | { 0x07, 0x38, 0xc0, 0, 0, 0, 0, 0 }, |
| 5921 | { 0x03, 0x0c, 0x30, 0xc0, 0, 0, 0, 0 }, |
| 5922 | { 0x03, 0x0c, 0x30, 0x40, 0x80, 0, 0, 0 }, |
| 5923 | { 0x03, 0x0c, 0x10, 0x20, 0x40, 0x80, 0, 0 }, |
| 5924 | { 0x03, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0 }, |
| 5925 | { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, |
| 5926 | }; |
| 5927 | |
| 5928 | static void mv88e6xxx_lag_set_port_mask(u16 *mask, int port, |
| 5929 | int num_tx, int nth) |
| 5930 | { |
| 5931 | u8 active = 0; |
| 5932 | int i; |
| 5933 | |
| 5934 | num_tx = num_tx <= 8 ? num_tx : 8; |
| 5935 | if (nth < num_tx) |
| 5936 | active = mv88e6xxx_lag_mask_table[num_tx - 1][nth]; |
| 5937 | |
| 5938 | for (i = 0; i < 8; i++) { |
| 5939 | if (BIT(i) & active) |
| 5940 | mask[i] |= BIT(port); |
| 5941 | } |
| 5942 | } |
| 5943 | |
| 5944 | static int mv88e6xxx_lag_sync_masks(struct dsa_switch *ds) |
| 5945 | { |
| 5946 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5947 | unsigned int id, num_tx; |
| 5948 | struct net_device *lag; |
| 5949 | struct dsa_port *dp; |
| 5950 | int i, err, nth; |
| 5951 | u16 mask[8]; |
| 5952 | u16 ivec; |
| 5953 | |
| 5954 | /* Assume no port is a member of any LAG. */ |
| 5955 | ivec = BIT(mv88e6xxx_num_ports(chip)) - 1; |
| 5956 | |
| 5957 | /* Disable all masks for ports that _are_ members of a LAG. */ |
| 5958 | list_for_each_entry(dp, &ds->dst->ports, list) { |
| 5959 | if (!dp->lag_dev || dp->ds != ds) |
| 5960 | continue; |
| 5961 | |
| 5962 | ivec &= ~BIT(dp->index); |
| 5963 | } |
| 5964 | |
| 5965 | for (i = 0; i < 8; i++) |
| 5966 | mask[i] = ivec; |
| 5967 | |
| 5968 | /* Enable the correct subset of masks for all LAG ports that |
| 5969 | * are in the Tx set. |
| 5970 | */ |
| 5971 | dsa_lags_foreach_id(id, ds->dst) { |
| 5972 | lag = dsa_lag_dev(ds->dst, id); |
| 5973 | if (!lag) |
| 5974 | continue; |
| 5975 | |
| 5976 | num_tx = 0; |
| 5977 | dsa_lag_foreach_port(dp, ds->dst, lag) { |
| 5978 | if (dp->lag_tx_enabled) |
| 5979 | num_tx++; |
| 5980 | } |
| 5981 | |
| 5982 | if (!num_tx) |
| 5983 | continue; |
| 5984 | |
| 5985 | nth = 0; |
| 5986 | dsa_lag_foreach_port(dp, ds->dst, lag) { |
| 5987 | if (!dp->lag_tx_enabled) |
| 5988 | continue; |
| 5989 | |
| 5990 | if (dp->ds == ds) |
| 5991 | mv88e6xxx_lag_set_port_mask(mask, dp->index, |
| 5992 | num_tx, nth); |
| 5993 | |
| 5994 | nth++; |
| 5995 | } |
| 5996 | } |
| 5997 | |
| 5998 | for (i = 0; i < 8; i++) { |
| 5999 | err = mv88e6xxx_g2_trunk_mask_write(chip, i, true, mask[i]); |
| 6000 | if (err) |
| 6001 | return err; |
| 6002 | } |
| 6003 | |
| 6004 | return 0; |
| 6005 | } |
| 6006 | |
| 6007 | static int mv88e6xxx_lag_sync_masks_map(struct dsa_switch *ds, |
| 6008 | struct net_device *lag) |
| 6009 | { |
| 6010 | int err; |
| 6011 | |
| 6012 | err = mv88e6xxx_lag_sync_masks(ds); |
| 6013 | |
| 6014 | if (!err) |
| 6015 | err = mv88e6xxx_lag_sync_map(ds, lag); |
| 6016 | |
| 6017 | return err; |
| 6018 | } |
| 6019 | |
| 6020 | static int mv88e6xxx_port_lag_change(struct dsa_switch *ds, int port) |
| 6021 | { |
| 6022 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6023 | int err; |
| 6024 | |
| 6025 | mv88e6xxx_reg_lock(chip); |
| 6026 | err = mv88e6xxx_lag_sync_masks(ds); |
| 6027 | mv88e6xxx_reg_unlock(chip); |
| 6028 | return err; |
| 6029 | } |
| 6030 | |
| 6031 | static int mv88e6xxx_port_lag_join(struct dsa_switch *ds, int port, |
| 6032 | struct net_device *lag, |
| 6033 | struct netdev_lag_upper_info *info) |
| 6034 | { |
| 6035 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6036 | int err, id; |
| 6037 | |
| 6038 | if (!mv88e6xxx_lag_can_offload(ds, lag, info)) |
| 6039 | return -EOPNOTSUPP; |
| 6040 | |
| 6041 | id = dsa_lag_id(ds->dst, lag); |
| 6042 | |
| 6043 | mv88e6xxx_reg_lock(chip); |
| 6044 | |
| 6045 | err = mv88e6xxx_port_set_trunk(chip, port, true, id); |
| 6046 | if (err) |
| 6047 | goto err_unlock; |
| 6048 | |
| 6049 | err = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6050 | if (err) |
| 6051 | goto err_clear_trunk; |
| 6052 | |
| 6053 | mv88e6xxx_reg_unlock(chip); |
| 6054 | return 0; |
| 6055 | |
| 6056 | err_clear_trunk: |
| 6057 | mv88e6xxx_port_set_trunk(chip, port, false, 0); |
| 6058 | err_unlock: |
| 6059 | mv88e6xxx_reg_unlock(chip); |
| 6060 | return err; |
| 6061 | } |
| 6062 | |
| 6063 | static int mv88e6xxx_port_lag_leave(struct dsa_switch *ds, int port, |
| 6064 | struct net_device *lag) |
| 6065 | { |
| 6066 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6067 | int err_sync, err_trunk; |
| 6068 | |
| 6069 | mv88e6xxx_reg_lock(chip); |
| 6070 | err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6071 | err_trunk = mv88e6xxx_port_set_trunk(chip, port, false, 0); |
| 6072 | mv88e6xxx_reg_unlock(chip); |
| 6073 | return err_sync ? : err_trunk; |
| 6074 | } |
| 6075 | |
| 6076 | static int mv88e6xxx_crosschip_lag_change(struct dsa_switch *ds, int sw_index, |
| 6077 | int port) |
| 6078 | { |
| 6079 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6080 | int err; |
| 6081 | |
| 6082 | mv88e6xxx_reg_lock(chip); |
| 6083 | err = mv88e6xxx_lag_sync_masks(ds); |
| 6084 | mv88e6xxx_reg_unlock(chip); |
| 6085 | return err; |
| 6086 | } |
| 6087 | |
| 6088 | static int mv88e6xxx_crosschip_lag_join(struct dsa_switch *ds, int sw_index, |
| 6089 | int port, struct net_device *lag, |
| 6090 | struct netdev_lag_upper_info *info) |
| 6091 | { |
| 6092 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6093 | int err; |
| 6094 | |
| 6095 | if (!mv88e6xxx_lag_can_offload(ds, lag, info)) |
| 6096 | return -EOPNOTSUPP; |
| 6097 | |
| 6098 | mv88e6xxx_reg_lock(chip); |
| 6099 | |
| 6100 | err = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6101 | if (err) |
| 6102 | goto unlock; |
| 6103 | |
| 6104 | err = mv88e6xxx_pvt_map(chip, sw_index, port); |
| 6105 | |
| 6106 | unlock: |
| 6107 | mv88e6xxx_reg_unlock(chip); |
| 6108 | return err; |
| 6109 | } |
| 6110 | |
| 6111 | static int mv88e6xxx_crosschip_lag_leave(struct dsa_switch *ds, int sw_index, |
| 6112 | int port, struct net_device *lag) |
| 6113 | { |
| 6114 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6115 | int err_sync, err_pvt; |
| 6116 | |
| 6117 | mv88e6xxx_reg_lock(chip); |
| 6118 | err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6119 | err_pvt = mv88e6xxx_pvt_map(chip, sw_index, port); |
| 6120 | mv88e6xxx_reg_unlock(chip); |
| 6121 | return err_sync ? : err_pvt; |
| 6122 | } |
| 6123 | |
Florian Fainelli | a82f67a | 2017-01-08 14:52:08 -0800 | [diff] [blame] | 6124 | static const struct dsa_switch_ops mv88e6xxx_switch_ops = { |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 6125 | .get_tag_protocol = mv88e6xxx_get_tag_protocol, |
Tobias Waldekranz | 9a99bef | 2021-04-20 20:53:08 +0200 | [diff] [blame] | 6126 | .change_tag_protocol = mv88e6xxx_change_tag_protocol, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6127 | .setup = mv88e6xxx_setup, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 6128 | .teardown = mv88e6xxx_teardown, |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 6129 | .port_setup = mv88e6xxx_port_setup, |
| 6130 | .port_teardown = mv88e6xxx_port_teardown, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 6131 | .phylink_validate = mv88e6xxx_validate, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 6132 | .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 6133 | .phylink_mac_config = mv88e6xxx_mac_config, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 6134 | .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 6135 | .phylink_mac_link_down = mv88e6xxx_mac_link_down, |
| 6136 | .phylink_mac_link_up = mv88e6xxx_mac_link_up, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6137 | .get_strings = mv88e6xxx_get_strings, |
| 6138 | .get_ethtool_stats = mv88e6xxx_get_ethtool_stats, |
| 6139 | .get_sset_count = mv88e6xxx_get_sset_count, |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 6140 | .port_enable = mv88e6xxx_port_enable, |
| 6141 | .port_disable = mv88e6xxx_port_disable, |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 6142 | .port_max_mtu = mv88e6xxx_get_max_mtu, |
| 6143 | .port_change_mtu = mv88e6xxx_change_mtu, |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 6144 | .get_mac_eee = mv88e6xxx_get_mac_eee, |
| 6145 | .set_mac_eee = mv88e6xxx_set_mac_eee, |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 6146 | .get_eeprom_len = mv88e6xxx_get_eeprom_len, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6147 | .get_eeprom = mv88e6xxx_get_eeprom, |
| 6148 | .set_eeprom = mv88e6xxx_set_eeprom, |
| 6149 | .get_regs_len = mv88e6xxx_get_regs_len, |
| 6150 | .get_regs = mv88e6xxx_get_regs, |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 6151 | .get_rxnfc = mv88e6xxx_get_rxnfc, |
| 6152 | .set_rxnfc = mv88e6xxx_set_rxnfc, |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 6153 | .set_ageing_time = mv88e6xxx_set_ageing_time, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6154 | .port_bridge_join = mv88e6xxx_port_bridge_join, |
| 6155 | .port_bridge_leave = mv88e6xxx_port_bridge_leave, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 6156 | .port_pre_bridge_flags = mv88e6xxx_port_pre_bridge_flags, |
| 6157 | .port_bridge_flags = mv88e6xxx_port_bridge_flags, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6158 | .port_stp_state_set = mv88e6xxx_port_stp_state_set, |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 6159 | .port_fast_age = mv88e6xxx_port_fast_age, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6160 | .port_vlan_filtering = mv88e6xxx_port_vlan_filtering, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6161 | .port_vlan_add = mv88e6xxx_port_vlan_add, |
| 6162 | .port_vlan_del = mv88e6xxx_port_vlan_del, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6163 | .port_fdb_add = mv88e6xxx_port_fdb_add, |
| 6164 | .port_fdb_del = mv88e6xxx_port_fdb_del, |
| 6165 | .port_fdb_dump = mv88e6xxx_port_fdb_dump, |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 6166 | .port_mdb_add = mv88e6xxx_port_mdb_add, |
| 6167 | .port_mdb_del = mv88e6xxx_port_mdb_del, |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 6168 | .port_mirror_add = mv88e6xxx_port_mirror_add, |
| 6169 | .port_mirror_del = mv88e6xxx_port_mirror_del, |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 6170 | .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join, |
| 6171 | .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave, |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 6172 | .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set, |
| 6173 | .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get, |
| 6174 | .port_txtstamp = mv88e6xxx_port_txtstamp, |
| 6175 | .port_rxtstamp = mv88e6xxx_port_rxtstamp, |
| 6176 | .get_ts_info = mv88e6xxx_get_ts_info, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 6177 | .devlink_param_get = mv88e6xxx_devlink_param_get, |
| 6178 | .devlink_param_set = mv88e6xxx_devlink_param_set, |
Andrew Lunn | 9315730 | 2020-09-18 21:11:09 +0200 | [diff] [blame] | 6179 | .devlink_info_get = mv88e6xxx_devlink_info_get, |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 6180 | .port_lag_change = mv88e6xxx_port_lag_change, |
| 6181 | .port_lag_join = mv88e6xxx_port_lag_join, |
| 6182 | .port_lag_leave = mv88e6xxx_port_lag_leave, |
| 6183 | .crosschip_lag_change = mv88e6xxx_crosschip_lag_change, |
| 6184 | .crosschip_lag_join = mv88e6xxx_crosschip_lag_join, |
| 6185 | .crosschip_lag_leave = mv88e6xxx_crosschip_lag_leave, |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 6186 | .port_bridge_tx_fwd_offload = mv88e6xxx_bridge_tx_fwd_offload, |
| 6187 | .port_bridge_tx_fwd_unoffload = mv88e6xxx_bridge_tx_fwd_unoffload, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6188 | }; |
| 6189 | |
Florian Fainelli | 55ed0ce | 2017-01-26 10:45:51 -0800 | [diff] [blame] | 6190 | static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip) |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6191 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6192 | struct device *dev = chip->dev; |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6193 | struct dsa_switch *ds; |
| 6194 | |
Vivien Didelot | 7e99e34 | 2019-10-21 16:51:30 -0400 | [diff] [blame] | 6195 | ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6196 | if (!ds) |
| 6197 | return -ENOMEM; |
| 6198 | |
Vivien Didelot | 7e99e34 | 2019-10-21 16:51:30 -0400 | [diff] [blame] | 6199 | ds->dev = dev; |
| 6200 | ds->num_ports = mv88e6xxx_num_ports(chip); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6201 | ds->priv = chip; |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6202 | ds->dev = dev; |
Vivien Didelot | 9d490b4 | 2016-08-23 12:38:56 -0400 | [diff] [blame] | 6203 | ds->ops = &mv88e6xxx_switch_ops; |
Vivien Didelot | 9ff74f2 | 2017-03-15 15:53:50 -0400 | [diff] [blame] | 6204 | ds->ageing_time_min = chip->info->age_time_coeff; |
| 6205 | ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX; |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6206 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 6207 | /* Some chips support up to 32, but that requires enabling the |
| 6208 | * 5-bit port mode, which we do not support. 640k^W16 ought to |
| 6209 | * be enough for anyone. |
| 6210 | */ |
Tobias Waldekranz | b80dc51 | 2021-01-15 13:52:59 +0100 | [diff] [blame] | 6211 | ds->num_lag_ids = mv88e6xxx_has_lag(chip) ? 16 : 0; |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 6212 | |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6213 | dev_set_drvdata(dev, ds); |
| 6214 | |
Vivien Didelot | 23c9ee4 | 2017-05-26 18:12:51 -0400 | [diff] [blame] | 6215 | return dsa_register_switch(ds); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6216 | } |
| 6217 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6218 | static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip) |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6219 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6220 | dsa_unregister_switch(chip->ds); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6221 | } |
| 6222 | |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6223 | static const void *pdata_device_get_match_data(struct device *dev) |
| 6224 | { |
| 6225 | const struct of_device_id *matches = dev->driver->of_match_table; |
| 6226 | const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data; |
| 6227 | |
| 6228 | for (; matches->name[0] || matches->type[0] || matches->compatible[0]; |
| 6229 | matches++) { |
| 6230 | if (!strcmp(pdata->compatible, matches->compatible)) |
| 6231 | return matches->data; |
| 6232 | } |
| 6233 | return NULL; |
| 6234 | } |
| 6235 | |
Miquel Raynal | bcd3d9d | 2019-02-05 12:07:28 +0100 | [diff] [blame] | 6236 | /* There is no suspend to RAM support at DSA level yet, the switch configuration |
| 6237 | * would be lost after a power cycle so prevent it to be suspended. |
| 6238 | */ |
| 6239 | static int __maybe_unused mv88e6xxx_suspend(struct device *dev) |
| 6240 | { |
| 6241 | return -EOPNOTSUPP; |
| 6242 | } |
| 6243 | |
| 6244 | static int __maybe_unused mv88e6xxx_resume(struct device *dev) |
| 6245 | { |
| 6246 | return 0; |
| 6247 | } |
| 6248 | |
| 6249 | static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume); |
| 6250 | |
Vivien Didelot | 57d3231 | 2016-06-20 13:13:58 -0400 | [diff] [blame] | 6251 | static int mv88e6xxx_probe(struct mdio_device *mdiodev) |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6252 | { |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6253 | struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data; |
David S. Miller | 7ddae24 | 2018-05-20 19:04:24 -0400 | [diff] [blame] | 6254 | const struct mv88e6xxx_info *compat_info = NULL; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6255 | struct device *dev = &mdiodev->dev; |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 6256 | struct device_node *np = dev->of_node; |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6257 | struct mv88e6xxx_chip *chip; |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6258 | int port; |
Andrew Lunn | 52638f7 | 2016-05-10 23:27:22 +0200 | [diff] [blame] | 6259 | int err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6260 | |
Andrew Lunn | 7bb8c99 | 2018-05-31 00:15:42 +0200 | [diff] [blame] | 6261 | if (!np && !pdata) |
| 6262 | return -EINVAL; |
| 6263 | |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6264 | if (np) |
| 6265 | compat_info = of_device_get_match_data(dev); |
| 6266 | |
| 6267 | if (pdata) { |
| 6268 | compat_info = pdata_device_get_match_data(dev); |
| 6269 | |
| 6270 | if (!pdata->netdev) |
| 6271 | return -EINVAL; |
| 6272 | |
| 6273 | for (port = 0; port < DSA_MAX_PORTS; port++) { |
| 6274 | if (!(pdata->enabled_ports & (1 << port))) |
| 6275 | continue; |
| 6276 | if (strcmp(pdata->cd.port_names[port], "cpu")) |
| 6277 | continue; |
| 6278 | pdata->cd.netdev[port] = &pdata->netdev->dev; |
| 6279 | break; |
| 6280 | } |
| 6281 | } |
| 6282 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 6283 | if (!compat_info) |
| 6284 | return -EINVAL; |
| 6285 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6286 | chip = mv88e6xxx_alloc_chip(dev); |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6287 | if (!chip) { |
| 6288 | err = -ENOMEM; |
| 6289 | goto out; |
| 6290 | } |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6291 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6292 | chip->info = compat_info; |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 6293 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6294 | err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr); |
Vivien Didelot | 4a70c4a | 2016-06-20 13:14:07 -0400 | [diff] [blame] | 6295 | if (err) |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6296 | goto out; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6297 | |
Andrew Lunn | b4308f0 | 2016-11-21 23:26:55 +0100 | [diff] [blame] | 6298 | chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6299 | if (IS_ERR(chip->reset)) { |
| 6300 | err = PTR_ERR(chip->reset); |
| 6301 | goto out; |
| 6302 | } |
Baruch Siach | 7b75e49 | 2019-06-27 21:17:39 +0300 | [diff] [blame] | 6303 | if (chip->reset) |
| 6304 | usleep_range(1000, 2000); |
Andrew Lunn | b4308f0 | 2016-11-21 23:26:55 +0100 | [diff] [blame] | 6305 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6306 | err = mv88e6xxx_detect(chip); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 6307 | if (err) |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6308 | goto out; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6309 | |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 6310 | if (chip->info->edsa_support == MV88E6XXX_EDSA_SUPPORTED) |
| 6311 | chip->tag_protocol = DSA_TAG_PROTO_EDSA; |
| 6312 | else |
| 6313 | chip->tag_protocol = DSA_TAG_PROTO_DSA; |
| 6314 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 6315 | mv88e6xxx_phy_init(chip); |
| 6316 | |
Andrew Lunn | 00baabe | 2018-05-19 22:31:35 +0200 | [diff] [blame] | 6317 | if (chip->info->ops->get_eeprom) { |
| 6318 | if (np) |
| 6319 | of_property_read_u32(np, "eeprom-length", |
| 6320 | &chip->eeprom_len); |
| 6321 | else |
| 6322 | chip->eeprom_len = pdata->eeprom_len; |
| 6323 | } |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 6324 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6325 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6326 | err = mv88e6xxx_switch_reset(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6327 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 6328 | if (err) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6329 | goto out; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 6330 | |
Andrew Lunn | a27415d | 2019-05-01 00:10:50 +0200 | [diff] [blame] | 6331 | if (np) { |
| 6332 | chip->irq = of_irq_get(np, 0); |
| 6333 | if (chip->irq == -EPROBE_DEFER) { |
| 6334 | err = chip->irq; |
| 6335 | goto out; |
| 6336 | } |
Andrew Lunn | 83c0afa | 2016-06-04 21:17:07 +0200 | [diff] [blame] | 6337 | } |
| 6338 | |
Andrew Lunn | a27415d | 2019-05-01 00:10:50 +0200 | [diff] [blame] | 6339 | if (pdata) |
| 6340 | chip->irq = pdata->irq; |
| 6341 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6342 | /* 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] | 6343 | * the PHYs will link their interrupts to these interrupt |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6344 | * controllers |
| 6345 | */ |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6346 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6347 | if (chip->irq > 0) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6348 | err = mv88e6xxx_g1_irq_setup(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6349 | else |
| 6350 | err = mv88e6xxx_irq_poll_setup(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6351 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6352 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6353 | if (err) |
| 6354 | goto out; |
| 6355 | |
| 6356 | if (chip->info->g2_irqs > 0) { |
| 6357 | err = mv88e6xxx_g2_irq_setup(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6358 | if (err) |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6359 | goto out_g1_irq; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6360 | } |
| 6361 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6362 | err = mv88e6xxx_g1_atu_prob_irq_setup(chip); |
| 6363 | if (err) |
| 6364 | goto out_g2_irq; |
| 6365 | |
| 6366 | err = mv88e6xxx_g1_vtu_prob_irq_setup(chip); |
| 6367 | if (err) |
| 6368 | goto out_g1_atu_prob_irq; |
| 6369 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 6370 | err = mv88e6xxx_mdios_register(chip, np); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6371 | if (err) |
Andrew Lunn | 62eb116 | 2018-01-14 02:32:45 +0100 | [diff] [blame] | 6372 | goto out_g1_vtu_prob_irq; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6373 | |
Florian Fainelli | 55ed0ce | 2017-01-26 10:45:51 -0800 | [diff] [blame] | 6374 | err = mv88e6xxx_register_switch(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6375 | if (err) |
| 6376 | goto out_mdio; |
| 6377 | |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6378 | return 0; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6379 | |
| 6380 | out_mdio: |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 6381 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | 62eb116 | 2018-01-14 02:32:45 +0100 | [diff] [blame] | 6382 | out_g1_vtu_prob_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6383 | mv88e6xxx_g1_vtu_prob_irq_free(chip); |
Andrew Lunn | 0977644 | 2018-01-14 02:32:44 +0100 | [diff] [blame] | 6384 | out_g1_atu_prob_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6385 | mv88e6xxx_g1_atu_prob_irq_free(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6386 | out_g2_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6387 | if (chip->info->g2_irqs > 0) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6388 | mv88e6xxx_g2_irq_free(chip); |
| 6389 | out_g1_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6390 | if (chip->irq > 0) |
Andrew Lunn | 46712644 | 2016-11-20 20:14:15 +0100 | [diff] [blame] | 6391 | mv88e6xxx_g1_irq_free(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6392 | else |
| 6393 | mv88e6xxx_irq_poll_free(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6394 | out: |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6395 | if (pdata) |
| 6396 | dev_put(pdata->netdev); |
| 6397 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6398 | return err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6399 | } |
| 6400 | |
| 6401 | static void mv88e6xxx_remove(struct mdio_device *mdiodev) |
| 6402 | { |
| 6403 | struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev); |
Vladimir Oltean | 0650bf5 | 2021-09-17 16:34:33 +0300 | [diff] [blame] | 6404 | struct mv88e6xxx_chip *chip; |
| 6405 | |
| 6406 | if (!ds) |
| 6407 | return; |
| 6408 | |
| 6409 | chip = ds->priv; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6410 | |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 6411 | if (chip->info->ptp_support) { |
| 6412 | mv88e6xxx_hwtstamp_free(chip); |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 6413 | mv88e6xxx_ptp_free(chip); |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 6414 | } |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 6415 | |
Andrew Lunn | 930188c | 2016-08-22 16:01:03 +0200 | [diff] [blame] | 6416 | mv88e6xxx_phy_destroy(chip); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6417 | mv88e6xxx_unregister_switch(chip); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 6418 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6419 | |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 6420 | mv88e6xxx_g1_vtu_prob_irq_free(chip); |
| 6421 | mv88e6xxx_g1_atu_prob_irq_free(chip); |
| 6422 | |
| 6423 | if (chip->info->g2_irqs > 0) |
| 6424 | mv88e6xxx_g2_irq_free(chip); |
| 6425 | |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 6426 | if (chip->irq > 0) |
Andrew Lunn | 46712644 | 2016-11-20 20:14:15 +0100 | [diff] [blame] | 6427 | mv88e6xxx_g1_irq_free(chip); |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 6428 | else |
| 6429 | mv88e6xxx_irq_poll_free(chip); |
Vladimir Oltean | 0650bf5 | 2021-09-17 16:34:33 +0300 | [diff] [blame] | 6430 | |
| 6431 | dev_set_drvdata(&mdiodev->dev, NULL); |
| 6432 | } |
| 6433 | |
| 6434 | static void mv88e6xxx_shutdown(struct mdio_device *mdiodev) |
| 6435 | { |
| 6436 | struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev); |
| 6437 | |
| 6438 | if (!ds) |
| 6439 | return; |
| 6440 | |
| 6441 | dsa_switch_shutdown(ds); |
| 6442 | |
| 6443 | dev_set_drvdata(&mdiodev->dev, NULL); |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6444 | } |
| 6445 | |
| 6446 | static const struct of_device_id mv88e6xxx_of_match[] = { |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 6447 | { |
| 6448 | .compatible = "marvell,mv88e6085", |
| 6449 | .data = &mv88e6xxx_table[MV88E6085], |
| 6450 | }, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 6451 | { |
| 6452 | .compatible = "marvell,mv88e6190", |
| 6453 | .data = &mv88e6xxx_table[MV88E6190], |
| 6454 | }, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 6455 | { |
| 6456 | .compatible = "marvell,mv88e6250", |
| 6457 | .data = &mv88e6xxx_table[MV88E6250], |
| 6458 | }, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6459 | { /* sentinel */ }, |
| 6460 | }; |
| 6461 | |
| 6462 | MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match); |
| 6463 | |
| 6464 | static struct mdio_driver mv88e6xxx_driver = { |
| 6465 | .probe = mv88e6xxx_probe, |
| 6466 | .remove = mv88e6xxx_remove, |
Vladimir Oltean | 0650bf5 | 2021-09-17 16:34:33 +0300 | [diff] [blame] | 6467 | .shutdown = mv88e6xxx_shutdown, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6468 | .mdiodrv.driver = { |
| 6469 | .name = "mv88e6085", |
| 6470 | .of_match_table = mv88e6xxx_of_match, |
Miquel Raynal | bcd3d9d | 2019-02-05 12:07:28 +0100 | [diff] [blame] | 6471 | .pm = &mv88e6xxx_pm_ops, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6472 | }, |
| 6473 | }; |
| 6474 | |
Andrew Lunn | 7324d50 | 2019-04-27 19:19:10 +0200 | [diff] [blame] | 6475 | mdio_module_driver(mv88e6xxx_driver); |
Ben Hutchings | 3d825ed | 2011-11-25 14:37:16 +0000 | [diff] [blame] | 6476 | |
| 6477 | MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); |
| 6478 | MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips"); |
| 6479 | MODULE_LICENSE("GPL"); |