Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 2 | /* |
Vivien Didelot | 0d3cd4b | 2016-06-21 12:28:19 -0400 | [diff] [blame] | 3 | * Marvell 88e6xxx Ethernet switch single-chip support |
| 4 | * |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 5 | * Copyright (c) 2008 Marvell Semiconductor |
| 6 | * |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 7 | * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch> |
| 8 | * |
Vivien Didelot | 4333d61 | 2017-03-28 15:10:36 -0400 | [diff] [blame] | 9 | * Copyright (c) 2016-2017 Savoir-faire Linux Inc. |
| 10 | * Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
Vivien Didelot | 19fb7f6 | 2019-08-09 18:47:55 -0400 | [diff] [blame] | 13 | #include <linux/bitfield.h> |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 14 | #include <linux/delay.h> |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 15 | #include <linux/dsa/mv88e6xxx.h> |
Guenter Roeck | defb05b | 2015-03-26 18:36:38 -0700 | [diff] [blame] | 16 | #include <linux/etherdevice.h> |
Andrew Lunn | dea8702 | 2015-08-31 15:56:47 +0200 | [diff] [blame] | 17 | #include <linux/ethtool.h> |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 18 | #include <linux/if_bridge.h> |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 19 | #include <linux/interrupt.h> |
| 20 | #include <linux/irq.h> |
| 21 | #include <linux/irqdomain.h> |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 22 | #include <linux/jiffies.h> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 23 | #include <linux/list.h> |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 24 | #include <linux/mdio.h> |
Paul Gortmaker | 2bbba27 | 2012-01-24 10:41:40 +0000 | [diff] [blame] | 25 | #include <linux/module.h> |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 26 | #include <linux/of_device.h> |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 27 | #include <linux/of_irq.h> |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 28 | #include <linux/of_mdio.h> |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 29 | #include <linux/platform_data/mv88e6xxx.h> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 30 | #include <linux/netdevice.h> |
Andrew Lunn | c8c1b39a | 2015-11-20 03:56:24 +0100 | [diff] [blame] | 31 | #include <linux/gpio/consumer.h> |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 32 | #include <linux/phylink.h> |
Ben Hutchings | c8f0b86 | 2011-11-27 17:06:08 +0000 | [diff] [blame] | 33 | #include <net/dsa.h> |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 34 | |
Vivien Didelot | 4d5f2ba7 | 2017-06-02 17:06:15 -0400 | [diff] [blame] | 35 | #include "chip.h" |
Andrew Lunn | 9dd43aa | 2020-09-18 21:11:05 +0200 | [diff] [blame] | 36 | #include "devlink.h" |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 37 | #include "global1.h" |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 38 | #include "global2.h" |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 39 | #include "hwtstamp.h" |
Andrew Lunn | 10fa5bf | 2017-05-26 01:03:20 +0200 | [diff] [blame] | 40 | #include "phy.h" |
Vivien Didelot | 18abed2 | 2016-11-04 03:23:26 +0100 | [diff] [blame] | 41 | #include "port.h" |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 42 | #include "ptp.h" |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 43 | #include "serdes.h" |
Vivien Didelot | e7ba0fa | 2019-05-03 19:28:22 -0400 | [diff] [blame] | 44 | #include "smi.h" |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 45 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 46 | static void assert_reg_lock(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 3996a4f | 2015-10-30 18:56:45 -0400 | [diff] [blame] | 47 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 48 | if (unlikely(!mutex_is_locked(&chip->reg_lock))) { |
| 49 | dev_err(chip->dev, "Switch registers lock not held!\n"); |
Vivien Didelot | 3996a4f | 2015-10-30 18:56:45 -0400 | [diff] [blame] | 50 | dump_stack(); |
| 51 | } |
| 52 | } |
| 53 | |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 54 | int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val) |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 55 | { |
| 56 | int err; |
| 57 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 58 | assert_reg_lock(chip); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 59 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 60 | err = mv88e6xxx_smi_read(chip, addr, reg, val); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 61 | if (err) |
| 62 | return err; |
| 63 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 64 | dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n", |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 65 | addr, reg, *val); |
| 66 | |
| 67 | return 0; |
| 68 | } |
| 69 | |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 70 | int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val) |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 71 | { |
| 72 | int err; |
| 73 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 74 | assert_reg_lock(chip); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 75 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 76 | err = mv88e6xxx_smi_write(chip, addr, reg, val); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 77 | if (err) |
| 78 | return err; |
| 79 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 80 | dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n", |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 81 | addr, reg, val); |
| 82 | |
| 83 | return 0; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 84 | } |
| 85 | |
Vivien Didelot | 683f224 | 2019-08-09 18:47:54 -0400 | [diff] [blame] | 86 | int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg, |
| 87 | u16 mask, u16 val) |
| 88 | { |
| 89 | u16 data; |
| 90 | int err; |
| 91 | int i; |
| 92 | |
| 93 | /* There's no bus specific operation to wait for a mask */ |
| 94 | for (i = 0; i < 16; i++) { |
| 95 | err = mv88e6xxx_read(chip, addr, reg, &data); |
| 96 | if (err) |
| 97 | return err; |
| 98 | |
| 99 | if ((data & mask) == val) |
| 100 | return 0; |
| 101 | |
| 102 | usleep_range(1000, 2000); |
| 103 | } |
| 104 | |
| 105 | dev_err(chip->dev, "Timeout while waiting for switch\n"); |
| 106 | return -ETIMEDOUT; |
| 107 | } |
| 108 | |
Vivien Didelot | 19fb7f6 | 2019-08-09 18:47:55 -0400 | [diff] [blame] | 109 | int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg, |
| 110 | int bit, int val) |
| 111 | { |
| 112 | return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit), |
| 113 | val ? BIT(bit) : 0x0000); |
| 114 | } |
| 115 | |
Andrew Lunn | 10fa5bf | 2017-05-26 01:03:20 +0200 | [diff] [blame] | 116 | struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip) |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 117 | { |
| 118 | struct mv88e6xxx_mdio_bus *mdio_bus; |
| 119 | |
| 120 | mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus, |
| 121 | list); |
| 122 | if (!mdio_bus) |
| 123 | return NULL; |
| 124 | |
| 125 | return mdio_bus->bus; |
| 126 | } |
| 127 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 128 | static void mv88e6xxx_g1_irq_mask(struct irq_data *d) |
| 129 | { |
| 130 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 131 | unsigned int n = d->hwirq; |
| 132 | |
| 133 | chip->g1_irq.masked |= (1 << n); |
| 134 | } |
| 135 | |
| 136 | static void mv88e6xxx_g1_irq_unmask(struct irq_data *d) |
| 137 | { |
| 138 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 139 | unsigned int n = d->hwirq; |
| 140 | |
| 141 | chip->g1_irq.masked &= ~(1 << n); |
| 142 | } |
| 143 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 144 | static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 145 | { |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 146 | unsigned int nhandled = 0; |
| 147 | unsigned int sub_irq; |
| 148 | unsigned int n; |
| 149 | u16 reg; |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 150 | u16 ctl1; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 151 | int err; |
| 152 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 153 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 8246692 | 2017-06-15 12:13:59 -0400 | [diff] [blame] | 154 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 155 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 156 | |
| 157 | if (err) |
| 158 | goto out; |
| 159 | |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 160 | do { |
| 161 | for (n = 0; n < chip->g1_irq.nirqs; ++n) { |
| 162 | if (reg & (1 << n)) { |
| 163 | sub_irq = irq_find_mapping(chip->g1_irq.domain, |
| 164 | n); |
| 165 | handle_nested_irq(sub_irq); |
| 166 | ++nhandled; |
| 167 | } |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 168 | } |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 169 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 170 | mv88e6xxx_reg_lock(chip); |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 171 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1); |
| 172 | if (err) |
| 173 | goto unlock; |
| 174 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); |
| 175 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 176 | mv88e6xxx_reg_unlock(chip); |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 177 | if (err) |
| 178 | goto out; |
| 179 | ctl1 &= GENMASK(chip->g1_irq.nirqs, 0); |
| 180 | } while (reg & ctl1); |
| 181 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 182 | out: |
| 183 | return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE); |
| 184 | } |
| 185 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 186 | static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id) |
| 187 | { |
| 188 | struct mv88e6xxx_chip *chip = dev_id; |
| 189 | |
| 190 | return mv88e6xxx_g1_irq_thread_work(chip); |
| 191 | } |
| 192 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 193 | static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d) |
| 194 | { |
| 195 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 196 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 197 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d) |
| 201 | { |
| 202 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 203 | u16 mask = GENMASK(chip->g1_irq.nirqs, 0); |
| 204 | u16 reg; |
| 205 | int err; |
| 206 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 207 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, ®); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 208 | if (err) |
| 209 | goto out; |
| 210 | |
| 211 | reg &= ~mask; |
| 212 | reg |= (~chip->g1_irq.masked & mask); |
| 213 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 214 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 215 | if (err) |
| 216 | goto out; |
| 217 | |
| 218 | out: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 219 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 220 | } |
| 221 | |
Bhumika Goyal | 6eb15e2 | 2017-08-19 16:25:52 +0530 | [diff] [blame] | 222 | static const struct irq_chip mv88e6xxx_g1_irq_chip = { |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 223 | .name = "mv88e6xxx-g1", |
| 224 | .irq_mask = mv88e6xxx_g1_irq_mask, |
| 225 | .irq_unmask = mv88e6xxx_g1_irq_unmask, |
| 226 | .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock, |
| 227 | .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock, |
| 228 | }; |
| 229 | |
| 230 | static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d, |
| 231 | unsigned int irq, |
| 232 | irq_hw_number_t hwirq) |
| 233 | { |
| 234 | struct mv88e6xxx_chip *chip = d->host_data; |
| 235 | |
| 236 | irq_set_chip_data(irq, d->host_data); |
| 237 | irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq); |
| 238 | irq_set_noprobe(irq); |
| 239 | |
| 240 | return 0; |
| 241 | } |
| 242 | |
| 243 | static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = { |
| 244 | .map = mv88e6xxx_g1_irq_domain_map, |
| 245 | .xlate = irq_domain_xlate_twocell, |
| 246 | }; |
| 247 | |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 248 | /* To be called with reg_lock held */ |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 249 | static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 250 | { |
| 251 | int irq, virq; |
Andrew Lunn | 3460a57 | 2016-11-20 20:14:16 +0100 | [diff] [blame] | 252 | u16 mask; |
| 253 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 254 | mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask); |
Andrew Lunn | 3d5fdba | 2017-12-07 01:05:56 +0100 | [diff] [blame] | 255 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 256 | mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | 3460a57 | 2016-11-20 20:14:16 +0100 | [diff] [blame] | 257 | |
Andreas Färber | 5edef2f | 2016-11-27 23:26:28 +0100 | [diff] [blame] | 258 | for (irq = 0; irq < chip->g1_irq.nirqs; irq++) { |
Andrew Lunn | a3db3d3 | 2016-11-20 20:14:14 +0100 | [diff] [blame] | 259 | virq = irq_find_mapping(chip->g1_irq.domain, irq); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 260 | irq_dispose_mapping(virq); |
| 261 | } |
| 262 | |
Andrew Lunn | a3db3d3 | 2016-11-20 20:14:14 +0100 | [diff] [blame] | 263 | irq_domain_remove(chip->g1_irq.domain); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 264 | } |
| 265 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 266 | static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip) |
| 267 | { |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 268 | /* |
| 269 | * free_irq must be called without reg_lock taken because the irq |
| 270 | * handler takes this lock, too. |
| 271 | */ |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 272 | free_irq(chip->irq, chip); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 273 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 274 | mv88e6xxx_reg_lock(chip); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 275 | mv88e6xxx_g1_irq_free_common(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 276 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 280 | { |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 281 | int err, irq, virq; |
| 282 | u16 reg, mask; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 283 | |
| 284 | chip->g1_irq.nirqs = chip->info->g1_irqs; |
| 285 | chip->g1_irq.domain = irq_domain_add_simple( |
| 286 | NULL, chip->g1_irq.nirqs, 0, |
| 287 | &mv88e6xxx_g1_irq_domain_ops, chip); |
| 288 | if (!chip->g1_irq.domain) |
| 289 | return -ENOMEM; |
| 290 | |
| 291 | for (irq = 0; irq < chip->g1_irq.nirqs; irq++) |
| 292 | irq_create_mapping(chip->g1_irq.domain, irq); |
| 293 | |
| 294 | chip->g1_irq.chip = mv88e6xxx_g1_irq_chip; |
| 295 | chip->g1_irq.masked = ~0; |
| 296 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 297 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 298 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 299 | goto out_mapping; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 300 | |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 301 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 302 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 303 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 304 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 305 | goto out_disable; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 306 | |
| 307 | /* Reading the interrupt status clears (most of) them */ |
Vivien Didelot | 8246692 | 2017-06-15 12:13:59 -0400 | [diff] [blame] | 308 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 309 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 310 | goto out_disable; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 311 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 312 | return 0; |
| 313 | |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 314 | out_disable: |
Andrew Lunn | 3d5fdba | 2017-12-07 01:05:56 +0100 | [diff] [blame] | 315 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 316 | mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 317 | |
| 318 | out_mapping: |
| 319 | for (irq = 0; irq < 16; irq++) { |
| 320 | virq = irq_find_mapping(chip->g1_irq.domain, irq); |
| 321 | irq_dispose_mapping(virq); |
| 322 | } |
| 323 | |
| 324 | irq_domain_remove(chip->g1_irq.domain); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 325 | |
| 326 | return err; |
| 327 | } |
| 328 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 329 | static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip) |
| 330 | { |
Andrew Lunn | f6d9758 | 2019-02-23 17:43:56 +0100 | [diff] [blame] | 331 | static struct lock_class_key lock_key; |
| 332 | static struct lock_class_key request_key; |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 333 | int err; |
| 334 | |
| 335 | err = mv88e6xxx_g1_irq_setup_common(chip); |
| 336 | if (err) |
| 337 | return err; |
| 338 | |
Andrew Lunn | f6d9758 | 2019-02-23 17:43:56 +0100 | [diff] [blame] | 339 | /* These lock classes tells lockdep that global 1 irqs are in |
| 340 | * a different category than their parent GPIO, so it won't |
| 341 | * report false recursion. |
| 342 | */ |
| 343 | irq_set_lockdep_class(chip->irq, &lock_key, &request_key); |
| 344 | |
Andrew Lunn | 3095383 | 2020-01-06 17:13:48 +0100 | [diff] [blame] | 345 | snprintf(chip->irq_name, sizeof(chip->irq_name), |
| 346 | "mv88e6xxx-%s", dev_name(chip->dev)); |
| 347 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 348 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 349 | err = request_threaded_irq(chip->irq, NULL, |
| 350 | mv88e6xxx_g1_irq_thread_fn, |
Marek Behún | 0340376 | 2018-08-30 02:13:50 +0200 | [diff] [blame] | 351 | IRQF_ONESHOT | IRQF_SHARED, |
Andrew Lunn | 3095383 | 2020-01-06 17:13:48 +0100 | [diff] [blame] | 352 | chip->irq_name, chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 353 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 354 | if (err) |
| 355 | mv88e6xxx_g1_irq_free_common(chip); |
| 356 | |
| 357 | return err; |
| 358 | } |
| 359 | |
| 360 | static void mv88e6xxx_irq_poll(struct kthread_work *work) |
| 361 | { |
| 362 | struct mv88e6xxx_chip *chip = container_of(work, |
| 363 | struct mv88e6xxx_chip, |
| 364 | irq_poll_work.work); |
| 365 | mv88e6xxx_g1_irq_thread_work(chip); |
| 366 | |
| 367 | kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work, |
| 368 | msecs_to_jiffies(100)); |
| 369 | } |
| 370 | |
| 371 | static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip) |
| 372 | { |
| 373 | int err; |
| 374 | |
| 375 | err = mv88e6xxx_g1_irq_setup_common(chip); |
| 376 | if (err) |
| 377 | return err; |
| 378 | |
| 379 | kthread_init_delayed_work(&chip->irq_poll_work, |
| 380 | mv88e6xxx_irq_poll); |
| 381 | |
Florian Fainelli | 3f8b869 | 2019-02-21 20:09:27 -0800 | [diff] [blame] | 382 | chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev)); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 383 | if (IS_ERR(chip->kworker)) |
| 384 | return PTR_ERR(chip->kworker); |
| 385 | |
| 386 | kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work, |
| 387 | msecs_to_jiffies(100)); |
| 388 | |
| 389 | return 0; |
| 390 | } |
| 391 | |
| 392 | static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip) |
| 393 | { |
| 394 | kthread_cancel_delayed_work_sync(&chip->irq_poll_work); |
| 395 | kthread_destroy_worker(chip->kworker); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 396 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 397 | mv88e6xxx_reg_lock(chip); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 398 | mv88e6xxx_g1_irq_free_common(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 399 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 400 | } |
| 401 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 402 | static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip, |
| 403 | int port, phy_interface_t interface) |
| 404 | { |
| 405 | int err; |
| 406 | |
| 407 | if (chip->info->ops->port_set_rgmii_delay) { |
| 408 | err = chip->info->ops->port_set_rgmii_delay(chip, port, |
| 409 | interface); |
| 410 | if (err && err != -EOPNOTSUPP) |
| 411 | return err; |
| 412 | } |
| 413 | |
| 414 | if (chip->info->ops->port_set_cmode) { |
| 415 | err = chip->info->ops->port_set_cmode(chip, port, |
| 416 | interface); |
| 417 | if (err && err != -EOPNOTSUPP) |
| 418 | return err; |
| 419 | } |
| 420 | |
| 421 | return 0; |
| 422 | } |
| 423 | |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 424 | static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, |
| 425 | int link, int speed, int duplex, int pause, |
| 426 | phy_interface_t mode) |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 427 | { |
| 428 | int err; |
| 429 | |
| 430 | if (!chip->info->ops->port_set_link) |
| 431 | return 0; |
| 432 | |
| 433 | /* Port's MAC control must not be changed unless the link is down */ |
Hubert Feurstein | 43c8e0a | 2019-07-30 12:11:42 +0200 | [diff] [blame] | 434 | err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 435 | if (err) |
| 436 | return err; |
| 437 | |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 438 | if (chip->info->ops->port_set_speed_duplex) { |
| 439 | err = chip->info->ops->port_set_speed_duplex(chip, port, |
| 440 | speed, duplex); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 441 | if (err && err != -EOPNOTSUPP) |
| 442 | goto restore_link; |
| 443 | } |
| 444 | |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 445 | if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode) |
| 446 | mode = chip->info->ops->port_max_speed_mode(port); |
| 447 | |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 448 | if (chip->info->ops->port_set_pause) { |
| 449 | err = chip->info->ops->port_set_pause(chip, port, pause); |
| 450 | if (err) |
| 451 | goto restore_link; |
| 452 | } |
| 453 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 454 | err = mv88e6xxx_port_config_interface(chip, port, mode); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 455 | restore_link: |
| 456 | if (chip->info->ops->port_set_link(chip, port, link)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 457 | dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 458 | |
| 459 | return err; |
| 460 | } |
| 461 | |
Marek Vasut | d700ec4 | 2018-09-12 00:15:24 +0200 | [diff] [blame] | 462 | static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port) |
| 463 | { |
| 464 | struct mv88e6xxx_chip *chip = ds->priv; |
| 465 | |
| 466 | return port < chip->info->num_internal_phys; |
| 467 | } |
| 468 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 469 | static int mv88e6xxx_port_ppu_updates(struct mv88e6xxx_chip *chip, int port) |
| 470 | { |
| 471 | u16 reg; |
| 472 | int err; |
| 473 | |
Russell King (Oracle) | 2b29cb9 | 2021-12-07 10:32:43 +0000 | [diff] [blame] | 474 | /* The 88e6250 family does not have the PHY detect bit. Instead, |
| 475 | * report whether the port is internal. |
| 476 | */ |
| 477 | if (chip->info->family == MV88E6XXX_FAMILY_6250) |
| 478 | return port < chip->info->num_internal_phys; |
| 479 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 480 | err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, ®); |
| 481 | if (err) { |
| 482 | dev_err(chip->dev, |
| 483 | "p%d: %s: failed to read port status\n", |
| 484 | port, __func__); |
| 485 | return err; |
| 486 | } |
| 487 | |
| 488 | return !!(reg & MV88E6XXX_PORT_STS_PHY_DETECT); |
| 489 | } |
| 490 | |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 491 | static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port, |
| 492 | struct phylink_link_state *state) |
| 493 | { |
| 494 | struct mv88e6xxx_chip *chip = ds->priv; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 495 | int lane; |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 496 | int err; |
| 497 | |
| 498 | mv88e6xxx_reg_lock(chip); |
| 499 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 500 | if (lane >= 0 && chip->info->ops->serdes_pcs_get_state) |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 501 | err = chip->info->ops->serdes_pcs_get_state(chip, port, lane, |
| 502 | state); |
| 503 | else |
| 504 | err = -EOPNOTSUPP; |
| 505 | mv88e6xxx_reg_unlock(chip); |
| 506 | |
| 507 | return err; |
| 508 | } |
| 509 | |
| 510 | static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port, |
| 511 | unsigned int mode, |
| 512 | phy_interface_t interface, |
| 513 | const unsigned long *advertise) |
| 514 | { |
| 515 | const struct mv88e6xxx_ops *ops = chip->info->ops; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 516 | int lane; |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 517 | |
| 518 | if (ops->serdes_pcs_config) { |
| 519 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 520 | if (lane >= 0) |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 521 | return ops->serdes_pcs_config(chip, port, lane, mode, |
| 522 | interface, advertise); |
| 523 | } |
| 524 | |
| 525 | return 0; |
| 526 | } |
| 527 | |
| 528 | static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port) |
| 529 | { |
| 530 | struct mv88e6xxx_chip *chip = ds->priv; |
| 531 | const struct mv88e6xxx_ops *ops; |
| 532 | int err = 0; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 533 | int lane; |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 534 | |
| 535 | ops = chip->info->ops; |
| 536 | |
| 537 | if (ops->serdes_pcs_an_restart) { |
| 538 | mv88e6xxx_reg_lock(chip); |
| 539 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 540 | if (lane >= 0) |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 541 | err = ops->serdes_pcs_an_restart(chip, port, lane); |
| 542 | mv88e6xxx_reg_unlock(chip); |
| 543 | |
| 544 | if (err) |
| 545 | dev_err(ds->dev, "p%d: failed to restart AN\n", port); |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port, |
| 550 | unsigned int mode, |
| 551 | int speed, int duplex) |
| 552 | { |
| 553 | const struct mv88e6xxx_ops *ops = chip->info->ops; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 554 | int lane; |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 555 | |
| 556 | if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) { |
| 557 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 558 | if (lane >= 0) |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 559 | return ops->serdes_pcs_link_up(chip, port, lane, |
| 560 | speed, duplex); |
| 561 | } |
| 562 | |
| 563 | return 0; |
| 564 | } |
| 565 | |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 566 | static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 567 | unsigned long *mask, |
| 568 | struct phylink_link_state *state) |
| 569 | { |
| 570 | if (!phy_interface_mode_is_8023z(state->interface)) { |
| 571 | /* 10M and 100M are only supported in non-802.3z mode */ |
| 572 | phylink_set(mask, 10baseT_Half); |
| 573 | phylink_set(mask, 10baseT_Full); |
| 574 | phylink_set(mask, 100baseT_Half); |
| 575 | phylink_set(mask, 100baseT_Full); |
| 576 | } |
| 577 | } |
| 578 | |
| 579 | static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 580 | unsigned long *mask, |
| 581 | struct phylink_link_state *state) |
| 582 | { |
| 583 | /* FIXME: if the port is in 1000Base-X mode, then it only supports |
| 584 | * 1000M FD speeds. In this case, CMODE will indicate 5. |
| 585 | */ |
| 586 | phylink_set(mask, 1000baseT_Full); |
| 587 | phylink_set(mask, 1000baseX_Full); |
| 588 | |
| 589 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 590 | } |
| 591 | |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 592 | static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 593 | unsigned long *mask, |
| 594 | struct phylink_link_state *state) |
| 595 | { |
| 596 | if (port >= 5) |
| 597 | phylink_set(mask, 2500baseX_Full); |
| 598 | |
| 599 | /* No ethtool bits for 200Mbps */ |
| 600 | phylink_set(mask, 1000baseT_Full); |
| 601 | phylink_set(mask, 1000baseX_Full); |
| 602 | |
| 603 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 604 | } |
| 605 | |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 606 | static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 607 | unsigned long *mask, |
| 608 | struct phylink_link_state *state) |
| 609 | { |
| 610 | /* No ethtool bits for 200Mbps */ |
| 611 | phylink_set(mask, 1000baseT_Full); |
| 612 | phylink_set(mask, 1000baseX_Full); |
| 613 | |
| 614 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 615 | } |
| 616 | |
| 617 | static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 618 | unsigned long *mask, |
| 619 | struct phylink_link_state *state) |
| 620 | { |
Andrew Lunn | ec26016 | 2019-02-08 22:25:44 +0100 | [diff] [blame] | 621 | if (port >= 9) { |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 622 | phylink_set(mask, 2500baseX_Full); |
Andrew Lunn | ec26016 | 2019-02-08 22:25:44 +0100 | [diff] [blame] | 623 | phylink_set(mask, 2500baseT_Full); |
| 624 | } |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 625 | |
| 626 | /* No ethtool bits for 200Mbps */ |
| 627 | phylink_set(mask, 1000baseT_Full); |
| 628 | phylink_set(mask, 1000baseX_Full); |
| 629 | |
| 630 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 631 | } |
| 632 | |
| 633 | static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 634 | unsigned long *mask, |
| 635 | struct phylink_link_state *state) |
| 636 | { |
| 637 | if (port >= 9) { |
| 638 | phylink_set(mask, 10000baseT_Full); |
| 639 | phylink_set(mask, 10000baseKR_Full); |
| 640 | } |
| 641 | |
| 642 | mv88e6390_phylink_validate(chip, port, mask, state); |
| 643 | } |
| 644 | |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 645 | static void mv88e6393x_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 646 | unsigned long *mask, |
| 647 | struct phylink_link_state *state) |
| 648 | { |
Marek Behún | dc2fc9f | 2021-11-04 18:17:47 +0100 | [diff] [blame] | 649 | bool is_6191x = |
| 650 | chip->info->prod_num == MV88E6XXX_PORT_SWITCH_ID_PROD_6191X; |
| 651 | |
| 652 | if (((port == 0 || port == 9) && !is_6191x) || port == 10) { |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 653 | phylink_set(mask, 10000baseT_Full); |
| 654 | phylink_set(mask, 10000baseKR_Full); |
| 655 | phylink_set(mask, 10000baseCR_Full); |
| 656 | phylink_set(mask, 10000baseSR_Full); |
| 657 | phylink_set(mask, 10000baseLR_Full); |
| 658 | phylink_set(mask, 10000baseLRM_Full); |
| 659 | phylink_set(mask, 10000baseER_Full); |
| 660 | phylink_set(mask, 5000baseT_Full); |
| 661 | phylink_set(mask, 2500baseX_Full); |
| 662 | phylink_set(mask, 2500baseT_Full); |
| 663 | } |
| 664 | |
| 665 | phylink_set(mask, 1000baseT_Full); |
| 666 | phylink_set(mask, 1000baseX_Full); |
| 667 | |
| 668 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 669 | } |
| 670 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 671 | static void mv88e6xxx_validate(struct dsa_switch *ds, int port, |
| 672 | unsigned long *supported, |
| 673 | struct phylink_link_state *state) |
| 674 | { |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 675 | __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; |
| 676 | struct mv88e6xxx_chip *chip = ds->priv; |
| 677 | |
| 678 | /* Allow all the expected bits */ |
| 679 | phylink_set(mask, Autoneg); |
| 680 | phylink_set(mask, Pause); |
| 681 | phylink_set_port_modes(mask); |
| 682 | |
| 683 | if (chip->info->ops->phylink_validate) |
| 684 | chip->info->ops->phylink_validate(chip, port, mask, state); |
| 685 | |
Sean Anderson | 4973056 | 2021-10-22 18:41:04 -0400 | [diff] [blame] | 686 | linkmode_and(supported, supported, mask); |
| 687 | linkmode_and(state->advertising, state->advertising, mask); |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 688 | |
| 689 | /* We can only operate at 2500BaseX or 1000BaseX. If requested |
| 690 | * to advertise both, only report advertising at 2500BaseX. |
| 691 | */ |
| 692 | phylink_helper_basex_speed(state); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 693 | } |
| 694 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 695 | static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port, |
| 696 | unsigned int mode, |
| 697 | const struct phylink_link_state *state) |
| 698 | { |
| 699 | struct mv88e6xxx_chip *chip = ds->priv; |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 700 | struct mv88e6xxx_port *p; |
Russell King (Oracle) | 04ec4e6 | 2021-12-09 09:26:47 +0000 | [diff] [blame] | 701 | int err = 0; |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 702 | |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 703 | p = &chip->ports[port]; |
| 704 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 705 | mv88e6xxx_reg_lock(chip); |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 706 | |
Russell King (Oracle) | 04ec4e6 | 2021-12-09 09:26:47 +0000 | [diff] [blame] | 707 | if (mode != MLO_AN_PHY || !mv88e6xxx_phy_is_internal(ds, port)) { |
| 708 | /* In inband mode, the link may come up at any time while the |
| 709 | * link is not forced down. Force the link down while we |
| 710 | * reconfigure the interface mode. |
| 711 | */ |
| 712 | if (mode == MLO_AN_INBAND && |
| 713 | p->interface != state->interface && |
| 714 | chip->info->ops->port_set_link) |
| 715 | chip->info->ops->port_set_link(chip, port, |
| 716 | LINK_FORCED_DOWN); |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 717 | |
Russell King (Oracle) | 04ec4e6 | 2021-12-09 09:26:47 +0000 | [diff] [blame] | 718 | err = mv88e6xxx_port_config_interface(chip, port, |
| 719 | state->interface); |
| 720 | if (err && err != -EOPNOTSUPP) |
| 721 | goto err_unlock; |
| 722 | |
| 723 | err = mv88e6xxx_serdes_pcs_config(chip, port, mode, |
| 724 | state->interface, |
| 725 | state->advertising); |
| 726 | /* FIXME: we should restart negotiation if something changed - |
| 727 | * which is something we get if we convert to using phylinks |
| 728 | * PCS operations. |
| 729 | */ |
| 730 | if (err > 0) |
| 731 | err = 0; |
| 732 | } |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 733 | |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 734 | /* Undo the forced down state above after completing configuration |
Russell King (Oracle) | 04ec4e6 | 2021-12-09 09:26:47 +0000 | [diff] [blame] | 735 | * irrespective of its state on entry, which allows the link to come |
| 736 | * up in the in-band case where there is no separate SERDES. Also |
| 737 | * ensure that the link can come up if the PPU is in use and we are |
| 738 | * in PHY mode (we treat the PPU as an effective in-band mechanism.) |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 739 | */ |
Russell King (Oracle) | 04ec4e6 | 2021-12-09 09:26:47 +0000 | [diff] [blame] | 740 | if (chip->info->ops->port_set_link && |
| 741 | ((mode == MLO_AN_INBAND && p->interface != state->interface) || |
| 742 | (mode == MLO_AN_PHY && mv88e6xxx_port_ppu_updates(chip, port)))) |
Russell King | fad5819 | 2020-07-19 12:00:35 +0100 | [diff] [blame] | 743 | chip->info->ops->port_set_link(chip, port, LINK_UNFORCED); |
| 744 | |
| 745 | p->interface = state->interface; |
| 746 | |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 747 | err_unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 748 | mv88e6xxx_reg_unlock(chip); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 749 | |
| 750 | if (err && err != -EOPNOTSUPP) |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 751 | 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] | 752 | } |
| 753 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 754 | static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port, |
| 755 | unsigned int mode, |
| 756 | phy_interface_t interface) |
| 757 | { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 758 | struct mv88e6xxx_chip *chip = ds->priv; |
| 759 | const struct mv88e6xxx_ops *ops; |
| 760 | int err = 0; |
| 761 | |
| 762 | ops = chip->info->ops; |
| 763 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 764 | mv88e6xxx_reg_lock(chip); |
Russell King (Oracle) | 2b29cb9 | 2021-12-07 10:32:43 +0000 | [diff] [blame] | 765 | /* Force the link down if we know the port may not be automatically |
| 766 | * updated by the switch or if we are using fixed-link mode. |
Maarten Zanders | 4a3e0ae | 2021-10-11 16:27:20 +0200 | [diff] [blame] | 767 | */ |
Russell King (Oracle) | 2b29cb9 | 2021-12-07 10:32:43 +0000 | [diff] [blame] | 768 | if ((!mv88e6xxx_port_ppu_updates(chip, port) || |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 769 | mode == MLO_AN_FIXED) && ops->port_sync_link) |
| 770 | err = ops->port_sync_link(chip, port, mode, false); |
Marek Behún | 9d591fc | 2021-12-11 23:51:41 +0100 | [diff] [blame] | 771 | |
| 772 | if (!err && ops->port_set_speed_duplex) |
| 773 | err = ops->port_set_speed_duplex(chip, port, SPEED_UNFORCED, |
| 774 | DUPLEX_UNFORCED); |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 775 | mv88e6xxx_reg_unlock(chip); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 776 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 777 | if (err) |
| 778 | dev_err(chip->dev, |
| 779 | "p%d: failed to force MAC link down\n", port); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 780 | } |
| 781 | |
| 782 | static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port, |
| 783 | unsigned int mode, phy_interface_t interface, |
Russell King | 5b502a7 | 2020-02-26 10:23:46 +0000 | [diff] [blame] | 784 | struct phy_device *phydev, |
| 785 | int speed, int duplex, |
| 786 | bool tx_pause, bool rx_pause) |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 787 | { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 788 | struct mv88e6xxx_chip *chip = ds->priv; |
| 789 | const struct mv88e6xxx_ops *ops; |
| 790 | int err = 0; |
| 791 | |
| 792 | ops = chip->info->ops; |
| 793 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 794 | mv88e6xxx_reg_lock(chip); |
Russell King (Oracle) | 2b29cb9 | 2021-12-07 10:32:43 +0000 | [diff] [blame] | 795 | /* Configure and force the link up if we know that the port may not |
| 796 | * automatically updated by the switch or if we are using fixed-link |
| 797 | * mode. |
Maarten Zanders | 4a3e0ae | 2021-10-11 16:27:20 +0200 | [diff] [blame] | 798 | */ |
Russell King (Oracle) | 2b29cb9 | 2021-12-07 10:32:43 +0000 | [diff] [blame] | 799 | if (!mv88e6xxx_port_ppu_updates(chip, port) || |
Maarten Zanders | 4a3e0ae | 2021-10-11 16:27:20 +0200 | [diff] [blame] | 800 | mode == MLO_AN_FIXED) { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 801 | /* FIXME: for an automedia port, should we force the link |
| 802 | * down here - what if the link comes up due to "other" media |
| 803 | * while we're bringing the port up, how is the exclusivity |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 804 | * handled in the Marvell hardware? E.g. port 2 on 88E6390 |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 805 | * shared between internal PHY and Serdes. |
| 806 | */ |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 807 | err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed, |
| 808 | duplex); |
| 809 | if (err) |
| 810 | goto error; |
| 811 | |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 812 | if (ops->port_set_speed_duplex) { |
| 813 | err = ops->port_set_speed_duplex(chip, port, |
| 814 | speed, duplex); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 815 | if (err && err != -EOPNOTSUPP) |
| 816 | goto error; |
| 817 | } |
| 818 | |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 819 | if (ops->port_sync_link) |
| 820 | err = ops->port_sync_link(chip, port, mode, true); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 821 | } |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame] | 822 | error: |
| 823 | mv88e6xxx_reg_unlock(chip); |
| 824 | |
| 825 | if (err && err != -EOPNOTSUPP) |
| 826 | dev_err(ds->dev, |
| 827 | "p%d: failed to configure MAC link up\n", port); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 828 | } |
| 829 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 830 | static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 831 | { |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 832 | if (!chip->info->ops->stats_snapshot) |
| 833 | return -EOPNOTSUPP; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 834 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 835 | return chip->info->ops->stats_snapshot(chip, port); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 836 | } |
| 837 | |
Andrew Lunn | e413e7e | 2015-04-02 04:06:38 +0200 | [diff] [blame] | 838 | static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = { |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 839 | { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, }, |
| 840 | { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, }, |
| 841 | { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, }, |
| 842 | { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, }, |
| 843 | { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, }, |
| 844 | { "in_pause", 4, 0x16, STATS_TYPE_BANK0, }, |
| 845 | { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, }, |
| 846 | { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, }, |
| 847 | { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, }, |
| 848 | { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, }, |
| 849 | { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, }, |
| 850 | { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, }, |
| 851 | { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, }, |
| 852 | { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, }, |
| 853 | { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, }, |
| 854 | { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, }, |
| 855 | { "out_pause", 4, 0x15, STATS_TYPE_BANK0, }, |
| 856 | { "excessive", 4, 0x11, STATS_TYPE_BANK0, }, |
| 857 | { "collisions", 4, 0x1e, STATS_TYPE_BANK0, }, |
| 858 | { "deferred", 4, 0x05, STATS_TYPE_BANK0, }, |
| 859 | { "single", 4, 0x14, STATS_TYPE_BANK0, }, |
| 860 | { "multiple", 4, 0x17, STATS_TYPE_BANK0, }, |
| 861 | { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, }, |
| 862 | { "late", 4, 0x1f, STATS_TYPE_BANK0, }, |
| 863 | { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, }, |
| 864 | { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, }, |
| 865 | { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, }, |
| 866 | { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, }, |
| 867 | { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, }, |
| 868 | { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, }, |
| 869 | { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, }, |
| 870 | { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, }, |
| 871 | { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, }, |
| 872 | { "in_discards", 4, 0x00, STATS_TYPE_BANK1, }, |
| 873 | { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, }, |
| 874 | { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, }, |
| 875 | { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, }, |
| 876 | { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, }, |
| 877 | { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, }, |
| 878 | { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, }, |
| 879 | { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, }, |
| 880 | { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, }, |
| 881 | { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, }, |
| 882 | { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, }, |
| 883 | { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, }, |
| 884 | { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, }, |
| 885 | { "in_management", 4, 0x0f, STATS_TYPE_BANK1, }, |
| 886 | { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, }, |
| 887 | { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, }, |
| 888 | { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, }, |
| 889 | { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, }, |
| 890 | { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, }, |
| 891 | { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, }, |
| 892 | { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, }, |
| 893 | { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, }, |
| 894 | { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, }, |
| 895 | { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, }, |
| 896 | { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, }, |
| 897 | { "out_management", 4, 0x1f, STATS_TYPE_BANK1, }, |
Andrew Lunn | e413e7e | 2015-04-02 04:06:38 +0200 | [diff] [blame] | 898 | }; |
| 899 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 900 | static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip, |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 901 | struct mv88e6xxx_hw_stat *s, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 902 | int port, u16 bank1_select, |
| 903 | u16 histogram) |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 904 | { |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 905 | u32 low; |
| 906 | u32 high = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 907 | u16 reg = 0; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 908 | int err; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 909 | u64 value; |
| 910 | |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 911 | switch (s->type) { |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 912 | case STATS_TYPE_PORT: |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 913 | err = mv88e6xxx_port_read(chip, port, s->reg, ®); |
| 914 | if (err) |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 915 | return U64_MAX; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 916 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 917 | low = reg; |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 918 | if (s->size == 4) { |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 919 | err = mv88e6xxx_port_read(chip, port, s->reg + 1, ®); |
| 920 | if (err) |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 921 | return U64_MAX; |
Rasmus Villemoes | 84b3fd1 | 2019-05-29 07:02:11 +0000 | [diff] [blame] | 922 | low |= ((u32)reg) << 16; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 923 | } |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 924 | break; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 925 | case STATS_TYPE_BANK1: |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 926 | reg = bank1_select; |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 927 | fallthrough; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 928 | case STATS_TYPE_BANK0: |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 929 | reg |= s->reg | histogram; |
Andrew Lunn | 7f9ef3a | 2016-11-21 23:27:05 +0100 | [diff] [blame] | 930 | mv88e6xxx_g1_stats_read(chip, reg, &low); |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 931 | if (s->size == 8) |
Andrew Lunn | 7f9ef3a | 2016-11-21 23:27:05 +0100 | [diff] [blame] | 932 | mv88e6xxx_g1_stats_read(chip, reg + 1, &high); |
Gustavo A. R. Silva | 9fc3e4d | 2017-05-11 22:11:29 -0500 | [diff] [blame] | 933 | break; |
| 934 | default: |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 935 | return U64_MAX; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 936 | } |
Andrew Lunn | 6e46e2d | 2019-02-28 18:14:03 +0100 | [diff] [blame] | 937 | value = (((u64)high) << 32) | low; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 938 | return value; |
| 939 | } |
| 940 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 941 | static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 942 | uint8_t *data, int types) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 943 | { |
| 944 | struct mv88e6xxx_hw_stat *stat; |
| 945 | int i, j; |
| 946 | |
| 947 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 948 | stat = &mv88e6xxx_hw_stats[i]; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 949 | if (stat->type & types) { |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 950 | memcpy(data + j * ETH_GSTRING_LEN, stat->string, |
| 951 | ETH_GSTRING_LEN); |
| 952 | j++; |
| 953 | } |
| 954 | } |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 955 | |
| 956 | return j; |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 957 | } |
| 958 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 959 | static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 960 | uint8_t *data) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 961 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 962 | return mv88e6xxx_stats_get_strings(chip, data, |
| 963 | STATS_TYPE_BANK0 | STATS_TYPE_PORT); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 964 | } |
| 965 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 966 | static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 967 | uint8_t *data) |
| 968 | { |
| 969 | return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0); |
| 970 | } |
| 971 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 972 | static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 973 | uint8_t *data) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 974 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 975 | return mv88e6xxx_stats_get_strings(chip, data, |
| 976 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 977 | } |
| 978 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 979 | static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = { |
| 980 | "atu_member_violation", |
| 981 | "atu_miss_violation", |
| 982 | "atu_full_violation", |
| 983 | "vtu_member_violation", |
| 984 | "vtu_miss_violation", |
| 985 | }; |
| 986 | |
| 987 | static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data) |
| 988 | { |
| 989 | unsigned int i; |
| 990 | |
| 991 | for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++) |
| 992 | strlcpy(data + i * ETH_GSTRING_LEN, |
| 993 | mv88e6xxx_atu_vtu_stats_strings[i], |
| 994 | ETH_GSTRING_LEN); |
| 995 | } |
| 996 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 997 | static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port, |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 998 | u32 stringset, uint8_t *data) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 999 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1000 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1001 | int count = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1002 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 1003 | if (stringset != ETH_SS_STATS) |
| 1004 | return; |
| 1005 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1006 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 1007 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1008 | if (chip->info->ops->stats_get_strings) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1009 | count = chip->info->ops->stats_get_strings(chip, data); |
| 1010 | |
| 1011 | if (chip->info->ops->serdes_get_strings) { |
| 1012 | data += count * ETH_GSTRING_LEN; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1013 | count = chip->info->ops->serdes_get_strings(chip, port, data); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1014 | } |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 1015 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1016 | data += count * ETH_GSTRING_LEN; |
| 1017 | mv88e6xxx_atu_vtu_get_strings(data); |
| 1018 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1019 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1020 | } |
| 1021 | |
| 1022 | static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip, |
| 1023 | int types) |
| 1024 | { |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 1025 | struct mv88e6xxx_hw_stat *stat; |
| 1026 | int i, j; |
| 1027 | |
| 1028 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 1029 | stat = &mv88e6xxx_hw_stats[i]; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1030 | if (stat->type & types) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 1031 | j++; |
| 1032 | } |
| 1033 | return j; |
| 1034 | } |
| 1035 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1036 | static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 1037 | { |
| 1038 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 | |
| 1039 | STATS_TYPE_PORT); |
| 1040 | } |
| 1041 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 1042 | static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 1043 | { |
| 1044 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0); |
| 1045 | } |
| 1046 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1047 | static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 1048 | { |
| 1049 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 | |
| 1050 | STATS_TYPE_BANK1); |
| 1051 | } |
| 1052 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 1053 | 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] | 1054 | { |
| 1055 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1056 | int serdes_count = 0; |
| 1057 | int count = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1058 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 1059 | if (sset != ETH_SS_STATS) |
| 1060 | return 0; |
| 1061 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1062 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1063 | if (chip->info->ops->stats_get_sset_count) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1064 | count = chip->info->ops->stats_get_sset_count(chip); |
| 1065 | if (count < 0) |
| 1066 | goto out; |
| 1067 | |
| 1068 | if (chip->info->ops->serdes_get_sset_count) |
| 1069 | serdes_count = chip->info->ops->serdes_get_sset_count(chip, |
| 1070 | port); |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1071 | if (serdes_count < 0) { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1072 | count = serdes_count; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1073 | goto out; |
| 1074 | } |
| 1075 | count += serdes_count; |
| 1076 | count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); |
| 1077 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1078 | out: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1079 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1080 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1081 | return count; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1082 | } |
| 1083 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1084 | static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1085 | uint64_t *data, int types, |
| 1086 | u16 bank1_select, u16 histogram) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1087 | { |
| 1088 | struct mv88e6xxx_hw_stat *stat; |
| 1089 | int i, j; |
| 1090 | |
| 1091 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 1092 | stat = &mv88e6xxx_hw_stats[i]; |
| 1093 | if (stat->type & types) { |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1094 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1095 | data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port, |
| 1096 | bank1_select, |
| 1097 | histogram); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1098 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 1099 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1100 | j++; |
| 1101 | } |
| 1102 | } |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1103 | return j; |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1104 | } |
| 1105 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1106 | static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1107 | uint64_t *data) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1108 | { |
| 1109 | return mv88e6xxx_stats_get_stats(chip, port, data, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1110 | STATS_TYPE_BANK0 | STATS_TYPE_PORT, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1111 | 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1112 | } |
| 1113 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 1114 | static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1115 | uint64_t *data) |
| 1116 | { |
| 1117 | return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0, |
| 1118 | 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
| 1119 | } |
| 1120 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1121 | static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1122 | uint64_t *data) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1123 | { |
| 1124 | return mv88e6xxx_stats_get_stats(chip, port, data, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1125 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1126 | MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9, |
| 1127 | MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1128 | } |
| 1129 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1130 | static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1131 | uint64_t *data) |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1132 | { |
| 1133 | return mv88e6xxx_stats_get_stats(chip, port, data, |
| 1134 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1135 | MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10, |
| 1136 | 0); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1137 | } |
| 1138 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1139 | static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1140 | uint64_t *data) |
| 1141 | { |
| 1142 | *data++ = chip->ports[port].atu_member_violation; |
| 1143 | *data++ = chip->ports[port].atu_miss_violation; |
| 1144 | *data++ = chip->ports[port].atu_full_violation; |
| 1145 | *data++ = chip->ports[port].vtu_member_violation; |
| 1146 | *data++ = chip->ports[port].vtu_miss_violation; |
| 1147 | } |
| 1148 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1149 | static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1150 | uint64_t *data) |
| 1151 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1152 | int count = 0; |
| 1153 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1154 | if (chip->info->ops->stats_get_stats) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1155 | count = chip->info->ops->stats_get_stats(chip, port, data); |
| 1156 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1157 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1158 | if (chip->info->ops->serdes_get_stats) { |
| 1159 | data += count; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1160 | count = chip->info->ops->serdes_get_stats(chip, port, data); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1161 | } |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1162 | data += count; |
| 1163 | mv88e6xxx_atu_vtu_get_stats(chip, port, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1164 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1165 | } |
| 1166 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1167 | static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port, |
| 1168 | uint64_t *data) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1169 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1170 | struct mv88e6xxx_chip *chip = ds->priv; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1171 | int ret; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1172 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1173 | mv88e6xxx_reg_lock(chip); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1174 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 1175 | ret = mv88e6xxx_stats_snapshot(chip, port); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1176 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 1177 | |
| 1178 | if (ret < 0) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1179 | return; |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1180 | |
| 1181 | mv88e6xxx_get_stats(chip, port, data); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1182 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1183 | } |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 1184 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1185 | static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port) |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1186 | { |
Andrew Lunn | 0d30bbd | 2020-02-16 18:54:13 +0100 | [diff] [blame] | 1187 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1188 | int len; |
| 1189 | |
| 1190 | len = 32 * sizeof(u16); |
| 1191 | if (chip->info->ops->serdes_get_regs_len) |
| 1192 | len += chip->info->ops->serdes_get_regs_len(chip, port); |
| 1193 | |
| 1194 | return len; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1195 | } |
| 1196 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1197 | static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port, |
| 1198 | struct ethtool_regs *regs, void *_p) |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1199 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1200 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1201 | int err; |
| 1202 | u16 reg; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1203 | u16 *p = _p; |
| 1204 | int i; |
| 1205 | |
Vivien Didelot | a5f3932 | 2018-12-17 16:05:21 -0500 | [diff] [blame] | 1206 | regs->version = chip->info->prod_num; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1207 | |
| 1208 | memset(p, 0xff, 32 * sizeof(u16)); |
| 1209 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1210 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 2306251 | 2016-05-09 13:22:45 -0400 | [diff] [blame] | 1211 | |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1212 | for (i = 0; i < 32; i++) { |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1213 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1214 | err = mv88e6xxx_port_read(chip, port, i, ®); |
| 1215 | if (!err) |
| 1216 | p[i] = reg; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1217 | } |
Vivien Didelot | 2306251 | 2016-05-09 13:22:45 -0400 | [diff] [blame] | 1218 | |
Andrew Lunn | 0d30bbd | 2020-02-16 18:54:13 +0100 | [diff] [blame] | 1219 | if (chip->info->ops->serdes_get_regs) |
| 1220 | chip->info->ops->serdes_get_regs(chip, port, &p[i]); |
| 1221 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1222 | mv88e6xxx_reg_unlock(chip); |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1223 | } |
| 1224 | |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 1225 | static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port, |
| 1226 | struct ethtool_eee *e) |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1227 | { |
Vivien Didelot | 5480db6 | 2017-08-01 16:32:40 -0400 | [diff] [blame] | 1228 | /* Nothing to do on the port's MAC */ |
| 1229 | return 0; |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1230 | } |
| 1231 | |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 1232 | static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port, |
| 1233 | struct ethtool_eee *e) |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1234 | { |
Vivien Didelot | 5480db6 | 2017-08-01 16:32:40 -0400 | [diff] [blame] | 1235 | /* Nothing to do on the port's MAC */ |
| 1236 | return 0; |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1237 | } |
| 1238 | |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1239 | /* 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] | 1240 | 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] | 1241 | { |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1242 | struct dsa_switch *ds = chip->ds; |
| 1243 | struct dsa_switch_tree *dst = ds->dst; |
Vladimir Oltean | 6514406 | 2021-12-06 18:57:51 +0200 | [diff] [blame] | 1244 | struct dsa_port *dp, *other_dp; |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1245 | bool found = false; |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1246 | u16 pvlan; |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1247 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1248 | /* dev is a physical switch */ |
| 1249 | if (dev <= dst->last_switch) { |
| 1250 | list_for_each_entry(dp, &dst->ports, list) { |
| 1251 | if (dp->ds->index == dev && dp->index == port) { |
| 1252 | /* dp might be a DSA link or a user port, so it |
Vladimir Oltean | 6514406 | 2021-12-06 18:57:51 +0200 | [diff] [blame] | 1253 | * might or might not have a bridge. |
| 1254 | * Use the "found" variable for both cases. |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1255 | */ |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1256 | found = true; |
| 1257 | break; |
| 1258 | } |
| 1259 | } |
| 1260 | /* dev is a virtual bridge */ |
| 1261 | } else { |
| 1262 | list_for_each_entry(dp, &dst->ports, list) { |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1263 | unsigned int bridge_num = dsa_port_bridge_num_get(dp); |
| 1264 | |
| 1265 | if (!bridge_num) |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1266 | continue; |
| 1267 | |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1268 | if (bridge_num + dst->last_switch != dev) |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1269 | continue; |
| 1270 | |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1271 | found = true; |
| 1272 | break; |
| 1273 | } |
| 1274 | } |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1275 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 1276 | /* Prevent frames from unknown switch or virtual bridge */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1277 | if (!found) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1278 | return 0; |
| 1279 | |
| 1280 | /* Frames from DSA links and CPU ports can egress any local port */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1281 | 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] | 1282 | return mv88e6xxx_port_mask(chip); |
| 1283 | |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1284 | pvlan = 0; |
| 1285 | |
| 1286 | /* Frames from user ports can egress any local DSA links and CPU ports, |
| 1287 | * as well as any local member of their bridge group. |
| 1288 | */ |
Vladimir Oltean | 6514406 | 2021-12-06 18:57:51 +0200 | [diff] [blame] | 1289 | dsa_switch_for_each_port(other_dp, ds) |
| 1290 | if (other_dp->type == DSA_PORT_TYPE_CPU || |
| 1291 | other_dp->type == DSA_PORT_TYPE_DSA || |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1292 | dsa_port_bridge_same(dp, other_dp)) |
Vladimir Oltean | 6514406 | 2021-12-06 18:57:51 +0200 | [diff] [blame] | 1293 | pvlan |= BIT(other_dp->index); |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1294 | |
| 1295 | return pvlan; |
| 1296 | } |
| 1297 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 1298 | static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1299 | { |
| 1300 | u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port); |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1301 | |
| 1302 | /* prevent frames from going back out of the port they came in on */ |
| 1303 | output_ports &= ~BIT(port); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1304 | |
Vivien Didelot | 5a7921f | 2016-11-04 03:23:28 +0100 | [diff] [blame] | 1305 | return mv88e6xxx_port_set_vlan_map(chip, port, output_ports); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1306 | } |
| 1307 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1308 | static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port, |
| 1309 | u8 state) |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1310 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1311 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 553eb54 | 2016-05-13 20:38:23 -0400 | [diff] [blame] | 1312 | int err; |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1313 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1314 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | f894c29 | 2017-06-08 18:34:10 -0400 | [diff] [blame] | 1315 | err = mv88e6xxx_port_set_state(chip, port, state); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1316 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 553eb54 | 2016-05-13 20:38:23 -0400 | [diff] [blame] | 1317 | |
| 1318 | if (err) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1319 | dev_err(ds->dev, "p%d: failed to update state\n", port); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1320 | } |
| 1321 | |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 1322 | static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip) |
| 1323 | { |
| 1324 | int err; |
| 1325 | |
| 1326 | if (chip->info->ops->ieee_pri_map) { |
| 1327 | err = chip->info->ops->ieee_pri_map(chip); |
| 1328 | if (err) |
| 1329 | return err; |
| 1330 | } |
| 1331 | |
| 1332 | if (chip->info->ops->ip_pri_map) { |
| 1333 | err = chip->info->ops->ip_pri_map(chip); |
| 1334 | if (err) |
| 1335 | return err; |
| 1336 | } |
| 1337 | |
| 1338 | return 0; |
| 1339 | } |
| 1340 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1341 | static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip) |
| 1342 | { |
Vivien Didelot | c5f5176 | 2019-10-30 22:09:13 -0400 | [diff] [blame] | 1343 | struct dsa_switch *ds = chip->ds; |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1344 | int target, port; |
| 1345 | int err; |
| 1346 | |
| 1347 | if (!chip->info->global2_addr) |
| 1348 | return 0; |
| 1349 | |
| 1350 | /* Initialize the routing port to the 32 possible target devices */ |
| 1351 | for (target = 0; target < 32; target++) { |
Vivien Didelot | c5f5176 | 2019-10-30 22:09:13 -0400 | [diff] [blame] | 1352 | port = dsa_routing_port(ds, target); |
| 1353 | if (port == ds->num_ports) |
| 1354 | port = 0x1f; |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1355 | |
| 1356 | err = mv88e6xxx_g2_device_mapping_write(chip, target, port); |
| 1357 | if (err) |
| 1358 | return err; |
| 1359 | } |
| 1360 | |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 1361 | if (chip->info->ops->set_cascade_port) { |
| 1362 | port = MV88E6XXX_CASCADE_PORT_MULTIPLE; |
| 1363 | err = chip->info->ops->set_cascade_port(chip, port); |
| 1364 | if (err) |
| 1365 | return err; |
| 1366 | } |
| 1367 | |
Vivien Didelot | 23c9891 | 2018-05-09 11:38:50 -0400 | [diff] [blame] | 1368 | err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index); |
| 1369 | if (err) |
| 1370 | return err; |
| 1371 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1372 | return 0; |
| 1373 | } |
| 1374 | |
Vivien Didelot | b28f872 | 2018-04-26 21:56:44 -0400 | [diff] [blame] | 1375 | static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip) |
| 1376 | { |
| 1377 | /* Clear all trunk masks and mapping */ |
| 1378 | if (chip->info->global2_addr) |
| 1379 | return mv88e6xxx_g2_trunk_clear(chip); |
| 1380 | |
| 1381 | return 0; |
| 1382 | } |
| 1383 | |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 1384 | static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip) |
| 1385 | { |
| 1386 | if (chip->info->ops->rmu_disable) |
| 1387 | return chip->info->ops->rmu_disable(chip); |
| 1388 | |
| 1389 | return 0; |
| 1390 | } |
| 1391 | |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 1392 | static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip) |
| 1393 | { |
| 1394 | if (chip->info->ops->pot_clear) |
| 1395 | return chip->info->ops->pot_clear(chip); |
| 1396 | |
| 1397 | return 0; |
| 1398 | } |
| 1399 | |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 1400 | static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip) |
| 1401 | { |
| 1402 | if (chip->info->ops->mgmt_rsvd2cpu) |
| 1403 | return chip->info->ops->mgmt_rsvd2cpu(chip); |
| 1404 | |
| 1405 | return 0; |
| 1406 | } |
| 1407 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 1408 | static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip) |
| 1409 | { |
Vivien Didelot | c3a7d4a | 2017-03-11 16:12:51 -0500 | [diff] [blame] | 1410 | int err; |
| 1411 | |
Vivien Didelot | daefc94 | 2017-03-11 16:12:54 -0500 | [diff] [blame] | 1412 | err = mv88e6xxx_g1_atu_flush(chip, 0, true); |
| 1413 | if (err) |
| 1414 | return err; |
| 1415 | |
Rasmus Villemoes | 49506a9 | 2020-12-10 12:06:44 +0100 | [diff] [blame] | 1416 | /* The chips that have a "learn2all" bit in Global1, ATU |
| 1417 | * Control are precisely those whose port registers have a |
| 1418 | * Message Port bit in Port Control 1 and hence implement |
| 1419 | * ->port_setup_message_port. |
| 1420 | */ |
| 1421 | if (chip->info->ops->port_setup_message_port) { |
| 1422 | err = mv88e6xxx_g1_atu_set_learn2all(chip, true); |
| 1423 | if (err) |
| 1424 | return err; |
| 1425 | } |
Vivien Didelot | c3a7d4a | 2017-03-11 16:12:51 -0500 | [diff] [blame] | 1426 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 1427 | return mv88e6xxx_g1_atu_set_age_time(chip, 300000); |
| 1428 | } |
| 1429 | |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 1430 | static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip) |
| 1431 | { |
| 1432 | int port; |
| 1433 | int err; |
| 1434 | |
| 1435 | if (!chip->info->ops->irl_init_all) |
| 1436 | return 0; |
| 1437 | |
| 1438 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 1439 | /* Disable ingress rate limiting by resetting all per port |
| 1440 | * ingress rate limit resources to their initial state. |
| 1441 | */ |
| 1442 | err = chip->info->ops->irl_init_all(chip, port); |
| 1443 | if (err) |
| 1444 | return err; |
| 1445 | } |
| 1446 | |
| 1447 | return 0; |
| 1448 | } |
| 1449 | |
Vivien Didelot | 04a69a1 | 2017-10-13 14:18:05 -0400 | [diff] [blame] | 1450 | static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip) |
| 1451 | { |
| 1452 | if (chip->info->ops->set_switch_mac) { |
| 1453 | u8 addr[ETH_ALEN]; |
| 1454 | |
| 1455 | eth_random_addr(addr); |
| 1456 | |
| 1457 | return chip->info->ops->set_switch_mac(chip, addr); |
| 1458 | } |
| 1459 | |
| 1460 | return 0; |
| 1461 | } |
| 1462 | |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1463 | static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port) |
| 1464 | { |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1465 | struct dsa_switch_tree *dst = chip->ds->dst; |
| 1466 | struct dsa_switch *ds; |
| 1467 | struct dsa_port *dp; |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1468 | u16 pvlan = 0; |
| 1469 | |
| 1470 | if (!mv88e6xxx_has_pvt(chip)) |
Vivien Didelot | d14939b | 2019-10-21 16:51:25 -0400 | [diff] [blame] | 1471 | return 0; |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1472 | |
| 1473 | /* Skip the local source device, which uses in-chip port VLAN */ |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1474 | if (dev != chip->ds->index) { |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 1475 | pvlan = mv88e6xxx_port_vlan(chip, dev, port); |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1476 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1477 | ds = dsa_switch_find(dst->index, dev); |
| 1478 | dp = ds ? dsa_to_port(ds, port) : NULL; |
| 1479 | if (dp && dp->lag_dev) { |
| 1480 | /* As the PVT is used to limit flooding of |
| 1481 | * FORWARD frames, which use the LAG ID as the |
| 1482 | * source port, we must translate dev/port to |
| 1483 | * the special "LAG device" in the PVT, using |
| 1484 | * the LAG ID as the port number. |
| 1485 | */ |
Tobias Waldekranz | 78e70db | 2021-04-21 14:04:52 +0200 | [diff] [blame] | 1486 | dev = MV88E6XXX_G2_PVT_ADDR_DEV_TRUNK; |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 1487 | port = dsa_lag_id(dst, dp->lag_dev); |
| 1488 | } |
| 1489 | } |
| 1490 | |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1491 | return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan); |
| 1492 | } |
| 1493 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1494 | static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip) |
| 1495 | { |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1496 | int dev, port; |
| 1497 | int err; |
| 1498 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1499 | if (!mv88e6xxx_has_pvt(chip)) |
| 1500 | return 0; |
| 1501 | |
| 1502 | /* Clear 5 Bit Port for usage with Marvell Link Street devices: |
| 1503 | * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev. |
| 1504 | */ |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1505 | err = mv88e6xxx_g2_misc_4_bit_port(chip); |
| 1506 | if (err) |
| 1507 | return err; |
| 1508 | |
| 1509 | for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) { |
| 1510 | for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) { |
| 1511 | err = mv88e6xxx_pvt_map(chip, dev, port); |
| 1512 | if (err) |
| 1513 | return err; |
| 1514 | } |
| 1515 | } |
| 1516 | |
| 1517 | return 0; |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1518 | } |
| 1519 | |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1520 | static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port) |
| 1521 | { |
| 1522 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1523 | int err; |
| 1524 | |
Tobias Waldekranz | ffcec3f | 2021-03-18 20:25:34 +0100 | [diff] [blame] | 1525 | if (dsa_to_port(ds, port)->lag_dev) |
| 1526 | /* Hardware is incapable of fast-aging a LAG through a |
| 1527 | * regular ATU move operation. Until we have something |
| 1528 | * more fancy in place this is a no-op. |
| 1529 | */ |
| 1530 | return; |
| 1531 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1532 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 1533 | err = mv88e6xxx_g1_atu_remove(chip, 0, port, false); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1534 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1535 | |
| 1536 | if (err) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1537 | dev_err(ds->dev, "p%d: failed to flush ATU\n", port); |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1538 | } |
| 1539 | |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 1540 | static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip) |
| 1541 | { |
Tobias Waldekranz | e545f86 | 2020-11-10 19:57:20 +0100 | [diff] [blame] | 1542 | if (!mv88e6xxx_max_vid(chip)) |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 1543 | return 0; |
| 1544 | |
| 1545 | return mv88e6xxx_g1_vtu_flush(chip); |
| 1546 | } |
| 1547 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1548 | static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid, |
| 1549 | struct mv88e6xxx_vtu_entry *entry) |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1550 | { |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1551 | int err; |
| 1552 | |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1553 | if (!chip->info->ops->vtu_getnext) |
| 1554 | return -EOPNOTSUPP; |
| 1555 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1556 | entry->vid = vid ? vid - 1 : mv88e6xxx_max_vid(chip); |
| 1557 | entry->valid = false; |
| 1558 | |
| 1559 | err = chip->info->ops->vtu_getnext(chip, entry); |
| 1560 | |
| 1561 | if (entry->vid != vid) |
| 1562 | entry->valid = false; |
| 1563 | |
| 1564 | return err; |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1565 | } |
| 1566 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 1567 | static int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip, |
| 1568 | int (*cb)(struct mv88e6xxx_chip *chip, |
| 1569 | const struct mv88e6xxx_vtu_entry *entry, |
| 1570 | void *priv), |
| 1571 | void *priv) |
| 1572 | { |
| 1573 | struct mv88e6xxx_vtu_entry entry = { |
| 1574 | .vid = mv88e6xxx_max_vid(chip), |
| 1575 | .valid = false, |
| 1576 | }; |
| 1577 | int err; |
| 1578 | |
| 1579 | if (!chip->info->ops->vtu_getnext) |
| 1580 | return -EOPNOTSUPP; |
| 1581 | |
| 1582 | do { |
| 1583 | err = chip->info->ops->vtu_getnext(chip, &entry); |
| 1584 | if (err) |
| 1585 | return err; |
| 1586 | |
| 1587 | if (!entry.valid) |
| 1588 | break; |
| 1589 | |
| 1590 | err = cb(chip, &entry, priv); |
| 1591 | if (err) |
| 1592 | return err; |
| 1593 | } while (entry.vid < mv88e6xxx_max_vid(chip)); |
| 1594 | |
| 1595 | return 0; |
| 1596 | } |
| 1597 | |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 1598 | static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip, |
| 1599 | struct mv88e6xxx_vtu_entry *entry) |
| 1600 | { |
| 1601 | if (!chip->info->ops->vtu_loadpurge) |
| 1602 | return -EOPNOTSUPP; |
| 1603 | |
| 1604 | return chip->info->ops->vtu_loadpurge(chip, entry); |
| 1605 | } |
| 1606 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 1607 | static int mv88e6xxx_fid_map_vlan(struct mv88e6xxx_chip *chip, |
| 1608 | const struct mv88e6xxx_vtu_entry *entry, |
| 1609 | void *_fid_bitmap) |
| 1610 | { |
| 1611 | unsigned long *fid_bitmap = _fid_bitmap; |
| 1612 | |
| 1613 | set_bit(entry->fid, fid_bitmap); |
| 1614 | return 0; |
| 1615 | } |
| 1616 | |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1617 | int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap) |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1618 | { |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1619 | int i, err; |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1620 | u16 fid; |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1621 | |
| 1622 | bitmap_zero(fid_bitmap, MV88E6XXX_N_FID); |
| 1623 | |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1624 | /* Set every FID bit used by the (un)bridged ports */ |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 1625 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1626 | err = mv88e6xxx_port_get_fid(chip, i, &fid); |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1627 | if (err) |
| 1628 | return err; |
| 1629 | |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1630 | set_bit(fid, fid_bitmap); |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1631 | } |
| 1632 | |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1633 | /* Set every FID bit used by the VLAN entries */ |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 1634 | return mv88e6xxx_vtu_walk(chip, mv88e6xxx_fid_map_vlan, fid_bitmap); |
Andrew Lunn | 90b6dbd | 2020-09-18 21:11:06 +0200 | [diff] [blame] | 1635 | } |
| 1636 | |
| 1637 | static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid) |
| 1638 | { |
| 1639 | DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID); |
| 1640 | int err; |
| 1641 | |
| 1642 | err = mv88e6xxx_fid_map(chip, fid_bitmap); |
| 1643 | if (err) |
| 1644 | return err; |
| 1645 | |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1646 | /* The reset value 0x000 is used to indicate that multiple address |
| 1647 | * databases are not needed. Return the next positive available. |
| 1648 | */ |
| 1649 | *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1650 | if (unlikely(*fid >= mv88e6xxx_num_databases(chip))) |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1651 | return -ENOSPC; |
| 1652 | |
| 1653 | /* Clear the database */ |
Vivien Didelot | daefc94 | 2017-03-11 16:12:54 -0500 | [diff] [blame] | 1654 | return mv88e6xxx_g1_atu_flush(chip, *fid, true); |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1655 | } |
| 1656 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1657 | 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] | 1658 | u16 vid) |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1659 | { |
Vladimir Oltean | 0493fa7 | 2021-12-06 18:57:50 +0200 | [diff] [blame] | 1660 | struct dsa_port *dp = dsa_to_port(ds, port), *other_dp; |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1661 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 1662 | struct mv88e6xxx_vtu_entry vlan; |
Vladimir Oltean | 0493fa7 | 2021-12-06 18:57:50 +0200 | [diff] [blame] | 1663 | int err; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1664 | |
Andrew Lunn | db06ae41 | 2017-09-25 23:32:20 +0200 | [diff] [blame] | 1665 | /* DSA and CPU ports have to be members of multiple vlans */ |
Vladimir Oltean | 0493fa7 | 2021-12-06 18:57:50 +0200 | [diff] [blame] | 1666 | if (dsa_port_is_dsa(dp) || dsa_port_is_cpu(dp)) |
Andrew Lunn | db06ae41 | 2017-09-25 23:32:20 +0200 | [diff] [blame] | 1667 | return 0; |
| 1668 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1669 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1670 | if (err) |
| 1671 | return err; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1672 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1673 | if (!vlan.valid) |
| 1674 | return 0; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1675 | |
Vladimir Oltean | 0493fa7 | 2021-12-06 18:57:50 +0200 | [diff] [blame] | 1676 | dsa_switch_for_each_user_port(other_dp, ds) { |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1677 | struct net_device *other_br; |
| 1678 | |
Vladimir Oltean | 0493fa7 | 2021-12-06 18:57:50 +0200 | [diff] [blame] | 1679 | if (vlan.member[other_dp->index] == |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1680 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) |
| 1681 | continue; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1682 | |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1683 | if (dsa_port_bridge_same(dp, other_dp)) |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1684 | break; /* same bridge, check next VLAN */ |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1685 | |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1686 | other_br = dsa_port_bridge_dev_get(other_dp); |
| 1687 | if (!other_br) |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1688 | continue; |
Andrew Lunn | 66e2809 | 2016-12-11 21:07:19 +0100 | [diff] [blame] | 1689 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1690 | dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n", |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1691 | port, vlan.vid, other_dp->index, netdev_name(other_br)); |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1692 | return -EOPNOTSUPP; |
| 1693 | } |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1694 | |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1695 | return 0; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1696 | } |
| 1697 | |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1698 | static int mv88e6xxx_port_commit_pvid(struct mv88e6xxx_chip *chip, int port) |
| 1699 | { |
| 1700 | struct dsa_port *dp = dsa_to_port(chip->ds, port); |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1701 | struct net_device *br = dsa_port_bridge_dev_get(dp); |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1702 | struct mv88e6xxx_port *p = &chip->ports[port]; |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 1703 | u16 pvid = MV88E6XXX_VID_STANDALONE; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1704 | bool drop_untagged = false; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1705 | int err; |
| 1706 | |
Vladimir Oltean | 41fb0cf | 2021-12-06 18:57:53 +0200 | [diff] [blame] | 1707 | if (br) { |
| 1708 | if (br_vlan_enabled(br)) { |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 1709 | pvid = p->bridge_pvid.vid; |
| 1710 | drop_untagged = !p->bridge_pvid.valid; |
| 1711 | } else { |
| 1712 | pvid = MV88E6XXX_VID_BRIDGED; |
| 1713 | } |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1714 | } |
| 1715 | |
| 1716 | err = mv88e6xxx_port_set_pvid(chip, port, pvid); |
| 1717 | if (err) |
| 1718 | return err; |
| 1719 | |
| 1720 | return mv88e6xxx_port_drop_untagged(chip, port, drop_untagged); |
| 1721 | } |
| 1722 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1723 | static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port, |
Vladimir Oltean | 89153ed | 2021-02-13 22:43:19 +0200 | [diff] [blame] | 1724 | bool vlan_filtering, |
| 1725 | struct netlink_ext_ack *extack) |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1726 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1727 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 81c6edb | 2017-06-12 12:37:41 -0400 | [diff] [blame] | 1728 | u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE : |
| 1729 | MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1730 | int err; |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1731 | |
Vladimir Oltean | bae33f2 | 2021-01-09 02:01:50 +0200 | [diff] [blame] | 1732 | if (!mv88e6xxx_max_vid(chip)) |
| 1733 | return -EOPNOTSUPP; |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1734 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1735 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1736 | |
Vivien Didelot | 385a099 | 2016-11-04 03:23:31 +0100 | [diff] [blame] | 1737 | err = mv88e6xxx_port_set_8021q_mode(chip, port, mode); |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 1738 | if (err) |
| 1739 | goto unlock; |
| 1740 | |
| 1741 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 1742 | if (err) |
| 1743 | goto unlock; |
| 1744 | |
| 1745 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1746 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1747 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1748 | return err; |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1749 | } |
| 1750 | |
Vivien Didelot | 57d3231 | 2016-06-20 13:13:58 -0400 | [diff] [blame] | 1751 | static int |
| 1752 | mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port, |
Vivien Didelot | 80e0236 | 2017-11-30 11:23:57 -0500 | [diff] [blame] | 1753 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1754 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1755 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1756 | int err; |
| 1757 | |
Tobias Waldekranz | e545f86 | 2020-11-10 19:57:20 +0100 | [diff] [blame] | 1758 | if (!mv88e6xxx_max_vid(chip)) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1759 | return -EOPNOTSUPP; |
| 1760 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1761 | /* If the requested port doesn't belong to the same bridge as the VLAN |
| 1762 | * members, do not support it (yet) and fallback to software VLAN. |
| 1763 | */ |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1764 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 1765 | err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid); |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1766 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1767 | |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1768 | return err; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1769 | } |
| 1770 | |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1771 | static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port, |
| 1772 | const unsigned char *addr, u16 vid, |
| 1773 | u8 state) |
| 1774 | { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1775 | struct mv88e6xxx_atu_entry entry; |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1776 | struct mv88e6xxx_vtu_entry vlan; |
| 1777 | u16 fid; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1778 | int err; |
| 1779 | |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 1780 | /* Ports have two private address databases: one for when the port is |
| 1781 | * standalone and one for when the port is under a bridge and the |
| 1782 | * 802.1Q mode is disabled. When the port is standalone, DSA wants its |
| 1783 | * address database to remain 100% empty, so we never load an ATU entry |
| 1784 | * into a standalone port's database. Therefore, translate the null |
| 1785 | * VLAN ID into the port's database used for VLAN-unaware bridging. |
| 1786 | */ |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1787 | if (vid == 0) { |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 1788 | fid = MV88E6XXX_FID_BRIDGED; |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1789 | } else { |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1790 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1791 | if (err) |
| 1792 | return err; |
| 1793 | |
| 1794 | /* switchdev expects -EOPNOTSUPP to honor software VLANs */ |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 1795 | if (!vlan.valid) |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1796 | return -EOPNOTSUPP; |
| 1797 | |
| 1798 | fid = vlan.fid; |
| 1799 | } |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1800 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1801 | entry.state = 0; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1802 | ether_addr_copy(entry.mac, addr); |
| 1803 | eth_addr_dec(entry.mac); |
| 1804 | |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1805 | err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry); |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1806 | if (err) |
| 1807 | return err; |
| 1808 | |
| 1809 | /* Initialize a fresh ATU entry if it isn't found */ |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1810 | if (!entry.state || !ether_addr_equal(entry.mac, addr)) { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1811 | memset(&entry, 0, sizeof(entry)); |
| 1812 | ether_addr_copy(entry.mac, addr); |
| 1813 | } |
| 1814 | |
| 1815 | /* Purge the ATU entry only if no port is using it anymore */ |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1816 | if (!state) { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1817 | entry.portvec &= ~BIT(port); |
| 1818 | if (!entry.portvec) |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1819 | entry.state = 0; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1820 | } else { |
DENG Qingfang | f72f2fb | 2021-01-30 21:43:34 +0800 | [diff] [blame] | 1821 | if (state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC) |
| 1822 | entry.portvec = BIT(port); |
| 1823 | else |
| 1824 | entry.portvec |= BIT(port); |
| 1825 | |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1826 | entry.state = state; |
| 1827 | } |
| 1828 | |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1829 | return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry); |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1830 | } |
| 1831 | |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 1832 | static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port, |
| 1833 | const struct mv88e6xxx_policy *policy) |
| 1834 | { |
| 1835 | enum mv88e6xxx_policy_mapping mapping = policy->mapping; |
| 1836 | enum mv88e6xxx_policy_action action = policy->action; |
| 1837 | const u8 *addr = policy->addr; |
| 1838 | u16 vid = policy->vid; |
| 1839 | u8 state; |
| 1840 | int err; |
| 1841 | int id; |
| 1842 | |
| 1843 | if (!chip->info->ops->port_set_policy) |
| 1844 | return -EOPNOTSUPP; |
| 1845 | |
| 1846 | switch (mapping) { |
| 1847 | case MV88E6XXX_POLICY_MAPPING_DA: |
| 1848 | case MV88E6XXX_POLICY_MAPPING_SA: |
| 1849 | if (action == MV88E6XXX_POLICY_ACTION_NORMAL) |
| 1850 | state = 0; /* Dissociate the port and address */ |
| 1851 | else if (action == MV88E6XXX_POLICY_ACTION_DISCARD && |
| 1852 | is_multicast_ether_addr(addr)) |
| 1853 | state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY; |
| 1854 | else if (action == MV88E6XXX_POLICY_ACTION_DISCARD && |
| 1855 | is_unicast_ether_addr(addr)) |
| 1856 | state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY; |
| 1857 | else |
| 1858 | return -EOPNOTSUPP; |
| 1859 | |
| 1860 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, |
| 1861 | state); |
| 1862 | if (err) |
| 1863 | return err; |
| 1864 | break; |
| 1865 | default: |
| 1866 | return -EOPNOTSUPP; |
| 1867 | } |
| 1868 | |
| 1869 | /* Skip the port's policy clearing if the mapping is still in use */ |
| 1870 | if (action == MV88E6XXX_POLICY_ACTION_NORMAL) |
| 1871 | idr_for_each_entry(&chip->policies, policy, id) |
| 1872 | if (policy->port == port && |
| 1873 | policy->mapping == mapping && |
| 1874 | policy->action != action) |
| 1875 | return 0; |
| 1876 | |
| 1877 | return chip->info->ops->port_set_policy(chip, port, mapping, action); |
| 1878 | } |
| 1879 | |
| 1880 | static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port, |
| 1881 | struct ethtool_rx_flow_spec *fs) |
| 1882 | { |
| 1883 | struct ethhdr *mac_entry = &fs->h_u.ether_spec; |
| 1884 | struct ethhdr *mac_mask = &fs->m_u.ether_spec; |
| 1885 | enum mv88e6xxx_policy_mapping mapping; |
| 1886 | enum mv88e6xxx_policy_action action; |
| 1887 | struct mv88e6xxx_policy *policy; |
| 1888 | u16 vid = 0; |
| 1889 | u8 *addr; |
| 1890 | int err; |
| 1891 | int id; |
| 1892 | |
| 1893 | if (fs->location != RX_CLS_LOC_ANY) |
| 1894 | return -EINVAL; |
| 1895 | |
| 1896 | if (fs->ring_cookie == RX_CLS_FLOW_DISC) |
| 1897 | action = MV88E6XXX_POLICY_ACTION_DISCARD; |
| 1898 | else |
| 1899 | return -EOPNOTSUPP; |
| 1900 | |
| 1901 | switch (fs->flow_type & ~FLOW_EXT) { |
| 1902 | case ETHER_FLOW: |
| 1903 | if (!is_zero_ether_addr(mac_mask->h_dest) && |
| 1904 | is_zero_ether_addr(mac_mask->h_source)) { |
| 1905 | mapping = MV88E6XXX_POLICY_MAPPING_DA; |
| 1906 | addr = mac_entry->h_dest; |
| 1907 | } else if (is_zero_ether_addr(mac_mask->h_dest) && |
| 1908 | !is_zero_ether_addr(mac_mask->h_source)) { |
| 1909 | mapping = MV88E6XXX_POLICY_MAPPING_SA; |
| 1910 | addr = mac_entry->h_source; |
| 1911 | } else { |
| 1912 | /* Cannot support DA and SA mapping in the same rule */ |
| 1913 | return -EOPNOTSUPP; |
| 1914 | } |
| 1915 | break; |
| 1916 | default: |
| 1917 | return -EOPNOTSUPP; |
| 1918 | } |
| 1919 | |
| 1920 | if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) { |
Andrew Lunn | 0484428 | 2020-07-05 21:38:08 +0200 | [diff] [blame] | 1921 | if (fs->m_ext.vlan_tci != htons(0xffff)) |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 1922 | return -EOPNOTSUPP; |
| 1923 | vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK; |
| 1924 | } |
| 1925 | |
| 1926 | idr_for_each_entry(&chip->policies, policy, id) { |
| 1927 | if (policy->port == port && policy->mapping == mapping && |
| 1928 | policy->action == action && policy->vid == vid && |
| 1929 | ether_addr_equal(policy->addr, addr)) |
| 1930 | return -EEXIST; |
| 1931 | } |
| 1932 | |
| 1933 | policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL); |
| 1934 | if (!policy) |
| 1935 | return -ENOMEM; |
| 1936 | |
| 1937 | fs->location = 0; |
| 1938 | err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff, |
| 1939 | GFP_KERNEL); |
| 1940 | if (err) { |
| 1941 | devm_kfree(chip->dev, policy); |
| 1942 | return err; |
| 1943 | } |
| 1944 | |
| 1945 | memcpy(&policy->fs, fs, sizeof(*fs)); |
| 1946 | ether_addr_copy(policy->addr, addr); |
| 1947 | policy->mapping = mapping; |
| 1948 | policy->action = action; |
| 1949 | policy->port = port; |
| 1950 | policy->vid = vid; |
| 1951 | |
| 1952 | err = mv88e6xxx_policy_apply(chip, port, policy); |
| 1953 | if (err) { |
| 1954 | idr_remove(&chip->policies, fs->location); |
| 1955 | devm_kfree(chip->dev, policy); |
| 1956 | return err; |
| 1957 | } |
| 1958 | |
| 1959 | return 0; |
| 1960 | } |
| 1961 | |
| 1962 | static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port, |
| 1963 | struct ethtool_rxnfc *rxnfc, u32 *rule_locs) |
| 1964 | { |
| 1965 | struct ethtool_rx_flow_spec *fs = &rxnfc->fs; |
| 1966 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1967 | struct mv88e6xxx_policy *policy; |
| 1968 | int err; |
| 1969 | int id; |
| 1970 | |
| 1971 | mv88e6xxx_reg_lock(chip); |
| 1972 | |
| 1973 | switch (rxnfc->cmd) { |
| 1974 | case ETHTOOL_GRXCLSRLCNT: |
| 1975 | rxnfc->data = 0; |
| 1976 | rxnfc->data |= RX_CLS_LOC_SPECIAL; |
| 1977 | rxnfc->rule_cnt = 0; |
| 1978 | idr_for_each_entry(&chip->policies, policy, id) |
| 1979 | if (policy->port == port) |
| 1980 | rxnfc->rule_cnt++; |
| 1981 | err = 0; |
| 1982 | break; |
| 1983 | case ETHTOOL_GRXCLSRULE: |
| 1984 | err = -ENOENT; |
| 1985 | policy = idr_find(&chip->policies, fs->location); |
| 1986 | if (policy) { |
| 1987 | memcpy(fs, &policy->fs, sizeof(*fs)); |
| 1988 | err = 0; |
| 1989 | } |
| 1990 | break; |
| 1991 | case ETHTOOL_GRXCLSRLALL: |
| 1992 | rxnfc->data = 0; |
| 1993 | rxnfc->rule_cnt = 0; |
| 1994 | idr_for_each_entry(&chip->policies, policy, id) |
| 1995 | if (policy->port == port) |
| 1996 | rule_locs[rxnfc->rule_cnt++] = id; |
| 1997 | err = 0; |
| 1998 | break; |
| 1999 | default: |
| 2000 | err = -EOPNOTSUPP; |
| 2001 | break; |
| 2002 | } |
| 2003 | |
| 2004 | mv88e6xxx_reg_unlock(chip); |
| 2005 | |
| 2006 | return err; |
| 2007 | } |
| 2008 | |
| 2009 | static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port, |
| 2010 | struct ethtool_rxnfc *rxnfc) |
| 2011 | { |
| 2012 | struct ethtool_rx_flow_spec *fs = &rxnfc->fs; |
| 2013 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2014 | struct mv88e6xxx_policy *policy; |
| 2015 | int err; |
| 2016 | |
| 2017 | mv88e6xxx_reg_lock(chip); |
| 2018 | |
| 2019 | switch (rxnfc->cmd) { |
| 2020 | case ETHTOOL_SRXCLSRLINS: |
| 2021 | err = mv88e6xxx_policy_insert(chip, port, fs); |
| 2022 | break; |
| 2023 | case ETHTOOL_SRXCLSRLDEL: |
| 2024 | err = -ENOENT; |
| 2025 | policy = idr_remove(&chip->policies, fs->location); |
| 2026 | if (policy) { |
| 2027 | policy->action = MV88E6XXX_POLICY_ACTION_NORMAL; |
| 2028 | err = mv88e6xxx_policy_apply(chip, port, policy); |
| 2029 | devm_kfree(chip->dev, policy); |
| 2030 | } |
| 2031 | break; |
| 2032 | default: |
| 2033 | err = -EOPNOTSUPP; |
| 2034 | break; |
| 2035 | } |
| 2036 | |
| 2037 | mv88e6xxx_reg_unlock(chip); |
| 2038 | |
| 2039 | return err; |
| 2040 | } |
| 2041 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2042 | static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port, |
| 2043 | u16 vid) |
| 2044 | { |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2045 | u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC; |
Tobias Waldekranz | 0806dd46 | 2021-03-18 20:25:37 +0100 | [diff] [blame] | 2046 | u8 broadcast[ETH_ALEN]; |
| 2047 | |
| 2048 | eth_broadcast_addr(broadcast); |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2049 | |
| 2050 | return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state); |
| 2051 | } |
| 2052 | |
| 2053 | static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid) |
| 2054 | { |
| 2055 | int port; |
| 2056 | int err; |
| 2057 | |
| 2058 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 2059 | struct dsa_port *dp = dsa_to_port(chip->ds, port); |
| 2060 | struct net_device *brport; |
| 2061 | |
| 2062 | if (dsa_is_unused_port(chip->ds, port)) |
| 2063 | continue; |
| 2064 | |
| 2065 | brport = dsa_port_to_bridge_port(dp); |
| 2066 | if (brport && !br_port_flag_is_set(brport, BR_BCAST_FLOOD)) |
| 2067 | /* Skip bridged user ports where broadcast |
| 2068 | * flooding is disabled. |
| 2069 | */ |
| 2070 | continue; |
| 2071 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2072 | err = mv88e6xxx_port_add_broadcast(chip, port, vid); |
| 2073 | if (err) |
| 2074 | return err; |
| 2075 | } |
| 2076 | |
| 2077 | return 0; |
| 2078 | } |
| 2079 | |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 2080 | struct mv88e6xxx_port_broadcast_sync_ctx { |
| 2081 | int port; |
| 2082 | bool flood; |
| 2083 | }; |
| 2084 | |
| 2085 | static int |
| 2086 | mv88e6xxx_port_broadcast_sync_vlan(struct mv88e6xxx_chip *chip, |
| 2087 | const struct mv88e6xxx_vtu_entry *vlan, |
| 2088 | void *_ctx) |
| 2089 | { |
| 2090 | struct mv88e6xxx_port_broadcast_sync_ctx *ctx = _ctx; |
| 2091 | u8 broadcast[ETH_ALEN]; |
| 2092 | u8 state; |
| 2093 | |
| 2094 | if (ctx->flood) |
| 2095 | state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC; |
| 2096 | else |
| 2097 | state = MV88E6XXX_G1_ATU_DATA_STATE_MC_UNUSED; |
| 2098 | |
| 2099 | eth_broadcast_addr(broadcast); |
| 2100 | |
| 2101 | return mv88e6xxx_port_db_load_purge(chip, ctx->port, broadcast, |
| 2102 | vlan->vid, state); |
| 2103 | } |
| 2104 | |
| 2105 | static int mv88e6xxx_port_broadcast_sync(struct mv88e6xxx_chip *chip, int port, |
| 2106 | bool flood) |
| 2107 | { |
| 2108 | struct mv88e6xxx_port_broadcast_sync_ctx ctx = { |
| 2109 | .port = port, |
| 2110 | .flood = flood, |
| 2111 | }; |
| 2112 | struct mv88e6xxx_vtu_entry vid0 = { |
| 2113 | .vid = 0, |
| 2114 | }; |
| 2115 | int err; |
| 2116 | |
| 2117 | /* Update the port's private database... */ |
| 2118 | err = mv88e6xxx_port_broadcast_sync_vlan(chip, &vid0, &ctx); |
| 2119 | if (err) |
| 2120 | return err; |
| 2121 | |
| 2122 | /* ...and the database for all VLANs. */ |
| 2123 | return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_broadcast_sync_vlan, |
| 2124 | &ctx); |
| 2125 | } |
| 2126 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2127 | static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port, |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2128 | u16 vid, u8 member, bool warn) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2129 | { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2130 | const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 2131 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2132 | int i, err; |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 2133 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2134 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2135 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2136 | return err; |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2137 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2138 | if (!vlan.valid) { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2139 | memset(&vlan, 0, sizeof(vlan)); |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 2140 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2141 | err = mv88e6xxx_atu_new(chip, &vlan.fid); |
| 2142 | if (err) |
| 2143 | return err; |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2144 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2145 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) |
| 2146 | if (i == port) |
| 2147 | vlan.member[i] = member; |
| 2148 | else |
| 2149 | vlan.member[i] = non_member; |
| 2150 | |
| 2151 | vlan.vid = vid; |
| 2152 | vlan.valid = true; |
| 2153 | |
| 2154 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
| 2155 | if (err) |
| 2156 | return err; |
| 2157 | |
| 2158 | err = mv88e6xxx_broadcast_setup(chip, vlan.vid); |
| 2159 | if (err) |
| 2160 | return err; |
| 2161 | } else if (vlan.member[port] != member) { |
| 2162 | vlan.member[port] = member; |
| 2163 | |
| 2164 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
| 2165 | if (err) |
| 2166 | return err; |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2167 | } else if (warn) { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 2168 | dev_info(chip->dev, "p%d: already a member of VLAN %d\n", |
| 2169 | port, vid); |
| 2170 | } |
| 2171 | |
| 2172 | return 0; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2173 | } |
| 2174 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2175 | static int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, |
Vladimir Oltean | 31046a5 | 2021-02-13 22:43:18 +0200 | [diff] [blame] | 2176 | const struct switchdev_obj_port_vlan *vlan, |
| 2177 | struct netlink_ext_ack *extack) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2178 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2179 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2180 | bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; |
| 2181 | bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2182 | struct mv88e6xxx_port *p = &chip->ports[port]; |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2183 | bool warn; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2184 | u8 member; |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2185 | int err; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2186 | |
Eldar Gasanov | b8b79c4 | 2021-06-21 11:54:38 +0300 | [diff] [blame] | 2187 | if (!vlan->vid) |
| 2188 | return 0; |
| 2189 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2190 | err = mv88e6xxx_port_vlan_prepare(ds, port, vlan); |
| 2191 | if (err) |
| 2192 | return err; |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 2193 | |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2194 | 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] | 2195 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2196 | else if (untagged) |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2197 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2198 | else |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2199 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 2200 | |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 2201 | /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port |
| 2202 | * and then the CPU port. Do not warn for duplicates for the CPU port. |
| 2203 | */ |
| 2204 | warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port); |
| 2205 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2206 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2207 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2208 | err = mv88e6xxx_port_vlan_join(chip, port, vlan->vid, member, warn); |
| 2209 | if (err) { |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 2210 | dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port, |
| 2211 | vlan->vid, untagged ? 'u' : 't'); |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2212 | goto out; |
| 2213 | } |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2214 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2215 | if (pvid) { |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2216 | p->bridge_pvid.vid = vlan->vid; |
| 2217 | p->bridge_pvid.valid = true; |
| 2218 | |
| 2219 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 2220 | if (err) |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2221 | goto out; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2222 | } else if (vlan->vid && p->bridge_pvid.vid == vlan->vid) { |
| 2223 | /* The old pvid was reinstalled as a non-pvid VLAN */ |
| 2224 | p->bridge_pvid.valid = false; |
| 2225 | |
| 2226 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 2227 | if (err) |
| 2228 | goto out; |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2229 | } |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2230 | |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2231 | out: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2232 | mv88e6xxx_reg_unlock(chip); |
Vladimir Oltean | 1958d58 | 2021-01-09 02:01:53 +0200 | [diff] [blame] | 2233 | |
| 2234 | return err; |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 2235 | } |
| 2236 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2237 | static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip, |
| 2238 | int port, u16 vid) |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2239 | { |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 2240 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2241 | int i, err; |
| 2242 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2243 | if (!vid) |
Vladimir Oltean | c92c741 | 2021-07-22 16:05:51 +0300 | [diff] [blame] | 2244 | return 0; |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2245 | |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2246 | err = mv88e6xxx_vtu_get(chip, vid, &vlan); |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2247 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2248 | return err; |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2249 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2250 | /* If the VLAN doesn't exist in hardware or the port isn't a member, |
| 2251 | * tell switchdev that this VLAN is likely handled in software. |
| 2252 | */ |
Tobias Waldekranz | 34065c5 | 2021-03-18 20:25:36 +0100 | [diff] [blame] | 2253 | if (!vlan.valid || |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2254 | vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) |
Vivien Didelot | 3c06f08 | 2016-02-05 14:04:39 -0500 | [diff] [blame] | 2255 | return -EOPNOTSUPP; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2256 | |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2257 | vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2258 | |
| 2259 | /* keep the VLAN unless all ports are excluded */ |
Vivien Didelot | f02bdff | 2015-10-11 18:08:36 -0400 | [diff] [blame] | 2260 | vlan.valid = false; |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 2261 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2262 | if (vlan.member[i] != |
| 2263 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) { |
Vivien Didelot | f02bdff | 2015-10-11 18:08:36 -0400 | [diff] [blame] | 2264 | vlan.valid = true; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2265 | break; |
| 2266 | } |
| 2267 | } |
| 2268 | |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2269 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2270 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2271 | return err; |
| 2272 | |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 2273 | return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2274 | } |
| 2275 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2276 | static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, |
| 2277 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2278 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2279 | struct mv88e6xxx_chip *chip = ds->priv; |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2280 | struct mv88e6xxx_port *p = &chip->ports[port]; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2281 | int err = 0; |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 2282 | u16 pvid; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2283 | |
Tobias Waldekranz | e545f86 | 2020-11-10 19:57:20 +0100 | [diff] [blame] | 2284 | if (!mv88e6xxx_max_vid(chip)) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 2285 | return -EOPNOTSUPP; |
| 2286 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2287 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2288 | |
Vivien Didelot | 77064f3 | 2016-11-04 03:23:30 +0100 | [diff] [blame] | 2289 | err = mv88e6xxx_port_get_pvid(chip, port, &pvid); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2290 | if (err) |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2291 | goto unlock; |
| 2292 | |
Vladimir Oltean | b7a9e0d | 2021-01-09 02:01:46 +0200 | [diff] [blame] | 2293 | err = mv88e6xxx_port_vlan_leave(chip, port, vlan->vid); |
| 2294 | if (err) |
| 2295 | goto unlock; |
| 2296 | |
| 2297 | if (vlan->vid == pvid) { |
Vladimir Oltean | 8b6836d | 2021-10-07 19:47:10 +0300 | [diff] [blame] | 2298 | p->bridge_pvid.valid = false; |
| 2299 | |
| 2300 | err = mv88e6xxx_port_commit_pvid(chip, port); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2301 | if (err) |
| 2302 | goto unlock; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2303 | } |
| 2304 | |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2305 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2306 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2307 | |
| 2308 | return err; |
| 2309 | } |
| 2310 | |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2311 | static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port, |
| 2312 | const unsigned char *addr, u16 vid) |
Guenter Roeck | defb05b | 2015-03-26 18:36:38 -0700 | [diff] [blame] | 2313 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2314 | struct mv88e6xxx_chip *chip = ds->priv; |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2315 | int err; |
Vivien Didelot | 6630e23 | 2015-08-06 01:44:07 -0400 | [diff] [blame] | 2316 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2317 | mv88e6xxx_reg_lock(chip); |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2318 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, |
| 2319 | MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2320 | mv88e6xxx_reg_unlock(chip); |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2321 | |
| 2322 | return err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2323 | } |
| 2324 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2325 | static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port, |
Arkadi Sharshevsky | 6c2c1dc | 2017-08-06 16:15:39 +0300 | [diff] [blame] | 2326 | const unsigned char *addr, u16 vid) |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2327 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2328 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2329 | int err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2330 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2331 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2332 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2333 | mv88e6xxx_reg_unlock(chip); |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2334 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2335 | return err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2336 | } |
| 2337 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2338 | static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip, |
| 2339 | u16 fid, u16 vid, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2340 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2341 | { |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2342 | struct mv88e6xxx_atu_entry addr; |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2343 | bool is_static; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2344 | int err; |
| 2345 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2346 | addr.state = 0; |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2347 | eth_broadcast_addr(addr.mac); |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2348 | |
| 2349 | do { |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2350 | err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr); |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2351 | if (err) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2352 | return err; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2353 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2354 | if (!addr.state) |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2355 | break; |
| 2356 | |
Vivien Didelot | 01bd96c | 2017-03-11 16:12:57 -0500 | [diff] [blame] | 2357 | if (addr.trunk || (addr.portvec & BIT(port)) == 0) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2358 | continue; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2359 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2360 | if (!is_unicast_ether_addr(addr.mac)) |
| 2361 | continue; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2362 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2363 | is_static = (addr.state == |
| 2364 | MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); |
| 2365 | err = cb(addr.mac, vid, is_static, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2366 | if (err) |
| 2367 | return err; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2368 | } while (!is_broadcast_ether_addr(addr.mac)); |
| 2369 | |
| 2370 | return err; |
| 2371 | } |
| 2372 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 2373 | struct mv88e6xxx_port_db_dump_vlan_ctx { |
| 2374 | int port; |
| 2375 | dsa_fdb_dump_cb_t *cb; |
| 2376 | void *data; |
| 2377 | }; |
| 2378 | |
| 2379 | static int mv88e6xxx_port_db_dump_vlan(struct mv88e6xxx_chip *chip, |
| 2380 | const struct mv88e6xxx_vtu_entry *entry, |
| 2381 | void *_data) |
| 2382 | { |
| 2383 | struct mv88e6xxx_port_db_dump_vlan_ctx *ctx = _data; |
| 2384 | |
| 2385 | return mv88e6xxx_port_db_dump_fid(chip, entry->fid, entry->vid, |
| 2386 | ctx->port, ctx->cb, ctx->data); |
| 2387 | } |
| 2388 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2389 | static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2390 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2391 | { |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 2392 | struct mv88e6xxx_port_db_dump_vlan_ctx ctx = { |
| 2393 | .port = port, |
| 2394 | .cb = cb, |
| 2395 | .data = data, |
| 2396 | }; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2397 | u16 fid; |
| 2398 | int err; |
| 2399 | |
| 2400 | /* Dump port's default Filtering Information Database (VLAN ID 0) */ |
Vivien Didelot | b4e48c5 | 2016-11-04 03:23:29 +0100 | [diff] [blame] | 2401 | err = mv88e6xxx_port_get_fid(chip, port, &fid); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2402 | if (err) |
| 2403 | return err; |
| 2404 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2405 | err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2406 | if (err) |
| 2407 | return err; |
| 2408 | |
Tobias Waldekranz | d89ef4b | 2021-03-18 20:25:35 +0100 | [diff] [blame] | 2409 | return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_db_dump_vlan, &ctx); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2410 | } |
| 2411 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2412 | static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2413 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2414 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2415 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2416 | int err; |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2417 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2418 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2419 | err = mv88e6xxx_port_db_dump(chip, port, cb, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2420 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2421 | |
| 2422 | return err; |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2423 | } |
| 2424 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2425 | static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip, |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame] | 2426 | struct dsa_bridge bridge) |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2427 | { |
Vivien Didelot | ef2025e | 2019-10-21 16:51:27 -0400 | [diff] [blame] | 2428 | struct dsa_switch *ds = chip->ds; |
| 2429 | struct dsa_switch_tree *dst = ds->dst; |
| 2430 | struct dsa_port *dp; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2431 | int err; |
| 2432 | |
Vivien Didelot | ef2025e | 2019-10-21 16:51:27 -0400 | [diff] [blame] | 2433 | list_for_each_entry(dp, &dst->ports, list) { |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame] | 2434 | if (dsa_port_offloads_bridge(dp, &bridge)) { |
Vivien Didelot | ef2025e | 2019-10-21 16:51:27 -0400 | [diff] [blame] | 2435 | if (dp->ds == ds) { |
| 2436 | /* This is a local bridge group member, |
| 2437 | * remap its Port VLAN Map. |
| 2438 | */ |
| 2439 | err = mv88e6xxx_port_vlan_map(chip, dp->index); |
| 2440 | if (err) |
| 2441 | return err; |
| 2442 | } else { |
| 2443 | /* This is an external bridge group member, |
| 2444 | * remap its cross-chip Port VLAN Table entry. |
| 2445 | */ |
| 2446 | err = mv88e6xxx_pvt_map(chip, dp->ds->index, |
| 2447 | dp->index); |
Vivien Didelot | e96a6e0 | 2017-03-30 17:37:13 -0400 | [diff] [blame] | 2448 | if (err) |
| 2449 | return err; |
| 2450 | } |
| 2451 | } |
| 2452 | } |
| 2453 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2454 | return 0; |
| 2455 | } |
| 2456 | |
Vladimir Oltean | 857fdd7 | 2021-12-06 18:57:58 +0200 | [diff] [blame] | 2457 | /* Treat the software bridge as a virtual single-port switch behind the |
| 2458 | * CPU and map in the PVT. First dst->last_switch elements are taken by |
| 2459 | * physical switches, so start from beyond that range. |
| 2460 | */ |
| 2461 | static int mv88e6xxx_map_virtual_bridge_to_pvt(struct dsa_switch *ds, |
| 2462 | unsigned int bridge_num) |
| 2463 | { |
| 2464 | u8 dev = bridge_num + ds->dst->last_switch; |
| 2465 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2466 | |
| 2467 | return mv88e6xxx_pvt_map(chip, dev, 0); |
| 2468 | } |
| 2469 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2470 | static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, |
Vladimir Oltean | b079922 | 2021-12-06 18:57:57 +0200 | [diff] [blame] | 2471 | struct dsa_bridge bridge, |
| 2472 | bool *tx_fwd_offload) |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2473 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2474 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2475 | int err; |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2476 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2477 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2478 | |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame] | 2479 | err = mv88e6xxx_bridge_map(chip, bridge); |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2480 | if (err) |
| 2481 | goto unlock; |
| 2482 | |
| 2483 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 2484 | if (err) |
| 2485 | goto unlock; |
| 2486 | |
Vladimir Oltean | 857fdd7 | 2021-12-06 18:57:58 +0200 | [diff] [blame] | 2487 | if (mv88e6xxx_has_pvt(chip)) { |
| 2488 | err = mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge.num); |
| 2489 | if (err) |
| 2490 | goto unlock; |
| 2491 | |
| 2492 | *tx_fwd_offload = true; |
| 2493 | } |
| 2494 | |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2495 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2496 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | a669275 | 2016-02-12 12:09:39 -0500 | [diff] [blame] | 2497 | |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2498 | return err; |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2499 | } |
| 2500 | |
Vivien Didelot | f123f2f | 2017-01-27 15:29:41 -0500 | [diff] [blame] | 2501 | static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port, |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame] | 2502 | struct dsa_bridge bridge) |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2503 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2504 | struct mv88e6xxx_chip *chip = ds->priv; |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2505 | int err; |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2506 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2507 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2508 | |
Vladimir Oltean | 857fdd7 | 2021-12-06 18:57:58 +0200 | [diff] [blame] | 2509 | if (bridge.tx_fwd_offload && |
| 2510 | mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge.num)) |
| 2511 | dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n"); |
| 2512 | |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame] | 2513 | if (mv88e6xxx_bridge_map(chip, bridge) || |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2514 | mv88e6xxx_port_vlan_map(chip, port)) |
| 2515 | dev_err(ds->dev, "failed to remap in-chip Port VLAN\n"); |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2516 | |
| 2517 | err = mv88e6xxx_port_commit_pvid(chip, port); |
| 2518 | if (err) |
| 2519 | dev_err(ds->dev, |
| 2520 | "port %d failed to restore standalone pvid: %pe\n", |
| 2521 | port, ERR_PTR(err)); |
| 2522 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2523 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 66d9cd0 | 2016-02-05 14:07:14 -0500 | [diff] [blame] | 2524 | } |
| 2525 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2526 | static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, |
| 2527 | int tree_index, int sw_index, |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame] | 2528 | int port, struct dsa_bridge bridge) |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2529 | { |
| 2530 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2531 | int err; |
| 2532 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2533 | if (tree_index != ds->dst->index) |
| 2534 | return 0; |
| 2535 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2536 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2537 | err = mv88e6xxx_pvt_map(chip, sw_index, port); |
Tobias Waldekranz | e006862 | 2021-12-09 23:24:24 +0100 | [diff] [blame] | 2538 | err = err ? : mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge.num); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2539 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2540 | |
| 2541 | return err; |
| 2542 | } |
| 2543 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2544 | static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, |
| 2545 | int tree_index, int sw_index, |
Vladimir Oltean | d3eed0e | 2021-12-06 18:57:56 +0200 | [diff] [blame] | 2546 | int port, struct dsa_bridge bridge) |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2547 | { |
| 2548 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2549 | |
Vladimir Oltean | f66a6a6 | 2020-05-10 19:37:41 +0300 | [diff] [blame] | 2550 | if (tree_index != ds->dst->index) |
| 2551 | return; |
| 2552 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2553 | mv88e6xxx_reg_lock(chip); |
Tobias Waldekranz | e006862 | 2021-12-09 23:24:24 +0100 | [diff] [blame] | 2554 | if (mv88e6xxx_pvt_map(chip, sw_index, port) || |
| 2555 | mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge.num)) |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2556 | dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2557 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2558 | } |
| 2559 | |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2560 | static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip) |
| 2561 | { |
| 2562 | if (chip->info->ops->reset) |
| 2563 | return chip->info->ops->reset(chip); |
| 2564 | |
| 2565 | return 0; |
| 2566 | } |
| 2567 | |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2568 | static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip) |
| 2569 | { |
| 2570 | struct gpio_desc *gpiod = chip->reset; |
| 2571 | |
| 2572 | /* If there is a GPIO connected to the reset pin, toggle it */ |
| 2573 | if (gpiod) { |
| 2574 | gpiod_set_value_cansleep(gpiod, 1); |
| 2575 | usleep_range(10000, 20000); |
| 2576 | gpiod_set_value_cansleep(gpiod, 0); |
| 2577 | usleep_range(10000, 20000); |
Andrew Lunn | a3dcb3e | 2020-11-16 08:43:01 -0800 | [diff] [blame] | 2578 | |
| 2579 | mv88e6xxx_g1_wait_eeprom_done(chip); |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2580 | } |
| 2581 | } |
| 2582 | |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2583 | static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip) |
| 2584 | { |
| 2585 | int i, err; |
| 2586 | |
| 2587 | /* Set all ports to the Disabled state */ |
| 2588 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
Vivien Didelot | f894c29 | 2017-06-08 18:34:10 -0400 | [diff] [blame] | 2589 | err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED); |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2590 | if (err) |
| 2591 | return err; |
| 2592 | } |
| 2593 | |
| 2594 | /* Wait for transmit queues to drain, |
| 2595 | * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps. |
| 2596 | */ |
| 2597 | usleep_range(2000, 4000); |
| 2598 | |
| 2599 | return 0; |
| 2600 | } |
| 2601 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2602 | static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2603 | { |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 2604 | int err; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2605 | |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2606 | err = mv88e6xxx_disable_ports(chip); |
| 2607 | if (err) |
| 2608 | return err; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2609 | |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2610 | mv88e6xxx_hardware_reset(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2611 | |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2612 | return mv88e6xxx_software_reset(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2613 | } |
| 2614 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2615 | static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2616 | enum mv88e6xxx_frame_mode frame, |
| 2617 | enum mv88e6xxx_egress_mode egress, u16 etype) |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2618 | { |
| 2619 | int err; |
| 2620 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2621 | if (!chip->info->ops->port_set_frame_mode) |
| 2622 | return -EOPNOTSUPP; |
| 2623 | |
| 2624 | err = mv88e6xxx_port_set_egress_mode(chip, port, egress); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2625 | if (err) |
| 2626 | return err; |
| 2627 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2628 | err = chip->info->ops->port_set_frame_mode(chip, port, frame); |
| 2629 | if (err) |
| 2630 | return err; |
| 2631 | |
| 2632 | if (chip->info->ops->port_set_ether_type) |
| 2633 | return chip->info->ops->port_set_ether_type(chip, port, etype); |
| 2634 | |
| 2635 | return 0; |
| 2636 | } |
| 2637 | |
| 2638 | static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port) |
| 2639 | { |
| 2640 | return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2641 | MV88E6XXX_EGRESS_MODE_UNMODIFIED, |
Vivien Didelot | b810959 | 2017-06-12 12:37:45 -0400 | [diff] [blame] | 2642 | MV88E6XXX_PORT_ETH_TYPE_DEFAULT); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2643 | } |
| 2644 | |
| 2645 | static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port) |
| 2646 | { |
| 2647 | return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2648 | MV88E6XXX_EGRESS_MODE_UNMODIFIED, |
Vivien Didelot | b810959 | 2017-06-12 12:37:45 -0400 | [diff] [blame] | 2649 | MV88E6XXX_PORT_ETH_TYPE_DEFAULT); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2650 | } |
| 2651 | |
| 2652 | static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port) |
| 2653 | { |
| 2654 | return mv88e6xxx_set_port_mode(chip, port, |
| 2655 | MV88E6XXX_FRAME_MODE_ETHERTYPE, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2656 | MV88E6XXX_EGRESS_MODE_ETHERTYPE, |
| 2657 | ETH_P_EDSA); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2658 | } |
| 2659 | |
| 2660 | static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port) |
| 2661 | { |
| 2662 | if (dsa_is_dsa_port(chip->ds, port)) |
| 2663 | return mv88e6xxx_set_port_mode_dsa(chip, port); |
| 2664 | |
Vivien Didelot | 2b3e989 | 2017-10-26 11:22:54 -0400 | [diff] [blame] | 2665 | if (dsa_is_user_port(chip->ds, port)) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2666 | return mv88e6xxx_set_port_mode_normal(chip, port); |
| 2667 | |
| 2668 | /* Setup CPU port mode depending on its supported tag format */ |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 2669 | if (chip->tag_protocol == DSA_TAG_PROTO_DSA) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2670 | return mv88e6xxx_set_port_mode_dsa(chip, port); |
| 2671 | |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 2672 | if (chip->tag_protocol == DSA_TAG_PROTO_EDSA) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2673 | return mv88e6xxx_set_port_mode_edsa(chip, port); |
| 2674 | |
| 2675 | return -EINVAL; |
| 2676 | } |
| 2677 | |
Vivien Didelot | ea698f4 | 2017-03-11 16:12:50 -0500 | [diff] [blame] | 2678 | static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port) |
| 2679 | { |
| 2680 | bool message = dsa_is_dsa_port(chip->ds, port); |
| 2681 | |
| 2682 | return mv88e6xxx_port_set_message_port(chip, port, message); |
| 2683 | } |
| 2684 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2685 | static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port) |
| 2686 | { |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2687 | int err; |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2688 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2689 | if (chip->info->ops->port_set_ucast_flood) { |
Tobias Waldekranz | 7b9f16f | 2021-03-18 20:25:38 +0100 | [diff] [blame] | 2690 | err = chip->info->ops->port_set_ucast_flood(chip, port, true); |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2691 | if (err) |
| 2692 | return err; |
| 2693 | } |
| 2694 | if (chip->info->ops->port_set_mcast_flood) { |
Tobias Waldekranz | 7b9f16f | 2021-03-18 20:25:38 +0100 | [diff] [blame] | 2695 | err = chip->info->ops->port_set_mcast_flood(chip, port, true); |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 2696 | if (err) |
| 2697 | return err; |
| 2698 | } |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2699 | |
David S. Miller | 407308f | 2019-06-15 13:35:29 -0700 | [diff] [blame] | 2700 | return 0; |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2701 | } |
| 2702 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2703 | static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id) |
| 2704 | { |
| 2705 | struct mv88e6xxx_port *mvp = dev_id; |
| 2706 | struct mv88e6xxx_chip *chip = mvp->chip; |
| 2707 | irqreturn_t ret = IRQ_NONE; |
| 2708 | int port = mvp->port; |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2709 | int lane; |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2710 | |
| 2711 | mv88e6xxx_reg_lock(chip); |
| 2712 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2713 | if (lane >= 0) |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2714 | ret = mv88e6xxx_serdes_irq_status(chip, port, lane); |
| 2715 | mv88e6xxx_reg_unlock(chip); |
| 2716 | |
| 2717 | return ret; |
| 2718 | } |
| 2719 | |
| 2720 | static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port, |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2721 | int lane) |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2722 | { |
| 2723 | struct mv88e6xxx_port *dev_id = &chip->ports[port]; |
| 2724 | unsigned int irq; |
| 2725 | int err; |
| 2726 | |
| 2727 | /* Nothing to request if this SERDES port has no IRQ */ |
| 2728 | irq = mv88e6xxx_serdes_irq_mapping(chip, port); |
| 2729 | if (!irq) |
| 2730 | return 0; |
| 2731 | |
Andrew Lunn | e6f2f6b | 2020-01-06 17:13:49 +0100 | [diff] [blame] | 2732 | snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name), |
| 2733 | "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port); |
| 2734 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2735 | /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */ |
| 2736 | mv88e6xxx_reg_unlock(chip); |
| 2737 | err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn, |
Andrew Lunn | e6f2f6b | 2020-01-06 17:13:49 +0100 | [diff] [blame] | 2738 | IRQF_ONESHOT, dev_id->serdes_irq_name, |
| 2739 | dev_id); |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2740 | mv88e6xxx_reg_lock(chip); |
| 2741 | if (err) |
| 2742 | return err; |
| 2743 | |
| 2744 | dev_id->serdes_irq = irq; |
| 2745 | |
| 2746 | return mv88e6xxx_serdes_irq_enable(chip, port, lane); |
| 2747 | } |
| 2748 | |
| 2749 | static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port, |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2750 | int lane) |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2751 | { |
| 2752 | struct mv88e6xxx_port *dev_id = &chip->ports[port]; |
| 2753 | unsigned int irq = dev_id->serdes_irq; |
| 2754 | int err; |
| 2755 | |
| 2756 | /* Nothing to free if no IRQ has been requested */ |
| 2757 | if (!irq) |
| 2758 | return 0; |
| 2759 | |
| 2760 | err = mv88e6xxx_serdes_irq_disable(chip, port, lane); |
| 2761 | |
| 2762 | /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */ |
| 2763 | mv88e6xxx_reg_unlock(chip); |
| 2764 | free_irq(irq, dev_id); |
| 2765 | mv88e6xxx_reg_lock(chip); |
| 2766 | |
| 2767 | dev_id->serdes_irq = 0; |
| 2768 | |
| 2769 | return err; |
| 2770 | } |
| 2771 | |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2772 | static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port, |
| 2773 | bool on) |
| 2774 | { |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2775 | int lane; |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2776 | int err; |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2777 | |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2778 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
Pavana Sharma | 193c5b2 | 2021-03-17 14:46:40 +0100 | [diff] [blame] | 2779 | if (lane < 0) |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2780 | return 0; |
| 2781 | |
| 2782 | if (on) { |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2783 | err = mv88e6xxx_serdes_power_up(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2784 | if (err) |
| 2785 | return err; |
| 2786 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2787 | err = mv88e6xxx_serdes_irq_request(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2788 | } else { |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2789 | err = mv88e6xxx_serdes_irq_free(chip, port, lane); |
| 2790 | if (err) |
| 2791 | return err; |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2792 | |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2793 | err = mv88e6xxx_serdes_power_down(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2794 | } |
| 2795 | |
| 2796 | return err; |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2797 | } |
| 2798 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2799 | static int mv88e6xxx_set_egress_port(struct mv88e6xxx_chip *chip, |
| 2800 | enum mv88e6xxx_egress_direction direction, |
| 2801 | int port) |
| 2802 | { |
| 2803 | int err; |
| 2804 | |
| 2805 | if (!chip->info->ops->set_egress_port) |
| 2806 | return -EOPNOTSUPP; |
| 2807 | |
| 2808 | err = chip->info->ops->set_egress_port(chip, direction, port); |
| 2809 | if (err) |
| 2810 | return err; |
| 2811 | |
| 2812 | if (direction == MV88E6XXX_EGRESS_DIR_INGRESS) |
| 2813 | chip->ingress_dest_port = port; |
| 2814 | else |
| 2815 | chip->egress_dest_port = port; |
| 2816 | |
| 2817 | return 0; |
| 2818 | } |
| 2819 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2820 | static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port) |
| 2821 | { |
| 2822 | struct dsa_switch *ds = chip->ds; |
| 2823 | int upstream_port; |
| 2824 | int err; |
| 2825 | |
Vivien Didelot | 07073c7 | 2017-12-05 15:34:13 -0500 | [diff] [blame] | 2826 | upstream_port = dsa_upstream_port(ds, port); |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2827 | if (chip->info->ops->port_set_upstream_port) { |
| 2828 | err = chip->info->ops->port_set_upstream_port(chip, port, |
| 2829 | upstream_port); |
| 2830 | if (err) |
| 2831 | return err; |
| 2832 | } |
| 2833 | |
Vivien Didelot | 0ea54dd | 2017-12-05 15:34:11 -0500 | [diff] [blame] | 2834 | if (port == upstream_port) { |
| 2835 | if (chip->info->ops->set_cpu_port) { |
| 2836 | err = chip->info->ops->set_cpu_port(chip, |
| 2837 | upstream_port); |
| 2838 | if (err) |
| 2839 | return err; |
| 2840 | } |
| 2841 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2842 | err = mv88e6xxx_set_egress_port(chip, |
Iwan R Timmer | 5c74c54 | 2019-11-07 22:11:13 +0100 | [diff] [blame] | 2843 | MV88E6XXX_EGRESS_DIR_INGRESS, |
| 2844 | upstream_port); |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2845 | if (err && err != -EOPNOTSUPP) |
| 2846 | return err; |
Iwan R Timmer | 5c74c54 | 2019-11-07 22:11:13 +0100 | [diff] [blame] | 2847 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2848 | err = mv88e6xxx_set_egress_port(chip, |
Iwan R Timmer | 5c74c54 | 2019-11-07 22:11:13 +0100 | [diff] [blame] | 2849 | MV88E6XXX_EGRESS_DIR_EGRESS, |
| 2850 | upstream_port); |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 2851 | if (err && err != -EOPNOTSUPP) |
| 2852 | return err; |
Vivien Didelot | 0ea54dd | 2017-12-05 15:34:11 -0500 | [diff] [blame] | 2853 | } |
| 2854 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2855 | return 0; |
| 2856 | } |
| 2857 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2858 | static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2859 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2860 | struct dsa_switch *ds = chip->ds; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2861 | int err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2862 | u16 reg; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2863 | |
Andrew Lunn | 7b89846 | 2018-08-09 15:38:47 +0200 | [diff] [blame] | 2864 | chip->ports[port].chip = chip; |
| 2865 | chip->ports[port].port = port; |
| 2866 | |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2867 | /* MAC Forcing register: don't force link, speed, duplex or flow control |
| 2868 | * state to any particular values on physical ports, but force the CPU |
| 2869 | * port and all DSA ports to their maximum bandwidth and full duplex. |
| 2870 | */ |
| 2871 | if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) |
| 2872 | err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP, |
| 2873 | SPEED_MAX, DUPLEX_FULL, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 2874 | PAUSE_OFF, |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2875 | PHY_INTERFACE_MODE_NA); |
| 2876 | else |
| 2877 | err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED, |
| 2878 | SPEED_UNFORCED, DUPLEX_UNFORCED, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 2879 | PAUSE_ON, |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2880 | PHY_INTERFACE_MODE_NA); |
| 2881 | if (err) |
| 2882 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2883 | |
| 2884 | /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock, |
| 2885 | * disable Header mode, enable IGMP/MLD snooping, disable VLAN |
| 2886 | * tunneling, determine priority by looking at 802.1p and IP |
| 2887 | * priority fields (IP prio has precedence), and set STP state |
| 2888 | * to Forwarding. |
| 2889 | * |
| 2890 | * If this is the CPU link, use DSA or EDSA tagging depending |
| 2891 | * on which tagging mode was configured. |
| 2892 | * |
| 2893 | * If this is a link to another switch, use DSA tagging mode. |
| 2894 | * |
| 2895 | * If this is the upstream port for this switch, enable |
| 2896 | * forwarding of unknown unicasts and multicasts. |
| 2897 | */ |
Vivien Didelot | a89b433be | 2017-06-12 12:37:37 -0400 | [diff] [blame] | 2898 | reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP | |
| 2899 | MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP | |
| 2900 | MV88E6XXX_PORT_CTL0_STATE_FORWARDING; |
| 2901 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2902 | if (err) |
| 2903 | return err; |
Andrew Lunn | 6083ce7 | 2015-08-17 23:52:52 +0200 | [diff] [blame] | 2904 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2905 | err = mv88e6xxx_setup_port_mode(chip, port); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2906 | if (err) |
| 2907 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2908 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2909 | err = mv88e6xxx_setup_egress_floods(chip, port); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2910 | if (err) |
| 2911 | return err; |
| 2912 | |
Andrew Lunn | b92ce2f | 2021-09-26 19:41:25 +0200 | [diff] [blame] | 2913 | /* Port Control 2: don't force a good FCS, set the MTU size to |
| 2914 | * 10222 bytes, disable 802.1q tags checking, don't discard tagged or |
Vivien Didelot | 8efdda4 | 2015-08-13 12:52:23 -0400 | [diff] [blame] | 2915 | * untagged frames on this port, do a destination address lookup on all |
| 2916 | * received packets as usual, disable ARP mirroring and don't send a |
| 2917 | * copy of all transmitted/received frames on this port to the CPU. |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2918 | */ |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2919 | err = mv88e6xxx_port_set_map_da(chip, port); |
| 2920 | if (err) |
| 2921 | return err; |
| 2922 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2923 | err = mv88e6xxx_setup_upstream_port(chip, port); |
| 2924 | if (err) |
| 2925 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2926 | |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2927 | err = mv88e6xxx_port_set_8021q_mode(chip, port, |
Vivien Didelot | 81c6edb | 2017-06-12 12:37:41 -0400 | [diff] [blame] | 2928 | MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED); |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2929 | if (err) |
| 2930 | return err; |
| 2931 | |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 2932 | /* Associate MV88E6XXX_VID_BRIDGED with MV88E6XXX_FID_BRIDGED in the |
| 2933 | * ATU by virtue of the fact that mv88e6xxx_atu_new() will pick it as |
| 2934 | * the first free FID after MV88E6XXX_FID_STANDALONE. This will be used |
| 2935 | * as the private PVID on ports under a VLAN-unaware bridge. |
| 2936 | * Shared (DSA and CPU) ports must also be members of it, to translate |
| 2937 | * the VID from the DSA tag into MV88E6XXX_FID_BRIDGED, instead of |
| 2938 | * relying on their port default FID. |
| 2939 | */ |
| 2940 | err = mv88e6xxx_port_vlan_join(chip, port, MV88E6XXX_VID_BRIDGED, |
| 2941 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED, |
| 2942 | false); |
| 2943 | if (err) |
| 2944 | return err; |
| 2945 | |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2946 | if (chip->info->ops->port_set_jumbo_size) { |
Andrew Lunn | b92ce2f | 2021-09-26 19:41:25 +0200 | [diff] [blame] | 2947 | err = chip->info->ops->port_set_jumbo_size(chip, port, 10218); |
Andrew Lunn | 5f43666 | 2016-12-03 04:45:17 +0100 | [diff] [blame] | 2948 | if (err) |
| 2949 | return err; |
| 2950 | } |
| 2951 | |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 2952 | /* Port Association Vector: disable automatic address learning |
| 2953 | * on all user ports since they start out in standalone |
| 2954 | * mode. When joining a bridge, learning will be configured to |
| 2955 | * match the bridge port settings. Enable learning on all |
| 2956 | * DSA/CPU ports. NOTE: FROM_CPU frames always bypass the |
| 2957 | * learning process. |
| 2958 | * |
| 2959 | * Disable HoldAt1, IntOnAgeOut, LockedPort, IgnoreWrongData, |
| 2960 | * and RefreshLocked. I.e. setup standard automatic learning. |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2961 | */ |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 2962 | if (dsa_is_user_port(ds, port)) |
Vivien Didelot | 65fa402 | 2016-04-14 14:42:07 -0400 | [diff] [blame] | 2963 | reg = 0; |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 2964 | else |
| 2965 | reg = 1 << port; |
Andrew Lunn | 4c7ea3c | 2015-11-03 10:52:36 -0500 | [diff] [blame] | 2966 | |
Vivien Didelot | 2a4614e | 2017-06-12 12:37:43 -0400 | [diff] [blame] | 2967 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR, |
| 2968 | reg); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2969 | if (err) |
| 2970 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2971 | |
| 2972 | /* Egress rate control 2: disable egress rate control. */ |
Vivien Didelot | 2cb8cb1 | 2017-06-12 12:37:42 -0400 | [diff] [blame] | 2973 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2, |
| 2974 | 0x0000); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2975 | if (err) |
| 2976 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2977 | |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2978 | if (chip->info->ops->port_pause_limit) { |
| 2979 | err = chip->info->ops->port_pause_limit(chip, port, 0, 0); |
Andrew Lunn | b35d322a | 2016-12-03 04:45:19 +0100 | [diff] [blame] | 2980 | if (err) |
| 2981 | return err; |
| 2982 | } |
| 2983 | |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2984 | if (chip->info->ops->port_disable_learn_limit) { |
| 2985 | err = chip->info->ops->port_disable_learn_limit(chip, port); |
| 2986 | if (err) |
| 2987 | return err; |
| 2988 | } |
| 2989 | |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2990 | if (chip->info->ops->port_disable_pri_override) { |
| 2991 | err = chip->info->ops->port_disable_pri_override(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2992 | if (err) |
| 2993 | return err; |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2994 | } |
Andrew Lunn | 2bbb33b | 2016-08-22 16:01:02 +0200 | [diff] [blame] | 2995 | |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2996 | if (chip->info->ops->port_tag_remap) { |
| 2997 | err = chip->info->ops->port_tag_remap(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2998 | if (err) |
| 2999 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 3000 | } |
| 3001 | |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3002 | if (chip->info->ops->port_egress_rate_limiting) { |
| 3003 | err = chip->info->ops->port_egress_rate_limiting(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 3004 | if (err) |
| 3005 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 3006 | } |
| 3007 | |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3008 | if (chip->info->ops->port_setup_message_port) { |
| 3009 | err = chip->info->ops->port_setup_message_port(chip, port); |
| 3010 | if (err) |
| 3011 | return err; |
| 3012 | } |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 3013 | |
Vivien Didelot | 207afda | 2016-04-14 14:42:09 -0400 | [diff] [blame] | 3014 | /* Port based VLAN map: give each port the same default address |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 3015 | * database, and allow bidirectional communication between the |
| 3016 | * CPU and DSA port(s), and the other ports. |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 3017 | */ |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 3018 | err = mv88e6xxx_port_set_fid(chip, port, MV88E6XXX_FID_STANDALONE); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 3019 | if (err) |
| 3020 | return err; |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 3021 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 3022 | err = mv88e6xxx_port_vlan_map(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 3023 | if (err) |
| 3024 | return err; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 3025 | |
| 3026 | /* Default VLAN ID and priority: don't set a default VLAN |
| 3027 | * ID, and set the default packet priority to zero. |
| 3028 | */ |
Vivien Didelot | b7929fb | 2017-06-12 12:37:40 -0400 | [diff] [blame] | 3029 | return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0); |
Andrew Lunn | dbde9e6 | 2015-05-06 01:09:48 +0200 | [diff] [blame] | 3030 | } |
| 3031 | |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 3032 | static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port) |
| 3033 | { |
| 3034 | struct mv88e6xxx_chip *chip = ds->priv; |
| 3035 | |
| 3036 | if (chip->info->ops->port_set_jumbo_size) |
Andrew Lunn | b9c587f | 2021-09-26 19:41:26 +0200 | [diff] [blame] | 3037 | return 10240 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3038 | else if (chip->info->ops->set_max_frame_size) |
Andrew Lunn | b9c587f | 2021-09-26 19:41:26 +0200 | [diff] [blame] | 3039 | return 1632 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; |
| 3040 | return 1522 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 3041 | } |
| 3042 | |
| 3043 | static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu) |
| 3044 | { |
| 3045 | struct mv88e6xxx_chip *chip = ds->priv; |
| 3046 | int ret = 0; |
| 3047 | |
Andrew Lunn | b9c587f | 2021-09-26 19:41:26 +0200 | [diff] [blame] | 3048 | if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) |
| 3049 | new_mtu += EDSA_HLEN; |
| 3050 | |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 3051 | mv88e6xxx_reg_lock(chip); |
| 3052 | if (chip->info->ops->port_set_jumbo_size) |
| 3053 | ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu); |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3054 | else if (chip->info->ops->set_max_frame_size) |
| 3055 | ret = chip->info->ops->set_max_frame_size(chip, new_mtu); |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 3056 | else |
| 3057 | if (new_mtu > 1522) |
| 3058 | ret = -EINVAL; |
| 3059 | mv88e6xxx_reg_unlock(chip); |
| 3060 | |
| 3061 | return ret; |
| 3062 | } |
| 3063 | |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3064 | static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port, |
| 3065 | struct phy_device *phydev) |
| 3066 | { |
| 3067 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 3068 | int err; |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3069 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3070 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 3071 | err = mv88e6xxx_serdes_power(chip, port, true); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3072 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3073 | |
| 3074 | return err; |
| 3075 | } |
| 3076 | |
Andrew Lunn | 75104db | 2019-02-24 20:44:43 +0100 | [diff] [blame] | 3077 | static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port) |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3078 | { |
| 3079 | struct mv88e6xxx_chip *chip = ds->priv; |
| 3080 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3081 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 3082 | if (mv88e6xxx_serdes_power(chip, port, false)) |
| 3083 | dev_err(chip->dev, "failed to power off SERDES\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3084 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 3085 | } |
| 3086 | |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 3087 | static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds, |
| 3088 | unsigned int ageing_time) |
| 3089 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3090 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 3091 | int err; |
| 3092 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3093 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 720c634 | 2017-03-11 16:12:48 -0500 | [diff] [blame] | 3094 | err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3095 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 3096 | |
| 3097 | return err; |
| 3098 | } |
| 3099 | |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 3100 | static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 3101 | { |
| 3102 | int err; |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 3103 | |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3104 | /* Initialize the statistics unit */ |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 3105 | if (chip->info->ops->stats_set_histogram) { |
| 3106 | err = chip->info->ops->stats_set_histogram(chip); |
| 3107 | if (err) |
| 3108 | return err; |
| 3109 | } |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3110 | |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3111 | return mv88e6xxx_g1_stats_clear(chip); |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3112 | } |
| 3113 | |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3114 | /* Check if the errata has already been applied. */ |
| 3115 | static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip) |
| 3116 | { |
| 3117 | int port; |
| 3118 | int err; |
| 3119 | u16 val; |
| 3120 | |
| 3121 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Marek Behún | 6090701 | 2019-08-26 23:31:51 +0200 | [diff] [blame] | 3122 | err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val); |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3123 | if (err) { |
| 3124 | dev_err(chip->dev, |
| 3125 | "Error reading hidden register: %d\n", err); |
| 3126 | return false; |
| 3127 | } |
| 3128 | if (val != 0x01c0) |
| 3129 | return false; |
| 3130 | } |
| 3131 | |
| 3132 | return true; |
| 3133 | } |
| 3134 | |
| 3135 | /* The 6390 copper ports have an errata which require poking magic |
| 3136 | * values into undocumented hidden registers and then performing a |
| 3137 | * software reset. |
| 3138 | */ |
| 3139 | static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip) |
| 3140 | { |
| 3141 | int port; |
| 3142 | int err; |
| 3143 | |
| 3144 | if (mv88e6390_setup_errata_applied(chip)) |
| 3145 | return 0; |
| 3146 | |
| 3147 | /* Set the ports into blocking mode */ |
| 3148 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 3149 | err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED); |
| 3150 | if (err) |
| 3151 | return err; |
| 3152 | } |
| 3153 | |
| 3154 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Marek Behún | 6090701 | 2019-08-26 23:31:51 +0200 | [diff] [blame] | 3155 | err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0); |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3156 | if (err) |
| 3157 | return err; |
| 3158 | } |
| 3159 | |
| 3160 | return mv88e6xxx_software_reset(chip); |
| 3161 | } |
| 3162 | |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3163 | static void mv88e6xxx_teardown(struct dsa_switch *ds) |
| 3164 | { |
| 3165 | mv88e6xxx_teardown_devlink_params(ds); |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3166 | dsa_devlink_resources_unregister(ds); |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 3167 | mv88e6xxx_teardown_devlink_regions_global(ds); |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3168 | } |
| 3169 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3170 | static int mv88e6xxx_setup(struct dsa_switch *ds) |
Guenter Roeck | acdaffc | 2015-03-26 18:36:28 -0700 | [diff] [blame] | 3171 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3172 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3173 | u8 cmode; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3174 | int err; |
Vivien Didelot | a1a6a4d | 2016-05-09 13:22:56 -0400 | [diff] [blame] | 3175 | int i; |
| 3176 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3177 | chip->ds = ds; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3178 | ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3179 | |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 3180 | /* Since virtual bridges are mapped in the PVT, the number we support |
| 3181 | * depends on the physical switch topology. We need to let DSA figure |
| 3182 | * that out and therefore we cannot set this at dsa_register_switch() |
| 3183 | * time. |
| 3184 | */ |
| 3185 | if (mv88e6xxx_has_pvt(chip)) |
Vladimir Oltean | 947c874 | 2021-12-06 18:57:48 +0200 | [diff] [blame] | 3186 | ds->max_num_bridges = MV88E6XXX_MAX_PVT_SWITCHES - |
| 3187 | ds->dst->last_switch - 1; |
Vladimir Oltean | ce5df68 | 2021-07-22 18:55:41 +0300 | [diff] [blame] | 3188 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3189 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3190 | |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3191 | if (chip->info->ops->setup_errata) { |
| 3192 | err = chip->info->ops->setup_errata(chip); |
| 3193 | if (err) |
| 3194 | goto unlock; |
| 3195 | } |
| 3196 | |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3197 | /* Cache the cmode of each port. */ |
| 3198 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
| 3199 | if (chip->info->ops->port_get_cmode) { |
| 3200 | err = chip->info->ops->port_get_cmode(chip, i, &cmode); |
| 3201 | if (err) |
Dan Carpenter | e29129f | 2018-08-14 12:09:05 +0300 | [diff] [blame] | 3202 | goto unlock; |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3203 | |
| 3204 | chip->ports[i].cmode = cmode; |
| 3205 | } |
| 3206 | } |
| 3207 | |
Vladimir Oltean | 5bded82 | 2021-10-07 19:47:11 +0300 | [diff] [blame] | 3208 | err = mv88e6xxx_vtu_setup(chip); |
| 3209 | if (err) |
| 3210 | goto unlock; |
| 3211 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3212 | /* Setup Switch Port Registers */ |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 3213 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
Vivien Didelot | b759f52 | 2019-08-19 16:00:52 -0400 | [diff] [blame] | 3214 | if (dsa_is_unused_port(ds, i)) |
| 3215 | continue; |
| 3216 | |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 3217 | /* Prevent the use of an invalid port. */ |
Vivien Didelot | b759f52 | 2019-08-19 16:00:52 -0400 | [diff] [blame] | 3218 | if (mv88e6xxx_is_invalid_port(chip, i)) { |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 3219 | dev_err(chip->dev, "port %d is invalid\n", i); |
| 3220 | err = -EINVAL; |
| 3221 | goto unlock; |
| 3222 | } |
| 3223 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3224 | err = mv88e6xxx_setup_port(chip, i); |
| 3225 | if (err) |
| 3226 | goto unlock; |
| 3227 | } |
| 3228 | |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3229 | err = mv88e6xxx_irl_setup(chip); |
| 3230 | if (err) |
| 3231 | goto unlock; |
| 3232 | |
Vivien Didelot | 04a69a1 | 2017-10-13 14:18:05 -0400 | [diff] [blame] | 3233 | err = mv88e6xxx_mac_setup(chip); |
| 3234 | if (err) |
| 3235 | goto unlock; |
| 3236 | |
Vivien Didelot | 1b17aed | 2017-05-26 18:03:05 -0400 | [diff] [blame] | 3237 | err = mv88e6xxx_phy_setup(chip); |
| 3238 | if (err) |
| 3239 | goto unlock; |
| 3240 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 3241 | err = mv88e6xxx_pvt_setup(chip); |
| 3242 | if (err) |
| 3243 | goto unlock; |
| 3244 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 3245 | err = mv88e6xxx_atu_setup(chip); |
| 3246 | if (err) |
| 3247 | goto unlock; |
| 3248 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 3249 | err = mv88e6xxx_broadcast_setup(chip, 0); |
| 3250 | if (err) |
| 3251 | goto unlock; |
| 3252 | |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3253 | err = mv88e6xxx_pot_setup(chip); |
| 3254 | if (err) |
| 3255 | goto unlock; |
| 3256 | |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3257 | err = mv88e6xxx_rmu_setup(chip); |
| 3258 | if (err) |
| 3259 | goto unlock; |
| 3260 | |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3261 | err = mv88e6xxx_rsvd2cpu_setup(chip); |
| 3262 | if (err) |
| 3263 | goto unlock; |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 3264 | |
Vivien Didelot | b28f872 | 2018-04-26 21:56:44 -0400 | [diff] [blame] | 3265 | err = mv88e6xxx_trunk_setup(chip); |
| 3266 | if (err) |
| 3267 | goto unlock; |
| 3268 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 3269 | err = mv88e6xxx_devmap_setup(chip); |
| 3270 | if (err) |
| 3271 | goto unlock; |
| 3272 | |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3273 | err = mv88e6xxx_pri_setup(chip); |
| 3274 | if (err) |
| 3275 | goto unlock; |
| 3276 | |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 3277 | /* Setup PTP Hardware Clock and timestamping */ |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3278 | if (chip->info->ptp_support) { |
| 3279 | err = mv88e6xxx_ptp_setup(chip); |
| 3280 | if (err) |
| 3281 | goto unlock; |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 3282 | |
| 3283 | err = mv88e6xxx_hwtstamp_setup(chip); |
| 3284 | if (err) |
| 3285 | goto unlock; |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3286 | } |
| 3287 | |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 3288 | err = mv88e6xxx_stats_setup(chip); |
| 3289 | if (err) |
| 3290 | goto unlock; |
| 3291 | |
Vivien Didelot | 6b17e86 | 2015-08-13 12:52:18 -0400 | [diff] [blame] | 3292 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3293 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | db687a5 | 2015-06-20 21:31:29 +0200 | [diff] [blame] | 3294 | |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3295 | if (err) |
| 3296 | return err; |
| 3297 | |
| 3298 | /* Have to be called without holding the register lock, since |
| 3299 | * they take the devlink lock, and we later take the locks in |
| 3300 | * the reverse order when getting/setting parameters or |
| 3301 | * resource occupancy. |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3302 | */ |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3303 | err = mv88e6xxx_setup_devlink_resources(ds); |
| 3304 | if (err) |
| 3305 | return err; |
| 3306 | |
| 3307 | err = mv88e6xxx_setup_devlink_params(ds); |
| 3308 | if (err) |
Andrew Lunn | bfb2554 | 2020-09-18 21:11:07 +0200 | [diff] [blame] | 3309 | goto out_resources; |
| 3310 | |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 3311 | err = mv88e6xxx_setup_devlink_regions_global(ds); |
Andrew Lunn | bfb2554 | 2020-09-18 21:11:07 +0200 | [diff] [blame] | 3312 | if (err) |
| 3313 | goto out_params; |
| 3314 | |
| 3315 | return 0; |
| 3316 | |
| 3317 | out_params: |
| 3318 | mv88e6xxx_teardown_devlink_params(ds); |
| 3319 | out_resources: |
| 3320 | dsa_devlink_resources_unregister(ds); |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3321 | |
| 3322 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 3323 | } |
| 3324 | |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 3325 | static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port) |
| 3326 | { |
| 3327 | return mv88e6xxx_setup_devlink_regions_port(ds, port); |
| 3328 | } |
| 3329 | |
| 3330 | static void mv88e6xxx_port_teardown(struct dsa_switch *ds, int port) |
| 3331 | { |
| 3332 | mv88e6xxx_teardown_devlink_regions_port(ds, port); |
| 3333 | } |
| 3334 | |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3335 | /* prod_id for switch families which do not have a PHY model number */ |
| 3336 | static const u16 family_prod_id_table[] = { |
| 3337 | [MV88E6XXX_FAMILY_6341] = MV88E6XXX_PORT_SWITCH_ID_PROD_6341, |
| 3338 | [MV88E6XXX_FAMILY_6390] = MV88E6XXX_PORT_SWITCH_ID_PROD_6390, |
Marek Behún | c5d015b | 2021-04-20 09:54:02 +0200 | [diff] [blame] | 3339 | [MV88E6XXX_FAMILY_6393] = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X, |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3340 | }; |
| 3341 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3342 | 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] | 3343 | { |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3344 | struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; |
| 3345 | struct mv88e6xxx_chip *chip = mdio_bus->chip; |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3346 | u16 prod_id; |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3347 | u16 val; |
| 3348 | int err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3349 | |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3350 | if (!chip->info->ops->phy_read) |
| 3351 | return -EOPNOTSUPP; |
| 3352 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3353 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3354 | err = chip->info->ops->phy_read(chip, bus, phy, reg, &val); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3355 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3356 | |
Pali Rohár | 1fe976d | 2021-04-12 18:57:39 +0200 | [diff] [blame] | 3357 | /* Some internal PHYs don't have a model number. */ |
| 3358 | if (reg == MII_PHYSID2 && !(val & 0x3f0) && |
| 3359 | chip->info->family < ARRAY_SIZE(family_prod_id_table)) { |
| 3360 | prod_id = family_prod_id_table[chip->info->family]; |
| 3361 | if (prod_id) |
| 3362 | val |= prod_id >> 4; |
Andrew Lunn | da9f330 | 2017-02-01 03:40:05 +0100 | [diff] [blame] | 3363 | } |
| 3364 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3365 | return err ? err : val; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3366 | } |
| 3367 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3368 | 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] | 3369 | { |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3370 | struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; |
| 3371 | struct mv88e6xxx_chip *chip = mdio_bus->chip; |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3372 | int err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3373 | |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3374 | if (!chip->info->ops->phy_write) |
| 3375 | return -EOPNOTSUPP; |
| 3376 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3377 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3378 | err = chip->info->ops->phy_write(chip, bus, phy, reg, val); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3379 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3380 | |
| 3381 | return err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3382 | } |
| 3383 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3384 | static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip, |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3385 | struct device_node *np, |
| 3386 | bool external) |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3387 | { |
| 3388 | static int index; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3389 | struct mv88e6xxx_mdio_bus *mdio_bus; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3390 | struct mii_bus *bus; |
| 3391 | int err; |
| 3392 | |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3393 | if (external) { |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3394 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3395 | err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3396 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3397 | |
| 3398 | if (err) |
| 3399 | return err; |
| 3400 | } |
| 3401 | |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3402 | bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus)); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3403 | if (!bus) |
| 3404 | return -ENOMEM; |
| 3405 | |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3406 | mdio_bus = bus->priv; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3407 | mdio_bus->bus = bus; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3408 | mdio_bus->chip = chip; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3409 | INIT_LIST_HEAD(&mdio_bus->list); |
| 3410 | mdio_bus->external = external; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3411 | |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3412 | if (np) { |
| 3413 | bus->name = np->full_name; |
Rob Herring | f7ce910 | 2017-07-18 16:43:19 -0500 | [diff] [blame] | 3414 | snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3415 | } else { |
| 3416 | bus->name = "mv88e6xxx SMI"; |
| 3417 | snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++); |
| 3418 | } |
| 3419 | |
| 3420 | bus->read = mv88e6xxx_mdio_read; |
| 3421 | bus->write = mv88e6xxx_mdio_write; |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3422 | bus->parent = chip->dev; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3423 | |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3424 | if (!external) { |
| 3425 | err = mv88e6xxx_g2_irq_mdio_setup(chip, bus); |
| 3426 | if (err) |
| 3427 | return err; |
| 3428 | } |
| 3429 | |
Florian Fainelli | 00e798c | 2018-05-15 16:56:19 -0700 | [diff] [blame] | 3430 | err = of_mdiobus_register(bus, np); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3431 | if (err) { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3432 | dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err); |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3433 | mv88e6xxx_g2_irq_mdio_free(chip, bus); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3434 | return err; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3435 | } |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3436 | |
| 3437 | if (external) |
| 3438 | list_add_tail(&mdio_bus->list, &chip->mdios); |
| 3439 | else |
| 3440 | list_add(&mdio_bus->list, &chip->mdios); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3441 | |
| 3442 | return 0; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3443 | } |
| 3444 | |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3445 | static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip) |
| 3446 | |
| 3447 | { |
| 3448 | struct mv88e6xxx_mdio_bus *mdio_bus; |
| 3449 | struct mii_bus *bus; |
| 3450 | |
| 3451 | list_for_each_entry(mdio_bus, &chip->mdios, list) { |
| 3452 | bus = mdio_bus->bus; |
| 3453 | |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3454 | if (!mdio_bus->external) |
| 3455 | mv88e6xxx_g2_irq_mdio_free(chip, bus); |
| 3456 | |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3457 | mdiobus_unregister(bus); |
| 3458 | } |
| 3459 | } |
| 3460 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3461 | static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, |
| 3462 | struct device_node *np) |
| 3463 | { |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3464 | struct device_node *child; |
| 3465 | int err; |
| 3466 | |
| 3467 | /* Always register one mdio bus for the internal/default mdio |
| 3468 | * bus. This maybe represented in the device tree, but is |
| 3469 | * optional. |
| 3470 | */ |
| 3471 | child = of_get_child_by_name(np, "mdio"); |
| 3472 | err = mv88e6xxx_mdio_register(chip, child, false); |
| 3473 | if (err) |
| 3474 | return err; |
| 3475 | |
| 3476 | /* Walk the device tree, and see if there are any other nodes |
| 3477 | * which say they are compatible with the external mdio |
| 3478 | * bus. |
| 3479 | */ |
| 3480 | for_each_available_child_of_node(np, child) { |
Andrew Lunn | ceb96fa | 2020-09-01 04:32:57 +0200 | [diff] [blame] | 3481 | if (of_device_is_compatible( |
| 3482 | child, "marvell,mv88e6xxx-mdio-external")) { |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3483 | err = mv88e6xxx_mdio_register(chip, child, true); |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3484 | if (err) { |
| 3485 | mv88e6xxx_mdios_unregister(chip); |
Nishka Dasgupta | 78e4204 | 2019-07-23 16:13:07 +0530 | [diff] [blame] | 3486 | of_node_put(child); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3487 | return err; |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3488 | } |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3489 | } |
| 3490 | } |
| 3491 | |
| 3492 | return 0; |
| 3493 | } |
| 3494 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3495 | static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds) |
| 3496 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3497 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3498 | |
| 3499 | return chip->eeprom_len; |
| 3500 | } |
| 3501 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3502 | static int mv88e6xxx_get_eeprom(struct dsa_switch *ds, |
| 3503 | struct ethtool_eeprom *eeprom, u8 *data) |
| 3504 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3505 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3506 | int err; |
| 3507 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3508 | if (!chip->info->ops->get_eeprom) |
| 3509 | return -EOPNOTSUPP; |
| 3510 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3511 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3512 | err = chip->info->ops->get_eeprom(chip, eeprom, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3513 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3514 | |
| 3515 | if (err) |
| 3516 | return err; |
| 3517 | |
| 3518 | eeprom->magic = 0xc3ec4951; |
| 3519 | |
| 3520 | return 0; |
| 3521 | } |
| 3522 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3523 | static int mv88e6xxx_set_eeprom(struct dsa_switch *ds, |
| 3524 | struct ethtool_eeprom *eeprom, u8 *data) |
| 3525 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3526 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3527 | int err; |
| 3528 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3529 | if (!chip->info->ops->set_eeprom) |
| 3530 | return -EOPNOTSUPP; |
| 3531 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3532 | if (eeprom->magic != 0xc3ec4951) |
| 3533 | return -EINVAL; |
| 3534 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3535 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3536 | err = chip->info->ops->set_eeprom(chip, eeprom, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3537 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3538 | |
| 3539 | return err; |
| 3540 | } |
| 3541 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3542 | static const struct mv88e6xxx_ops mv88e6085_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3543 | /* MV88E6XXX_FAMILY_6097 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3544 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3545 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3546 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3547 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3548 | .phy_read = mv88e6185_phy_ppu_read, |
| 3549 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3550 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3551 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3552 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3553 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3554 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3555 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3556 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3557 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3558 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3559 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3560 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3561 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3562 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3563 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3564 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3565 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3566 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3567 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3568 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3569 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3570 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3571 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3572 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3573 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3574 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 3575 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3576 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3577 | .rmu_disable = mv88e6085_g1_rmu_disable, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3578 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3579 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3580 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3581 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3582 | }; |
| 3583 | |
| 3584 | static const struct mv88e6xxx_ops mv88e6095_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3585 | /* MV88E6XXX_FAMILY_6095 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3586 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3587 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3588 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3589 | .phy_read = mv88e6185_phy_ppu_read, |
| 3590 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3591 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3592 | .port_sync_link = mv88e6185_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3593 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3594 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3595 | .port_set_ucast_flood = mv88e6185_port_set_forward_unknown, |
| 3596 | .port_set_mcast_flood = mv88e6185_port_set_default_forward, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 3597 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3598 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3599 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3600 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3601 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3602 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3603 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3604 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3605 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Chris Packham | f5be107 | 2020-11-24 17:34:38 +1300 | [diff] [blame] | 3606 | .serdes_power = mv88e6185_serdes_power, |
| 3607 | .serdes_get_lane = mv88e6185_serdes_get_lane, |
| 3608 | .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3609 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 3610 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3611 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3612 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3613 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3614 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3615 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3616 | }; |
| 3617 | |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3618 | static const struct mv88e6xxx_ops mv88e6097_ops = { |
Stefan Eichenberger | 15da3cc | 2016-11-25 09:41:30 +0100 | [diff] [blame] | 3619 | /* MV88E6XXX_FAMILY_6097 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3620 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3621 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3622 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3623 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3624 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3625 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3626 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3627 | .port_sync_link = mv88e6185_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3628 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3629 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3630 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3631 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3632 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3633 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3634 | .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3635 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3636 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3637 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3638 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3639 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3640 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3641 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3642 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3643 | .stats_get_strings = mv88e6095_stats_get_strings, |
| 3644 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3645 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3646 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Volodymyr Bendiuga | 91eaa47 | 2017-02-14 11:29:30 +0100 | [diff] [blame] | 3647 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3648 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Chris Packham | f5be107 | 2020-11-24 17:34:38 +1300 | [diff] [blame] | 3649 | .serdes_power = mv88e6185_serdes_power, |
| 3650 | .serdes_get_lane = mv88e6185_serdes_get_lane, |
| 3651 | .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, |
Chris Packham | 5c19bc8 | 2020-11-24 17:34:39 +1300 | [diff] [blame] | 3652 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
| 3653 | .serdes_irq_enable = mv88e6097_serdes_irq_enable, |
| 3654 | .serdes_irq_status = mv88e6097_serdes_irq_status, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3655 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3656 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3657 | .rmu_disable = mv88e6085_g1_rmu_disable, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3658 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3659 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3660 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3661 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3662 | }; |
| 3663 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3664 | static const struct mv88e6xxx_ops mv88e6123_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3665 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3666 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3667 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3668 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3669 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | ec8378b | 2017-06-02 23:22:45 +0200 | [diff] [blame] | 3670 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3671 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3672 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3673 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3674 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3675 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3676 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3677 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3678 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3679 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3680 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3681 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 0ac64c3 | 2017-06-02 23:22:46 +0200 | [diff] [blame] | 3682 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3683 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3684 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3685 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3686 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3687 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3688 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3689 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3690 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3691 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3692 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3693 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3694 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3695 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3696 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3697 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 3698 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3699 | }; |
| 3700 | |
| 3701 | static const struct mv88e6xxx_ops mv88e6131_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3702 | /* MV88E6XXX_FAMILY_6185 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3703 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3704 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3705 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3706 | .phy_read = mv88e6185_phy_ppu_read, |
| 3707 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3708 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3709 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3710 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3711 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3712 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3713 | .port_set_ucast_flood = mv88e6185_port_set_forward_unknown, |
| 3714 | .port_set_mcast_flood = mv88e6185_port_set_default_forward, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3715 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 3716 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3717 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3718 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3719 | .port_pause_limit = mv88e6097_port_pause_limit, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 3720 | .port_set_pause = mv88e6185_port_set_pause, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3721 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3722 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3723 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3724 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3725 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3726 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3727 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3728 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3729 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3730 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3731 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3732 | .ppu_enable = mv88e6185_g1_ppu_enable, |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 3733 | .set_cascade_port = mv88e6185_g1_set_cascade_port, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3734 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3735 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3736 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3737 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3738 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3739 | }; |
| 3740 | |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3741 | static const struct mv88e6xxx_ops mv88e6141_ops = { |
| 3742 | /* MV88E6XXX_FAMILY_6341 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3743 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3744 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3745 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3746 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3747 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 3748 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3749 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3750 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3751 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3752 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3753 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3754 | .port_set_speed_duplex = mv88e6341_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 3755 | .port_max_speed_mode = mv88e6341_port_max_speed_mode, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3756 | .port_tag_remap = mv88e6095_port_tag_remap, |
Marek Behún | 7da467d | 2021-07-01 00:22:26 +0200 | [diff] [blame] | 3757 | .port_set_policy = mv88e6352_port_set_policy, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3758 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3759 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3760 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3761 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3762 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3763 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3764 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3765 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 3766 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3767 | .port_get_cmode = mv88e6352_port_get_cmode, |
Marek Behún | 7a3007d | 2019-08-26 23:31:55 +0200 | [diff] [blame] | 3768 | .port_set_cmode = mv88e6341_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3769 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3770 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Marek Behún | 11527f3 | 2021-07-01 00:22:27 +0200 | [diff] [blame] | 3771 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3772 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3773 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 3774 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3775 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 3776 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3777 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 3778 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3779 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3780 | .reset = mv88e6352_g1_reset, |
Marek Behún | 3709488 | 2021-07-01 00:22:28 +0200 | [diff] [blame] | 3781 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Marek Behún | c07fff3 | 2021-07-01 00:22:29 +0200 | [diff] [blame] | 3782 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3783 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3784 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3785 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 3786 | .serdes_power = mv88e6390_serdes_power, |
| 3787 | .serdes_get_lane = mv88e6341_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 3788 | /* Check status register pause & lpa register */ |
| 3789 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 3790 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 3791 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 3792 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 3793 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 3794 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 3795 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3796 | .gpio_ops = &mv88e6352_gpio_ops, |
Marek Behún | a03b98d | 2021-07-01 00:22:30 +0200 | [diff] [blame] | 3797 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 3798 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 3799 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Marek Behún | 953b0dc | 2021-07-01 00:22:31 +0200 | [diff] [blame] | 3800 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 3801 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 3802 | .phylink_validate = mv88e6341_phylink_validate, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3803 | }; |
| 3804 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3805 | static const struct mv88e6xxx_ops mv88e6161_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3806 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3807 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3808 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3809 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3810 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | ec8378b | 2017-06-02 23:22:45 +0200 | [diff] [blame] | 3811 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3812 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3813 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3814 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3815 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3816 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3817 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3818 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3819 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3820 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3821 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3822 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3823 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3824 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3825 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3826 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a6da21b | 2019-03-01 23:43:39 +0100 | [diff] [blame] | 3827 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3828 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3829 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3830 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3831 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3832 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3833 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3834 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3835 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3836 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3837 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3838 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3839 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3840 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3841 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | a469a61 | 2018-07-18 22:38:21 +0200 | [diff] [blame] | 3842 | .avb_ops = &mv88e6165_avb_ops, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 3843 | .ptp_ops = &mv88e6165_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3844 | .phylink_validate = mv88e6185_phylink_validate, |
Andrew Lunn | fe23036 | 2021-09-26 19:41:24 +0200 | [diff] [blame] | 3845 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3846 | }; |
| 3847 | |
| 3848 | static const struct mv88e6xxx_ops mv88e6165_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3849 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3850 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3851 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3852 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3853 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | efb3e74 | 2017-01-24 14:53:47 +0100 | [diff] [blame] | 3854 | .phy_read = mv88e6165_phy_read, |
| 3855 | .phy_write = mv88e6165_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3856 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3857 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3858 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3859 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3860 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3861 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3862 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3863 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3864 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3865 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3866 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3867 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3868 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3869 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3870 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3871 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3872 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3873 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3874 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3875 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3876 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3877 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | a469a61 | 2018-07-18 22:38:21 +0200 | [diff] [blame] | 3878 | .avb_ops = &mv88e6165_avb_ops, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 3879 | .ptp_ops = &mv88e6165_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3880 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3881 | }; |
| 3882 | |
| 3883 | static const struct mv88e6xxx_ops mv88e6171_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3884 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3885 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3886 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3887 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3888 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3889 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3890 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3891 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3892 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 3893 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3894 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3895 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3896 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3897 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3898 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3899 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3900 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3901 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3902 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3903 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3904 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3905 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3906 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3907 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3908 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3909 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3910 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3911 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3912 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3913 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3914 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3915 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3916 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3917 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3918 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3919 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3920 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3921 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3922 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3923 | }; |
| 3924 | |
| 3925 | static const struct mv88e6xxx_ops mv88e6172_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3926 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3927 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3928 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3929 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3930 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 3931 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3932 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3933 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3934 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3935 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3936 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 3937 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3938 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3939 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 3940 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3941 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3942 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3943 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3944 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3945 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3946 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3947 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3948 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3949 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3950 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3951 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3952 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3953 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3954 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3955 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3956 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3957 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3958 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3959 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3960 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3961 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3962 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3963 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3964 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3965 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3966 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3967 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 3968 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 3969 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 3970 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 3971 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 3972 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 3973 | .serdes_power = mv88e6352_serdes_power, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 3974 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 3975 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3976 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3977 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3978 | }; |
| 3979 | |
| 3980 | static const struct mv88e6xxx_ops mv88e6175_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3981 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3982 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3983 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3984 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3985 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3986 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3987 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3988 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 3989 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 3990 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3991 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3992 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3993 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 3994 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 3995 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3996 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3997 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3998 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3999 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4000 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4001 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4002 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4003 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4004 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4005 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4006 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4007 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4008 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4009 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4010 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4011 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4012 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4013 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4014 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4015 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4016 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4017 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4018 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4019 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4020 | }; |
| 4021 | |
| 4022 | static const struct mv88e6xxx_ops mv88e6176_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4023 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4024 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4025 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4026 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4027 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4028 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4029 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4030 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4031 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4032 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4033 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4034 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4035 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4036 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4037 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4038 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4039 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4040 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4041 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4042 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4043 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4044 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4045 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4046 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4047 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4048 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4049 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4050 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4051 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4052 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4053 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4054 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4055 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4056 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4057 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4058 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4059 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4060 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4061 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4062 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4063 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4064 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4065 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4066 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 4067 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 4068 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 4069 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4070 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4071 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4072 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4073 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4074 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4075 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4076 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4077 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4078 | }; |
| 4079 | |
| 4080 | static const struct mv88e6xxx_ops mv88e6185_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4081 | /* MV88E6XXX_FAMILY_6185 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4082 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4083 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4084 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 4085 | .phy_read = mv88e6185_phy_ppu_read, |
| 4086 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4087 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4088 | .port_sync_link = mv88e6185_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4089 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4090 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4091 | .port_set_ucast_flood = mv88e6185_port_set_forward_unknown, |
| 4092 | .port_set_mcast_flood = mv88e6185_port_set_default_forward, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4093 | .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 4094 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 4095 | .port_set_pause = mv88e6185_port_set_pause, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4096 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4097 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4098 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4099 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4100 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4101 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4102 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4103 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4104 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4105 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4106 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Chris Packham | f5be107 | 2020-11-24 17:34:38 +1300 | [diff] [blame] | 4107 | .serdes_power = mv88e6185_serdes_power, |
| 4108 | .serdes_get_lane = mv88e6185_serdes_get_lane, |
| 4109 | .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state, |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 4110 | .set_cascade_port = mv88e6185_g1_set_cascade_port, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 4111 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 4112 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4113 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4114 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4115 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4116 | .phylink_validate = mv88e6185_phylink_validate, |
Chris Packham | 1baf0fa | 2020-07-24 11:21:22 +1200 | [diff] [blame] | 4117 | .set_max_frame_size = mv88e6185_g1_set_max_frame_size, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4118 | }; |
| 4119 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4120 | static const struct mv88e6xxx_ops mv88e6190_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4121 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4122 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4123 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4124 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4125 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4126 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4127 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4128 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4129 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4130 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4131 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4132 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4133 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4134 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4135 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4136 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4137 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4138 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4139 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Chris Packham | e8b34c6 | 2020-07-24 11:21:21 +1200 | [diff] [blame] | 4140 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4141 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4142 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4143 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4144 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4145 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4146 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4147 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4148 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4149 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4150 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4151 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4152 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4153 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4154 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4155 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4156 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4157 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4158 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4159 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4160 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4161 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4162 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4163 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4164 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4165 | /* Check status register pause & lpa register */ |
| 4166 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4167 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4168 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4169 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4170 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4171 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4172 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4173 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4174 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4175 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4176 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4177 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4178 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4179 | }; |
| 4180 | |
| 4181 | static const struct mv88e6xxx_ops mv88e6190x_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4182 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4183 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4184 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4185 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4186 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4187 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4188 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4189 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4190 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4191 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4192 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4193 | .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4194 | .port_max_speed_mode = mv88e6390x_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4195 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4196 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4197 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4198 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4199 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4200 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Chris Packham | e8b34c6 | 2020-07-24 11:21:21 +1200 | [diff] [blame] | 4201 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4202 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4203 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4204 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4205 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4206 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4207 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4208 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4209 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4210 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4211 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4212 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4213 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4214 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4215 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4216 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4217 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4218 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4219 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4220 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4221 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4222 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4223 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4224 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4225 | .serdes_get_lane = mv88e6390x_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4226 | /* Check status register pause & lpa register */ |
| 4227 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4228 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4229 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4230 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4231 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4232 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4233 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4234 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4235 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4236 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4237 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4238 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4239 | .phylink_validate = mv88e6390x_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4240 | }; |
| 4241 | |
| 4242 | static const struct mv88e6xxx_ops mv88e6191_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4243 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4244 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4245 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4246 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4247 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4248 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4249 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4250 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4251 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4252 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4253 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4254 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4255 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4256 | .port_tag_remap = mv88e6390_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4257 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4258 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4259 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4260 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4261 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4262 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4263 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4264 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4265 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4266 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4267 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4268 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4269 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4270 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4271 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4272 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4273 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4274 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4275 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4276 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4277 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4278 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4279 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4280 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4281 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4282 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4283 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4284 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4285 | /* Check status register pause & lpa register */ |
| 4286 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4287 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4288 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4289 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4290 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4291 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4292 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4293 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4294 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4295 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4296 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4297 | .avb_ops = &mv88e6390_avb_ops, |
| 4298 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4299 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4300 | }; |
| 4301 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4302 | static const struct mv88e6xxx_ops mv88e6240_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4303 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4304 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4305 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4306 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4307 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4308 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4309 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4310 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4311 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4312 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4313 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4314 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4315 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4316 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4317 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4318 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4319 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4320 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4321 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4322 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4323 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4324 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4325 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4326 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4327 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4328 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4329 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4330 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4331 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4332 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4333 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4334 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4335 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4336 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4337 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4338 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4339 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4340 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4341 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4342 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4343 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4344 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4345 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4346 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 4347 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 4348 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 4349 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4350 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4351 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4352 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4353 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4354 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4355 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4356 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4357 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4358 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4359 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4360 | }; |
| 4361 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4362 | static const struct mv88e6xxx_ops mv88e6250_ops = { |
| 4363 | /* MV88E6XXX_FAMILY_6250 */ |
| 4364 | .ieee_pri_map = mv88e6250_g1_ieee_pri_map, |
| 4365 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
| 4366 | .irl_init_all = mv88e6352_g2_irl_init_all, |
| 4367 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4368 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
| 4369 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4370 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4371 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4372 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4373 | .port_sync_link = mv88e6xxx_port_sync_link, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4374 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4375 | .port_set_speed_duplex = mv88e6250_port_set_speed_duplex, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4376 | .port_tag_remap = mv88e6095_port_tag_remap, |
| 4377 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4378 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4379 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4380 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
| 4381 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
| 4382 | .port_pause_limit = mv88e6097_port_pause_limit, |
| 4383 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4384 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
| 4385 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
| 4386 | .stats_get_sset_count = mv88e6250_stats_get_sset_count, |
| 4387 | .stats_get_strings = mv88e6250_stats_get_strings, |
| 4388 | .stats_get_stats = mv88e6250_stats_get_stats, |
| 4389 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4390 | .set_egress_port = mv88e6095_g1_set_egress_port, |
| 4391 | .watchdog_ops = &mv88e6250_watchdog_ops, |
| 4392 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
| 4393 | .pot_clear = mv88e6xxx_g2_pot_clear, |
| 4394 | .reset = mv88e6250_g1_reset, |
Rasmus Villemoes | 67c9ed1 | 2021-01-25 16:04:48 +0100 | [diff] [blame] | 4395 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Rasmus Villemoes | b28f3f3 | 2021-01-25 16:04:49 +0100 | [diff] [blame] | 4396 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 4397 | .avb_ops = &mv88e6352_avb_ops, |
| 4398 | .ptp_ops = &mv88e6250_ptp_ops, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4399 | .phylink_validate = mv88e6065_phylink_validate, |
| 4400 | }; |
| 4401 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4402 | static const struct mv88e6xxx_ops mv88e6290_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4403 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4404 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4405 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4406 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4407 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4408 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4409 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4410 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4411 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4412 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4413 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4414 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4415 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4416 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4417 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4418 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4419 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4420 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4421 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4422 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4423 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4424 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4425 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4426 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4427 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4428 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4429 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4430 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4431 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4432 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4433 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4434 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4435 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4436 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4437 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4438 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4439 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4440 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4441 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4442 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4443 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4444 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4445 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4446 | /* Check status register pause & lpa register */ |
| 4447 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4448 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4449 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4450 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4451 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4452 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4453 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4454 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4455 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4456 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4457 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4458 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4459 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4460 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4461 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4462 | }; |
| 4463 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4464 | static const struct mv88e6xxx_ops mv88e6320_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4465 | /* MV88E6XXX_FAMILY_6320 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4466 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4467 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4468 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4469 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4470 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4471 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4472 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4473 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4474 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4475 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4476 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4477 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4478 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4479 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4480 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4481 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4482 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4483 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4484 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4485 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4486 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4487 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4488 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4489 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4490 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4491 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4492 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4493 | .stats_get_stats = mv88e6320_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4494 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4495 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | 9c7f37e | 2018-12-19 18:28:54 +0100 | [diff] [blame] | 4496 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4497 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4498 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4499 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4500 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4501 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4502 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4503 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4504 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4505 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4506 | }; |
| 4507 | |
| 4508 | static const struct mv88e6xxx_ops mv88e6321_ops = { |
Vivien Didelot | bd80720 | 2017-07-17 13:03:37 -0400 | [diff] [blame] | 4509 | /* MV88E6XXX_FAMILY_6320 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4510 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4511 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4512 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4513 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4514 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4515 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4516 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4517 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4518 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4519 | .port_sync_link = mv88e6xxx_port_sync_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4520 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4521 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4522 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4523 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4524 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4525 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4526 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4527 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4528 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4529 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4530 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4531 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4532 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4533 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4534 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4535 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4536 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4537 | .stats_get_stats = mv88e6320_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4538 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4539 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | 9c7f37e | 2018-12-19 18:28:54 +0100 | [diff] [blame] | 4540 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4541 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4542 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4543 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4544 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4545 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4546 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4547 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4548 | }; |
| 4549 | |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4550 | static const struct mv88e6xxx_ops mv88e6341_ops = { |
| 4551 | /* MV88E6XXX_FAMILY_6341 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4552 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4553 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4554 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4555 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4556 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 4557 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4558 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4559 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4560 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4561 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4562 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4563 | .port_set_speed_duplex = mv88e6341_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4564 | .port_max_speed_mode = mv88e6341_port_max_speed_mode, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4565 | .port_tag_remap = mv88e6095_port_tag_remap, |
Marek Behún | 7da467d | 2021-07-01 00:22:26 +0200 | [diff] [blame] | 4566 | .port_set_policy = mv88e6352_port_set_policy, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4567 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4568 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4569 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4570 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4571 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4572 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4573 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4574 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 4575 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4576 | .port_get_cmode = mv88e6352_port_get_cmode, |
Marek Behún | 7a3007d | 2019-08-26 23:31:55 +0200 | [diff] [blame] | 4577 | .port_set_cmode = mv88e6341_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4578 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4579 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Marek Behún | 11527f3 | 2021-07-01 00:22:27 +0200 | [diff] [blame] | 4580 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4581 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4582 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 4583 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4584 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4585 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4586 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 4587 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4588 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4589 | .reset = mv88e6352_g1_reset, |
Marek Behún | 3709488 | 2021-07-01 00:22:28 +0200 | [diff] [blame] | 4590 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Marek Behún | c07fff3 | 2021-07-01 00:22:29 +0200 | [diff] [blame] | 4591 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4592 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4593 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4594 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4595 | .serdes_power = mv88e6390_serdes_power, |
| 4596 | .serdes_get_lane = mv88e6341_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4597 | /* Check status register pause & lpa register */ |
| 4598 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4599 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4600 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4601 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4602 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4603 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4604 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4605 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4606 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4607 | .ptp_ops = &mv88e6352_ptp_ops, |
Marek Behún | a03b98d | 2021-07-01 00:22:30 +0200 | [diff] [blame] | 4608 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4609 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4610 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Marek Behún | 953b0dc | 2021-07-01 00:22:31 +0200 | [diff] [blame] | 4611 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4612 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 4613 | .phylink_validate = mv88e6341_phylink_validate, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4614 | }; |
| 4615 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4616 | static const struct mv88e6xxx_ops mv88e6350_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4617 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4618 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4619 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4620 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4621 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4622 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4623 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4624 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4625 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 4626 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4627 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4628 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4629 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4630 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4631 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4632 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4633 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4634 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4635 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4636 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4637 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4638 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4639 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4640 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4641 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4642 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4643 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4644 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4645 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4646 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4647 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4648 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4649 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4650 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4651 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4652 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4653 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4654 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4655 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4656 | }; |
| 4657 | |
| 4658 | static const struct mv88e6xxx_ops mv88e6351_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4659 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4660 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4661 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4662 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4663 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4664 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4665 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4666 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4667 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 4668 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4669 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4670 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4671 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4672 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4673 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4674 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4675 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4676 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4677 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4678 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4679 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4680 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4681 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4682 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4683 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4684 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4685 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4686 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4687 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4688 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4689 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4690 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4691 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4692 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4693 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4694 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4695 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4696 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4697 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4698 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4699 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4700 | }; |
| 4701 | |
| 4702 | static const struct mv88e6xxx_ops mv88e6352_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4703 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4704 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4705 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4706 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4707 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4708 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4709 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4710 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4711 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4712 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4713 | .port_sync_link = mv88e6xxx_port_sync_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4714 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4715 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4716 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4717 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4718 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4719 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4720 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4721 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4722 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4723 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4724 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4725 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4726 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4727 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4728 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4729 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4730 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4731 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4732 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4733 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4734 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4735 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4736 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4737 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4738 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4739 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4740 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4741 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4742 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4743 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4744 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4745 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4746 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 4747 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 4748 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 4749 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4750 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4751 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4752 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4753 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4754 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4755 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4756 | .ptp_ops = &mv88e6352_ptp_ops, |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 4757 | .serdes_get_sset_count = mv88e6352_serdes_get_sset_count, |
| 4758 | .serdes_get_strings = mv88e6352_serdes_get_strings, |
| 4759 | .serdes_get_stats = mv88e6352_serdes_get_stats, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4760 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4761 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4762 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4763 | }; |
| 4764 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4765 | static const struct mv88e6xxx_ops mv88e6390_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4766 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4767 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4768 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4769 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4770 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4771 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4772 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4773 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4774 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4775 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4776 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4777 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4778 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4779 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4780 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4781 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4782 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4783 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4784 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4785 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4786 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4787 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4788 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4789 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4790 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4791 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4792 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4793 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4794 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4795 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4796 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4797 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4798 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4799 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4800 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4801 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4802 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4803 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4804 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4805 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4806 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4807 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4808 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4809 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4810 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4811 | /* Check status register pause & lpa register */ |
| 4812 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4813 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4814 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4815 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4816 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4817 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4818 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4819 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4820 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4821 | .ptp_ops = &mv88e6352_ptp_ops, |
Nikita Yushchenko | 0df9528 | 2019-12-25 08:22:38 +0300 | [diff] [blame] | 4822 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4823 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4824 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4825 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4826 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4827 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4828 | }; |
| 4829 | |
| 4830 | static const struct mv88e6xxx_ops mv88e6390x_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4831 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4832 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4833 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4834 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4835 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4836 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4837 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4838 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4839 | .port_set_link = mv88e6xxx_port_set_link, |
Chris Packham | 4efe7662 | 2020-11-24 17:34:37 +1300 | [diff] [blame] | 4840 | .port_sync_link = mv88e6xxx_port_sync_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4841 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4842 | .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4843 | .port_max_speed_mode = mv88e6390x_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4844 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4845 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4846 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 4847 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4848 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4849 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4850 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4851 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4852 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4853 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4854 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4855 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | b3dce4d | 2018-11-11 00:32:14 +0100 | [diff] [blame] | 4856 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4857 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4858 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4859 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4860 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4861 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4862 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4863 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4864 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4865 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4866 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4867 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4868 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4869 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4870 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4871 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4872 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4873 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4874 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4875 | .serdes_get_lane = mv88e6390x_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4876 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4877 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4878 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4879 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4880 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4881 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4882 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4883 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4884 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4885 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4886 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4887 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4888 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4889 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4890 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4891 | .phylink_validate = mv88e6390x_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4892 | }; |
| 4893 | |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 4894 | static const struct mv88e6xxx_ops mv88e6393x_ops = { |
| 4895 | /* MV88E6XXX_FAMILY_6393 */ |
| 4896 | .setup_errata = mv88e6393x_serdes_setup_errata, |
| 4897 | .irl_init_all = mv88e6390_g2_irl_init_all, |
| 4898 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4899 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 4900 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4901 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4902 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4903 | .port_set_link = mv88e6xxx_port_set_link, |
| 4904 | .port_sync_link = mv88e6xxx_port_sync_link, |
| 4905 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 4906 | .port_set_speed_duplex = mv88e6393x_port_set_speed_duplex, |
| 4907 | .port_max_speed_mode = mv88e6393x_port_max_speed_mode, |
| 4908 | .port_tag_remap = mv88e6390_port_tag_remap, |
Marek Behún | 6584b26 | 2021-03-17 14:46:43 +0100 | [diff] [blame] | 4909 | .port_set_policy = mv88e6393x_port_set_policy, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 4910 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
| 4911 | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, |
| 4912 | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, |
| 4913 | .port_set_ether_type = mv88e6393x_port_set_ether_type, |
| 4914 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
| 4915 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
| 4916 | .port_pause_limit = mv88e6390_port_pause_limit, |
| 4917 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 4918 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
| 4919 | .port_get_cmode = mv88e6352_port_get_cmode, |
| 4920 | .port_set_cmode = mv88e6393x_port_set_cmode, |
| 4921 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
| 4922 | .port_set_upstream_port = mv88e6393x_port_set_upstream_port, |
| 4923 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
| 4924 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
| 4925 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4926 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 4927 | .stats_get_stats = mv88e6390_stats_get_stats, |
| 4928 | /* .set_cpu_port is missing because this family does not support a global |
| 4929 | * CPU port, only per port CPU port which is set via |
| 4930 | * .port_set_upstream_port method. |
| 4931 | */ |
| 4932 | .set_egress_port = mv88e6393x_set_egress_port, |
| 4933 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 4934 | .mgmt_rsvd2cpu = mv88e6393x_port_mgmt_rsvd2cpu, |
| 4935 | .pot_clear = mv88e6xxx_g2_pot_clear, |
| 4936 | .reset = mv88e6352_g1_reset, |
| 4937 | .rmu_disable = mv88e6390_g1_rmu_disable, |
| 4938 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4939 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
| 4940 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4941 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
| 4942 | .serdes_power = mv88e6393x_serdes_power, |
| 4943 | .serdes_get_lane = mv88e6393x_serdes_get_lane, |
| 4944 | .serdes_pcs_get_state = mv88e6393x_serdes_pcs_get_state, |
| 4945 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4946 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4947 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
| 4948 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
| 4949 | .serdes_irq_enable = mv88e6393x_serdes_irq_enable, |
| 4950 | .serdes_irq_status = mv88e6393x_serdes_irq_status, |
| 4951 | /* TODO: serdes stats */ |
| 4952 | .gpio_ops = &mv88e6352_gpio_ops, |
| 4953 | .avb_ops = &mv88e6390_avb_ops, |
| 4954 | .ptp_ops = &mv88e6352_ptp_ops, |
| 4955 | .phylink_validate = mv88e6393x_phylink_validate, |
| 4956 | }; |
| 4957 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4958 | static const struct mv88e6xxx_info mv88e6xxx_table[] = { |
| 4959 | [MV88E6085] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4960 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4961 | .family = MV88E6XXX_FAMILY_6097, |
| 4962 | .name = "Marvell 88E6085", |
| 4963 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4964 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4965 | .num_ports = 10, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4966 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4967 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4968 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4969 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4970 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4971 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4972 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4973 | .g1_irqs = 8, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4974 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4975 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4976 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4977 | .multi_chip = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4978 | .ops = &mv88e6085_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4979 | }, |
| 4980 | |
| 4981 | [MV88E6095] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4982 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4983 | .family = MV88E6XXX_FAMILY_6095, |
| 4984 | .name = "Marvell 88E6095/88E6095F", |
| 4985 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4986 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4987 | .num_ports = 11, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4988 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4989 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4990 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4991 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4992 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4993 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4994 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4995 | .g1_irqs = 8, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4996 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4997 | .multi_chip = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4998 | .ops = &mv88e6095_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4999 | }, |
| 5000 | |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5001 | [MV88E6097] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5002 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5003 | .family = MV88E6XXX_FAMILY_6097, |
| 5004 | .name = "Marvell 88E6097/88E6097F", |
| 5005 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5006 | .num_macs = 8192, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5007 | .num_ports = 11, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5008 | .num_internal_phys = 8, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5009 | .max_vid = 4095, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5010 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5011 | .phy_base_addr = 0x0, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5012 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5013 | .global2_addr = 0x1c, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5014 | .age_time_coeff = 15000, |
Stefan Eichenberger | c534178 | 2016-11-25 09:41:29 +0100 | [diff] [blame] | 5015 | .g1_irqs = 8, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5016 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5017 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5018 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5019 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5020 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 5021 | .ops = &mv88e6097_ops, |
| 5022 | }, |
| 5023 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5024 | [MV88E6123] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5025 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5026 | .family = MV88E6XXX_FAMILY_6165, |
| 5027 | .name = "Marvell 88E6123", |
| 5028 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5029 | .num_macs = 1024, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5030 | .num_ports = 3, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5031 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5032 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5033 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5034 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5035 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5036 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5037 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5038 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5039 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5040 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5041 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5042 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5043 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5044 | .ops = &mv88e6123_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5045 | }, |
| 5046 | |
| 5047 | [MV88E6131] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5048 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5049 | .family = MV88E6XXX_FAMILY_6185, |
| 5050 | .name = "Marvell 88E6131", |
| 5051 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5052 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5053 | .num_ports = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5054 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5055 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5056 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5057 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5058 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5059 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5060 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5061 | .g1_irqs = 9, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5062 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5063 | .multi_chip = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5064 | .ops = &mv88e6131_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5065 | }, |
| 5066 | |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5067 | [MV88E6141] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5068 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5069 | .family = MV88E6XXX_FAMILY_6341, |
Uwe Kleine-König | 79a68b2 | 2018-03-20 10:44:40 +0100 | [diff] [blame] | 5070 | .name = "Marvell 88E6141", |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5071 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5072 | .num_macs = 2048, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5073 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5074 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5075 | .num_gpio = 11, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5076 | .max_vid = 4095, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5077 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5078 | .phy_base_addr = 0x10, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5079 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5080 | .global2_addr = 0x1c, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5081 | .age_time_coeff = 3750, |
| 5082 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | adfccf1 | 2018-03-17 20:32:03 +0100 | [diff] [blame] | 5083 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5084 | .g2_irqs = 10, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5085 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5086 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5087 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 5088 | .ops = &mv88e6141_ops, |
| 5089 | }, |
| 5090 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5091 | [MV88E6161] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5092 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5093 | .family = MV88E6XXX_FAMILY_6165, |
| 5094 | .name = "Marvell 88E6161", |
| 5095 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5096 | .num_macs = 1024, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5097 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5098 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5099 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5100 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5101 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5102 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5103 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5104 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5105 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5106 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5107 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5108 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5109 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5110 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 5111 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5112 | .ops = &mv88e6161_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5113 | }, |
| 5114 | |
| 5115 | [MV88E6165] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5116 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5117 | .family = MV88E6XXX_FAMILY_6165, |
| 5118 | .name = "Marvell 88E6165", |
| 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 = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5122 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5123 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5124 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5125 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5126 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5127 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5128 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5129 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5130 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5131 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5132 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5133 | .multi_chip = true, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 5134 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5135 | .ops = &mv88e6165_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5136 | }, |
| 5137 | |
| 5138 | [MV88E6171] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5139 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5140 | .family = MV88E6XXX_FAMILY_6351, |
| 5141 | .name = "Marvell 88E6171", |
| 5142 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5143 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5144 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5145 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5146 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5147 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5148 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5149 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5150 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5151 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5152 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5153 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5154 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5155 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5156 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5157 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5158 | .ops = &mv88e6171_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5159 | }, |
| 5160 | |
| 5161 | [MV88E6172] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5162 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5163 | .family = MV88E6XXX_FAMILY_6352, |
| 5164 | .name = "Marvell 88E6172", |
| 5165 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5166 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5167 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5168 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5169 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5170 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5171 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5172 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5173 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5174 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5175 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5176 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5177 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5178 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5179 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5180 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5181 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5182 | .ops = &mv88e6172_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5183 | }, |
| 5184 | |
| 5185 | [MV88E6175] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5186 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5187 | .family = MV88E6XXX_FAMILY_6351, |
| 5188 | .name = "Marvell 88E6175", |
| 5189 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5190 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5191 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5192 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5193 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5194 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5195 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5196 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5197 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5198 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5199 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5200 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5201 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5202 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5203 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5204 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5205 | .ops = &mv88e6175_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5206 | }, |
| 5207 | |
| 5208 | [MV88E6176] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5209 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5210 | .family = MV88E6XXX_FAMILY_6352, |
| 5211 | .name = "Marvell 88E6176", |
| 5212 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5213 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5214 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5215 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5216 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5217 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5218 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5219 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5220 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5221 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5222 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5223 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5224 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5225 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5226 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5227 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5228 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5229 | .ops = &mv88e6176_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5230 | }, |
| 5231 | |
| 5232 | [MV88E6185] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5233 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5234 | .family = MV88E6XXX_FAMILY_6185, |
| 5235 | .name = "Marvell 88E6185", |
| 5236 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5237 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5238 | .num_ports = 10, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5239 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5240 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5241 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5242 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5243 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5244 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5245 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5246 | .g1_irqs = 8, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5247 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5248 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5249 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5250 | .ops = &mv88e6185_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5251 | }, |
| 5252 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5253 | [MV88E6190] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5254 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5255 | .family = MV88E6XXX_FAMILY_6390, |
| 5256 | .name = "Marvell 88E6190", |
| 5257 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5258 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5259 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5260 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5261 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5262 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5263 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5264 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5265 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5266 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5267 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5268 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5269 | .g2_irqs = 14, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5270 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5271 | .multi_chip = true, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5272 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5273 | .ops = &mv88e6190_ops, |
| 5274 | }, |
| 5275 | |
| 5276 | [MV88E6190X] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5277 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5278 | .family = MV88E6XXX_FAMILY_6390, |
| 5279 | .name = "Marvell 88E6190X", |
| 5280 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5281 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5282 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5283 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5284 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5285 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5286 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5287 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5288 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5289 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5290 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5291 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5292 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5293 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5294 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5295 | .multi_chip = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5296 | .ops = &mv88e6190x_ops, |
| 5297 | }, |
| 5298 | |
| 5299 | [MV88E6191] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5300 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5301 | .family = MV88E6XXX_FAMILY_6390, |
| 5302 | .name = "Marvell 88E6191", |
| 5303 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5304 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5305 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5306 | .num_internal_phys = 9, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5307 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5308 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5309 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5310 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5311 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5312 | .age_time_coeff = 3750, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5313 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5314 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5315 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5316 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5317 | .multi_chip = true, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5318 | .ptp_support = true, |
Vivien Didelot | 2cf4cefb | 2017-03-28 13:50:34 -0400 | [diff] [blame] | 5319 | .ops = &mv88e6191_ops, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5320 | }, |
| 5321 | |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5322 | [MV88E6191X] = { |
| 5323 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191X, |
| 5324 | .family = MV88E6XXX_FAMILY_6393, |
| 5325 | .name = "Marvell 88E6191X", |
| 5326 | .num_databases = 4096, |
| 5327 | .num_ports = 11, /* 10 + Z80 */ |
| 5328 | .num_internal_phys = 9, |
| 5329 | .max_vid = 8191, |
| 5330 | .port_base_addr = 0x0, |
| 5331 | .phy_base_addr = 0x0, |
| 5332 | .global1_addr = 0x1b, |
| 5333 | .global2_addr = 0x1c, |
| 5334 | .age_time_coeff = 3750, |
| 5335 | .g1_irqs = 10, |
| 5336 | .g2_irqs = 14, |
| 5337 | .atu_move_port_mask = 0x1f, |
| 5338 | .pvt = true, |
| 5339 | .multi_chip = true, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5340 | .ptp_support = true, |
| 5341 | .ops = &mv88e6393x_ops, |
| 5342 | }, |
| 5343 | |
| 5344 | [MV88E6193X] = { |
| 5345 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6193X, |
| 5346 | .family = MV88E6XXX_FAMILY_6393, |
| 5347 | .name = "Marvell 88E6193X", |
| 5348 | .num_databases = 4096, |
| 5349 | .num_ports = 11, /* 10 + Z80 */ |
| 5350 | .num_internal_phys = 9, |
| 5351 | .max_vid = 8191, |
| 5352 | .port_base_addr = 0x0, |
| 5353 | .phy_base_addr = 0x0, |
| 5354 | .global1_addr = 0x1b, |
| 5355 | .global2_addr = 0x1c, |
| 5356 | .age_time_coeff = 3750, |
| 5357 | .g1_irqs = 10, |
| 5358 | .g2_irqs = 14, |
| 5359 | .atu_move_port_mask = 0x1f, |
| 5360 | .pvt = true, |
| 5361 | .multi_chip = true, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5362 | .ptp_support = true, |
| 5363 | .ops = &mv88e6393x_ops, |
| 5364 | }, |
| 5365 | |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5366 | [MV88E6220] = { |
| 5367 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220, |
| 5368 | .family = MV88E6XXX_FAMILY_6250, |
| 5369 | .name = "Marvell 88E6220", |
| 5370 | .num_databases = 64, |
| 5371 | |
| 5372 | /* Ports 2-4 are not routed to pins |
| 5373 | * => usable ports 0, 1, 5, 6 |
| 5374 | */ |
| 5375 | .num_ports = 7, |
| 5376 | .num_internal_phys = 2, |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 5377 | .invalid_port_mask = BIT(2) | BIT(3) | BIT(4), |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5378 | .max_vid = 4095, |
| 5379 | .port_base_addr = 0x08, |
| 5380 | .phy_base_addr = 0x00, |
| 5381 | .global1_addr = 0x0f, |
| 5382 | .global2_addr = 0x07, |
| 5383 | .age_time_coeff = 15000, |
| 5384 | .g1_irqs = 9, |
| 5385 | .g2_irqs = 10, |
| 5386 | .atu_move_port_mask = 0xf, |
| 5387 | .dual_chip = true, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 5388 | .ptp_support = true, |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5389 | .ops = &mv88e6250_ops, |
| 5390 | }, |
| 5391 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5392 | [MV88E6240] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5393 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5394 | .family = MV88E6XXX_FAMILY_6352, |
| 5395 | .name = "Marvell 88E6240", |
| 5396 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5397 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5398 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5399 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5400 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5401 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5402 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5403 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5404 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5405 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5406 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5407 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5408 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5409 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5410 | .pvt = true, |
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 = &mv88e6240_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5415 | }, |
| 5416 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 5417 | [MV88E6250] = { |
| 5418 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250, |
| 5419 | .family = MV88E6XXX_FAMILY_6250, |
| 5420 | .name = "Marvell 88E6250", |
| 5421 | .num_databases = 64, |
| 5422 | .num_ports = 7, |
| 5423 | .num_internal_phys = 5, |
| 5424 | .max_vid = 4095, |
| 5425 | .port_base_addr = 0x08, |
| 5426 | .phy_base_addr = 0x00, |
| 5427 | .global1_addr = 0x0f, |
| 5428 | .global2_addr = 0x07, |
| 5429 | .age_time_coeff = 15000, |
| 5430 | .g1_irqs = 9, |
| 5431 | .g2_irqs = 10, |
| 5432 | .atu_move_port_mask = 0xf, |
| 5433 | .dual_chip = true, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 5434 | .ptp_support = true, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 5435 | .ops = &mv88e6250_ops, |
| 5436 | }, |
| 5437 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5438 | [MV88E6290] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5439 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5440 | .family = MV88E6XXX_FAMILY_6390, |
| 5441 | .name = "Marvell 88E6290", |
| 5442 | .num_databases = 4096, |
| 5443 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5444 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5445 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5446 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5447 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5448 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5449 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5450 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5451 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5452 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5453 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5454 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5455 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5456 | .multi_chip = true, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5457 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5458 | .ops = &mv88e6290_ops, |
| 5459 | }, |
| 5460 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5461 | [MV88E6320] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5462 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5463 | .family = MV88E6XXX_FAMILY_6320, |
| 5464 | .name = "Marvell 88E6320", |
| 5465 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5466 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5467 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5468 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5469 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5470 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5471 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5472 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5473 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5474 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5475 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5476 | .g1_irqs = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5477 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5478 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5479 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5480 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5481 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5482 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5483 | .ops = &mv88e6320_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5484 | }, |
| 5485 | |
| 5486 | [MV88E6321] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5487 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5488 | .family = MV88E6XXX_FAMILY_6320, |
| 5489 | .name = "Marvell 88E6321", |
| 5490 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5491 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5492 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5493 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5494 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5495 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5496 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5497 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5498 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5499 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5500 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5501 | .g1_irqs = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5502 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5503 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5504 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5505 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5506 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5507 | .ops = &mv88e6321_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5508 | }, |
| 5509 | |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5510 | [MV88E6341] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5511 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5512 | .family = MV88E6XXX_FAMILY_6341, |
| 5513 | .name = "Marvell 88E6341", |
| 5514 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5515 | .num_macs = 2048, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5516 | .num_internal_phys = 5, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5517 | .num_ports = 6, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5518 | .num_gpio = 11, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5519 | .max_vid = 4095, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5520 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5521 | .phy_base_addr = 0x10, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5522 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5523 | .global2_addr = 0x1c, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5524 | .age_time_coeff = 3750, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5525 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | adfccf1 | 2018-03-17 20:32:03 +0100 | [diff] [blame] | 5526 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5527 | .g2_irqs = 10, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5528 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5529 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5530 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5531 | .ptp_support = true, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5532 | .ops = &mv88e6341_ops, |
| 5533 | }, |
| 5534 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5535 | [MV88E6350] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5536 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5537 | .family = MV88E6XXX_FAMILY_6351, |
| 5538 | .name = "Marvell 88E6350", |
| 5539 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5540 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5541 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5542 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5543 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5544 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5545 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5546 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5547 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5548 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5549 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5550 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5551 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5552 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5553 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5554 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5555 | .ops = &mv88e6350_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5556 | }, |
| 5557 | |
| 5558 | [MV88E6351] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5559 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5560 | .family = MV88E6XXX_FAMILY_6351, |
| 5561 | .name = "Marvell 88E6351", |
| 5562 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5563 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5564 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5565 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5566 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5567 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5568 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5569 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5570 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5571 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5572 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5573 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5574 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5575 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5576 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5577 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5578 | .ops = &mv88e6351_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5579 | }, |
| 5580 | |
| 5581 | [MV88E6352] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5582 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5583 | .family = MV88E6XXX_FAMILY_6352, |
| 5584 | .name = "Marvell 88E6352", |
| 5585 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5586 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5587 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5588 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5589 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5590 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5591 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5592 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5593 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5594 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5595 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5596 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5597 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5598 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5599 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5600 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5601 | .edsa_support = MV88E6XXX_EDSA_SUPPORTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5602 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5603 | .ops = &mv88e6352_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5604 | }, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5605 | [MV88E6390] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5606 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5607 | .family = MV88E6XXX_FAMILY_6390, |
| 5608 | .name = "Marvell 88E6390", |
| 5609 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5610 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5611 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5612 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5613 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5614 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5615 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5616 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5617 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5618 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5619 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5620 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5621 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5622 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5623 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5624 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5625 | .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5626 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5627 | .ops = &mv88e6390_ops, |
| 5628 | }, |
| 5629 | [MV88E6390X] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5630 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5631 | .family = MV88E6XXX_FAMILY_6390, |
| 5632 | .name = "Marvell 88E6390X", |
| 5633 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5634 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5635 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5636 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5637 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5638 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5639 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5640 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5641 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5642 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5643 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5644 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5645 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5646 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5647 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5648 | .multi_chip = true, |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5649 | .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5650 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5651 | .ops = &mv88e6390x_ops, |
| 5652 | }, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5653 | |
| 5654 | [MV88E6393X] = { |
| 5655 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X, |
| 5656 | .family = MV88E6XXX_FAMILY_6393, |
| 5657 | .name = "Marvell 88E6393X", |
| 5658 | .num_databases = 4096, |
| 5659 | .num_ports = 11, /* 10 + Z80 */ |
| 5660 | .num_internal_phys = 9, |
| 5661 | .max_vid = 8191, |
| 5662 | .port_base_addr = 0x0, |
| 5663 | .phy_base_addr = 0x0, |
| 5664 | .global1_addr = 0x1b, |
| 5665 | .global2_addr = 0x1c, |
| 5666 | .age_time_coeff = 3750, |
| 5667 | .g1_irqs = 10, |
| 5668 | .g2_irqs = 14, |
| 5669 | .atu_move_port_mask = 0x1f, |
| 5670 | .pvt = true, |
| 5671 | .multi_chip = true, |
Pavana Sharma | de776d0 | 2021-03-17 14:46:42 +0100 | [diff] [blame] | 5672 | .ptp_support = true, |
| 5673 | .ops = &mv88e6393x_ops, |
| 5674 | }, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5675 | }; |
| 5676 | |
Vivien Didelot | 5f7c036 | 2016-06-20 13:14:04 -0400 | [diff] [blame] | 5677 | static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num) |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5678 | { |
Vivien Didelot | a439c06 | 2016-04-17 13:23:58 -0400 | [diff] [blame] | 5679 | int i; |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5680 | |
Vivien Didelot | 5f7c036 | 2016-06-20 13:14:04 -0400 | [diff] [blame] | 5681 | for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i) |
| 5682 | if (mv88e6xxx_table[i].prod_num == prod_num) |
| 5683 | return &mv88e6xxx_table[i]; |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5684 | |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5685 | return NULL; |
| 5686 | } |
| 5687 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5688 | static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip) |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5689 | { |
| 5690 | const struct mv88e6xxx_info *info; |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 5691 | unsigned int prod_num, rev; |
| 5692 | u16 id; |
| 5693 | int err; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5694 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5695 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5696 | err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5697 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 5698 | if (err) |
| 5699 | return err; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5700 | |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5701 | prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK; |
| 5702 | rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5703 | |
| 5704 | info = mv88e6xxx_lookup_info(prod_num); |
| 5705 | if (!info) |
| 5706 | return -ENODEV; |
| 5707 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 5708 | /* Update the compatible info with the probed one */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5709 | chip->info = info; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5710 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5711 | dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n", |
| 5712 | chip->info->prod_num, chip->info->name, rev); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5713 | |
| 5714 | return 0; |
| 5715 | } |
| 5716 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5717 | static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5718 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5719 | struct mv88e6xxx_chip *chip; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5720 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5721 | chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); |
| 5722 | if (!chip) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5723 | return NULL; |
| 5724 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5725 | chip->dev = dev; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5726 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5727 | mutex_init(&chip->reg_lock); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 5728 | INIT_LIST_HEAD(&chip->mdios); |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 5729 | idr_init(&chip->policies); |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5730 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5731 | return chip; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5732 | } |
| 5733 | |
Florian Fainelli | 5ed4e3e | 2017-11-10 15:22:52 -0800 | [diff] [blame] | 5734 | 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] | 5735 | int port, |
| 5736 | enum dsa_tag_protocol m) |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 5737 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5738 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 2bbb33b | 2016-08-22 16:01:02 +0200 | [diff] [blame] | 5739 | |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 5740 | return chip->tag_protocol; |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 5741 | } |
| 5742 | |
Tobias Waldekranz | 9a99bef | 2021-04-20 20:53:08 +0200 | [diff] [blame] | 5743 | static int mv88e6xxx_change_tag_protocol(struct dsa_switch *ds, int port, |
| 5744 | enum dsa_tag_protocol proto) |
| 5745 | { |
| 5746 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5747 | enum dsa_tag_protocol old_protocol; |
| 5748 | int err; |
| 5749 | |
| 5750 | switch (proto) { |
| 5751 | case DSA_TAG_PROTO_EDSA: |
| 5752 | switch (chip->info->edsa_support) { |
| 5753 | case MV88E6XXX_EDSA_UNSUPPORTED: |
| 5754 | return -EPROTONOSUPPORT; |
| 5755 | case MV88E6XXX_EDSA_UNDOCUMENTED: |
| 5756 | dev_warn(chip->dev, "Relying on undocumented EDSA tagging behavior\n"); |
| 5757 | fallthrough; |
| 5758 | case MV88E6XXX_EDSA_SUPPORTED: |
| 5759 | break; |
| 5760 | } |
| 5761 | break; |
| 5762 | case DSA_TAG_PROTO_DSA: |
| 5763 | break; |
| 5764 | default: |
| 5765 | return -EPROTONOSUPPORT; |
| 5766 | } |
| 5767 | |
| 5768 | old_protocol = chip->tag_protocol; |
| 5769 | chip->tag_protocol = proto; |
| 5770 | |
| 5771 | mv88e6xxx_reg_lock(chip); |
| 5772 | err = mv88e6xxx_setup_port_mode(chip, port); |
| 5773 | mv88e6xxx_reg_unlock(chip); |
| 5774 | |
| 5775 | if (err) |
| 5776 | chip->tag_protocol = old_protocol; |
| 5777 | |
| 5778 | return err; |
| 5779 | } |
| 5780 | |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5781 | static int mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port, |
| 5782 | const struct switchdev_obj_port_mdb *mdb) |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5783 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5784 | struct mv88e6xxx_chip *chip = ds->priv; |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5785 | int err; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5786 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5787 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5788 | err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, |
| 5789 | MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5790 | mv88e6xxx_reg_unlock(chip); |
Vladimir Oltean | a52b2da | 2021-01-09 02:01:52 +0200 | [diff] [blame] | 5791 | |
| 5792 | return err; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5793 | } |
| 5794 | |
| 5795 | static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port, |
| 5796 | const struct switchdev_obj_port_mdb *mdb) |
| 5797 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5798 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5799 | int err; |
| 5800 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5801 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 5802 | 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] | 5803 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5804 | |
| 5805 | return err; |
| 5806 | } |
| 5807 | |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5808 | static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port, |
| 5809 | struct dsa_mall_mirror_tc_entry *mirror, |
| 5810 | bool ingress) |
| 5811 | { |
| 5812 | enum mv88e6xxx_egress_direction direction = ingress ? |
| 5813 | MV88E6XXX_EGRESS_DIR_INGRESS : |
| 5814 | MV88E6XXX_EGRESS_DIR_EGRESS; |
| 5815 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5816 | bool other_mirrors = false; |
| 5817 | int i; |
| 5818 | int err; |
| 5819 | |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5820 | mutex_lock(&chip->reg_lock); |
| 5821 | if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) != |
| 5822 | mirror->to_local_port) { |
| 5823 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) |
| 5824 | other_mirrors |= ingress ? |
| 5825 | chip->ports[i].mirror_ingress : |
| 5826 | chip->ports[i].mirror_egress; |
| 5827 | |
| 5828 | /* Can't change egress port when other mirror is active */ |
| 5829 | if (other_mirrors) { |
| 5830 | err = -EBUSY; |
| 5831 | goto out; |
| 5832 | } |
| 5833 | |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 5834 | err = mv88e6xxx_set_egress_port(chip, direction, |
| 5835 | mirror->to_local_port); |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5836 | if (err) |
| 5837 | goto out; |
| 5838 | } |
| 5839 | |
| 5840 | err = mv88e6xxx_port_set_mirror(chip, port, direction, true); |
| 5841 | out: |
| 5842 | mutex_unlock(&chip->reg_lock); |
| 5843 | |
| 5844 | return err; |
| 5845 | } |
| 5846 | |
| 5847 | static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port, |
| 5848 | struct dsa_mall_mirror_tc_entry *mirror) |
| 5849 | { |
| 5850 | enum mv88e6xxx_egress_direction direction = mirror->ingress ? |
| 5851 | MV88E6XXX_EGRESS_DIR_INGRESS : |
| 5852 | MV88E6XXX_EGRESS_DIR_EGRESS; |
| 5853 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5854 | bool other_mirrors = false; |
| 5855 | int i; |
| 5856 | |
| 5857 | mutex_lock(&chip->reg_lock); |
| 5858 | if (mv88e6xxx_port_set_mirror(chip, port, direction, false)) |
| 5859 | dev_err(ds->dev, "p%d: failed to disable mirroring\n", port); |
| 5860 | |
| 5861 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) |
| 5862 | other_mirrors |= mirror->ingress ? |
| 5863 | chip->ports[i].mirror_ingress : |
| 5864 | chip->ports[i].mirror_egress; |
| 5865 | |
| 5866 | /* Reset egress port when no other mirror is active */ |
| 5867 | if (!other_mirrors) { |
Marek Behún | 2fda45f | 2021-03-17 14:46:41 +0100 | [diff] [blame] | 5868 | if (mv88e6xxx_set_egress_port(chip, direction, |
| 5869 | dsa_upstream_port(ds, port))) |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5870 | dev_err(ds->dev, "failed to set egress port\n"); |
| 5871 | } |
| 5872 | |
| 5873 | mutex_unlock(&chip->reg_lock); |
| 5874 | } |
| 5875 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5876 | static int mv88e6xxx_port_pre_bridge_flags(struct dsa_switch *ds, int port, |
| 5877 | struct switchdev_brport_flags flags, |
| 5878 | struct netlink_ext_ack *extack) |
| 5879 | { |
| 5880 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5881 | const struct mv88e6xxx_ops *ops; |
| 5882 | |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 5883 | if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | |
| 5884 | BR_BCAST_FLOOD)) |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5885 | return -EINVAL; |
| 5886 | |
| 5887 | ops = chip->info->ops; |
| 5888 | |
| 5889 | if ((flags.mask & BR_FLOOD) && !ops->port_set_ucast_flood) |
| 5890 | return -EINVAL; |
| 5891 | |
| 5892 | if ((flags.mask & BR_MCAST_FLOOD) && !ops->port_set_mcast_flood) |
| 5893 | return -EINVAL; |
| 5894 | |
| 5895 | return 0; |
| 5896 | } |
| 5897 | |
| 5898 | static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port, |
| 5899 | struct switchdev_brport_flags flags, |
| 5900 | struct netlink_ext_ack *extack) |
Russell King | 4f85901 | 2019-02-20 15:35:05 -0800 | [diff] [blame] | 5901 | { |
| 5902 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5903 | int err = -EOPNOTSUPP; |
| 5904 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5905 | mv88e6xxx_reg_lock(chip); |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5906 | |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 5907 | if (flags.mask & BR_LEARNING) { |
| 5908 | bool learning = !!(flags.val & BR_LEARNING); |
| 5909 | u16 pav = learning ? (1 << port) : 0; |
| 5910 | |
| 5911 | err = mv88e6xxx_port_set_assoc_vector(chip, port, pav); |
| 5912 | if (err) |
| 5913 | goto out; |
Tobias Waldekranz | 041bd54 | 2021-03-18 20:25:39 +0100 | [diff] [blame] | 5914 | } |
| 5915 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5916 | if (flags.mask & BR_FLOOD) { |
| 5917 | bool unicast = !!(flags.val & BR_FLOOD); |
| 5918 | |
| 5919 | err = chip->info->ops->port_set_ucast_flood(chip, port, |
| 5920 | unicast); |
| 5921 | if (err) |
| 5922 | goto out; |
| 5923 | } |
| 5924 | |
| 5925 | if (flags.mask & BR_MCAST_FLOOD) { |
| 5926 | bool multicast = !!(flags.val & BR_MCAST_FLOOD); |
| 5927 | |
| 5928 | err = chip->info->ops->port_set_mcast_flood(chip, port, |
| 5929 | multicast); |
| 5930 | if (err) |
| 5931 | goto out; |
| 5932 | } |
| 5933 | |
Tobias Waldekranz | 8d1d829 | 2021-03-18 20:25:40 +0100 | [diff] [blame] | 5934 | if (flags.mask & BR_BCAST_FLOOD) { |
| 5935 | bool broadcast = !!(flags.val & BR_BCAST_FLOOD); |
| 5936 | |
| 5937 | err = mv88e6xxx_port_broadcast_sync(chip, port, broadcast); |
| 5938 | if (err) |
| 5939 | goto out; |
| 5940 | } |
| 5941 | |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 5942 | out: |
| 5943 | mv88e6xxx_reg_unlock(chip); |
| 5944 | |
| 5945 | return err; |
| 5946 | } |
| 5947 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 5948 | static bool mv88e6xxx_lag_can_offload(struct dsa_switch *ds, |
| 5949 | struct net_device *lag, |
| 5950 | struct netdev_lag_upper_info *info) |
| 5951 | { |
Tobias Waldekranz | b80dc51 | 2021-01-15 13:52:59 +0100 | [diff] [blame] | 5952 | struct mv88e6xxx_chip *chip = ds->priv; |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 5953 | struct dsa_port *dp; |
| 5954 | int id, members = 0; |
| 5955 | |
Tobias Waldekranz | b80dc51 | 2021-01-15 13:52:59 +0100 | [diff] [blame] | 5956 | if (!mv88e6xxx_has_lag(chip)) |
| 5957 | return false; |
| 5958 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 5959 | id = dsa_lag_id(ds->dst, lag); |
| 5960 | if (id < 0 || id >= ds->num_lag_ids) |
| 5961 | return false; |
| 5962 | |
| 5963 | dsa_lag_foreach_port(dp, ds->dst, lag) |
| 5964 | /* Includes the port joining the LAG */ |
| 5965 | members++; |
| 5966 | |
| 5967 | if (members > 8) |
| 5968 | return false; |
| 5969 | |
| 5970 | /* We could potentially relax this to include active |
| 5971 | * backup in the future. |
| 5972 | */ |
| 5973 | if (info->tx_type != NETDEV_LAG_TX_TYPE_HASH) |
| 5974 | return false; |
| 5975 | |
| 5976 | /* Ideally we would also validate that the hash type matches |
| 5977 | * the hardware. Alas, this is always set to unknown on team |
| 5978 | * interfaces. |
| 5979 | */ |
| 5980 | return true; |
| 5981 | } |
| 5982 | |
| 5983 | static int mv88e6xxx_lag_sync_map(struct dsa_switch *ds, struct net_device *lag) |
| 5984 | { |
| 5985 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5986 | struct dsa_port *dp; |
| 5987 | u16 map = 0; |
| 5988 | int id; |
| 5989 | |
| 5990 | id = dsa_lag_id(ds->dst, lag); |
| 5991 | |
| 5992 | /* Build the map of all ports to distribute flows destined for |
| 5993 | * this LAG. This can be either a local user port, or a DSA |
| 5994 | * port if the LAG port is on a remote chip. |
| 5995 | */ |
| 5996 | dsa_lag_foreach_port(dp, ds->dst, lag) |
| 5997 | map |= BIT(dsa_towards_port(ds, dp->ds->index, dp->index)); |
| 5998 | |
| 5999 | return mv88e6xxx_g2_trunk_mapping_write(chip, id, map); |
| 6000 | } |
| 6001 | |
| 6002 | static const u8 mv88e6xxx_lag_mask_table[8][8] = { |
| 6003 | /* Row number corresponds to the number of active members in a |
| 6004 | * LAG. Each column states which of the eight hash buckets are |
| 6005 | * mapped to the column:th port in the LAG. |
| 6006 | * |
| 6007 | * Example: In a LAG with three active ports, the second port |
| 6008 | * ([2][1]) would be selected for traffic mapped to buckets |
| 6009 | * 3,4,5 (0x38). |
| 6010 | */ |
| 6011 | { 0xff, 0, 0, 0, 0, 0, 0, 0 }, |
| 6012 | { 0x0f, 0xf0, 0, 0, 0, 0, 0, 0 }, |
| 6013 | { 0x07, 0x38, 0xc0, 0, 0, 0, 0, 0 }, |
| 6014 | { 0x03, 0x0c, 0x30, 0xc0, 0, 0, 0, 0 }, |
| 6015 | { 0x03, 0x0c, 0x30, 0x40, 0x80, 0, 0, 0 }, |
| 6016 | { 0x03, 0x0c, 0x10, 0x20, 0x40, 0x80, 0, 0 }, |
| 6017 | { 0x03, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0 }, |
| 6018 | { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, |
| 6019 | }; |
| 6020 | |
| 6021 | static void mv88e6xxx_lag_set_port_mask(u16 *mask, int port, |
| 6022 | int num_tx, int nth) |
| 6023 | { |
| 6024 | u8 active = 0; |
| 6025 | int i; |
| 6026 | |
| 6027 | num_tx = num_tx <= 8 ? num_tx : 8; |
| 6028 | if (nth < num_tx) |
| 6029 | active = mv88e6xxx_lag_mask_table[num_tx - 1][nth]; |
| 6030 | |
| 6031 | for (i = 0; i < 8; i++) { |
| 6032 | if (BIT(i) & active) |
| 6033 | mask[i] |= BIT(port); |
| 6034 | } |
| 6035 | } |
| 6036 | |
| 6037 | static int mv88e6xxx_lag_sync_masks(struct dsa_switch *ds) |
| 6038 | { |
| 6039 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6040 | unsigned int id, num_tx; |
| 6041 | struct net_device *lag; |
| 6042 | struct dsa_port *dp; |
| 6043 | int i, err, nth; |
| 6044 | u16 mask[8]; |
| 6045 | u16 ivec; |
| 6046 | |
| 6047 | /* Assume no port is a member of any LAG. */ |
| 6048 | ivec = BIT(mv88e6xxx_num_ports(chip)) - 1; |
| 6049 | |
| 6050 | /* Disable all masks for ports that _are_ members of a LAG. */ |
| 6051 | list_for_each_entry(dp, &ds->dst->ports, list) { |
| 6052 | if (!dp->lag_dev || dp->ds != ds) |
| 6053 | continue; |
| 6054 | |
| 6055 | ivec &= ~BIT(dp->index); |
| 6056 | } |
| 6057 | |
| 6058 | for (i = 0; i < 8; i++) |
| 6059 | mask[i] = ivec; |
| 6060 | |
| 6061 | /* Enable the correct subset of masks for all LAG ports that |
| 6062 | * are in the Tx set. |
| 6063 | */ |
| 6064 | dsa_lags_foreach_id(id, ds->dst) { |
| 6065 | lag = dsa_lag_dev(ds->dst, id); |
| 6066 | if (!lag) |
| 6067 | continue; |
| 6068 | |
| 6069 | num_tx = 0; |
| 6070 | dsa_lag_foreach_port(dp, ds->dst, lag) { |
| 6071 | if (dp->lag_tx_enabled) |
| 6072 | num_tx++; |
| 6073 | } |
| 6074 | |
| 6075 | if (!num_tx) |
| 6076 | continue; |
| 6077 | |
| 6078 | nth = 0; |
| 6079 | dsa_lag_foreach_port(dp, ds->dst, lag) { |
| 6080 | if (!dp->lag_tx_enabled) |
| 6081 | continue; |
| 6082 | |
| 6083 | if (dp->ds == ds) |
| 6084 | mv88e6xxx_lag_set_port_mask(mask, dp->index, |
| 6085 | num_tx, nth); |
| 6086 | |
| 6087 | nth++; |
| 6088 | } |
| 6089 | } |
| 6090 | |
| 6091 | for (i = 0; i < 8; i++) { |
| 6092 | err = mv88e6xxx_g2_trunk_mask_write(chip, i, true, mask[i]); |
| 6093 | if (err) |
| 6094 | return err; |
| 6095 | } |
| 6096 | |
| 6097 | return 0; |
| 6098 | } |
| 6099 | |
| 6100 | static int mv88e6xxx_lag_sync_masks_map(struct dsa_switch *ds, |
| 6101 | struct net_device *lag) |
| 6102 | { |
| 6103 | int err; |
| 6104 | |
| 6105 | err = mv88e6xxx_lag_sync_masks(ds); |
| 6106 | |
| 6107 | if (!err) |
| 6108 | err = mv88e6xxx_lag_sync_map(ds, lag); |
| 6109 | |
| 6110 | return err; |
| 6111 | } |
| 6112 | |
| 6113 | static int mv88e6xxx_port_lag_change(struct dsa_switch *ds, int port) |
| 6114 | { |
| 6115 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6116 | int err; |
| 6117 | |
| 6118 | mv88e6xxx_reg_lock(chip); |
| 6119 | err = mv88e6xxx_lag_sync_masks(ds); |
| 6120 | mv88e6xxx_reg_unlock(chip); |
| 6121 | return err; |
| 6122 | } |
| 6123 | |
| 6124 | static int mv88e6xxx_port_lag_join(struct dsa_switch *ds, int port, |
| 6125 | struct net_device *lag, |
| 6126 | struct netdev_lag_upper_info *info) |
| 6127 | { |
| 6128 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6129 | int err, id; |
| 6130 | |
| 6131 | if (!mv88e6xxx_lag_can_offload(ds, lag, info)) |
| 6132 | return -EOPNOTSUPP; |
| 6133 | |
| 6134 | id = dsa_lag_id(ds->dst, lag); |
| 6135 | |
| 6136 | mv88e6xxx_reg_lock(chip); |
| 6137 | |
| 6138 | err = mv88e6xxx_port_set_trunk(chip, port, true, id); |
| 6139 | if (err) |
| 6140 | goto err_unlock; |
| 6141 | |
| 6142 | err = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6143 | if (err) |
| 6144 | goto err_clear_trunk; |
| 6145 | |
| 6146 | mv88e6xxx_reg_unlock(chip); |
| 6147 | return 0; |
| 6148 | |
| 6149 | err_clear_trunk: |
| 6150 | mv88e6xxx_port_set_trunk(chip, port, false, 0); |
| 6151 | err_unlock: |
| 6152 | mv88e6xxx_reg_unlock(chip); |
| 6153 | return err; |
| 6154 | } |
| 6155 | |
| 6156 | static int mv88e6xxx_port_lag_leave(struct dsa_switch *ds, int port, |
| 6157 | struct net_device *lag) |
| 6158 | { |
| 6159 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6160 | int err_sync, err_trunk; |
| 6161 | |
| 6162 | mv88e6xxx_reg_lock(chip); |
| 6163 | err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6164 | err_trunk = mv88e6xxx_port_set_trunk(chip, port, false, 0); |
| 6165 | mv88e6xxx_reg_unlock(chip); |
| 6166 | return err_sync ? : err_trunk; |
| 6167 | } |
| 6168 | |
| 6169 | static int mv88e6xxx_crosschip_lag_change(struct dsa_switch *ds, int sw_index, |
| 6170 | int port) |
| 6171 | { |
| 6172 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6173 | int err; |
| 6174 | |
| 6175 | mv88e6xxx_reg_lock(chip); |
| 6176 | err = mv88e6xxx_lag_sync_masks(ds); |
| 6177 | mv88e6xxx_reg_unlock(chip); |
| 6178 | return err; |
| 6179 | } |
| 6180 | |
| 6181 | static int mv88e6xxx_crosschip_lag_join(struct dsa_switch *ds, int sw_index, |
| 6182 | int port, struct net_device *lag, |
| 6183 | struct netdev_lag_upper_info *info) |
| 6184 | { |
| 6185 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6186 | int err; |
| 6187 | |
| 6188 | if (!mv88e6xxx_lag_can_offload(ds, lag, info)) |
| 6189 | return -EOPNOTSUPP; |
| 6190 | |
| 6191 | mv88e6xxx_reg_lock(chip); |
| 6192 | |
| 6193 | err = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6194 | if (err) |
| 6195 | goto unlock; |
| 6196 | |
| 6197 | err = mv88e6xxx_pvt_map(chip, sw_index, port); |
| 6198 | |
| 6199 | unlock: |
| 6200 | mv88e6xxx_reg_unlock(chip); |
| 6201 | return err; |
| 6202 | } |
| 6203 | |
| 6204 | static int mv88e6xxx_crosschip_lag_leave(struct dsa_switch *ds, int sw_index, |
| 6205 | int port, struct net_device *lag) |
| 6206 | { |
| 6207 | struct mv88e6xxx_chip *chip = ds->priv; |
| 6208 | int err_sync, err_pvt; |
| 6209 | |
| 6210 | mv88e6xxx_reg_lock(chip); |
| 6211 | err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag); |
| 6212 | err_pvt = mv88e6xxx_pvt_map(chip, sw_index, port); |
| 6213 | mv88e6xxx_reg_unlock(chip); |
| 6214 | return err_sync ? : err_pvt; |
| 6215 | } |
| 6216 | |
Florian Fainelli | a82f67a | 2017-01-08 14:52:08 -0800 | [diff] [blame] | 6217 | static const struct dsa_switch_ops mv88e6xxx_switch_ops = { |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 6218 | .get_tag_protocol = mv88e6xxx_get_tag_protocol, |
Tobias Waldekranz | 9a99bef | 2021-04-20 20:53:08 +0200 | [diff] [blame] | 6219 | .change_tag_protocol = mv88e6xxx_change_tag_protocol, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6220 | .setup = mv88e6xxx_setup, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 6221 | .teardown = mv88e6xxx_teardown, |
Vladimir Oltean | fd292c1 | 2021-09-17 17:29:16 +0300 | [diff] [blame] | 6222 | .port_setup = mv88e6xxx_port_setup, |
| 6223 | .port_teardown = mv88e6xxx_port_teardown, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 6224 | .phylink_validate = mv88e6xxx_validate, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 6225 | .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 6226 | .phylink_mac_config = mv88e6xxx_mac_config, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 6227 | .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 6228 | .phylink_mac_link_down = mv88e6xxx_mac_link_down, |
| 6229 | .phylink_mac_link_up = mv88e6xxx_mac_link_up, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6230 | .get_strings = mv88e6xxx_get_strings, |
| 6231 | .get_ethtool_stats = mv88e6xxx_get_ethtool_stats, |
| 6232 | .get_sset_count = mv88e6xxx_get_sset_count, |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 6233 | .port_enable = mv88e6xxx_port_enable, |
| 6234 | .port_disable = mv88e6xxx_port_disable, |
Andrew Lunn | 2a550ae | 2020-07-11 22:32:05 +0200 | [diff] [blame] | 6235 | .port_max_mtu = mv88e6xxx_get_max_mtu, |
| 6236 | .port_change_mtu = mv88e6xxx_change_mtu, |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 6237 | .get_mac_eee = mv88e6xxx_get_mac_eee, |
| 6238 | .set_mac_eee = mv88e6xxx_set_mac_eee, |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 6239 | .get_eeprom_len = mv88e6xxx_get_eeprom_len, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6240 | .get_eeprom = mv88e6xxx_get_eeprom, |
| 6241 | .set_eeprom = mv88e6xxx_set_eeprom, |
| 6242 | .get_regs_len = mv88e6xxx_get_regs_len, |
| 6243 | .get_regs = mv88e6xxx_get_regs, |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 6244 | .get_rxnfc = mv88e6xxx_get_rxnfc, |
| 6245 | .set_rxnfc = mv88e6xxx_set_rxnfc, |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 6246 | .set_ageing_time = mv88e6xxx_set_ageing_time, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6247 | .port_bridge_join = mv88e6xxx_port_bridge_join, |
| 6248 | .port_bridge_leave = mv88e6xxx_port_bridge_leave, |
Vladimir Oltean | a8b659e | 2021-02-12 17:15:56 +0200 | [diff] [blame] | 6249 | .port_pre_bridge_flags = mv88e6xxx_port_pre_bridge_flags, |
| 6250 | .port_bridge_flags = mv88e6xxx_port_bridge_flags, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6251 | .port_stp_state_set = mv88e6xxx_port_stp_state_set, |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 6252 | .port_fast_age = mv88e6xxx_port_fast_age, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6253 | .port_vlan_filtering = mv88e6xxx_port_vlan_filtering, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6254 | .port_vlan_add = mv88e6xxx_port_vlan_add, |
| 6255 | .port_vlan_del = mv88e6xxx_port_vlan_del, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6256 | .port_fdb_add = mv88e6xxx_port_fdb_add, |
| 6257 | .port_fdb_del = mv88e6xxx_port_fdb_del, |
| 6258 | .port_fdb_dump = mv88e6xxx_port_fdb_dump, |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 6259 | .port_mdb_add = mv88e6xxx_port_mdb_add, |
| 6260 | .port_mdb_del = mv88e6xxx_port_mdb_del, |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 6261 | .port_mirror_add = mv88e6xxx_port_mirror_add, |
| 6262 | .port_mirror_del = mv88e6xxx_port_mirror_del, |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 6263 | .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join, |
| 6264 | .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave, |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 6265 | .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set, |
| 6266 | .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get, |
| 6267 | .port_txtstamp = mv88e6xxx_port_txtstamp, |
| 6268 | .port_rxtstamp = mv88e6xxx_port_rxtstamp, |
| 6269 | .get_ts_info = mv88e6xxx_get_ts_info, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 6270 | .devlink_param_get = mv88e6xxx_devlink_param_get, |
| 6271 | .devlink_param_set = mv88e6xxx_devlink_param_set, |
Andrew Lunn | 9315730 | 2020-09-18 21:11:09 +0200 | [diff] [blame] | 6272 | .devlink_info_get = mv88e6xxx_devlink_info_get, |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 6273 | .port_lag_change = mv88e6xxx_port_lag_change, |
| 6274 | .port_lag_join = mv88e6xxx_port_lag_join, |
| 6275 | .port_lag_leave = mv88e6xxx_port_lag_leave, |
| 6276 | .crosschip_lag_change = mv88e6xxx_crosschip_lag_change, |
| 6277 | .crosschip_lag_join = mv88e6xxx_crosschip_lag_join, |
| 6278 | .crosschip_lag_leave = mv88e6xxx_crosschip_lag_leave, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 6279 | }; |
| 6280 | |
Florian Fainelli | 55ed0ce | 2017-01-26 10:45:51 -0800 | [diff] [blame] | 6281 | static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip) |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6282 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6283 | struct device *dev = chip->dev; |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6284 | struct dsa_switch *ds; |
| 6285 | |
Vivien Didelot | 7e99e34 | 2019-10-21 16:51:30 -0400 | [diff] [blame] | 6286 | ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6287 | if (!ds) |
| 6288 | return -ENOMEM; |
| 6289 | |
Vivien Didelot | 7e99e34 | 2019-10-21 16:51:30 -0400 | [diff] [blame] | 6290 | ds->dev = dev; |
| 6291 | ds->num_ports = mv88e6xxx_num_ports(chip); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6292 | ds->priv = chip; |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6293 | ds->dev = dev; |
Vivien Didelot | 9d490b4 | 2016-08-23 12:38:56 -0400 | [diff] [blame] | 6294 | ds->ops = &mv88e6xxx_switch_ops; |
Vivien Didelot | 9ff74f2 | 2017-03-15 15:53:50 -0400 | [diff] [blame] | 6295 | ds->ageing_time_min = chip->info->age_time_coeff; |
| 6296 | ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX; |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6297 | |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 6298 | /* Some chips support up to 32, but that requires enabling the |
| 6299 | * 5-bit port mode, which we do not support. 640k^W16 ought to |
| 6300 | * be enough for anyone. |
| 6301 | */ |
Tobias Waldekranz | b80dc51 | 2021-01-15 13:52:59 +0100 | [diff] [blame] | 6302 | ds->num_lag_ids = mv88e6xxx_has_lag(chip) ? 16 : 0; |
Tobias Waldekranz | 57e661a | 2021-01-13 09:42:54 +0100 | [diff] [blame] | 6303 | |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6304 | dev_set_drvdata(dev, ds); |
| 6305 | |
Vivien Didelot | 23c9ee4 | 2017-05-26 18:12:51 -0400 | [diff] [blame] | 6306 | return dsa_register_switch(ds); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6307 | } |
| 6308 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6309 | static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip) |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6310 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6311 | dsa_unregister_switch(chip->ds); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 6312 | } |
| 6313 | |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6314 | static const void *pdata_device_get_match_data(struct device *dev) |
| 6315 | { |
| 6316 | const struct of_device_id *matches = dev->driver->of_match_table; |
| 6317 | const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data; |
| 6318 | |
| 6319 | for (; matches->name[0] || matches->type[0] || matches->compatible[0]; |
| 6320 | matches++) { |
| 6321 | if (!strcmp(pdata->compatible, matches->compatible)) |
| 6322 | return matches->data; |
| 6323 | } |
| 6324 | return NULL; |
| 6325 | } |
| 6326 | |
Miquel Raynal | bcd3d9d | 2019-02-05 12:07:28 +0100 | [diff] [blame] | 6327 | /* There is no suspend to RAM support at DSA level yet, the switch configuration |
| 6328 | * would be lost after a power cycle so prevent it to be suspended. |
| 6329 | */ |
| 6330 | static int __maybe_unused mv88e6xxx_suspend(struct device *dev) |
| 6331 | { |
| 6332 | return -EOPNOTSUPP; |
| 6333 | } |
| 6334 | |
| 6335 | static int __maybe_unused mv88e6xxx_resume(struct device *dev) |
| 6336 | { |
| 6337 | return 0; |
| 6338 | } |
| 6339 | |
| 6340 | static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume); |
| 6341 | |
Vivien Didelot | 57d3231 | 2016-06-20 13:13:58 -0400 | [diff] [blame] | 6342 | static int mv88e6xxx_probe(struct mdio_device *mdiodev) |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6343 | { |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6344 | struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data; |
David S. Miller | 7ddae24 | 2018-05-20 19:04:24 -0400 | [diff] [blame] | 6345 | const struct mv88e6xxx_info *compat_info = NULL; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6346 | struct device *dev = &mdiodev->dev; |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 6347 | struct device_node *np = dev->of_node; |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6348 | struct mv88e6xxx_chip *chip; |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6349 | int port; |
Andrew Lunn | 52638f7 | 2016-05-10 23:27:22 +0200 | [diff] [blame] | 6350 | int err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6351 | |
Andrew Lunn | 7bb8c99 | 2018-05-31 00:15:42 +0200 | [diff] [blame] | 6352 | if (!np && !pdata) |
| 6353 | return -EINVAL; |
| 6354 | |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6355 | if (np) |
| 6356 | compat_info = of_device_get_match_data(dev); |
| 6357 | |
| 6358 | if (pdata) { |
| 6359 | compat_info = pdata_device_get_match_data(dev); |
| 6360 | |
| 6361 | if (!pdata->netdev) |
| 6362 | return -EINVAL; |
| 6363 | |
| 6364 | for (port = 0; port < DSA_MAX_PORTS; port++) { |
| 6365 | if (!(pdata->enabled_ports & (1 << port))) |
| 6366 | continue; |
| 6367 | if (strcmp(pdata->cd.port_names[port], "cpu")) |
| 6368 | continue; |
| 6369 | pdata->cd.netdev[port] = &pdata->netdev->dev; |
| 6370 | break; |
| 6371 | } |
| 6372 | } |
| 6373 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 6374 | if (!compat_info) |
| 6375 | return -EINVAL; |
| 6376 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6377 | chip = mv88e6xxx_alloc_chip(dev); |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6378 | if (!chip) { |
| 6379 | err = -ENOMEM; |
| 6380 | goto out; |
| 6381 | } |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6382 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6383 | chip->info = compat_info; |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 6384 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6385 | err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr); |
Vivien Didelot | 4a70c4a | 2016-06-20 13:14:07 -0400 | [diff] [blame] | 6386 | if (err) |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6387 | goto out; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6388 | |
Andrew Lunn | b4308f0 | 2016-11-21 23:26:55 +0100 | [diff] [blame] | 6389 | chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6390 | if (IS_ERR(chip->reset)) { |
| 6391 | err = PTR_ERR(chip->reset); |
| 6392 | goto out; |
| 6393 | } |
Baruch Siach | 7b75e49 | 2019-06-27 21:17:39 +0300 | [diff] [blame] | 6394 | if (chip->reset) |
| 6395 | usleep_range(1000, 2000); |
Andrew Lunn | b4308f0 | 2016-11-21 23:26:55 +0100 | [diff] [blame] | 6396 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6397 | err = mv88e6xxx_detect(chip); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 6398 | if (err) |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6399 | goto out; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6400 | |
Tobias Waldekranz | 670bb80 | 2021-04-20 20:53:07 +0200 | [diff] [blame] | 6401 | if (chip->info->edsa_support == MV88E6XXX_EDSA_SUPPORTED) |
| 6402 | chip->tag_protocol = DSA_TAG_PROTO_EDSA; |
| 6403 | else |
| 6404 | chip->tag_protocol = DSA_TAG_PROTO_DSA; |
| 6405 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 6406 | mv88e6xxx_phy_init(chip); |
| 6407 | |
Andrew Lunn | 00baabe | 2018-05-19 22:31:35 +0200 | [diff] [blame] | 6408 | if (chip->info->ops->get_eeprom) { |
| 6409 | if (np) |
| 6410 | of_property_read_u32(np, "eeprom-length", |
| 6411 | &chip->eeprom_len); |
| 6412 | else |
| 6413 | chip->eeprom_len = pdata->eeprom_len; |
| 6414 | } |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 6415 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6416 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6417 | err = mv88e6xxx_switch_reset(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6418 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 6419 | if (err) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6420 | goto out; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 6421 | |
Andrew Lunn | a27415d | 2019-05-01 00:10:50 +0200 | [diff] [blame] | 6422 | if (np) { |
| 6423 | chip->irq = of_irq_get(np, 0); |
| 6424 | if (chip->irq == -EPROBE_DEFER) { |
| 6425 | err = chip->irq; |
| 6426 | goto out; |
| 6427 | } |
Andrew Lunn | 83c0afa | 2016-06-04 21:17:07 +0200 | [diff] [blame] | 6428 | } |
| 6429 | |
Andrew Lunn | a27415d | 2019-05-01 00:10:50 +0200 | [diff] [blame] | 6430 | if (pdata) |
| 6431 | chip->irq = pdata->irq; |
| 6432 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6433 | /* 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] | 6434 | * the PHYs will link their interrupts to these interrupt |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6435 | * controllers |
| 6436 | */ |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6437 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6438 | if (chip->irq > 0) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6439 | err = mv88e6xxx_g1_irq_setup(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6440 | else |
| 6441 | err = mv88e6xxx_irq_poll_setup(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 6442 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6443 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6444 | if (err) |
| 6445 | goto out; |
| 6446 | |
| 6447 | if (chip->info->g2_irqs > 0) { |
| 6448 | err = mv88e6xxx_g2_irq_setup(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6449 | if (err) |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6450 | goto out_g1_irq; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6451 | } |
| 6452 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6453 | err = mv88e6xxx_g1_atu_prob_irq_setup(chip); |
| 6454 | if (err) |
| 6455 | goto out_g2_irq; |
| 6456 | |
| 6457 | err = mv88e6xxx_g1_vtu_prob_irq_setup(chip); |
| 6458 | if (err) |
| 6459 | goto out_g1_atu_prob_irq; |
| 6460 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 6461 | err = mv88e6xxx_mdios_register(chip, np); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6462 | if (err) |
Andrew Lunn | 62eb116 | 2018-01-14 02:32:45 +0100 | [diff] [blame] | 6463 | goto out_g1_vtu_prob_irq; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6464 | |
Florian Fainelli | 55ed0ce | 2017-01-26 10:45:51 -0800 | [diff] [blame] | 6465 | err = mv88e6xxx_register_switch(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6466 | if (err) |
| 6467 | goto out_mdio; |
| 6468 | |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6469 | return 0; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6470 | |
| 6471 | out_mdio: |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 6472 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | 62eb116 | 2018-01-14 02:32:45 +0100 | [diff] [blame] | 6473 | out_g1_vtu_prob_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6474 | mv88e6xxx_g1_vtu_prob_irq_free(chip); |
Andrew Lunn | 0977644 | 2018-01-14 02:32:44 +0100 | [diff] [blame] | 6475 | out_g1_atu_prob_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6476 | mv88e6xxx_g1_atu_prob_irq_free(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6477 | out_g2_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6478 | if (chip->info->g2_irqs > 0) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6479 | mv88e6xxx_g2_irq_free(chip); |
| 6480 | out_g1_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6481 | if (chip->irq > 0) |
Andrew Lunn | 46712644 | 2016-11-20 20:14:15 +0100 | [diff] [blame] | 6482 | mv88e6xxx_g1_irq_free(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 6483 | else |
| 6484 | mv88e6xxx_irq_poll_free(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6485 | out: |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 6486 | if (pdata) |
| 6487 | dev_put(pdata->netdev); |
| 6488 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6489 | return err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6490 | } |
| 6491 | |
| 6492 | static void mv88e6xxx_remove(struct mdio_device *mdiodev) |
| 6493 | { |
| 6494 | struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev); |
Vladimir Oltean | 0650bf5 | 2021-09-17 16:34:33 +0300 | [diff] [blame] | 6495 | struct mv88e6xxx_chip *chip; |
| 6496 | |
| 6497 | if (!ds) |
| 6498 | return; |
| 6499 | |
| 6500 | chip = ds->priv; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6501 | |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 6502 | if (chip->info->ptp_support) { |
| 6503 | mv88e6xxx_hwtstamp_free(chip); |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 6504 | mv88e6xxx_ptp_free(chip); |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 6505 | } |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 6506 | |
Andrew Lunn | 930188c | 2016-08-22 16:01:03 +0200 | [diff] [blame] | 6507 | mv88e6xxx_phy_destroy(chip); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 6508 | mv88e6xxx_unregister_switch(chip); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 6509 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 6510 | |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 6511 | mv88e6xxx_g1_vtu_prob_irq_free(chip); |
| 6512 | mv88e6xxx_g1_atu_prob_irq_free(chip); |
| 6513 | |
| 6514 | if (chip->info->g2_irqs > 0) |
| 6515 | mv88e6xxx_g2_irq_free(chip); |
| 6516 | |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 6517 | if (chip->irq > 0) |
Andrew Lunn | 46712644 | 2016-11-20 20:14:15 +0100 | [diff] [blame] | 6518 | mv88e6xxx_g1_irq_free(chip); |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 6519 | else |
| 6520 | mv88e6xxx_irq_poll_free(chip); |
Vladimir Oltean | 0650bf5 | 2021-09-17 16:34:33 +0300 | [diff] [blame] | 6521 | |
| 6522 | dev_set_drvdata(&mdiodev->dev, NULL); |
| 6523 | } |
| 6524 | |
| 6525 | static void mv88e6xxx_shutdown(struct mdio_device *mdiodev) |
| 6526 | { |
| 6527 | struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev); |
| 6528 | |
| 6529 | if (!ds) |
| 6530 | return; |
| 6531 | |
| 6532 | dsa_switch_shutdown(ds); |
| 6533 | |
| 6534 | dev_set_drvdata(&mdiodev->dev, NULL); |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6535 | } |
| 6536 | |
| 6537 | static const struct of_device_id mv88e6xxx_of_match[] = { |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 6538 | { |
| 6539 | .compatible = "marvell,mv88e6085", |
| 6540 | .data = &mv88e6xxx_table[MV88E6085], |
| 6541 | }, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 6542 | { |
| 6543 | .compatible = "marvell,mv88e6190", |
| 6544 | .data = &mv88e6xxx_table[MV88E6190], |
| 6545 | }, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 6546 | { |
| 6547 | .compatible = "marvell,mv88e6250", |
| 6548 | .data = &mv88e6xxx_table[MV88E6250], |
| 6549 | }, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6550 | { /* sentinel */ }, |
| 6551 | }; |
| 6552 | |
| 6553 | MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match); |
| 6554 | |
| 6555 | static struct mdio_driver mv88e6xxx_driver = { |
| 6556 | .probe = mv88e6xxx_probe, |
| 6557 | .remove = mv88e6xxx_remove, |
Vladimir Oltean | 0650bf5 | 2021-09-17 16:34:33 +0300 | [diff] [blame] | 6558 | .shutdown = mv88e6xxx_shutdown, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6559 | .mdiodrv.driver = { |
| 6560 | .name = "mv88e6085", |
| 6561 | .of_match_table = mv88e6xxx_of_match, |
Miquel Raynal | bcd3d9d | 2019-02-05 12:07:28 +0100 | [diff] [blame] | 6562 | .pm = &mv88e6xxx_pm_ops, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6563 | }, |
| 6564 | }; |
| 6565 | |
Andrew Lunn | 7324d50 | 2019-04-27 19:19:10 +0200 | [diff] [blame] | 6566 | mdio_module_driver(mv88e6xxx_driver); |
Ben Hutchings | 3d825ed | 2011-11-25 14:37:16 +0000 | [diff] [blame] | 6567 | |
| 6568 | MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); |
| 6569 | MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips"); |
| 6570 | MODULE_LICENSE("GPL"); |